[petsc-users] how to use MatSetValues?

Tomasz Jankowski tomjan at jay.au.poznan.pl
Tue Mar 8 02:39:53 CST 2011


hello,

Could someone give me a hand with MatSetValues function?

suppose such example sparse matrix

0   1.1 0   0   0
2.2 0   0   0   0
0   0   0   0   3.3
0   0   4.4 0   0
0   0   0   5.5 0

after storing it in row, col and val arrays we have

row[0] = 0;col[0]=1;val[0]=1.1;
row[1] = 1;col[1]=0;val[1]=2.2;
row[2] = 2;col[2]=4;val[2]=3.3;
row[3] = 3;col[3]=2;val[3]=4.4;
row[3] = 4;col[3]=3;val[4]=5.5;

question is: how to use MatSetValues with it?

I thought that 'MatSetValues(xx,5,row,1,col,val,INSERT_VALUES);' would be 
good but it doesn't .(I suppose I don't fully anderstand how it works...)

thanks,

tom

########################################################
#               tomjan at jay.au.poznan.pl                #
#              jay.au.poznan.pl/~tomjan/               #
########################################################


More information about the petsc-users mailing list