1 #pragma once 2 3 #include <../src/ksp/ksp/utils/lmvm/lmvm.h> 4 5 /* 6 Limited-memory Broyden's method for approximating the inverse of 7 a Jacobian. 8 */ 9 10 // Bases used by Broyden & Bad Broyden algorithms beyond those provided in Mat_LMVM 11 enum { 12 BROYDEN_BASIS_Y_MINUS_BKS = 0, // storage for the vectors Y_k - B_k S_k 13 BROYDEN_BASIS_S_MINUS_HKY = 1, // dual to the above, S_k - H_k Y_k 14 BROYDEN_BASIS_COUNT 15 }; 16 17 typedef PetscInt BroydenBasisType; 18 19 // Products used by Broyden & Bad Broyden algorithms beyond those provided in Mat_LMVM 20 enum { 21 BROYDEN_PRODUCTS_STHKY = 0, // diagonal S_k^T (H_k Y_k) values for recursive algorithms 22 BROYDEN_PRODUCTS_YTBKS = 1, // dual to the above, diagonal Y_k^T (B_K S_K) values 23 BROYDEN_PRODUCTS_STH0Y_MINUS_STS = 2, // stores and factors S^T B_0 Y - stril(S^T S) for compact algorithms 24 BROYDEN_PRODUCTS_YTB0S_MINUS_YTY = 3, // dual to the above, Y^T H_0 S - stril(Y^T Y) for compact algorithms 25 BROYDEN_PRODUCTS_COUNT 26 }; 27 28 typedef PetscInt BroydenProductsType; 29 30 typedef struct { 31 LMBasis basis[BROYDEN_BASIS_COUNT]; 32 LMProducts products[BROYDEN_PRODUCTS_COUNT]; 33 Vec YtFprev; 34 } Mat_Brdn; 35 36 PETSC_INTERN PetscErrorCode BroydenKernel_Recursive(Mat, MatLMVMMode, Vec, Vec); 37 PETSC_INTERN PetscErrorCode BroydenKernel_CompactDense(Mat, MatLMVMMode, Vec, Vec); 38 PETSC_INTERN PetscErrorCode BroydenKernel_Dense(Mat, MatLMVMMode, Vec, Vec); 39 PETSC_INTERN PetscErrorCode BroydenKernelHermitianTranspose_Recursive(Mat, MatLMVMMode, Vec, Vec); 40 PETSC_INTERN PetscErrorCode BroydenKernelHermitianTranspose_CompactDense(Mat, MatLMVMMode, Vec, Vec); 41 PETSC_INTERN PetscErrorCode BroydenKernelHermitianTranspose_Dense(Mat, MatLMVMMode, Vec, Vec); 42 PETSC_INTERN PetscErrorCode BadBroydenKernel_Recursive(Mat, MatLMVMMode, Vec, Vec); 43 PETSC_INTERN PetscErrorCode BadBroydenKernel_CompactDense(Mat, MatLMVMMode, Vec, Vec); 44 PETSC_INTERN PetscErrorCode BadBroydenKernel_Dense(Mat, MatLMVMMode, Vec, Vec); 45 PETSC_INTERN PetscErrorCode BadBroydenKernelHermitianTranspose_Recursive(Mat, MatLMVMMode, Vec, Vec); 46 PETSC_INTERN PetscErrorCode BadBroydenKernelHermitianTranspose_CompactDense(Mat, MatLMVMMode, Vec, Vec); 47 PETSC_INTERN PetscErrorCode BadBroydenKernelHermitianTranspose_Dense(Mat, MatLMVMMode, Vec, Vec); 48