我遇到了一个非常奇怪的问题。armadillo的随机函数不起作用。它只返回零。例如:
#include <iostream>
#include <armadillo>
using namespace std;
using namespace arma;
int
main(int argc, char **argv) {
// 2D field of matrices; 3D fields are also supported
field<mat> F(4, 2);
for (uword col = 0; col < F.n_cols; ++col)
for (uword row = 0; row < F.n_rows; ++row) {
F(row, col) = randu < mat > (2, 3); // each element in field<mat> is a matrix
}
F.print("F:");
return 0;
}输出为:
F:
[field column 0]
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
[field column 1]
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0知道为什么会这样吗?
发布于 2018-01-26 23:00:58
我也有类似的问题(在Windows上)。我在config.hpp中注释掉了下面这行
#define ARMA_USE_WRAPPER在那之后,randu/randn等命令可以正常工作。
https://stackoverflow.com/questions/38103832
复制相似问题