Actual source code: denseqn.h

      1: #pragma once

      3: #include <../src/ksp/ksp/utils/lmvm/lmvm.h>
      4: #include <../src/ksp/ksp/utils/lmvm/rescale/symbrdnrescale.h>

      6: /*
      7:   dense representation for the limited-memory BFGS/DFP method.
      8: */

     10: typedef struct {
     11:   PetscInt          num_updates;
     12:   PetscInt          num_mult_updates;
     13:   Mat               HY, BS; // Stored in recycled order
     14:   Vec               StFprev;
     15:   Mat               StY_triu;        // triu(StY) is the R matrix
     16:   Mat               StY_triu_strict; // strict_triu(YtS) is the R matrix
     17:   Mat               YtS_triu_strict; // strict_triu(YtS) is the L^T matrix
     18:   Mat               YtS_triu;        // triu(YtS) is the L matrix
     19:   Mat               YtHY;
     20:   Mat               StBS;
     21:   Mat               J;
     22:   Mat               temp_mat;
     23:   Vec              *PQ; /* P for BFGS, Q for DFP */
     24:   Vec               diag_vec;
     25:   Vec               diag_vec_recycle_order;
     26:   Vec               inv_diag_vec;
     27:   Vec               column_work, column_work2, rwork1, rwork2, rwork3;
     28:   Vec               rwork2_local, rwork3_local;
     29:   Vec               local_work_vec, local_work_vec_copy;
     30:   Vec               cyclic_work_vec;
     31:   MatType           dense_type;
     32:   MatLMVMDenseType  strategy;
     33:   SymBroydenRescale rescale; /* context for diagonal or scalar rescaling */

     35:   PetscReal       *ytq, *stp, *yts;
     36:   PetscScalar     *workscalar;
     37:   PetscInt         S_count, St_count, Y_count, Yt_count;
     38:   PetscInt         watchdog, max_seq_rejects;        /* tracker to reset after a certain # of consecutive rejects */
     39:   PetscBool        allocated, use_recursive, needPQ; /* P for BFGS, Q for DFP */
     40:   Vec              Fprev_ref;
     41:   PetscObjectState Fprev_state;
     42: } Mat_DQN;

     44: PETSC_INTERN PetscErrorCode MatView_LMVMDDFP(Mat, PetscViewer);
     45: PETSC_INTERN PetscErrorCode MatView_LMVMDBFGS(Mat, PetscViewer);

     47: PETSC_INTERN PetscErrorCode MatUpperTriangularSolveInPlace_CUPM(PetscBool, PetscInt, const PetscScalar[], PetscInt, PetscScalar[], PetscInt);
     48: PETSC_INTERN PetscErrorCode MatUpperTriangularSolveInPlaceCyclic_CUPM(PetscBool, PetscInt, PetscInt, PetscInt, const PetscScalar[], PetscInt, PetscScalar[], PetscInt);

     50: PETSC_INTERN PetscErrorCode VecCyclicShift(Mat, Vec, PetscInt, Vec);
     51: PETSC_INTERN PetscErrorCode VecRecycleOrderToHistoryOrder(Mat, Vec, PetscInt, Vec);
     52: PETSC_INTERN PetscErrorCode VecHistoryOrderToRecycleOrder(Mat, Vec, PetscInt, Vec);
     53: PETSC_INTERN PetscErrorCode MatUpperTriangularSolveInPlace(Mat, Mat, Vec, PetscBool, PetscInt, MatLMVMDenseType);
     54: PETSC_INTERN PetscErrorCode MatMove_LR3(Mat, Mat, PetscInt);