set a column of a matrix

Satish Balay balay at
Sun Nov 1 11:14:03 CST 2009

On Sun, 1 Nov 2009, Umut Tabak wrote:

> On Sun, Nov 01, 2009 at 07:44:58AM -0600, Barry Smith wrote:
> >
> >    MatSetValues() so long as you have good matrix preallocation this  
> > will work fine.
> >
> >    Doing a transpose is very expensive.
> >
> Dear Barry and Matt,
>      Thanks for the replies, I am not doing anything in parallel. I
>      should use MatSetValues with appropriate column and row indices.
>      Actually, what I would like to do, I would like to set up a
>      vectorset(rectangular) and assign to a block in a matrix. Is 
>      there a vectorset that I could use directly to somehow put 
>      these vectors directly into this set. And use this vectorset to
>      set some part of a matrix.

You can set a block of values at a time with MatSetValues(). However
you should first get preallocation correct - and then time the
MatSetValues() code - before attempting additional optimization.

Once the preallocation is perfect - the primary savings with the
setting block of values is the reduction in the number of calls of
MatSetValues(). The other optimization you can do with setting block
of values - is to hav the col indices [of the block of values set] be
sorted. This saves a bit with searches [during insertion]


More information about the petsc-users mailing list