1c4aff060SBarry Smith #include "private/matimpl.h" /*I "petscmat.h" I*/ 2c4aff060SBarry Smith 3c4aff060SBarry Smith #undef __FUNCT__ 4c4aff060SBarry Smith #define __FUNCT__ "MatPythonSetType" 5c4aff060SBarry Smith /*@C 6c4aff060SBarry Smith MatPythonSetType - Initalize a Mat object implemented in Python. 7c4aff060SBarry Smith 8c4aff060SBarry Smith Collective on Mat 9c4aff060SBarry Smith 10c4aff060SBarry Smith Input Parameter: 11c4aff060SBarry Smith + mat - the matrix (Mat) object. 12c4aff060SBarry Smith - pyname - full dotted Python name [package].module[.{class|function}] 13c4aff060SBarry Smith 14c4aff060SBarry Smith Options Database Key: 15c4aff060SBarry Smith . -mat_python_type <pyname> 16c4aff060SBarry Smith 17c4aff060SBarry Smith Level: intermediate 18c4aff060SBarry Smith 19c4aff060SBarry Smith .keywords: Mat, Python 20c4aff060SBarry Smith 21c4aff060SBarry Smith .seealso: MATPYTHON, MatCreatePython(), PetscPythonInitialize() 22c4aff060SBarry Smith @*/ 23c4aff060SBarry Smith PetscErrorCode PETSCMAT_DLLEXPORT MatPythonSetType(Mat mat,const char pyname[]) 24c4aff060SBarry Smith { 25c4aff060SBarry Smith PetscErrorCode (*f)(Mat, const char[]) = 0; 26c4aff060SBarry Smith PetscErrorCode ierr; 27c4aff060SBarry Smith PetscFunctionBegin; 28*0700a824SBarry Smith PetscValidHeaderSpecific(mat,MAT_CLASSID,1); 29c4aff060SBarry Smith PetscValidCharPointer(pyname,2); 30c4aff060SBarry Smith ierr = PetscObjectQueryFunction((PetscObject)mat,"MatPythonSetType_C", 31c4aff060SBarry Smith (PetscVoidFunction*)&f);CHKERRQ(ierr); 32c4aff060SBarry Smith if (f) {ierr = (*f)(mat,pyname);CHKERRQ(ierr);} 33c4aff060SBarry Smith PetscFunctionReturn(0); 34c4aff060SBarry Smith } 35c4aff060SBarry Smith 36c4aff060SBarry Smith 37c4aff060SBarry Smith /*@C 38c4aff060SBarry Smith MatPythonCreate - Create a Mat object implemented in Python. 39c4aff060SBarry Smith 40c4aff060SBarry Smith Collective on Mat 41c4aff060SBarry Smith 42c4aff060SBarry Smith Input Parameters: 43c4aff060SBarry Smith + comm - MPI communicator 44c4aff060SBarry Smith . m - number of local rows (or PETSC_DECIDE to have calculated if M is given) 45c4aff060SBarry Smith . n - number of local columns (or PETSC_DECIDE to have calculated if N is given) 46c4aff060SBarry Smith . M - number of global rows (or PETSC_DECIDE to have calculated if m is given) 47c4aff060SBarry Smith . N - number of global columns (or PETSC_DECIDE to have calculated if n is given) 48c4aff060SBarry Smith - pyname - full dotted Python name [package].module[.{class|function}] 49c4aff060SBarry Smith 50c4aff060SBarry Smith Output Parameter: 51c4aff060SBarry Smith . A - the matrix 52c4aff060SBarry Smith 53c4aff060SBarry Smith Level: intermediate 54c4aff060SBarry Smith 55c4aff060SBarry Smith .keywords: Mat, Python 56c4aff060SBarry Smith 57c4aff060SBarry Smith .seealso: MATPYTHON, MatPythonSetType(), PetscPythonInitialize() 58c4aff060SBarry Smith 59c4aff060SBarry Smith @*/ 60c4aff060SBarry Smith #undef __FUNCT__ 61c4aff060SBarry Smith #define __FUNCT__ "MatPythonCreate" 62c4aff060SBarry Smith PetscErrorCode PETSCMAT_DLLEXPORT MatPythonCreate(MPI_Comm comm,PetscInt m,PetscInt n,PetscInt M,PetscInt N,const char pyname[],Mat *A) 63c4aff060SBarry Smith { 64c4aff060SBarry Smith PetscErrorCode ierr; 65c4aff060SBarry Smith PetscFunctionBegin; 66c4aff060SBarry Smith PetscValidCharPointer(pyname,6); 67c4aff060SBarry Smith PetscValidPointer(A,6); 68c4aff060SBarry Smith ierr = MatCreate(comm,A);CHKERRQ(ierr); 69c4aff060SBarry Smith ierr = MatSetSizes(*A,m,n,M,N);CHKERRQ(ierr); 70c4aff060SBarry Smith ierr = MatSetType(*A,MATPYTHON);CHKERRQ(ierr); 71c4aff060SBarry Smith ierr = MatPythonSetType(*A,pyname);CHKERRQ(ierr); 72c4aff060SBarry Smith PetscFunctionReturn(0); 73c4aff060SBarry Smith } 74