# [petsc-users] MatCreateMPIAIJWithArrays

Mon Jul 23 03:26:24 CDT 2018

```Hello,
I am a beginner user.  I meet a problem.  I have a very big matrix.  In shaping the matrix, every nodes produce some rows of it. So it is very easy to store it with files at every node.  In the solve Ax=b, I hope every node to read the file and construct the big matrix in parallel. Every file's is a sub matrix which is row block. So I use MatCreateMPIAIJWithArrays to Create the matrix.

For example:
-1	2	-1	0	0	0	0	0	0	0
0	-1	2	-1	0	0	0	0	0	0
---------------------------------------------------------------
0	0	-1	2	-1	0	0	0	0	0
0	0	0	-1	0	0	0	0	0	0
---------------------------------------------------------------
0	0	0	0	-1	2	-1	0	0	0
0	0	0	0	0	-1	2	-1	0	0
---------------------------------------------------------------
0	0	0	0	0	0	-1	2	-1	0
0	0	0	0	0	0	0	-1	2	-1
---------------------------------------------------------------
0	0	0	0	0	0	0	0	-1	2
0	0	0	0	0	0	0	0	0	-1

Node 1    0-1 row block
Node 2   2-3 row block
Node 3   4-5 row block
Node 4   6-7 row block
Node 5  8-9 row block

use

MatCreateMPIAIJWithArrays(PETSC_COMM_SELF, 2, 10, 10,10, i,j,a); for node1
MatCreateMPIAIJWithArrays(PETSC_COMM_SELF, 2, 10, 10,10, i,j,a); for node2
MatCreateMPIAIJWithArrays(PETSC_COMM_SELF, 2, 10, 10,10, i,j,a); for node3
MatCreateMPIAIJWithArrays(PETSC_COMM_SELF, 2, 10, 10,10, i,j,a); for node4
MatCreateMPIAIJWithArrays(PETSC_COMM_SELF, 2, 10, 10,10, i,j,a); for node5

but there are error .   sum of cols of five nodes is not equal 10 (global column).

How to solve this problem,  Hope to get your help!

thanks

Degang Jin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20180723/3a8561dd/attachment-0001.html>
```