> El 4 jul 2017, a las 11:22, errabii sohaib <[email protected]> escribió: > > Hi, > > I am trying to use petsc4py and slepc4py to read a matrix that is distributed > on several files, In which i save the non zero elements by specifiying three > arrays (A, I, J) for Coeffs, rows and columns indices. > I am currently using MUMPS and i simply read a file and pass the A,I,J arrays > to MUMPS with each process. I am trying to do the same, however i am still > confused how matrices are structured in PETSc and if its even possible to > read n files and pass the matrix to PETsc to solve with slepc4py using > atleast n processes. > > Thank you very much for your time, > Sohaib. > > >
You can use createAIJWithArrays(), for instance I = [0, 2, 5, 8, 11, 14, 16] J = [0, 1, 0, 1, 2, 1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5] A = [2, -1, -1, 2, -1, -1, 2, -1, -1, 2, -1, -1, 2, -1, -1, 2] M = PETSc.Mat(); M.createAIJWithArrays([6, 6], (I,J,A)) M.view() Note that I is not the row index but the pointer to row start (according to the usual compressed sparse row format). Jose
