Date: 2026-03-31T13:23:32+00:00

Actual source code: krylovschur.h

      1: /*
      2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
      4:    Copyright (c) 2002-, Universitat Politecnica de Valencia, Spain

      6:    This file is part of SLEPc.
      7:    SLEPc is distributed under a 2-clause BSD license (see LICENSE).
      8:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      9: */
     10: /*
     11:    Private header for Krylov-Schur
     12: */

     14: #pragma once

     16: SLEPC_INTERN PetscErrorCode EPSSolve_KrylovSchur_Default(EPS);
     17: SLEPC_INTERN PetscErrorCode EPSSolve_KrylovSchur_TwoSided(EPS);
     18: SLEPC_INTERN PetscErrorCode EPSSolve_KrylovSchur_Slice(EPS);
     19: SLEPC_INTERN PetscErrorCode EPSSetUp_KrylovSchur_Slice(EPS);
     20: SLEPC_INTERN PetscErrorCode EPSReset_KrylovSchur_Slice(EPS);
     21: SLEPC_INTERN PetscErrorCode EPSDestroy_KrylovSchur_Slice(EPS);
     22: SLEPC_INTERN PetscErrorCode EPSSolve_KrylovSchur_Indefinite(EPS);
     23: SLEPC_INTERN PetscErrorCode EPSSetUp_KrylovSchur_BSE(EPS);
     24: SLEPC_INTERN PetscErrorCode EPSSolve_KrylovSchur_BSE_Shao(EPS);
     25: SLEPC_INTERN PetscErrorCode EPSSolve_KrylovSchur_BSE_Gruning(EPS);
     26: SLEPC_INTERN PetscErrorCode EPSSolve_KrylovSchur_BSE_ProjectedBSE(EPS);
     27: SLEPC_INTERN PetscErrorCode EPSSetUp_KrylovSchur_Hamilt(EPS);
     28: SLEPC_INTERN PetscErrorCode EPSSolve_KrylovSchur_Hamilt(EPS);
     29: SLEPC_INTERN PetscErrorCode EPSSetUp_KrylovSchur_LREP(EPS);
     30: SLEPC_INTERN PetscErrorCode EPSSolve_KrylovSchur_LREP_Teng(EPS);
     31: SLEPC_INTERN PetscErrorCode EPSGetArbitraryValues(EPS,PetscScalar*,PetscScalar*);
     32: SLEPC_INTERN PetscErrorCode EPSKrylovSchurGetChildEPS(EPS,EPS*);

     34: /* Structure characterizing a shift in spectrum slicing */
     35: typedef struct _n_shift *EPS_shift;
     36: struct _n_shift {
     37:   PetscReal     value;
     38:   PetscInt      inertia;
     39:   PetscBool     comp[2];      /* Shows completion of subintervals (left and right) */
     40:   EPS_shift     neighb[2];    /* Adjacent shifts */
     41:   PetscInt      index;        /* Index in eig where found values are stored */
     42:   PetscInt      neigs;        /* Number of values found */
     43:   PetscReal     ext[2];       /* Limits for accepted values */
     44:   PetscInt      nsch[2];      /* Number of missing values for each subinterval */
     45:   PetscInt      nconv[2];     /* Converged on each side (accepted or not) */
     46:   PetscBool     rep;          /* Present shift is reused */
     47: };

     49: /* Structure for storing the state of spectrum slicing */
     50: struct _n_SR {
     51:   PetscReal     int0,int1;    /* Extremes of the interval */
     52:   PetscInt      dir;          /* Determines the order of values in eig (+1 incr, -1 decr) */
     53:   PetscBool     hasEnd;       /* Tells whether the interval has an end */
     54:   PetscInt      inertia0,inertia1;
     55:   PetscScalar   *back;
     56:   PetscInt      numEigs;      /* Number of eigenvalues in the interval */
     57:   PetscInt      indexEig;
     58:   EPS_shift     sPres;        /* Present shift */
     59:   EPS_shift     *pending;     /* Pending shifts array */
     60:   PetscInt      nPend;        /* Number of pending shifts */
     61:   PetscInt      maxPend;      /* Size of "pending" array */
     62:   PetscInt      *idxDef;      /* For deflation */
     63:   PetscInt      nMAXCompl;
     64:   PetscInt      iterCompl;
     65:   PetscInt      itsKs;        /* Krylovschur restarts */
     66:   PetscInt      nleap;
     67:   EPS_shift     s0;           /* Initial shift */
     68:   PetscScalar   *S;           /* Matrix for projected problem */
     69:   PetscInt      nS;
     70:   EPS_shift     sPrev;
     71:   PetscInt      nv;           /* position of restart vector */
     72:   BV            V;            /* working basis (for subsolve) */
     73:   BV            Vnext;        /* temporary working basis during change of shift */
     74:   PetscScalar   *eigr,*eigi;  /* eigenvalues (for subsolve) */
     75:   PetscReal     *errest;      /* error estimates (for subsolve) */
     76:   PetscInt      *perm;        /* permutation (for subsolve) */
     77: };
     78: typedef struct _n_SR *EPS_SR;

     80: typedef struct {
     81:   PetscReal        keep;               /* restart parameter */
     82:   PetscBool        lock;               /* locking/non-locking variant */
     83:   /* the following are used only in spectrum slicing */
     84:   EPS_SR           sr;                 /* spectrum slicing context */
     85:   PetscInt         nev;                /* number of eigenvalues to compute */
     86:   PetscInt         ncv;                /* number of basis vectors */
     87:   PetscInt         mpd;                /* maximum dimension of projected problem */
     88:   PetscInt         npart;              /* number of partitions of subcommunicator */
     89:   PetscBool        detect;             /* check for zeros during factorizations */
     90:   PetscReal        *subintervals;      /* partition of global interval */
     91:   PetscBool        subintset;          /* subintervals set by user */
     92:   PetscMPIInt      *nconv_loc;         /* converged eigenpairs for each subinterval */
     93:   EPS              eps;                /* additional eps for slice runs */
     94:   PetscBool        global;             /* flag distinguishing global from local eps */
     95:   PetscReal        *shifts;            /* array containing global shifts */
     96:   PetscInt         *inertias;          /* array containing global inertias */
     97:   PetscInt         nshifts;            /* elements in the arrays of shifts and inertias */
     98:   PetscSubcomm     subc;               /* context for subcommunicators */
     99:   MPI_Comm         commrank;           /* group processes with same rank in subcommunicators */
    100:   PetscBool        commset;            /* flag indicating that commrank was created */
    101:   PetscObjectState Astate,Bstate;      /* state of subcommunicator matrices */
    102:   PetscObjectId    Aid,Bid;            /* Id of subcommunicator matrices */
    103:   IS               isrow,iscol;        /* index sets used in update of subcomm mats */
    104:   Mat              *submata,*submatb;  /* seq matrices used in update of subcomm mats */
    105:   /* the following are used only in filter */
    106:   PetscBool        estimatedrange;     /* the filter range was not set by the user */
    107:   /* the following are used only for BSE problem type */
    108:   EPSKrylovSchurBSEType bse;           /* the BSE method */
    109: } EPS_KRYLOVSCHUR;