문제

do you know if with Armadillo library it is possible to reshape a Cube to a matrix, like in matlab, with a single instruction:

A = reshape(A,M*N,D); , where A was and now it is

thanks a lot

도움이 되었습니까?

해결책

Try something along these lines:

cube A = randu<cube>(5,4,3);

// method 1: 
A.reshape(5*4, 3, 1);
mat B = A.slice(0);

// method 2:
mat C = reshape( mat(A.memptr(), A.n_elem, 1, false), 5*4, 3);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top