[petsc-users] MatElemDiv

Barry Smith bsmith at mcs.anl.gov
Tue Feb 16 13:22:05 CST 2010


On Feb 15, 2010, at 4:36 PM, Matthew Knepley wrote:

> You get the local piece.
>
>   Matt

    But note that sparse matrices may have more than one "piece", for  
example AIJ, BAIJ and SBAIJ sparse matrices have two parts (see the  
manual pages for creating them for the definition of the two parts).  
Thus you need to actually call the MatGetArray() on each part.  
Something like

#include "src/mat/impls/aij/mpi/mpiaij.h"

    Mat A;
    Mat_MPIAIJ *a = (Mat_MPIAIJ*) A->data;
    PetscScalar *d,*o;

    ierr = MatGetArray(a->A,&d);
    ierr = MatGetArray(a->B,&o);

    gives you access to the two parts of the matrix A.

    Barry

>
> On Mon, Feb 15, 2010 at 9:44 AM, John-Michael Fischer <fischej at umich.edu 
> > wrote:
> On the documentation page for MatGetArray() it says the result is,  
> understandably, dependent on matrix structure.
> My question is if I'm using an MPI Mat then will MatGetArray get the  
> local array on each proc, or will it assemble the whole array?
>
> Thank you,
> John-Michael Fischer
>
> On Feb 11, 2010, at 2:36 PM, Barry Smith wrote:
>
> >
> >  If you "know" that the two matrices have the same nonzero pattern  
> you can do this efficiently with a call to MatGetArray() on each  
> matrix.
> >
> >   Barry
> >
> > On Feb 11, 2010, at 10:06 AM, Matthew Knepley wrote:
> >
> >> On Thu, Feb 11, 2010 at 10:01 AM, John-Michael Fischer <fischej at umich.edu 
> > wrote:
> >> This seems like a silly question, but is there a reason I cannot  
> find a function for MatrixElementWiseDivide that would accept two  
> matricies, M1 and M2 and perform element wise division?
> >>
> >> I can go through the process of getting local rows on each proc,  
> doing the element by element division, etc... but it just seems like  
> a perfect candidate for a built-in.
> >>
> >> We do not have any Mat element-wise functions, since with sparse  
> matrices this might
> >> be ill-defined with different non-zero patterns, as well as slow  
> since the result might have
> >> a third nonzero pattern.
> >>
> >>   Matt
> >>
> >> Thanks
> >> John-Michael Fischer
> >> University of Michigan
> >> Nuclear Engineering and Radiological Sciences
> >>
> >>
> >>
> >> --
> >> 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
> >
> >
> >
>
>
>
>
> -- 
> 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



More information about the petsc-users mailing list