[petsc-users] Reshaping a vector into a matrix

Barry Smith bsmith at mcs.anl.gov
Thu Jan 6 21:53:19 CST 2011


  You've assumed that the PETSC_DECIDE for the MatLoad() for local sizes will match that for the VecCreate(). In general they will not be the same.
Once you've created your MATMAIJ   (by they way you don't need to call MatAssembly on the MAIJ matrix) call MatGetLocalSize() and use that local size in the construction of the vector.

   Barry


On Jan 6, 2011, at 9:46 PM, S V N Vishwanathan wrote:

>>> 
>>> Is there any place to read up about MAIJ matrices. I read the manual
>>> pages but they were rather cryptic. Perhaps some example code?
>> 
>> http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/src/snes/examples/tutorials/ex48.c.html is the only example that uses. 
> 
> I wrote a little example (attached) to test my understanding of the MAIJ
> matrices. When I run it on a single processor I have no trouble but when
> I use mpiexec -n 2 I get the following errors. Any pointers on how to
> overcome this problem are appreciated. The code loads a matrix from a
> file, which can be downloaded from
> 
> http://www.stat.purdue.edu/~vishy/adult9.train.x
> 
> Before someone has ideas ;-), I should clarify that this is a standard
> machine learning dataset.
> 
> [0]PETSC ERROR: --------------------- Error Message
> ------------------------------------
> [0]PETSC ERROR: Nonconforming object sizes!
> [0]PETSC ERROR: Mat mat,Vec y: local dim 48843 48842!
> [0]PETSC ERROR:
> ------------------------------------------------------------------------
> [0]PETSC ERROR: Petsc Release Version 3.1.0, Patch 7, Mon Dec 20
> 14:26:37 CST 2010
> [0]PETSC ERROR: See docs/changes/index.html for recent updates.
> [0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.
> [0]PETSC ERROR: See docs/index.html for manual pages.
> [0]PETSC ERROR:
> ------------------------------------------------------------------------
> [0]PETSC ERROR: ./chumma on a linux-gnu named vishy-laptop by vishy Thu
> Jan  6 22:28:26 2011
> [0]PETSC ERROR: Libraries linked
> from /home/vishy/Repositories/GenEntropy/Code/hpc/petsc-3.1-p7/linux-gnu-cxx-debug/lib
> [0]PETSC ERROR: Configure run at Thu Dec 30 23:48:41 2010
> [0]PETSC ERROR: Configure options --with-debugging=yes
> --with-clanguage=C++ --with-shared --download-mpich=ifneeded
> [0]PETSC ERROR:
> ------------------------------------------------------------------------
> [0]PETSC ERROR: MatMult() line 1889 in src/mat/interface/matrix.c
> [0]PETSC ERROR: main() line 61 in chumma.cpp
> application called MPI_Abort(MPI_COMM_WORLD, 60) - process 0[cli_0]:
> aborting job:
> application called MPI_Abort(MPI_COMM_WORLD, 60) - process 0
> [0]0:Return code = 60
> [0]1:Return code = 0, signaled with Interrupt
> 
> vishy
> <chumma.cpp>



More information about the petsc-users mailing list