# [petsc-users] Customizeing MatSetValuesBlocked(...)

Hong Zhang hzhang at mcs.anl.gov
Wed Aug 8 17:28:59 CDT 2012

```Jinquan:

You need understand some basic concepts in numerical computations, for
example:
- dense matrix vs. sparse matrix and their data structures
- algorithms for solve Ax=b
- available software packages, their targeted applications

See www.mcs.anl.gov/~hzhang/teach/cs595 for a list of references.

Hong

What I am trying to say is that ****
>
> **·         **allocated 1D array A in PETSc****
>
> **·         **passed 1D A into ScaLAPACK****
>
> **·         **obtained the indices of A^-1 computed from ScaLAPACK and
> stored them in a 1D array****
>
> **·         **indexed A^-1 as a 1D array in PETSc using the indices
> obtained from ScaLAPACK****
>
> **·         **constructed a sparse matrix, including A^-1 and others,
> using a new set of indices for A^-1.  ****
>
> I can have  the last step done in using ****
>
> ** **
>
>                        ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr);
> ****
>
>                        ierr =
> MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N);CHKERRQ(ierr);****
>
>                        ierr = MatSetFromOptions(A);CHKERRQ(ierr);****
>
>                        ierr = MatSetUp(A);CHKERRQ(ierr);****
>
>   ****
>
>   ierr = MatSetValues(A,1,&Ii,1,&J,&v,INSERT_VALUES);CHKERRQ(ierr);****
>
> ** **
>
> It just took too long.  This is the performance issue I am having.  ****
>
> ** **
>
> To improve the performance, it is necessary for preallocation.  The
> dilemma is: *MatCreateAIJ* and *MatXCreateAIJ* complained the setting of *d_nz,
> d_nnz,o_nz, o_nnz*  since there are no diagonal and off-diagonal parts
> defined in A^-1.****
>
> ** **
>
> Jinquan****
>
> ** **
>
> ** **
>
> *From:* petsc-users-bounces at mcs.anl.gov [mailto:
> petsc-users-bounces at mcs.anl.gov] *On Behalf Of *Jed Brown
> *Sent:* Wednesday, August 08, 2012 3:04 PM
>
> *To:* PETSc users list
> *Subject:* Re: [petsc-users] Customizeing MatSetValuesBlocked(...)****
>
> ** **
>
> On Wed, Aug 8, 2012 at 3:45 PM, Jinquan Zhong <jzhong at scsolutions.com>
> wrote:****
>
> It is a 1D matrix in PETSc.  I just passed it as a 2D matrix in
> ScaLAPACK.  It is still a 1D matrix when get back into PETSc.****
>
> ** **
>
> What are you trying to say?****
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120808/4693fd3e/attachment-0001.html>
```