Hi is saving sparse matrix same as normal matrix? I used " save xx" but the saved file is zero kb. Is there any special command for sparse matrix? Thanks.
1 Answer
0
You can save a sparse matrix inside of a GAUSS Data Archive (GDA). Here is a simple example:
//Declare 'a' to be a sparse matrix
sparse matrix a;
//Create sparse matrix with random data
a = densetosp(rndu(10, 5), 0.25);
//Save sparse matrix 'a' to file 'mysparsedata.gda'
ret = gdaSave("mysparsedata.gda", "a", 0, 1, 0);
//Declare 'a_copy' to be a sparse matrix
sparse matrix a_copy;
//Load sparse data from 'mysparsedata.gda'
a_copy = gdaReadSparse("mysparsedata.gda", "a");
if (a == a_copy);
print "success!";
else;
print "matrices are different";
endif;
Your Answer
1 Answer
0
You can save a sparse matrix inside of a GAUSS Data Archive (GDA). Here is a simple example:
//Declare 'a' to be a sparse matrix
sparse matrix a;
//Create sparse matrix with random data
a = densetosp(rndu(10, 5), 0.25);
//Save sparse matrix 'a' to file 'mysparsedata.gda'
ret = gdaSave("mysparsedata.gda", "a", 0, 1, 0);
//Declare 'a_copy' to be a sparse matrix
sparse matrix a_copy;
//Load sparse data from 'mysparsedata.gda'
a_copy = gdaReadSparse("mysparsedata.gda", "a");
if (a == a_copy);
print "success!";
else;
print "matrices are different";
endif;