Actual source code: pythonmat.c

petsc-3.3-p7 2013-05-11
  1: #include <petsc-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: MatCreate(), MatSetType(), MATPYTHON, PetscPythonInitialize()
 22: @*/
 23: PetscErrorCode  MatPythonSetType(Mat mat,const char pyname[])
 24: {
 29:   PetscTryMethod(mat,"MatPythonSetType_C",(Mat, const char[]),(mat,pyname));
 30:   return(0);
 31: }


 34: /*@C
 35:    MatPythonCreate - Create a Mat object implemented in Python.

 37:    Collective on Mat

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

 47:    Output Parameter:
 48: .  A - the matrix

 50:    Level: intermediate

 52: .keywords: Mat, Python

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

 56: @*/
 59: PetscErrorCode  MatPythonCreate(MPI_Comm comm,PetscInt m,PetscInt n,PetscInt M,PetscInt N,const char pyname[],Mat *A)
 60: {
 65:   MatCreate(comm,A);
 66:   MatSetSizes(*A,m,n,M,N);
 67:   MatSetType(*A,MATPYTHON);
 68:   MatPythonSetType(*A,pyname);
 69:   return(0);
 70: }