1、下载Armadillo 地址: http://arma.sourceforge.net/docs.html
2、解压压缩包:
命令:tar xf armadillo-8.400.0.tar.xz
3、安装一系列东西
-
sudo apt-get install libopenblas-dev
-
sudo apt-get install liblapack-dev
-
sudo apt-get install libarpack2-dev
-
sudo apt-get install libsuperlu-dev
4、然后依次执行
cmake .
make
sudo make install
完成安装,注意要在安装目录(解压目录下执行)
5、测试
vim test.cpp
代码:
#include <iostream>
#include <armadillo>
using namespace std;
using namespace arma;
int main()
{
mat A = randu<mat>(4,5);
mat B = randu<mat>(4,5);
cout << A*B.t() << endl;
return 0;
}
~
编译:g++ test.cpp -larmadillo
执行:./a.out
结果:
0.8635 0.6455 1.2309 0.3664
0.9823 0.7291 1.3008 0.7792
1.0882 1.0004 1.6399 0.6935
1.4101 0.9859 2.0146 0.7092
说明安装成功