Actual source code: pythonmat.c

petsc-3.14.6 2021-03-30
Report Typos and Errors
  1: #include <petsc/private/matimpl.h>

  3: /*@C
  4:    MatPythonSetType - Initalize a Mat object implemented in Python.

  6:    Collective on Mat

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

 12:    Options Database Key:
 13: .  -mat_python_type <pyname>

 15:    Level: intermediate

 17: .seealso: MatCreate(), MatSetType(), MATPYTHON, PetscPythonInitialize()
 18: @*/
 19: PetscErrorCode  MatPythonSetType(Mat mat,const char pyname[])
 20: {

 26:   PetscTryMethod(mat,"MatPythonSetType_C",(Mat, const char[]),(mat,pyname));
 27:   return(0);
 28: }


 31: /*@C
 32:    MatPythonCreate - Create a Mat object implemented in Python.

 34:    Collective on Mat

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

 44:    Output Parameter:
 45: .  A - the matrix

 47:    Level: intermediate

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

 51: @*/
 52: PetscErrorCode  MatPythonCreate(MPI_Comm comm,PetscInt m,PetscInt n,PetscInt M,PetscInt N,const char pyname[],Mat *A)
 53: {

 59:   MatCreate(comm,A);
 60:   MatSetSizes(*A,m,n,M,N);
 61:   MatSetType(*A,MATPYTHON);
 62:   MatPythonSetType(*A,pyname);
 63:   return(0);
 64: }