# How to fill a matrix with a vector parallelly

Barry Smith bsmith at mcs.anl.gov
Sun Nov 29 21:12:59 CST 2009

```On Nov 29, 2009, at 9:09 PM, ming zhu wrote:

> Two questions:
> one,     how do I know which part belongs to the present processor?

Call VecGetOwnershipRange() to know what rows of the vector belong
to the process. Then create the MPIDense matrix with the same number
of local rows.

> second, is there any examples for this kind of question?
>
> Thank you
>
> --- 09年11月30日，周一, Barry Smith <bsmith at mcs.anl.gov> 写
> 道：
>
> 发件人: Barry Smith <bsmith at mcs.anl.gov>
> 主题: Re: How to fill a matrix with a vector parallelly
> 收件人: "PETSc users list" <petsc-users at mcs.anl.gov>
> 日期: 2009年11月30日,周一,上午9:53
>
>
>   Since evenvectors will (almost always) be dense vectors you will
> want to use a MPIDENSE matrix to store them. So create a MPIDENSE
> matrix with the same row layout as the eigenvector then on each
> process use VecGetArray() to access that processes part of the
> vector and MatGetArray() to access that part of the matrix and copy
> the values over from the vector array to the matrix array.
>
>    Barry
>
> On Nov 29, 2009, at 7:41 PM, ming zhu wrote:
>
> > HI
> > I am trying to solve an eigenvalue problem. A = U * LAMBDA*U'.
> While SLEPC proivdes a solver to get an eigenvector and the related
> eigenvalue, I have to fill the eigenvector to form the eigen matrix.
> However, there seems no such function to do this directly. I was
> trying to use VecGetValues and filled the matrix one by one.
> Howevevr, it can not do that in parallel.
> >
> >    Is there anyone can help me ?
> >
> > Thank you
> >
> >
> > 好玩贺卡等你发，邮箱贺卡全新上线！
>
>
> 好玩贺卡等你发，邮箱贺卡全新上线！

```