How to import matrix into armadillo using binary files?

  armadillo, c++, lapack, matlab, openblas

I am trying to import a matrix generated in MATLAB into armadillo. For example, I have a matrix "A" which is 100×1 double. I used information from a previous question on stackoverflow to generate a binary file using MATLAB:

% Generate LocalX.bin
name = 'LocalX.bin';
[F,err] = fopen(name,'w');
if F<0,error(err);end
fwrite(F,LocalX, 'int32');
fclose(F);

and I imported it into armadillo using:

arma::Mat<int> LocalX;
std::string localx = "LocalX.bin";
LocalX.load(localx, arma::arma_binary);

The issue is, I have lost the matrix dimensions and I cannot perform any matrix manipulation on it using aramdillo.

How do I import the data into armadillo while maintaing the matrix dimensions?

Thank you.

(First time asking a question on stackoverflow)

Source: Windows Questions C++

LEAVE A COMMENT