Date: 2023-09-05T10:17:38+00:00

Actual source code: slepcds.h
slepc-3.19.2 2023-09-05
Report Typos and Errors

      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:    User interface for the direct solver object in SLEPc
     12: */

     14: #if !defined(SLEPCDS_H)
     15: #define SLEPCDS_H

     17: #include <slepcsc.h>
     18: #include <slepcfn.h>
     19: #include <slepcrg.h>

     21: /* SUBMANSEC = DS */

     23: #define DS_MAX_SOLVE 6

     25: SLEPC_EXTERN PetscErrorCode DSInitializePackage(void);
     26: /*S
     27:     DS - Direct solver (or dense system), to represent low-dimensional
     28:     eigenproblems that must be solved within iterative solvers. This is an
     29:     auxiliary object and is not normally needed by application programmers.

     31:     Level: beginner

     33: .seealso:  DSCreate()
     34: S*/
     35: typedef struct _p_DS* DS;

     37: /*J
     38:     DSType - String with the name of the type of direct solver. Roughly,
     39:     there are as many types as problem types are available within SLEPc.

     41:     Level: advanced

     43: .seealso: DSSetType(), DS
     44: J*/
     45: typedef const char* DSType;
     46: #define DSHEP    "hep"
     47: #define DSNHEP   "nhep"
     48: #define DSGHEP   "ghep"
     49: #define DSGHIEP  "ghiep"
     50: #define DSGNHEP  "gnhep"
     51: #define DSNHEPTS "nhepts"
     52: #define DSSVD    "svd"
     53: #define DSHSVD   "hsvd"
     54: #define DSGSVD   "gsvd"
     55: #define DSPEP    "pep"
     56: #define DSNEP    "nep"

     58: /* Logging support */
     59: SLEPC_EXTERN PetscClassId DS_CLASSID;

     61: /*E
     62:     DSStateType - Indicates in which state the direct solver is

     64:     Level: advanced

     66: .seealso: DSSetState()
     67: E*/
     68: typedef enum { DS_STATE_RAW,
     69:                DS_STATE_INTERMEDIATE,
     70:                DS_STATE_CONDENSED,
     71:                DS_STATE_TRUNCATED } DSStateType;
     72: SLEPC_EXTERN const char *DSStateTypes[];

     74: /*E
     75:     DSMatType - Used to refer to one of the matrices stored internally in DS

     77:     Notes:
     78:     The matrices preferentially refer to
     79: +   DS_MAT_A  - first matrix of eigenproblem/singular value problem
     80: .   DS_MAT_B  - second matrix of a generalized eigenproblem
     81: .   DS_MAT_C  - third matrix of a quadratic eigenproblem (deprecated)
     82: .   DS_MAT_T  - tridiagonal matrix
     83: .   DS_MAT_D  - diagonal matrix
     84: .   DS_MAT_Q  - orthogonal matrix of (right) Schur vectors
     85: .   DS_MAT_Z  - orthogonal matrix of left Schur vectors
     86: .   DS_MAT_X  - right eigenvectors
     87: .   DS_MAT_Y  - left eigenvectors
     88: .   DS_MAT_U  - left singular vectors
     89: .   DS_MAT_V  - right singular vectors
     90: .   DS_MAT_W  - workspace matrix
     91: -   DS_MAT_Ex - extra matrices (x=0,..,9)

     93:     All matrices can have space to hold ld x ld elements, except for
     94:     DS_MAT_T that has space for 3 x ld elements (ld = leading dimension)
     95:     and DS_MAT_D that has space for just ld elements.

     97:     In DSPEP problems, matrices A, B, W can have space for d*ld x d*ld,
     98:     where d is the polynomial degree, and X can have ld x d*ld.
     99:     Also DSNEP has exceptions. Check the manual page of each DS type
    100:     for details.

    102:     Level: advanced

    104: .seealso: DSAllocate(), DSGetArray(), DSGetArrayReal(), DSVectors()
    105: E*/
    106: typedef enum { DS_MAT_A,
    107:                DS_MAT_B,
    108:                DS_MAT_C,
    109:                DS_MAT_T,
    110:                DS_MAT_D,
    111:                DS_MAT_Q,
    112:                DS_MAT_Z,
    113:                DS_MAT_X,
    114:                DS_MAT_Y,
    115:                DS_MAT_U,
    116:                DS_MAT_V,
    117:                DS_MAT_W,
    118:                DS_MAT_E0,
    119:                DS_MAT_E1,
    120:                DS_MAT_E2,
    121:                DS_MAT_E3,
    122:                DS_MAT_E4,
    123:                DS_MAT_E5,
    124:                DS_MAT_E6,
    125:                DS_MAT_E7,
    126:                DS_MAT_E8,
    127:                DS_MAT_E9,
    128:                DS_NUM_MAT } DSMatType;

    130: /* Convenience for indexing extra matrices */
    131: SLEPC_EXTERN DSMatType DSMatExtra[];
    132: #define DS_NUM_EXTRA  10

    134: /*E
    135:     DSParallelType - Indicates the parallel mode that the direct solver will use

    137:     Level: advanced

    139: .seealso: DSSetParallel()
    140: E*/
    141: typedef enum { DS_PARALLEL_REDUNDANT,
    142:                DS_PARALLEL_SYNCHRONIZED,
    143:                DS_PARALLEL_DISTRIBUTED } DSParallelType;
    144: SLEPC_EXTERN const char *DSParallelTypes[];

    146: SLEPC_EXTERN PetscErrorCode DSCreate(MPI_Comm,DS*);
    147: SLEPC_EXTERN PetscErrorCode DSSetType(DS,DSType);
    148: SLEPC_EXTERN PetscErrorCode DSGetType(DS,DSType*);
    149: SLEPC_EXTERN PetscErrorCode DSSetOptionsPrefix(DS,const char *);
    150: SLEPC_EXTERN PetscErrorCode DSAppendOptionsPrefix(DS,const char *);
    151: SLEPC_EXTERN PetscErrorCode DSGetOptionsPrefix(DS,const char *[]);
    152: SLEPC_EXTERN PetscErrorCode DSSetFromOptions(DS);
    153: SLEPC_EXTERN PetscErrorCode DSView(DS,PetscViewer);
    154: SLEPC_EXTERN PetscErrorCode DSViewFromOptions(DS,PetscObject,const char[]);
    155: SLEPC_EXTERN PetscErrorCode DSViewMat(DS,PetscViewer,DSMatType);
    156: SLEPC_EXTERN PetscErrorCode DSDestroy(DS*);
    157: SLEPC_EXTERN PetscErrorCode DSReset(DS);
    158: SLEPC_EXTERN PetscErrorCode DSDuplicate(DS,DS*);

    160: SLEPC_EXTERN PetscErrorCode DSAllocate(DS,PetscInt);
    161: SLEPC_EXTERN PetscErrorCode DSGetLeadingDimension(DS,PetscInt*);
    162: SLEPC_EXTERN PetscErrorCode DSSetState(DS,DSStateType);
    163: SLEPC_EXTERN PetscErrorCode DSGetState(DS,DSStateType*);
    164: SLEPC_EXTERN PetscErrorCode DSSetDimensions(DS,PetscInt,PetscInt,PetscInt);
    165: SLEPC_EXTERN PetscErrorCode DSGetDimensions(DS,PetscInt*,PetscInt*,PetscInt*,PetscInt*);
    166: SLEPC_EXTERN PetscErrorCode DSSetBlockSize(DS,PetscInt);
    167: SLEPC_EXTERN PetscErrorCode DSGetBlockSize(DS,PetscInt*);
    168: SLEPC_EXTERN PetscErrorCode DSGetTruncateSize(DS,PetscInt,PetscInt,PetscInt*);
    169: SLEPC_EXTERN PetscErrorCode DSTruncate(DS,PetscInt,PetscBool);
    170: SLEPC_EXTERN PetscErrorCode DSSetIdentity(DS,DSMatType);
    171: SLEPC_EXTERN PetscErrorCode DSSetMethod(DS,PetscInt);
    172: SLEPC_EXTERN PetscErrorCode DSGetMethod(DS,PetscInt*);
    173: SLEPC_EXTERN PetscErrorCode DSSetParallel(DS,DSParallelType);
    174: SLEPC_EXTERN PetscErrorCode DSGetParallel(DS,DSParallelType*);
    175: SLEPC_EXTERN PetscErrorCode DSSetCompact(DS,PetscBool);
    176: SLEPC_EXTERN PetscErrorCode DSGetCompact(DS,PetscBool*);
    177: SLEPC_EXTERN PetscErrorCode DSSetExtraRow(DS,PetscBool);
    178: SLEPC_EXTERN PetscErrorCode DSGetExtraRow(DS,PetscBool*);
    179: SLEPC_EXTERN PetscErrorCode DSSetRefined(DS,PetscBool);
    180: SLEPC_EXTERN PetscErrorCode DSGetRefined(DS,PetscBool*);
    181: SLEPC_EXTERN PetscErrorCode DSGetMat(DS,DSMatType,Mat*);
    182: SLEPC_EXTERN PetscErrorCode DSRestoreMat(DS,DSMatType,Mat*);
    183: SLEPC_EXTERN PetscErrorCode DSGetMatAndColumn(DS,DSMatType,PetscInt,Mat*,Vec*);
    184: SLEPC_EXTERN PetscErrorCode DSRestoreMatAndColumn(DS,DSMatType,PetscInt,Mat*,Vec*);
    185: SLEPC_EXTERN PetscErrorCode DSGetArray(DS,DSMatType,PetscScalar*[]);
    186: SLEPC_EXTERN PetscErrorCode DSRestoreArray(DS,DSMatType,PetscScalar*[]);
    187: SLEPC_EXTERN PetscErrorCode DSGetArrayReal(DS,DSMatType,PetscReal*[]);
    188: SLEPC_EXTERN PetscErrorCode DSRestoreArrayReal(DS,DSMatType,PetscReal*[]);
    189: SLEPC_EXTERN PetscErrorCode DSVectors(DS,DSMatType,PetscInt*,PetscReal*);
    190: SLEPC_EXTERN PetscErrorCode DSSolve(DS,PetscScalar*,PetscScalar*);
    191: SLEPC_EXTERN PetscErrorCode DSSort(DS,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscInt*);
    192: SLEPC_EXTERN PetscErrorCode DSSortWithPermutation(DS,PetscInt*,PetscScalar*,PetscScalar*);
    193: SLEPC_EXTERN PetscErrorCode DSSynchronize(DS,PetscScalar*,PetscScalar*);
    194: PETSC_DEPRECATED_FUNCTION("Use DSGetMat()+MatDenseGetSubMatrix()+MatCopy()") static inline PetscErrorCode DSCopyMat(DS ds,DSMatType m,PetscInt mr,PetscInt mc,Mat A,PetscInt Ar,PetscInt Ac,PetscInt rows,PetscInt cols,PetscBool out)
    195: {
    196:   Mat M,M0,A0;
    197:   PetscFunctionBegin;
    198:   PetscCall(DSGetMat(ds,m,&M));
    199:   PetscCall(MatDenseGetSubMatrix(M,mr,mr+rows,mc,mc+cols,&M0));
    200:   PetscCall(MatDenseGetSubMatrix(A,Ar,Ar+rows,Ac,Ac+cols,&A0));
    201:   if (out) PetscCall(MatCopy(M0,A0,SAME_NONZERO_PATTERN));
    202:   else PetscCall(MatCopy(A0,M0,SAME_NONZERO_PATTERN));
    203:   PetscCall(MatDenseRestoreSubMatrix(M,&M0));
    204:   PetscCall(MatDenseRestoreSubMatrix(A,&A0));
    205:   PetscCall(DSRestoreMat(ds,m,&M));
    206:   PetscFunctionReturn(PETSC_SUCCESS);
    207: }
    208: SLEPC_EXTERN PetscErrorCode DSMatGetSize(DS,DSMatType,PetscInt*,PetscInt*);
    209: SLEPC_EXTERN PetscErrorCode DSMatIsHermitian(DS,DSMatType,PetscBool*);
    210: SLEPC_EXTERN PetscErrorCode DSSetSlepcSC(DS,SlepcSC);
    211: SLEPC_EXTERN PetscErrorCode DSGetSlepcSC(DS,SlepcSC*);
    212: SLEPC_EXTERN PetscErrorCode DSUpdateExtraRow(DS);
    213: SLEPC_EXTERN PetscErrorCode DSCond(DS,PetscReal*);
    214: SLEPC_EXTERN PetscErrorCode DSTranslateHarmonic(DS,PetscScalar,PetscReal,PetscBool,PetscScalar*,PetscReal*);
    215: SLEPC_EXTERN PetscErrorCode DSTranslateRKS(DS,PetscScalar);
    216: SLEPC_EXTERN PetscErrorCode DSOrthogonalize(DS,DSMatType,PetscInt,PetscInt*);
    217: SLEPC_EXTERN PetscErrorCode DSPseudoOrthogonalize(DS,DSMatType,PetscInt,PetscReal*,PetscInt*,PetscReal*);

    219: /* --------- options specific to particular solvers -------- */

    221: SLEPC_EXTERN PetscErrorCode DSSVDSetDimensions(DS,PetscInt);
    222: SLEPC_EXTERN PetscErrorCode DSSVDGetDimensions(DS,PetscInt*);
    223: SLEPC_EXTERN PetscErrorCode DSGSVDSetDimensions(DS,PetscInt,PetscInt);
    224: SLEPC_EXTERN PetscErrorCode DSGSVDGetDimensions(DS,PetscInt*,PetscInt*);
    225: SLEPC_EXTERN PetscErrorCode DSHSVDSetDimensions(DS,PetscInt);
    226: SLEPC_EXTERN PetscErrorCode DSHSVDGetDimensions(DS,PetscInt*);
    227: SLEPC_EXTERN PetscErrorCode DSHSVDSetReorthogonalize(DS,PetscBool);
    228: SLEPC_EXTERN PetscErrorCode DSHSVDGetReorthogonalize(DS,PetscBool*);

    230: SLEPC_EXTERN PetscErrorCode DSPEPSetDegree(DS,PetscInt);
    231: SLEPC_EXTERN PetscErrorCode DSPEPGetDegree(DS,PetscInt*);
    232: SLEPC_EXTERN PetscErrorCode DSPEPSetCoefficients(DS,PetscReal*);
    233: SLEPC_EXTERN PetscErrorCode DSPEPGetCoefficients(DS,PetscReal**);

    235: SLEPC_EXTERN PetscErrorCode DSNEPSetFN(DS,PetscInt,FN*);
    236: SLEPC_EXTERN PetscErrorCode DSNEPGetFN(DS,PetscInt,FN*);
    237: SLEPC_EXTERN PetscErrorCode DSNEPGetNumFN(DS,PetscInt*);
    238: SLEPC_EXTERN PetscErrorCode DSNEPSetMinimality(DS,PetscInt);
    239: SLEPC_EXTERN PetscErrorCode DSNEPGetMinimality(DS,PetscInt*);
    240: SLEPC_EXTERN PetscErrorCode DSNEPSetRefine(DS,PetscReal,PetscInt);
    241: SLEPC_EXTERN PetscErrorCode DSNEPGetRefine(DS,PetscReal*,PetscInt*);
    242: SLEPC_EXTERN PetscErrorCode DSNEPSetIntegrationPoints(DS,PetscInt);
    243: SLEPC_EXTERN PetscErrorCode DSNEPGetIntegrationPoints(DS,PetscInt*);
    244: SLEPC_EXTERN PetscErrorCode DSNEPSetSamplingSize(DS,PetscInt);
    245: SLEPC_EXTERN PetscErrorCode DSNEPGetSamplingSize(DS,PetscInt*);
    246: SLEPC_EXTERN PetscErrorCode DSNEPSetRG(DS,RG);
    247: SLEPC_EXTERN PetscErrorCode DSNEPGetRG(DS,RG*);
    248: SLEPC_EXTERN PetscErrorCode DSNEPSetComputeMatrixFunction(DS,PetscErrorCode (*)(DS,PetscScalar,PetscBool,DSMatType,void*),void*);
    249: SLEPC_EXTERN PetscErrorCode DSNEPGetComputeMatrixFunction(DS,PetscErrorCode (**)(DS,PetscScalar,PetscBool,DSMatType,void*),void**);

    251: SLEPC_EXTERN PetscFunctionList DSList;
    252: SLEPC_EXTERN PetscErrorCode DSRegister(const char[],PetscErrorCode(*)(DS));

    254: #endif