- 1. 下载压缩包,解压到目录,比如D:\ALGLIB\armadillo,只保留include文件夹和examples里的lib_win32文件夹即可;
下载地址:Armadillo: C++ library for linear algebra & scientific computinghttp://arma.sourceforge.net/download.html
- 2. 配置项目
将blas_win32_MT.dll和lapack_win32_MT.dll文件拷贝到exe根目录 。
- 测试代码
// ArmadilloTest.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include
#include
using namespace std;
using namespace arma;
int _tmain(int argc, _TCHAR* argv[])
{system("color 0A");mat A(4, 5, fill::randn);A.print("A:");A << 0.165300 << 0.454037 << 0.995795 << 0.124098 << 0.047084 << endr<< 0.688782 << 0.036549 << 0.552848 << 0.937664 << 0.866401 << endr<< 0.348740 << 0.479388 << 0.506228 << 0.145673 << 0.491547 << endr<< 0.148678 << 0.682258 << 0.571154 << 0.874724 << 0.444632 << endr<< 0.245726 << 0.595218 << 0.409327 << 0.367827 << 0.385736 << endr;A.print("A:");mat C = A.t();C.print("C:");mat D1 = max(A);D1.print("max(A):");mat D2 = max(A, 1);D2.print("max(A, 1):");double temp = max(max(A));cout << "max(max(A)):" << temp << endl;temp = accu(A);cout << "accu(A):" << temp << endl;mat E = eye(4, 4);E.print("E:");temp = A.max();cout << "A.max():" << temp << endl;mat F;F.ones(2, 5);F.print("F:");mat u;vec s;mat v;svd(u, s, v, A);u.print("u:");s.print("s:");v.print("v:");A = randn(2, 3);mat B = randn(4, 5);field Fi(2, 1);Fi(0, 0) = A;Fi(1, 0) = B;Fi.print("Fi:");Fi.save("mat_field.field");field F1;F1.load("mat_field.field");F1.print("F1:");system("pause");return 0;
}
- 结果