[petsc-users] forming a matrix from a set of vectors

Barry Smith bsmith at mcs.anl.gov
Wed Aug 26 15:21:04 CDT 2015


> On Aug 26, 2015, at 3:06 PM, Nicolas Pozin <nicolas.pozin at inria.fr> wrote:
> 
> Thank you for this answer.
> 
> What I want to do is to get the lines of this matrix and store them in vectors.

  If you want to treat the columns of the dense matrix as vectors then use MatDenseGetArray() and call VecCreateMPIWithArray() with a pointer to the first row of each column of the obtained array (PETSc dense matrices are stored by column; same as for example LAPACK).

  But if you explained more why you want to treat something sometimes as a Mat (which is a linear operator on vectors) and sometimes as vectors we might be able to suggest how to organize your code.

   Barry

> 
> 
> ----- Mail original -----
>> De: "Jed Brown" <jed at jedbrown.org>
>> À: "Nicolas Pozin" <nicolas.pozin at inria.fr>, petsc-users at mcs.anl.gov
>> Envoyé: Mercredi 26 Août 2015 20:38:37
>> Objet: Re: [petsc-users]  forming a matrix from a set of vectors
>> 
>> Nicolas Pozin <nicolas.pozin at inria.fr> writes:
>>> Given a set of vectors V1, V2,...,Vn, is there an efficient way to form the
>>> dense matrix [V1 V2 ... Vn]?
>> 
>> What do you want to do with that matrix?  The vector representation is
>> pretty flexible and the memory semantics are similar unless you store
>> the dense matrix row-aligned (not the default).
>> 



More information about the petsc-users mailing list