Actual source code: pythonmat.c
petsc-3.11.4 2019-09-28
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: .keywords: Mat, Python
19: .seealso: MatCreate(), MatSetType(), MATPYTHON, PetscPythonInitialize()
20: @*/
21: PetscErrorCode MatPythonSetType(Mat mat,const char pyname[])
22: {
28: PetscTryMethod(mat,"MatPythonSetType_C",(Mat, const char[]),(mat,pyname));
29: return(0);
30: }
33: /*@C
34: MatPythonCreate - Create a Mat object implemented in Python.
36: Collective on Mat
38: Input Parameters:
39: + comm - MPI communicator
40: . m - number of local rows (or PETSC_DECIDE to have calculated if M is given)
41: . n - number of local columns (or PETSC_DECIDE to have calculated if N is given)
42: . M - number of global rows (or PETSC_DECIDE to have calculated if m is given)
43: . N - number of global columns (or PETSC_DECIDE to have calculated if n is given)
44: - pyname - full dotted Python name [package].module[.{class|function}]
46: Output Parameter:
47: . A - the matrix
49: Level: intermediate
51: .keywords: Mat, Python
53: .seealso: MATPYTHON, MatPythonSetType(), PetscPythonInitialize()
55: @*/
56: PetscErrorCode MatPythonCreate(MPI_Comm comm,PetscInt m,PetscInt n,PetscInt M,PetscInt N,const char pyname[],Mat *A)
57: {
63: MatCreate(comm,A);
64: MatSetSizes(*A,m,n,M,N);
65: MatSetType(*A,MATPYTHON);
66: MatPythonSetType(*A,pyname);
67: return(0);
68: }