Resize to bigger dimension removes non-zero coefficients in sparse matrix?

Hello,

I am trying to resize a sparse matrix, but it appears to eliminate non-zeros coefficients? See below code and output. Many thanks for the help!

Regards,

Colin

Code:

int nnz=44330306;
int[int] I(nnz),J(nnz);
complex[int] C(nnz);
{
ifstream fileI(dir+“Qu_Chol.txt”);
for(int i=0; i<nnz; i++) fileI >> I[i] >> J[i] >> C[i];
}

matrix QuChol=[I,J,C];

cout << "QuChol.n = " <<QuChol.n << endl;
cout << "QuChol.m = " <<QuChol.m << endl;
cout << "QuChol.nbcoef = " <<QuChol.nbcoef << endl;

QuChol.resize(191720,191720);

cout << "QuChol.n = " <<QuChol.n << endl;
cout << "QuChol.m = " <<QuChol.m << endl;
cout << "QuChol.nbcoef = " <<QuChol.nbcoef << endl;

Output:

– Raw Matrix nxm =170260x170260 nb none zero coef. 44330306
QuChol.n = 170260
QuChol.m = 170260
QuChol.nbcoef = 44330306
QuChol.n = 191720
QuChol.m = 191720
QuChol.nbcoef = 44150820

OK, it seems it is implicitly calling the threshold function.

No,

mesh Th=square(10,10);
varf vM(u,v)= int2d(Th,qft=qf1pTlump)(u*v);
fespace Vh(Th,P1);
matrix A=vM(Vh,Vh);
cout << A.n << " nzz "<< A.nnz << endl;
A.resize(1000,1000);
cout << A.n << " nzz "<< A.nnz << endl;

the output is:

121 nzz 761

1000 nzz 761

I thing your version is very old …
Frederic Hecht.