55 error(
" Matrix must contain only real values ");
59 if strcmp(prec,
" single ")
64 if exist(folder,
" dir ") ~= 7
65 error(
" Directory '%s' does not exist. ", folder);
67 file = fullfile(folder,file);
73 if n > intmax(
" int32 ") || m > intmax(
" int32 ")
74 error(
" Cannot save matrix: Dimensions exceed max int32 value. ");
76 fwrite(f,n,
" int32 ");
77 fwrite(f,m,
" int32 ");
100 if ~isreal(vec) || ~isvector(vec)
101 error(
" vec must be a vector with real values ");
105 if strcmp(prec,
" single ")
110 if exist(folder,
" dir ") ~= 7
111 error(
" Directory '%s' does not exist. ", folder);
113 file = fullfile(folder,file);
119 if s > intmax(
" int32 ")
120 error(
" Cannot save vector: Dimension exceeds max int32 value. ");
122 fwrite(f,s,
" int32 ");
123 fwrite(f, vec, prec);
141 siz = sprintf(
" %d, ",size(value));
142 vals = sprintf(
" %.16e, ",value(:));
143 jsonobj = sprintf(
" {'dim':[%s], 'values':[%s]} ",siz(1:end-2),vals(1:end-2));
static const MachineFormat
The machine format (little/big endian, 32/64bit) to use upon export.
static function saveRealVector(vec, file, folder)
Stores a real double vector in little endian format.
static function char jsonobj = matrixToJSON(double value)
Takes a matrix and returns a JSON representation as JSONObject with the fields "dim" and "values"...
Util: Utility functions for export of matrices and vectors to files.
static function saveRealMatrix(mat, file, folder)
Stores a real double matrix in little endian format.