Input/Output

The matrix object can be saved on the drive either as a text file or a binary file.

readbin

template<typename T = double>
matrix<T> castor::readbin(std::string path, std::string filename)

Read matrix stored in *.bin file.

readbin(“path”,”filename”) read binary file with matrix stored in the following order : m n M(0,0) M(0,1) … M(i,j) … M(m-1,n-2) M(m-1,n-1)

matrix<> A = eye(3,4);
writebin("./","matrix.bin",A);
matrix<> B = readbin("./","matrix.bin");
disp(B);

See writebin, readtxt.

readtxt

template<typename T = double>
matrix<T> castor::readtxt(std::string path, std::string filename)

Read matrix stored in *.txt file.

readtxt(“path”,”filename”) read ascii text file with matrix stored in the following format : m n M(0,0) M(0,1) … M(0,n-2) M(0,n-1) … … M(m-1,0) M(m-1,1) … M(m-1,n-2) M(m-1,n-1)

matrix<> A = eye(3,4);
writetxt("./","matrix.txt",A);
matrix<> B = readtxt("./","matrix.txt");
disp(B);

See writetxt, readbin.

writebin

template<typename T>
void castor::writebin(std::string path, std::string filename, matrix<T> const &A)

Write matrix in *.bin file.

writebin(“path”,”filename”) write binary file with matrix stored in the following order : m n M(0,0) M(0,1) … M(i,j) … M(m-1,n-2) M(m-1,n-1)

matrix<> A = eye(3,4);
writebin("./","matrix.bin",A);
matrix<> B = readbin("./","matrix.bin");
disp(B);

See readbin, writetxt.

writetxt

template<typename T>
void castor::writetxt(std::string path, std::string filename, matrix<T> const &A)

Write matrix in *.txt file.

writetxt(“path”,”filename”) write ascii text file with matrix stored in the following format : m n M(0,0) M(0,1) … M(0,n-2) M(0,n-1) … … M(m-1,0) M(m-1,1) … M(m-1,n-2) M(m-1,n-1)

matrix<> A = eye(3,4);
writetxt("./","matrix.txt",A);
matrix<> B = readtxt("./","matrix.txt");
disp(B);

See readtxt, writebin.