Actual source code: pythonmat.c

  1: #include "private/matimpl.h"          /*I "petscmat.h" I*/

  5: /*@C
  6:    MatPythonSetType - Initalize a Mat object implemented in Python.

  8:    Collective on Mat

 10:    Input Parameter:
 11: +  mat - the matrix (Mat) object.
 12: -  pyname - full dotted Python name [package].module[.{class|function}]

 14:    Options Database Key:
 15: .  -mat_python_type <pyname>

 17:    Level: intermediate

 19: .keywords: Mat, Python

 21: .seealso: MATPYTHON, MatCreatePython(), PetscPythonInitialize()
 22: @*/
 23: PetscErrorCode  MatPythonSetType(Mat mat,const char pyname[])
 24: {
 25:   PetscErrorCode (*f)(Mat, const char[]) = 0;
 30:   PetscObjectQueryFunction((PetscObject)mat,"MatPythonSetType_C",
 31:                                   (PetscVoidFunction*)&f);
 32:   if (f) {(*f)(mat,pyname);}
 33:   return(0);
 34: }


 37: /*@C
 38:    MatPythonCreate - Create a Mat object implemented in Python.

 40:    Collective on Mat

 42:    Input Parameters:
 43: +  comm - MPI communicator
 44: .  m - number of local rows (or PETSC_DECIDE to have calculated if M is given)
 45: .  n - number of local columns (or PETSC_DECIDE to have calculated if N is given)
 46: .  M - number of global rows (or PETSC_DECIDE to have calculated if m is given)
 47: .  N - number of global columns (or PETSC_DECIDE to have calculated if n is given)
 48: -  pyname - full dotted Python name [package].module[.{class|function}]

 50:    Output Parameter:
 51: .  A - the matrix

 53:    Level: intermediate

 55: .keywords: Mat, Python

 57: .seealso: MATPYTHON, MatPythonSetType(), PetscPythonInitialize()

 59: @*/
 62: PetscErrorCode  MatPythonCreate(MPI_Comm comm,PetscInt m,PetscInt n,PetscInt M,PetscInt N,const char pyname[],Mat *A)
 63: {
 68:   MatCreate(comm,A);
 69:   MatSetSizes(*A,m,n,M,N);
 70:   MatSetType(*A,MATPYTHON);
 71:   MatPythonSetType(*A,pyname);
 72:   return(0);
 73: }