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

Sparse Matrix Block insertion

Tags: None
(comma "," separated)
xerion
Registered Member
Posts
20
Karma
0

Sparse Matrix Block insertion

Fri May 13, 2016 3:48 am
Hello,

I was wondering if there is an optimal way to achieve something I am going to describe.
The matrix I am working with is symmetric with an arrow head like shape

For most of the part of the sparse matrix I know the structure beforehand.
So I reserver the exact number of elements per column and then insert elements from lowest-->highest rows number .
I understand that I could be allocating a couple of extra elements which could help.

Regardless, say that I want to insert more elements in a column, I assume there will have to be some reallocation that I would like to minimize.
Code: Select all
a11  a12  a13  a14
      a22
          a33
               a44

Most of the times the insertion part is a block and I assume that if I do it one at a time is not going to be optimal.
So what would be the best way to say insert a24 which would be a square matrix ?
I guess something like .col(i).insert(start_row, end_row) could be useful ? (equivalent for row(i) for row major)

And a related question, since I read somewhere that there now Map<SparseMatrix> is available but could not find info.
Is there a way to use the Map such that I can say a24 += a*b where a and b are dense after the elements have been inserted?
I know that block is const so I cant use that but I was wondering if there is a way since now all the elements are inserted and present.

Thanks in advance.

Last edited by xerion on Sun May 15, 2016 4:20 am, edited 1 time in total.
steveshi
Registered Member
Posts
8
Karma
0

Re: Sparse Matrix element insertion

Fri May 13, 2016 4:42 am
Maybe Block class should work.
Code: Select all
SparseMatrix<double> spmat(n,n);
Block<SparseMatrix<double>> blk = spmat.block(i,j,p,q);
 

and you can operate blk
xerion
Registered Member
Posts
20
Karma
0

Re: Sparse Matrix element insertion

Fri May 13, 2016 2:44 pm
I dont think that this is possible.
operator+= not available for SparseMatrix Block
and operator= you get a nice error message for block = denseMatrix
"THE_EVAL_EVALTO_FUNCTION_SHOULD_NEVER_BE_CALLED_FOR_DENSE_OBJECTS"


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot], rockscient