1af0996ceSBarry Smith #include <petsc/private/matimpl.h> /*I "petscmat.h" I*/ 2c4aff060SBarry Smith 3c4aff060SBarry Smith /*@C 4a5b23f4aSJose E. Roman MatPythonSetType - Initialize a Mat object implemented in Python. 5c4aff060SBarry Smith 6c4aff060SBarry Smith Collective on Mat 7c4aff060SBarry Smith 8d8d19677SJose E. Roman Input Parameters: 9c4aff060SBarry Smith + mat - the matrix (Mat) object. 10c4aff060SBarry Smith - pyname - full dotted Python name [package].module[.{class|function}] 11c4aff060SBarry Smith 12c4aff060SBarry Smith Options Database Key: 1367b8a455SSatish Balay . -mat_python_type <pyname> - python class 14c4aff060SBarry Smith 15c4aff060SBarry Smith Level: intermediate 16c4aff060SBarry Smith 17186e87acSLisandro Dalcin .seealso: MatCreate(), MatSetType(), MATPYTHON, PetscPythonInitialize() 18c4aff060SBarry Smith @*/ 197087cfbeSBarry Smith PetscErrorCode MatPythonSetType(Mat mat,const char pyname[]) 20c4aff060SBarry Smith { 21c4aff060SBarry Smith PetscFunctionBegin; 220700a824SBarry Smith PetscValidHeaderSpecific(mat,MAT_CLASSID,1); 23c4aff060SBarry Smith PetscValidCharPointer(pyname,2); 24*9566063dSJacob Faibussowitsch PetscCall(PetscTryMethod(mat,"MatPythonSetType_C",(Mat, const char[]),(mat,pyname))); 25c4aff060SBarry Smith PetscFunctionReturn(0); 26c4aff060SBarry Smith } 27c4aff060SBarry Smith 28c4aff060SBarry Smith /*@C 29c4aff060SBarry Smith MatPythonCreate - Create a Mat object implemented in Python. 30c4aff060SBarry Smith 31c4aff060SBarry Smith Collective on Mat 32c4aff060SBarry Smith 33c4aff060SBarry Smith Input Parameters: 34c4aff060SBarry Smith + comm - MPI communicator 35c4aff060SBarry Smith . m - number of local rows (or PETSC_DECIDE to have calculated if M is given) 36c4aff060SBarry Smith . n - number of local columns (or PETSC_DECIDE to have calculated if N is given) 37c4aff060SBarry Smith . M - number of global rows (or PETSC_DECIDE to have calculated if m is given) 38c4aff060SBarry Smith . N - number of global columns (or PETSC_DECIDE to have calculated if n is given) 39c4aff060SBarry Smith - pyname - full dotted Python name [package].module[.{class|function}] 40c4aff060SBarry Smith 41c4aff060SBarry Smith Output Parameter: 42c4aff060SBarry Smith . A - the matrix 43c4aff060SBarry Smith 44c4aff060SBarry Smith Level: intermediate 45c4aff060SBarry Smith 46c4aff060SBarry Smith .seealso: MATPYTHON, MatPythonSetType(), PetscPythonInitialize() 47c4aff060SBarry Smith 48c4aff060SBarry Smith @*/ 497087cfbeSBarry Smith PetscErrorCode MatPythonCreate(MPI_Comm comm,PetscInt m,PetscInt n,PetscInt M,PetscInt N,const char pyname[],Mat *A) 50c4aff060SBarry Smith { 51c4aff060SBarry Smith PetscFunctionBegin; 52c4aff060SBarry Smith PetscValidCharPointer(pyname,6); 53c4aff060SBarry Smith PetscValidPointer(A,6); 54*9566063dSJacob Faibussowitsch PetscCall(MatCreate(comm,A)); 55*9566063dSJacob Faibussowitsch PetscCall(MatSetSizes(*A,m,n,M,N)); 56*9566063dSJacob Faibussowitsch PetscCall(MatSetType(*A,MATPYTHON)); 57*9566063dSJacob Faibussowitsch PetscCall(MatPythonSetType(*A,pyname)); 58c4aff060SBarry Smith PetscFunctionReturn(0); 59c4aff060SBarry Smith } 60