Lines Matching defs:B

10 + B - A `MATLMVM` matrix
24 If the sizes of `B` have not been specified (using `MatSetSizes()` or `MatSetLayouts()`) before `MatLMVMUpdate()` is
25 called, the row size and layout of `B` will be set to match `F` and the column size and layout of `B` will be set to
30 PetscErrorCode MatLMVMUpdate(Mat B, Vec X, Vec F)
36 PetscValidHeaderSpecific(B, MAT_CLASSID, 1);
39 PetscCall(PetscObjectBaseTypeCompare((PetscObject)B, MATLMVM, &same));
41 /* If B has specified layouts, this will check X and F are compatible;
42 if B does not have specified layouts, this will adopt them, so that
45 MatCreate(comm, &B);
46 MatLMVMSetType(B, MATLMVMBFGS);
47 MatLMVMUpdate(B, X, F);
49 PetscCall(MatLMVMUseVecLayoutsIfCompatible(B, X, F));
50 MatCheckPreallocated(B, 1);
52 lmvm = (Mat_LMVM *)B->data;
54 PetscCall((*lmvm->ops->update)(B, X, F));
59 static PetscErrorCode MatLMVMCreateJ0(Mat B, Mat *J0)
66 PetscCall(MatCreate(PetscObjectComm((PetscObject)B), J0));
67 PetscCall(MatGetLayouts(B, &rmap, &cmap));
69 PetscCall(MatGetVecType(B, &vec_type));
71 PetscCall(MatGetOptionsPrefix(B, &prefix));
77 static PetscErrorCode MatLMVMCreateJ0KSP(Mat B, KSP *ksp)
79 Mat_LMVM *lmvm = (Mat_LMVM *)B->data;
83 PetscCall(KSPCreate(PetscObjectComm((PetscObject)B), ksp));
85 PetscCall(PetscObjectIncrementTabLevel((PetscObject)B, (PetscObject)*ksp, 1));
86 PetscCall(MatGetOptionsPrefix(B, &prefix));
92 static PetscErrorCode MatLMVMCreateJ0KSP_ExactInverse(Mat B, KSP *ksp)
94 Mat_LMVM *lmvm = (Mat_LMVM *)B->data;
98 PetscCall(MatLMVMCreateJ0KSP(B, ksp));
112 . B - A `MATLMVM` matrix
118 PetscErrorCode MatLMVMClearJ0(Mat B)
124 PetscValidHeaderSpecific(B, MAT_CLASSID, 1);
125 PetscCall(PetscObjectBaseTypeCompare((PetscObject)B, MATLMVM, &same));
127 lmvm = (Mat_LMVM *)B->data;
130 PetscCall(MatLMVMCreateJ0(B, &lmvm->J0));
134 PetscCall(MatLMVMCreateJ0KSP_ExactInverse(B, &lmvm->J0ksp));
145 + B - A `MATLMVM` matrix
152 PetscErrorCode MatLMVMSetJ0Scale(Mat B, PetscReal scale)
159 PetscValidHeaderSpecific(B, MAT_CLASSID, 1);
160 PetscCall(PetscObjectBaseTypeCompare((PetscObject)B, MATLMVM, &same));
162 lmvm = (Mat_LMVM *)B->data;
164 if (!isconstant) PetscCall(MatLMVMClearJ0(B));
224 static PetscErrorCode MatLMVMUseJ0LayoutsIfCompatible(Mat B, Mat J0)
227 PetscCall(MatLMVMCheckArgumentLayout(B->rmap, J0->rmap));
228 PetscCall(MatLMVMCheckArgumentLayout(B->cmap, J0->cmap));
231 PetscCall(PetscLayoutReference(J0->rmap, &B->rmap));
232 PetscCall(PetscLayoutReference(J0->cmap, &B->cmap));
236 static PetscErrorCode MatLMVMUseJ0DiagLayoutsIfCompatible(Mat B, Vec J0_diag)
239 PetscCall(MatLMVMCheckArgumentLayout(B->rmap, J0_diag->map));
240 PetscCall(MatLMVMCheckArgumentLayout(B->cmap, J0_diag->map));
242 PetscCall(PetscLayoutReference(J0_diag->map, &B->rmap));
243 PetscCall(PetscLayoutReference(J0_diag->map, &B->cmap));
247 PETSC_INTERN PetscErrorCode MatLMVMUseVecLayoutsIfCompatible(Mat B, Vec X, Vec F)
249 Mat_LMVM *lmvm = (Mat_LMVM *)B->data;
252 PetscCall(MatLMVMCheckArgumentLayout(B->rmap, F->map));
253 PetscCall(MatLMVMCheckArgumentLayout(B->cmap, X->map));
256 PetscCall(PetscLayoutReference(F->map, &B->rmap));
257 PetscCall(PetscLayoutReference(X->map, &B->cmap));
259 PetscCall(PetscLayoutReference(B->rmap, &lmvm->J0->rmap));
260 PetscCall(PetscLayoutReference(B->cmap, &lmvm->J0->cmap));
270 + B - An LMVM-type matrix
276 If the sizes of `B` have not been specified (using `MatSetSizes()` or `MatSetLayouts()`) before `MatLMVMSetJ0Diag()` is
277 called, the rows and columns of `B` will each have the size and layout of `V`, and these sizes will be final.
281 PetscErrorCode MatLMVMSetJ0Diag(Mat B, Vec V)
288 PetscValidHeaderSpecific(B, MAT_CLASSID, 1);
290 PetscCall(PetscObjectBaseTypeCompare((PetscObject)B, MATLMVM, &same));
292 PetscCheckSameComm(B, 1, V, 2);
293 PetscCall(MatLMVMUseJ0DiagLayoutsIfCompatible(B, V));
294 PetscCall(MatCreate(PetscObjectComm((PetscObject)B), &J0diag));
300 PetscCall(MatLMVMSetJ0(B, J0diag));
305 PETSC_INTERN PetscErrorCode MatLMVMGetJ0InvDiag(Mat B, Vec *V)
307 Mat_LMVM *lmvm = (Mat_LMVM *)B->data;
313 PetscCall(MatLMVMClearJ0(B));
322 PETSC_INTERN PetscErrorCode MatLMVMRestoreJ0InvDiag(Mat B, Vec *V)
324 Mat_LMVM *lmvm = (Mat_LMVM *)B->data;
331 PETSC_INTERN PetscErrorCode MatLMVMJ0KSPIsExact(Mat B, PetscBool *is_exact)
334 Mat_LMVM *lmvm = (Mat_LMVM *)B->data;
360 + B - An LMVM-type matrix
361 - J0 - The initial Jacobian matrix, will be referenced by B.
369 If the sizes of `B` have not been specified (using `MatSetSizes()` or `MatSetLayouts()`) before `MatLMVMSetJ0()` is
370 called, then `B` will adopt the sizes and layouts of `J0`, and these sizes will be final.
374 PetscErrorCode MatLMVMSetJ0(Mat B, Mat J0)
381 PetscValidHeaderSpecific(B, MAT_CLASSID, 1);
383 PetscCall(PetscObjectBaseTypeCompare((PetscObject)B, MATLMVM, &same));
385 lmvm = (Mat_LMVM *)B->data;
387 PetscCheckSameComm(B, 1, J0, 2);
388 PetscCall(MatLMVMUseJ0LayoutsIfCompatible(B, J0));
396 PetscCall(MatLMVMCreateJ0KSP_ExactInverse(B, &lmvm->J0ksp));
418 PetscCall(MatLMVMCreateJ0KSP(B, &lmvm->J0ksp));
430 + B - A `MATLMVM` matrix
439 If the sizes of `B` have not been specified (using `MatSetSizes()` or `MatSetLayouts()`) before `MatLMVMSetJ0PC()` is
440 called, then `B` will adopt the sizes and layouts of the operators of `J0pc`, and these sizes will be final.
444 PetscErrorCode MatLMVMSetJ0PC(Mat B, PC J0pc)
452 PetscValidHeaderSpecific(B, MAT_CLASSID, 1);
454 PetscCall(PetscObjectBaseTypeCompare((PetscObject)B, MATLMVM, &same));
456 lmvm = (Mat_LMVM *)B->data;
458 PetscCheck(mat_set || pmat_set, PetscObjectComm((PetscObject)B), PETSC_ERR_ARG_WRONGSTATE, "PC has not operators, call PCSetOperators() before MatLMVMSetJ0PC()");
463 PetscCall(MatLMVMSetJ0(B, J0));
473 + B - A `MATLMVM` matrix
482 If the sizes of `B` have not been specified (using `MatSetSizes()` or `MatSetLayouts()`) before `MatLMVMSetJ0KSP()` is
483 called, then `B` will adopt the sizes and layouts of the operators of `J0ksp`, and these sizes will be final.
487 PetscErrorCode MatLMVMSetJ0KSP(Mat B, KSP J0ksp)
494 PetscValidHeaderSpecific(B, MAT_CLASSID, 1);
496 PetscCall(PetscObjectBaseTypeCompare((PetscObject)B, MATLMVM, &same));
498 lmvm = (Mat_LMVM *)B->data;
500 PetscCheck(mat_set || pmat_set, PetscObjectComm((PetscObject)B), PETSC_ERR_ARG_WRONGSTATE, "PC has not operators, call PCSetOperators() before MatLMVMSetJ0PC()");
504 PetscCall(MatLMVMSetJ0(B, J0));
519 . B - A `MATLMVM` matrix
528 If `J0` was created by `B` it will have the options prefix `-mat_lmvm_J0_`.
532 PetscErrorCode MatLMVMGetJ0(Mat B, Mat *J0)
538 PetscValidHeaderSpecific(B, MAT_CLASSID, 1);
539 PetscCall(PetscObjectBaseTypeCompare((PetscObject)B, MATLMVM, &same));
540 PetscCheck(same, PetscObjectComm((PetscObject)B), PETSC_ERR_ARG_WRONG, "Matrix must be an LMVM-type.");
541 lmvm = (Mat_LMVM *)B->data;
551 . B - A `MATLMVM` matrix
560 PetscErrorCode MatLMVMGetJ0PC(Mat B, PC *J0pc)
566 PetscValidHeaderSpecific(B, MAT_CLASSID, 1);
567 PetscCall(PetscObjectBaseTypeCompare((PetscObject)B, MATLMVM, &same));
568 PetscCheck(same, PetscObjectComm((PetscObject)B), PETSC_ERR_ARG_WRONG, "Matrix must be an LMVM-type.");
569 lmvm = (Mat_LMVM *)B->data;
579 . B - A `MATLMVM` matrix
588 PetscErrorCode MatLMVMGetJ0KSP(Mat B, KSP *J0ksp)
594 PetscValidHeaderSpecific(B, MAT_CLASSID, 1);
595 PetscCall(PetscObjectBaseTypeCompare((PetscObject)B, MATLMVM, &same));
596 PetscCheck(same, PetscObjectComm((PetscObject)B), PETSC_ERR_ARG_WRONG, "Matrix must be an LMVM-type.");
597 lmvm = (Mat_LMVM *)B->data;
607 + B - A `MATLMVM` matrix
618 PetscErrorCode MatLMVMApplyJ0Fwd(Mat B, Vec X, Vec Y)
620 Mat_LMVM *lmvm = (Mat_LMVM *)B->data;
627 PETSC_INTERN PetscErrorCode MatLMVMApplyJ0HermitianTranspose(Mat B, Vec X, Vec Y)
629 Mat_LMVM *lmvm = (Mat_LMVM *)B->data;
641 + B - A `MATLMVM` matrix
659 PetscErrorCode MatLMVMApplyJ0Inv(Mat B, Vec X, Vec Y)
661 Mat_LMVM *lmvm = (Mat_LMVM *)B->data;
670 PETSC_INTERN PetscErrorCode MatLMVMApplyJ0InvTranspose(Mat B, Vec X, Vec Y)
672 Mat_LMVM *lmvm = (Mat_LMVM *)B->data;
681 PETSC_INTERN PetscErrorCode MatLMVMApplyJ0InvHermitianTranspose(Mat B, Vec X, Vec Y)
685 PetscCall(MatLMVMApplyJ0InvTranspose(B, X, Y));
692 PetscCall(MatLMVMApplyJ0InvTranspose(B, X_conj, Y));
704 . B - A `MATLMVM` matrix
713 PetscErrorCode MatLMVMIsAllocated(Mat B, PetscBool *flg)
718 PetscValidHeaderSpecific(B, MAT_CLASSID, 1);
719 PetscCall(PetscObjectBaseTypeCompare((PetscObject)B, MATLMVM, &same));
720 PetscCheck(same, PetscObjectComm((PetscObject)B), PETSC_ERR_ARG_WRONG, "Matrix must be an LMVM-type.");
721 *flg = B->preallocated;
731 + B - A `MATLMVM` matrix
739 before `MatLMVMAllocate()`, the row layout of `B` will be set to match `F`
740 and the column layout of `B` will be set to match `X`.
744 PetscErrorCode MatLMVMAllocate(Mat B, Vec X, Vec F)
750 PetscValidHeaderSpecific(B, MAT_CLASSID, 1);
753 PetscCall(PetscObjectBaseTypeCompare((PetscObject)B, MATLMVM, &same));
755 lmvm = (Mat_LMVM *)B->data;
756 PetscCall(MatAllocate_LMVM(B, X, F));
765 . B - A `MATLMVM` matrix
771 PetscErrorCode MatLMVMResetShift(Mat B)
777 PetscValidHeaderSpecific(B, MAT_CLASSID, 1);
778 PetscCall(PetscObjectBaseTypeCompare((PetscObject)B, MATLMVM, &same));
780 lmvm = (Mat_LMVM *)B->data;
785 PETSC_INTERN PetscErrorCode MatLMVMReset_Internal(Mat B, MatLMVMResetMode mode)
791 PetscValidHeaderSpecific(B, MAT_CLASSID, 1);
792 PetscCall(PetscObjectBaseTypeCompare((PetscObject)B, MATLMVM, &same));
794 lmvm = (Mat_LMVM *)B->data;
796 if (lmvm->ops->reset) PetscCall((*lmvm->ops->reset)(B, mode));
797 PetscCall(MatReset_LMVM(B, mode));
806 + B - A `MATLMVM` matrix
823 PetscErrorCode MatLMVMReset(Mat B, PetscBool destructive)
829 PetscValidHeaderSpecific(B, MAT_CLASSID, 1);
830 PetscCall(PetscObjectBaseTypeCompare((PetscObject)B, MATLMVM, &same));
832 lmvm = (Mat_LMVM *)B->data;
833 PetscCall(PetscInfo(B, "Resetting %s after %" PetscInt_FMT " iterations\n", ((PetscObject)B)->type_name, lmvm->k));
834 PetscCall(MatLMVMReset_Internal(B, destructive ? MAT_LMVM_RESET_ALL : MAT_LMVM_RESET_HISTORY));
844 + B - A `MATLMVM` matrix
854 PetscErrorCode MatLMVMSetHistorySize(Mat B, PetscInt hist_size)
856 Mat_LMVM *lmvm = (Mat_LMVM *)B->data;
860 PetscValidHeaderSpecific(B, MAT_CLASSID, 1);
861 PetscCall(PetscObjectBaseTypeCompare((PetscObject)B, MATLMVM, &same));
863 PetscCheck(hist_size >= 0, PetscObjectComm((PetscObject)B), PETSC_ERR_ARG_WRONG, "QN history size must be a non-negative integer.");
864 if (lmvm->m != hist_size) PetscCall(MatLMVMReset_Internal(B, MAT_LMVM_RESET_BASES));
869 PetscErrorCode MatLMVMGetHistorySize(Mat B, PetscInt *hist_size)
871 Mat_LMVM *lmvm = (Mat_LMVM *)B->data;
875 PetscValidHeaderSpecific(B, MAT_CLASSID, 1);
876 PetscCall(PetscObjectBaseTypeCompare((PetscObject)B, MATLMVM, &same));
886 . B - A `MATLMVM` matrix
900 PetscErrorCode MatLMVMGetUpdateCount(Mat B, PetscInt *nupdates)
906 PetscValidHeaderSpecific(B, MAT_CLASSID, 1);
907 PetscCall(PetscObjectBaseTypeCompare((PetscObject)B, MATLMVM, &same));
908 PetscCheck(same, PetscObjectComm((PetscObject)B), PETSC_ERR_ARG_WRONG, "Matrix must be an LMVM-type.");
909 lmvm = (Mat_LMVM *)B->data;
919 . B - A `MATLMVM` matrix
928 PetscErrorCode MatLMVMGetRejectCount(Mat B, PetscInt *nrejects)
934 PetscValidHeaderSpecific(B, MAT_CLASSID, 1);
935 PetscCall(PetscObjectBaseTypeCompare((PetscObject)B, MATLMVM, &same));
936 PetscCheck(same, PetscObjectComm((PetscObject)B), PETSC_ERR_ARG_WRONG, "Matrix must be an LMVM-type.");
937 lmvm = (Mat_LMVM *)B->data;
942 PETSC_INTERN PetscErrorCode MatLMVMGetJ0Scalar(Mat B, PetscBool *is_scalar, PetscScalar *scale)
944 Mat_LMVM *lmvm = (Mat_LMVM *)B->data;
952 static PetscErrorCode MatLMVMUpdateOpVecs(Mat B, LMBasis X, LMBasis OpX, PetscErrorCode (*op)(Mat, Vec, Vec))
954 Mat_LMVM *lmvm = (Mat_LMVM *)B->data;
976 PetscCall(op(B, x_i, op_x_i));
980 PetscAssert(OpX->k == X->k && OpX->operator_id == J0_id && OpX->operator_state == J0_state, PetscObjectComm((PetscObject)B), PETSC_ERR_PLIB, "Invalid state for operator-updated LMBasis");
984 static PetscErrorCode MatLMVMUpdateOpDiffVecs(Mat B, LMBasis Y, PetscScalar alpha, LMBasis OpX, LMBasis YmalphaOpX)
986 Mat_LMVM *lmvm = (Mat_LMVM *)B->data;
995 PetscAssert(Y->m == OpX->m, PetscObjectComm((PetscObject)B), PETSC_ERR_PLIB, "Incompatible Y and OpX in MatLMVMUpdateOpDiffVecs()");
996 PetscAssert(Y->k == OpX->k, PetscObjectComm((PetscObject)B), PETSC_ERR_PLIB, "Stale OpX in MatLMVMUpdateOpDiffVecs()");
1024 PetscAssert(YmalphaOpX->k == Y->k && YmalphaOpX->operator_id == J0_id && YmalphaOpX->operator_state == J0_state, PetscObjectComm((PetscObject)B), PETSC_ERR_PLIB, "Invalid state for operator-updated LMBasis");
1028 PETSC_INTERN PetscErrorCode MatLMVMGetUpdatedBasis(Mat B, MatLMVMBasisType type, LMBasis *basis_p, MatLMVMBasisType *returned_type, PetscScalar *scale)
1030 Mat_LMVM *lmvm = (Mat_LMVM *)B->data;
1048 PetscCall(MatLMVMGetJ0Scalar(B, &is_scalar, &scale_));
1060 PetscCall(MatLMVMUpdateOpVecs(B, orig_basis, basis, (type == LMBASIS_B0S) ? MatLMVMApplyJ0Fwd : MatLMVMApplyJ0Inv));
1073 PetscCall(MatLMVMGetUpdatedBasis(B, op_basis_t, &op_basis, &op_basis_t, &scale_));
1074 PetscCall(MatLMVMUpdateOpDiffVecs(B, lmvm->basis[MatLMVMBasisSizeOf(type)], scale_, op_basis, basis));
1084 PETSC_INTERN PetscErrorCode MatLMVMBasisGetVecRead(Mat B, MatLMVMBasisType type, PetscInt i, Vec *y, PetscScalar *scale)
1086 Mat_LMVM *lmvm = (Mat_LMVM *)B->data;
1095 PetscCall(MatLMVMGetJ0Scalar(B, &is_scalar, &scale_));
1108 PetscCall(MatLMVMApplyJ0Fwd(B, w, tmp));
1110 PetscCall(MatLMVMApplyJ0Inv(B, w, tmp));
1119 PetscCall(MatLMVMGetUpdatedBasis(B, type, &basis, &type, &dummy));
1125 SETERRQ(PetscObjectComm((PetscObject)B), PETSC_ERR_ARG_WRONG, "MatLMVMBasisGetVecRead() is only for LMBASIS_B0S and LMBASIS_H0Y. Use MatLMVMGetUpdatedBasis() and LMBasisGetVecRead().");
1130 PETSC_INTERN PetscErrorCode MatLMVMBasisRestoreVecRead(Mat B, MatLMVMBasisType type, PetscInt i, Vec *y, PetscScalar *scale)
1132 Mat_LMVM *lmvm = (Mat_LMVM *)B->data;
1141 PetscCall(MatLMVMGetJ0Scalar(B, &is_scalar, &scale_));
1153 SETERRQ(PetscObjectComm((PetscObject)B), PETSC_ERR_ARG_WRONG, "MatLMVMBasisRestoreVecRead() is only for LMBASIS_B0S and LMBASIS_H0Y. Use MatLMVMGetUpdatedBasis() and LMBasisRestoreVecRead().");
1158 PETSC_INTERN PetscErrorCode MatLMVMGetRange(Mat B, PetscInt *oldest, PetscInt *next)
1160 Mat_LMVM *lmvm = (Mat_LMVM *)B->data;
1167 PETSC_INTERN PetscErrorCode MatLMVMGetWorkRow(Mat B, Vec *array_p)
1172 PetscCall(MatLMVMGetUpdatedBasis(B, LMBASIS_Y, &basis, NULL, NULL));
1177 PETSC_INTERN PetscErrorCode MatLMVMRestoreWorkRow(Mat B, Vec *array_p)
1182 PetscCall(MatLMVMGetUpdatedBasis(B, LMBASIS_Y, &basis, NULL, NULL));
1187 static PetscErrorCode MatLMVMApplyOpThenVecs(PetscScalar alpha, Mat B, PetscInt oldest, PetscInt next, MatLMVMBasisType type_S, PetscErrorCode (*op)(Mat, Vec, Vec), Vec x, PetscScalar beta, Vec y)
1193 PetscCall(MatLMVMGetUpdatedBasis(B, type_S, &S, NULL, NULL));
1195 PetscCall(op(B, x, B0x));
1201 static PetscErrorCode MatLMVMApplyVecsThenOp(PetscScalar alpha, Mat B, PetscInt oldest, PetscInt next, MatLMVMBasisType type_S, MatLMVMBasisType type_Y, PetscErrorCode (*op)(Mat, Vec, Vec), Vec x, PetscScalar beta, Vec y)
1208 PetscCall(MatLMVMGetUpdatedBasis(B, type_S, &S, NULL, NULL));
1209 PetscCall(MatLMVMGetUpdatedBasis(B, type_Y, &Y, NULL, NULL));
1213 PetscCall(op(B, S_x, B0S_x));
1220 PETSC_INTERN PetscErrorCode MatLMVMBasisGEMVH(Mat B, MatLMVMBasisType type, PetscInt oldest, PetscInt next, PetscScalar alpha, Vec v, PetscScalar beta, Vec array)
1222 Mat_LMVM *lmvm = (Mat_LMVM *)B->data;
1230 PetscCall(MatLMVMGetUpdatedBasis(B, type, &basis, &basis_t, &gamma));
1235 PetscCall(MatLMVMApplyOpThenVecs(alpha, B, oldest, next, LMBASIS_S, MatLMVMApplyJ0HermitianTranspose, v, beta, array));
1238 PetscCall(MatLMVMApplyOpThenVecs(alpha, B, oldest, next, LMBASIS_Y, MatLMVMApplyJ0InvHermitianTranspose, v, beta, array));
1242 PetscCall(MatLMVMBasisGEMVH(B, LMBASIS_B0S, oldest, next, -alpha, v, 1.0, array));
1246 PetscCall(MatLMVMBasisGEMVH(B, LMBASIS_H0Y, oldest, next, -alpha, v, 1.0, array));
1256 PETSC_INTERN PetscErrorCode MatLMVMBasisGEMV(Mat B, MatLMVMBasisType type, PetscInt oldest, PetscInt next, PetscScalar alpha, Vec x, PetscScalar beta, Vec y)
1258 Mat_LMVM *lmvm = (Mat_LMVM *)B->data;
1267 PetscCall(MatLMVMGetUpdatedBasis(B, type, &basis, &base_type, &gamma));
1272 PetscCall(MatLMVMApplyVecsThenOp(alpha, B, oldest, next, LMBASIS_S, LMBASIS_Y, MatLMVMApplyJ0Fwd, x, beta, y));
1275 PetscCall(MatLMVMApplyVecsThenOp(alpha, B, oldest, next, LMBASIS_Y, LMBASIS_S, MatLMVMApplyJ0Inv, x, beta, y));
1279 PetscCall(MatLMVMBasisGEMV(B, LMBASIS_B0S, oldest, next, -alpha, x, 1.0, y));
1283 PetscCall(MatLMVMBasisGEMV(B, LMBASIS_H0Y, oldest, next, -alpha, x, 1.0, y));
1292 PETSC_INTERN PetscErrorCode MatLMVMCreateProducts(Mat B, LMBlockType block_type, LMProducts *products)
1294 Mat_LMVM *lmvm = (Mat_LMVM *)B->data;
1302 static PetscErrorCode MatLMVMProductsUpdate(Mat B, MatLMVMBasisType type_X, MatLMVMBasisType type_Y, LMBlockType block_type)
1304 Mat_LMVM *lmvm = (Mat_LMVM *)B->data;
1312 PetscCall(MatLMVMGetUpdatedBasis(B, type_X, &X, &true_type_X, &alpha_X));
1313 PetscCall(MatLMVMGetUpdatedBasis(B, type_Y, &Y, &true_type_Y, &alpha_Y));
1314 if (!lmvm->products[block_type][true_type_X][true_type_Y]) PetscCall(MatLMVMCreateProducts(B, block_type, &lmvm->products[block_type][true_type_X][true_type_Y]));
1317 if (!lmvm->products[block_type][type_X][type_Y]) PetscCall(MatLMVMCreateProducts(B, block_type, &lmvm->products[block_type][type_X][type_Y]));
1319 PetscCall(MatLMVMGetRange(B, &oldest, &next));
1328 PETSC_INTERN PetscErrorCode MatLMVMGetUpdatedProducts(Mat B, MatLMVMBasisType type_X, MatLMVMBasisType type_Y, LMBlockType block_type, LMProducts *lmwd)
1330 Mat_LMVM *lmvm = (Mat_LMVM *)B->data;
1333 PetscCall(MatLMVMProductsUpdate(B, type_X, type_Y, block_type));
1338 PETSC_INTERN PetscErrorCode MatLMVMProductsInsertDiagonalValue(Mat B, MatLMVMBasisType type_X, MatLMVMBasisType type_Y, PetscInt idx, PetscScalar v)
1340 Mat_LMVM *lmvm = (Mat_LMVM *)B->data;
1344 if (!lmvm->products[LMBLOCK_DIAGONAL][type_X][type_Y]) PetscCall(MatLMVMCreateProducts(B, LMBLOCK_DIAGONAL, &lmvm->products[LMBLOCK_DIAGONAL][type_X][type_Y]));
1350 PETSC_INTERN PetscErrorCode MatLMVMProductsGetDiagonalValue(Mat B, MatLMVMBasisType type_X, MatLMVMBasisType type_Y, PetscInt idx, PetscScalar *v)
1355 PetscCall(MatLMVMGetUpdatedProducts(B, type_X, type_Y, LMBLOCK_DIAGONAL, &products));