This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Array of Matrix

Tags: None
(comma "," separated)
wendingmai
Registered Member
Posts
16
Karma
0

Array of Matrix

Sat Jul 09, 2016 10:21 am
Hi,

I would like to construct a series of matrix which similar to each other.
I tried to construct like below. However it cannot work. Would you pls help to give suggestion?
Thank you.

Code: Select all
SpMat C[n](Sum_nonzeros_C, Sum_nonzeros_C);
      vector<Tri> CT;
      CT.reserve(Sum_nonzeros_C);

for(int i=1; i<=n;i++)
{
for(t=0;t<Sum_nonzeros_C;t++)
         CT.push_back(Tri(IC[i][t], JC[i][t], PC[i][t]));
         C[i].setFromTriplets(CT.begin(), CT.end());
}
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Array of Matrix

Sun Jul 10, 2016 8:43 pm
The ligne SpMat "C[n](Sum_nonzeros_C, Sum_nonzeros_C);" is not legal C++, better use a std::vector:

vector<SpMat> C(n, SpMat(Sum_nonzeros_C, Sum_nonzeros_C) );

Then, I guess the main loop should be:

for(int i=0; i<n;i++)

and you probably also need to clear CT at each iteration. It is also strange that the number of rows/columns are the same as the number of non-zeros.


Bookmarks



Who is online

Registered users: Bing [Bot], blue_bullet, Google [Bot], rockscient, Yahoo [Bot]