File: matpython_protocol.py

package info (click to toggle)
petsc4py 3.23.1-1exp2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 3,448 kB
  • sloc: python: 12,503; ansic: 1,697; makefile: 343; f90: 313; sh: 14
file content (180 lines) | stat: -rw-r--r-- 5,341 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
from petsc4py.typing import Scalar
from petsc4py.PETSc import Mat
from petsc4py.PETSc import Vec
from petsc4py.PETSc import IS
from petsc4py.PETSc import InsertMode
from petsc4py.PETSc import NormType
from petsc4py.PETSc import Viewer


# A template class with the Python methods supported by MATPYTHON


class MatPythonProtocol:
    def mult(self, A: Mat, x: Vec, y: Vec) -> None:
        """Matrix vector multiplication: y = A @ x."""
        ...

    def multAdd(self, A: Mat, x: Vec, y: Vec, z: Vec) -> None:
        """Matrix vector multiplication: z = A @ x + y."""
        ...

    def multTranspose(self, A: Mat, x: Vec, y: Vec) -> None:
        """Transposed matrix vector multiplication: y = A^T @ x."""
        ...

    def multTransposeAdd(self, A: Mat, x: Vec, y: Vec, z: Vec) -> None:
        """Transposed matrix vector multiplication: z = A^T @ x + y."""
        ...

    def multHermitian(self, A: Mat, x: Vec, y: Vec) -> None:
        """Hermitian matrix vector multiplication: y = A^H @ x."""
        ...

    def multHermitianAdd(self, A: Mat, x: Vec, y: Vec, z: Vec) -> None:
        """Hermitian matrix vector multiplication: z = A^H @ x + y."""
        ...

    def view(self, A: Mat, viewer: Viewer) -> None:
        """View the matrix."""
        ...

    def setFromOptions(self, A: Mat) -> None:
        """Process command line for customization."""
        ...

    def multDiagonalBlock(self, A: Mat, x: Vec, y: Vec) -> None:
        """Perform the on-process matrix vector multiplication."""
        ...

    def createVecs(self, A: Mat) -> tuple[Vec, Vec]:
        """Return tuple of vectors (x,y) suitable for A @ x = y."""
        ...

    def scale(self, A: Mat, s: Scalar) -> None:
        """Scale the matrix by a scalar."""
        ...

    def shift(self, A: Mat, s: Scalar) -> None:
        """Shift the matrix by a scalar."""
        ...

    def createSubMatrix(self, A: Mat, r: IS, c: IS, out: Mat) -> Mat:
        """Return the submatrix corresponding to r rows and c columns.

        Matrix out must be reused if not None.

        """
        ...

    def zeroRowsColumns(self, A: Mat, r: IS, diag: Scalar, x: Vec, b: Vec) -> None:
        """Zero rows and columns of the matrix corresponding to the index set r.

        Insert diag on the diagonal and modify vectors x and b accordingly if not None.

        """
        ...

    def getDiagonal(self, A: Mat, d: Vec) -> None:
        """Compute the diagonal of the matrix: d = diag(A)."""
        ...

    def setDiagonal(self, A: Mat, d: Vec, im: InsertMode) -> None:
        """Set the diagonal of the matrix."""
        ...

    def missingDiagonal(self, A: Mat, d: Vec, im: InsertMode) -> tuple[bool, int]:
        """Return a flag indicating if the matrix is missing a diagonal entry and the location."""
        ...

    def diagonalScale(self, A: Mat, L: Vec, R: Vec) -> None:
        """Perform left and right diagonal scaling if vectors are not None.

        A = diag(L)@A@diag(R).

        """
        ...

    def getDiagonalBlock(self, A: Mat) -> Mat:
        """Return the on-process matrix."""
        ...

    def setUp(self, A: Mat) -> None:
        """Perform the required setup."""
        ...

    def duplicate(self, A: Mat, op: Mat.DuplicateOption) -> Mat:
        """Duplicate the matrix."""
        ...

    def copy(self, A: Mat, B: Mat, op: Mat.Structure) -> None:
        """Copy the matrix: B = A."""
        ...

    def productSetFromOptions(
        self, A: Mat, prodtype: str, X: Mat, Y: Mat, Z: Mat
    ) -> bool:
        """The boolean flag indicating if the matrix supports prodtype."""
        ...

    def productSymbolic(
        self, A: Mat, product: Mat, producttype: str, X: Mat, Y: Mat, Z: Mat
    ) -> None:
        """Perform the symbolic stage of the requested matrix product."""
        ...

    def productNumeric(
        self, A: Mat, product: Mat, producttype: str, X: Mat, Y: Mat, Z: Mat
    ) -> None:
        """Perform the numeric stage of the requested matrix product."""
        ...

    def zeroEntries(self, A: Mat) -> None:
        """Set the matrix to zero."""
        ...

    def norm(self, A: Mat, normtype: NormType) -> float:
        """Compute the norm of the matrix."""
        ...

    def solve(self, A: Mat, y: Vec, x: Vec) -> None:
        """Solve the equation: x = inv(A) y."""
        ...

    def solveAdd(self, A: Mat, y: Vec, z: Vec, x: Vec) -> None:
        """Solve the equation: x = inv(A) y + z."""
        ...

    def solveTranspose(self, A: Mat, y: Vec, x: Vec) -> None:
        """Solve the equation: x = inv(A)^T y."""
        ...

    def solveTransposeAdd(self, A: Mat, y: Vec, z: Vec, x: Vec) -> None:
        """Solve the equation: x = inv(A)^T y + z."""
        ...

    def SOR(
        self,
        A: Mat,
        b: Vec,
        omega: float,
        sortype: Mat.SORType,
        shift: float,
        its: int,
        lits: int,
        x: Vec,
    ) -> None:
        """Perform SOR iterations."""
        ...

    def conjugate(self, A: Mat) -> None:
        """Perform the conjugation of the matrix: A = conj(A)."""
        ...

    def imagPart(self, A: Mat) -> None:
        """Set real part to zero. A = imag(A)."""
        ...

    def realPart(self, A: Mat) -> None:
        """Set imaginary part to zero. A = real(A)."""
        ...