[petsc-users] forming a matrix from a set of vectors
Patrick Sanan
patrick.sanan at gmail.com
Wed Aug 26 16:04:17 CDT 2015
On Wed, Aug 26, 2015 at 11:02 PM, Patrick Sanan <patrick.sanan at gmail.com>
wrote:
>
>
> On Wed, Aug 26, 2015 at 10:41 PM, Nicolas Pozin <nicolas.pozin at inria.fr>
> wrote:
>
>> Actually I want to get the diagonal of the matrix : transpose(d)*A*d where
>> -d is a sparse matrix of size (n1,m1)
>> -A is a dense symetric matrix of size size (n1,n1)
>> with m1 very big compared to n1 (1 million against a few dozens).
>>
> If I read this correctly, another way to phrase what you need is
> ||d_i||_A^2 = <d_i,Ad_i>, for a few dozen values of i . Naively you could
> do that by iterating through an array of Vec objects (which need not all be
> stored in memory simultaneously), calling MatMult followed by VecDot. You
> could perhaps get more clever later (if the size of the system justifies
> it) by doing things like using non-blocking/split versions of VecDot (or
> VecMDot) so that you can overlap the matrix multiplications with the dot
> products.
>
Ah, sorry, I had the sparsity of A and d reversed in my reading.
>
>> The problem is too big to allow the use of MatMatMult.
>> What I planned to do :
>> -compute the vectors Vi defined by transpose(d)*Ai where Ai is the i-th
>> column of A : quick since d is sparse and n1 is small
>> -deduce the matrix transpose(d)*A = [V1 ... Vn]
>> and then get the diagonal of transpose(d)*transpose([V1 ...Vn]) through
>> -transpose([V1 ...Vn]) and get its columns C1 ... Cn
>> -conclude on the i-th diagonal value which is the i-th component of
>> tranpose(d)*Ci
>>
>>
>>
>> ----- Mail original -----
>> > De: "Barry Smith" <bsmith at mcs.anl.gov>
>> > À: "Nicolas Pozin" <nicolas.pozin at inria.fr>
>> > Cc: "Jed Brown" <jed at jedbrown.org>, petsc-users at mcs.anl.gov
>> > Envoyé: Mercredi 26 Août 2015 22:21:04
>> > Objet: Re: [petsc-users] forming a matrix from a set of vectors
>> >
>> >
>> > > 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).
>> > >>
>> >
>> >
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20150826/f3c9c564/attachment.html>
More information about the petsc-users
mailing list