我只是从Armadillo矩阵库documentation复制粘贴来直接初始化矩阵对象:
#include <armadillo>
using namespace arma;
int main()
{
mat A = { {1, 3, 5},
{2, 4, 6} };
A.print();
return 0;
}
以下是我编译它的方式:
g++ -std=c++11 test.cpp -larmadillo
但我无法理解为什么会收到此错误:
test.cpp: In function ‘int main()’:
test.cpp:8:22: error: could not convert ‘{{1, 3, 5}, {2, 4, 6}}’ from ‘<brace-enclosed initializer list>’ to ‘arma::mat {aka arma::Mat<double>}’
{2, 4, 6} };
^