문제

I have a Sparse matrix and I would like to initialize an Array from it.

Is there something better and more "compact" than a for cycle? I'm looking for something like:

SparseMatrix<float, RowMajor> SpM;
ArrayXf Af;
Af = Arrayf(SpM.row(1));

Thanks in advance,

도움이 되었습니까?

해결책

What you wrote is almost correct. The only subtle difference to make it work is to first construct a dense VectorXf before moving to the array world:

SparseMatrix<float,RowMajor> mat;
ArrayXf Af;
Af = VectorXf(mat.row(1));
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top