<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Aug 26, 2015 at 11:02 PM, Patrick Sanan <span dir="ltr"><<a href="mailto:patrick.sanan@gmail.com" target="_blank">patrick.sanan@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Wed, Aug 26, 2015 at 10:41 PM, Nicolas Pozin <span dir="ltr"><<a href="mailto:nicolas.pozin@inria.fr" target="_blank">nicolas.pozin@inria.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Actually I want to get the diagonal of the matrix : transpose(d)*A*d where<br>
-d is a sparse matrix of size (n1,m1)<br>
-A is a dense symetric matrix of size size (n1,n1)<br>
with m1 very big compared to n1 (1 million against a few dozens).<br></blockquote></span><div>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. </div></div></div></div></blockquote><div>Ah, sorry, I had the sparsity of A and d reversed in my reading. </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
The problem is too big to allow the use of MatMatMult.<br>
What I planned to do :<br>
-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<br>
-deduce the matrix transpose(d)*A = [V1 ... Vn]<br>
and then get the diagonal of transpose(d)*transpose([V1 ...Vn]) through<br>
-transpose([V1 ...Vn]) and get its columns C1 ... Cn<br>
-conclude on the i-th diagonal value which is the i-th component of tranpose(d)*Ci<br>
<br>
<br>
<br>
----- Mail original -----<br>
> De: "Barry Smith" <<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>><br>
> À: "Nicolas Pozin" <<a href="mailto:nicolas.pozin@inria.fr" target="_blank">nicolas.pozin@inria.fr</a>><br>
> Cc: "Jed Brown" <<a href="mailto:jed@jedbrown.org" target="_blank">jed@jedbrown.org</a>>, <a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a><br>
> Envoyé: Mercredi 26 Août 2015 22:21:04<br>
<div><div>> Objet: Re: [petsc-users] forming a matrix from a set of vectors<br>
><br>
><br>
> > On Aug 26, 2015, at 3:06 PM, Nicolas Pozin <<a href="mailto:nicolas.pozin@inria.fr" target="_blank">nicolas.pozin@inria.fr</a>> wrote:<br>
> ><br>
> > Thank you for this answer.<br>
> ><br>
> > What I want to do is to get the lines of this matrix and store them in<br>
> > vectors.<br>
><br>
> If you want to treat the columns of the dense matrix as vectors then use<br>
> MatDenseGetArray() and call VecCreateMPIWithArray() with a pointer to the<br>
> first row of each column of the obtained array (PETSc dense matrices are<br>
> stored by column; same as for example LAPACK).<br>
><br>
> But if you explained more why you want to treat something sometimes as a<br>
> Mat (which is a linear operator on vectors) and sometimes as vectors we<br>
> might be able to suggest how to organize your code.<br>
><br>
> Barry<br>
><br>
> ><br>
> ><br>
> > ----- Mail original -----<br>
> >> De: "Jed Brown" <<a href="mailto:jed@jedbrown.org" target="_blank">jed@jedbrown.org</a>><br>
> >> À: "Nicolas Pozin" <<a href="mailto:nicolas.pozin@inria.fr" target="_blank">nicolas.pozin@inria.fr</a>>, <a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a><br>
> >> Envoyé: Mercredi 26 Août 2015 20:38:37<br>
> >> Objet: Re: [petsc-users] forming a matrix from a set of vectors<br>
> >><br>
> >> Nicolas Pozin <<a href="mailto:nicolas.pozin@inria.fr" target="_blank">nicolas.pozin@inria.fr</a>> writes:<br>
> >>> Given a set of vectors V1, V2,...,Vn, is there an efficient way to form<br>
> >>> the<br>
> >>> dense matrix [V1 V2 ... Vn]?<br>
> >><br>
> >> What do you want to do with that matrix? The vector representation is<br>
> >> pretty flexible and the memory semantics are similar unless you store<br>
> >> the dense matrix row-aligned (not the default).<br>
> >><br>
><br>
><br>
</div></div></blockquote></div></div></div><br></div></div>
</blockquote></div><br></div></div>