[petsc-users] Create csr matrix

Jakub Pola jakub.pola at gmail.com
Sun Dec 12 15:15:08 CST 2010


The reason I want to perform this operation is that I have CG solver
based on GPU. It takes arguments in the way I have written so 

double  vals  [] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0} ;
int     c_idx [] = {1,   3,   2,   0,   1,   2,   2,   3} ;
int     r_idx [] = {0, 2, 3, 6, 8} ;
int     n_rows   = 4 ; //square matrix

That will help me a lot with testing. I can load matrix using PETSC then
I would like to extract this matrix to those arrays.

Dnia 2010-12-12, nie o godzinie 14:58 -0600, Barry Smith pisze:
> On Dec 12, 2010, at 2:41 PM, Jakub Pola wrote:
> 
> > Thanks, 
> > 
> > Is there also so easy way to extract those arrays from already created
> > matrix?
> 
>   Not particularly because we do not like the idea of directly manipulating the storage details of a particular sparse matrix type. But you can use MatGetRowIJ()/MatRestoreRowIJ() and MatGetArray() if you really want to.
> 
> 
> > I created matrix A with function:
> > MatCreateSeqAIJWithArrays(PETSC_COMM_SELF, n_rows, n_rows, r_idx, c_idx,
> > vals, A);
> 
> > 
> > Now I would like to extract all tables from matrix A;
> 
>    What is a "table" of a matrix A?
> 
>    Barry
> 
> > 
> > 
> > Dnia 2010-12-12, nie o godzinie 14:30 -0600, Barry Smith pisze:
> >> MatCreateSeqAIJWithArrays
> > 
> 




More information about the petsc-users mailing list