Lines Matching refs:PetscCall
15 PetscCall(MatShellGetContext(A, &user)); in MatView_User()
16 PetscCall(MatView(user->B, viewer)); in MatView_User()
25 PetscCall(MatShellGetContext(A, &user)); in MatMult_User()
26 PetscCall(MatMult(user->B, X, Y)); in MatMult_User()
35 PetscCall(MatShellGetContext(A, &user)); in MatMultTranspose_User()
36 PetscCall(MatMultTranspose(user->B, X, Y)); in MatMultTranspose_User()
45 PetscCall(MatShellGetContext(A, &user)); in MatGetDiagonal_User()
46 PetscCall(MatGetDiagonal(user->B, X)); in MatGetDiagonal_User()
68 PetscCall(PetscObjectGetType((PetscObject)A, &mattypename)); in TestMatrix()
69 PetscCall(PetscViewerASCIIPrintf(viewer, "\nMatrix of type: %s\n", mattypename)); in TestMatrix()
70 PetscCall(VecDuplicate(X, &W1)); in TestMatrix()
71 PetscCall(VecDuplicate(X, &W2)); in TestMatrix()
72 PetscCall(VecDuplicate(X, &W3)); in TestMatrix()
73 PetscCall(MatScale(A, 31)); in TestMatrix()
74 PetscCall(MatShift(A, 37)); in TestMatrix()
75 PetscCall(MatDiagonalScale(A, X, Y)); in TestMatrix()
76 PetscCall(MatScale(A, 41)); in TestMatrix()
77 PetscCall(MatDiagonalScale(A, Y, Z)); in TestMatrix()
78 PetscCall(MatComputeOperator(A, MATDENSE, &E)); in TestMatrix()
80 PetscCall(MatView(E, viewer)); in TestMatrix()
81 PetscCall(PetscViewerASCIIPrintf(viewer, "Testing MatMult + MatMultTranspose\n")); in TestMatrix()
82 PetscCall(MatMult(A, Z, W1)); in TestMatrix()
83 PetscCall(MatMultTranspose(A, W1, W2)); in TestMatrix()
84 PetscCall(VecView(W2, viewer)); in TestMatrix()
85 PetscCall(PetscViewerASCIIPrintf(viewer, "Testing MatMultHermitianTranspose\n")); in TestMatrix()
86 PetscCall(VecConjugate(W1)); in TestMatrix()
87 PetscCall(MatMultHermitianTranspose(A, W1, W2)); in TestMatrix()
88 PetscCall(VecConjugate(W2)); in TestMatrix()
89 PetscCall(VecView(W2, viewer)); in TestMatrix()
91 PetscCall(PetscViewerASCIIPrintf(viewer, "Testing MatMultAdd\n")); in TestMatrix()
92 PetscCall(VecCreateSeqWithArray(PETSC_COMM_SELF, 1, 2, multadd, &diff)); in TestMatrix()
93 PetscCall(VecSet(W1, -1.0)); in TestMatrix()
94 PetscCall(MatMultAdd(A, W1, W1, W2)); in TestMatrix()
95 PetscCall(VecView(W2, viewer)); in TestMatrix()
96 PetscCall(VecAXPY(W2, -1.0, diff)); in TestMatrix()
97 PetscCall(VecNorm(W2, NORM_2, &nrm)); in TestMatrix()
102 PetscCall(VecSet(W2, -1.0)); in TestMatrix()
103 PetscCall(MatMultAdd(A, W1, W2, W2)); in TestMatrix()
104 PetscCall(VecView(W2, viewer)); in TestMatrix()
105 PetscCall(VecAXPY(W2, -1.0, diff)); in TestMatrix()
106 PetscCall(VecNorm(W2, NORM_2, &nrm)); in TestMatrix()
110 PetscCall(VecDestroy(&diff)); in TestMatrix()
112 PetscCall(PetscViewerASCIIPrintf(viewer, "Testing MatMultTransposeAdd\n")); in TestMatrix()
113 PetscCall(VecCreateSeqWithArray(PETSC_COMM_SELF, 1, 2, multtadd, &diff)); in TestMatrix()
115 PetscCall(VecSet(W1, -1.0)); in TestMatrix()
116 PetscCall(MatMultTransposeAdd(A, W1, W1, W2)); in TestMatrix()
117 PetscCall(VecView(W2, viewer)); in TestMatrix()
118 PetscCall(VecAXPY(W2, -1.0, diff)); in TestMatrix()
119 PetscCall(VecNorm(W2, NORM_2, &nrm)); in TestMatrix()
124 PetscCall(VecSet(W2, -1.0)); in TestMatrix()
125 PetscCall(MatMultTransposeAdd(A, W1, W2, W2)); in TestMatrix()
126 PetscCall(VecView(W2, viewer)); in TestMatrix()
127 PetscCall(VecAXPY(W2, -1.0, diff)); in TestMatrix()
128 PetscCall(VecNorm(W2, NORM_2, &nrm)); in TestMatrix()
132 PetscCall(VecDestroy(&diff)); in TestMatrix()
134 PetscCall(PetscViewerASCIIPrintf(viewer, "Testing MatMultHermitianTransposeAdd\n")); in TestMatrix()
135 PetscCall(VecCreateSeqWithArray(PETSC_COMM_SELF, 1, 2, multtadd, &diff)); in TestMatrix()
137 PetscCall(VecSet(W1, -1.0)); in TestMatrix()
138 PetscCall(MatMultHermitianTransposeAdd(A, W1, W1, W3)); in TestMatrix()
139 PetscCall(VecConjugate(W3)); in TestMatrix()
140 PetscCall(VecView(W3, viewer)); in TestMatrix()
141 PetscCall(VecAXPY(W3, -1.0, diff)); in TestMatrix()
142 PetscCall(VecNorm(W3, NORM_2, &nrm)); in TestMatrix()
147 PetscCall(VecSet(W3, -1.0)); in TestMatrix()
148 PetscCall(MatMultHermitianTransposeAdd(A, W1, W3, W3)); in TestMatrix()
149 PetscCall(VecConjugate(W3)); in TestMatrix()
150 PetscCall(VecView(W3, viewer)); in TestMatrix()
151 PetscCall(VecAXPY(W3, -1.0, diff)); in TestMatrix()
152 PetscCall(VecNorm(W3, NORM_2, &nrm)); in TestMatrix()
156 PetscCall(VecDestroy(&diff)); in TestMatrix()
158 PetscCall(PetscViewerASCIIPrintf(viewer, "Testing MatGetDiagonal\n")); in TestMatrix()
159 PetscCall(MatGetDiagonal(A, W2)); in TestMatrix()
160 PetscCall(VecView(W2, viewer)); in TestMatrix()
161 PetscCall(VecCreateSeqWithArray(PETSC_COMM_SELF, 1, 2, diag, &diff)); in TestMatrix()
162 PetscCall(VecAXPY(diff, -1.0, W2)); in TestMatrix()
163 PetscCall(VecNorm(diff, NORM_2, &nrm)); in TestMatrix()
167 PetscCall(VecDestroy(&diff)); in TestMatrix()
171 PetscCall(MatDiagonalSet(A, X, INSERT_VALUES)); in TestMatrix()
172 PetscCall(MatGetDiagonal(A, W1)); in TestMatrix()
173 PetscCall(VecView(W1, viewer)); in TestMatrix()
175 PetscCall(PetscViewerASCIIPrintf(viewer, "MatDiagonalSet not tested on MATSHELL\n")); in TestMatrix()
178 PetscCall(MatDestroy(&E)); in TestMatrix()
179 PetscCall(VecDestroy(&W1)); in TestMatrix()
180 PetscCall(VecDestroy(&W2)); in TestMatrix()
181 PetscCall(VecDestroy(&W3)); in TestMatrix()
201 PetscCall(PetscInitialize(&argc, &args, NULL, help)); in main()
202 PetscCall(MatCreateSeqAIJ(PETSC_COMM_WORLD, 2, 2, 2, NULL, &A)); in main()
203 PetscCall(MatSetUp(A)); in main()
204 PetscCall(VecCreateSeq(PETSC_COMM_WORLD, 2, &X)); in main()
205 PetscCall(VecDuplicate(X, &Y)); in main()
206 PetscCall(VecDuplicate(X, &Z)); in main()
207 PetscCall(MatSetValues(A, 2, inds, 2, inds, avals, INSERT_VALUES)); in main()
208 PetscCall(VecSetValues(X, 2, inds, xvals, INSERT_VALUES)); in main()
209 PetscCall(VecSetValues(Y, 2, inds, yvals, INSERT_VALUES)); in main()
210 PetscCall(VecSetValues(Z, 2, inds, zvals, INSERT_VALUES)); in main()
211 PetscCall(MatAssemblyBegin(A, MAT_FINAL_ASSEMBLY)); in main()
212 PetscCall(MatAssemblyEnd(A, MAT_FINAL_ASSEMBLY)); in main()
213 PetscCall(VecAssemblyBegin(X)); in main()
214 PetscCall(VecAssemblyBegin(Y)); in main()
215 PetscCall(VecAssemblyBegin(Z)); in main()
216 PetscCall(VecAssemblyEnd(X)); in main()
217 PetscCall(VecAssemblyEnd(Y)); in main()
218 PetscCall(VecAssemblyEnd(Z)); in main()
220 PetscCall(PetscNew(&user)); in main()
223 PetscCall(MatCreateShell(PETSC_COMM_WORLD, 2, 2, 2, 2, user, &S)); in main()
224 PetscCall(MatSetUp(S)); in main()
225 PetscCall(MatShellSetOperation(S, MATOP_VIEW, (PetscErrorCodeFn *)MatView_User)); in main()
226 PetscCall(MatShellSetOperation(S, MATOP_MULT, (PetscErrorCodeFn *)MatMult_User)); in main()
227 …PetscCall(MatShellSetOperation(S, MATOP_MULT_TRANSPOSE, (PetscErrorCodeFn *)MatMultTranspose_User)… in main()
228 PetscCall(MatShellSetOperation(S, MATOP_GET_DIAGONAL, (PetscErrorCodeFn *)MatGetDiagonal_User)); in main()
230 for (i = 0; i < 4; i++) PetscCall(MatCreateSeqDense(PETSC_COMM_WORLD, 1, 1, &avals[i], &D[i])); in main()
231 PetscCall(MatCreateNest(PETSC_COMM_WORLD, 2, NULL, 2, NULL, D, &N)); in main()
232 PetscCall(MatSetUp(N)); in main()
234 PetscCall(TestMatrix(S, X, Y, Z)); in main()
235 PetscCall(TestMatrix(A, X, Y, Z)); in main()
236 PetscCall(TestMatrix(N, X, Y, Z)); in main()
238 for (i = 0; i < 4; i++) PetscCall(MatDestroy(&D[i])); in main()
239 PetscCall(MatDestroy(&A)); in main()
240 PetscCall(MatDestroy(&S)); in main()
241 PetscCall(MatDestroy(&N)); in main()
242 PetscCall(VecDestroy(&X)); in main()
243 PetscCall(VecDestroy(&Y)); in main()
244 PetscCall(VecDestroy(&Z)); in main()
245 PetscCall(PetscFree(user)); in main()
246 PetscCall(PetscFinalize()); in main()