[petsc-users] Forming a matrix from vectors

Matthew Knepley knepley at gmail.com
Mon Feb 17 06:01:42 CST 2020


On Mon, Feb 17, 2020 at 4:24 AM Jose E. Roman <jroman at dsic.upv.es> wrote:

> I would use MatDenseGetColumn() and VecGetArrayRead() to get the two
> pointers and then copy the values with a loop.
>

I would do as Jose says to get it working. After you verify it, we could
show you how to avoid a copy.

  Thanks,

     Matt


> Jose
>
> > El 17 feb 2020, a las 9:35, Eda Oktay <eda.oktay at metu.edu.tr> escribió:
> >
> > Hello all,
> >
> > I am trying to form a matrix whose columns are eigenvectors I have
> calculated before U = [v1,v2,v3]. Is there any easy way of forming this
> matrix? My matrix should be parallel and I have created vectors as below,
> where nev i s the number of requested eigenvalues. So each V[i] represents
> an eigenvector and I should form a matrix by using V.
> >
> > Vec *V;
> >   VecDuplicateVecs(vr,nev,&V);
> >   for (i=0; i<nev;i++){
> >   ierr = EPSGetEigenpair(eps,i,&kr,NULL,V[i],NULL);
> >   }
> >
> > Thanks!
> >
> > Eda
>
>

-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20200217/964ae0bd/attachment-0001.html>


More information about the petsc-users mailing list