1af0996ceSBarry Smith #include <petsc/private/matimpl.h> /*I "petscmat.h" I*/ 2c4aff060SBarry Smith 3c4aff060SBarry Smith /*@C 4*a5b23f4aSJose E. Roman MatPythonSetType - Initialize a Mat object implemented in Python. 5c4aff060SBarry Smith 6c4aff060SBarry Smith Collective on Mat 7c4aff060SBarry Smith 8c4aff060SBarry Smith Input Parameter: 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: 13c4aff060SBarry Smith . -mat_python_type <pyname> 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 PetscErrorCode ierr; 225fd66863SKarl Rupp 23c4aff060SBarry Smith PetscFunctionBegin; 240700a824SBarry Smith PetscValidHeaderSpecific(mat,MAT_CLASSID,1); 25c4aff060SBarry Smith PetscValidCharPointer(pyname,2); 264ac538c5SBarry Smith ierr = PetscTryMethod(mat,"MatPythonSetType_C",(Mat, const char[]),(mat,pyname));CHKERRQ(ierr); 27c4aff060SBarry Smith PetscFunctionReturn(0); 28c4aff060SBarry Smith } 29c4aff060SBarry Smith 30c4aff060SBarry Smith /*@C 31c4aff060SBarry Smith MatPythonCreate - Create a Mat object implemented in Python. 32c4aff060SBarry Smith 33c4aff060SBarry Smith Collective on Mat 34c4aff060SBarry Smith 35c4aff060SBarry Smith Input Parameters: 36c4aff060SBarry Smith + comm - MPI communicator 37c4aff060SBarry Smith . m - number of local rows (or PETSC_DECIDE to have calculated if M is given) 38c4aff060SBarry Smith . n - number of local columns (or PETSC_DECIDE to have calculated if N is given) 39c4aff060SBarry Smith . M - number of global rows (or PETSC_DECIDE to have calculated if m is given) 40c4aff060SBarry Smith . N - number of global columns (or PETSC_DECIDE to have calculated if n is given) 41c4aff060SBarry Smith - pyname - full dotted Python name [package].module[.{class|function}] 42c4aff060SBarry Smith 43c4aff060SBarry Smith Output Parameter: 44c4aff060SBarry Smith . A - the matrix 45c4aff060SBarry Smith 46c4aff060SBarry Smith Level: intermediate 47c4aff060SBarry Smith 48c4aff060SBarry Smith .seealso: MATPYTHON, MatPythonSetType(), PetscPythonInitialize() 49c4aff060SBarry Smith 50c4aff060SBarry Smith @*/ 517087cfbeSBarry Smith PetscErrorCode MatPythonCreate(MPI_Comm comm,PetscInt m,PetscInt n,PetscInt M,PetscInt N,const char pyname[],Mat *A) 52c4aff060SBarry Smith { 53c4aff060SBarry Smith PetscErrorCode ierr; 545fd66863SKarl Rupp 55c4aff060SBarry Smith PetscFunctionBegin; 56c4aff060SBarry Smith PetscValidCharPointer(pyname,6); 57c4aff060SBarry Smith PetscValidPointer(A,6); 58c4aff060SBarry Smith ierr = MatCreate(comm,A);CHKERRQ(ierr); 59c4aff060SBarry Smith ierr = MatSetSizes(*A,m,n,M,N);CHKERRQ(ierr); 60c4aff060SBarry Smith ierr = MatSetType(*A,MATPYTHON);CHKERRQ(ierr); 61c4aff060SBarry Smith ierr = MatPythonSetType(*A,pyname);CHKERRQ(ierr); 62c4aff060SBarry Smith PetscFunctionReturn(0); 63c4aff060SBarry Smith } 64