Actual source code: lmeimpl.h

slepc-main 2023-10-18
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: */

 11: #pragma once

 13: #include <slepclme.h>
 14: #include <slepc/private/slepcimpl.h>

 16: /* SUBMANSEC = LME */

 18: SLEPC_EXTERN PetscBool LMERegisterAllCalled;
 19: SLEPC_EXTERN PetscBool LMEMonitorRegisterAllCalled;
 20: SLEPC_EXTERN PetscErrorCode LMERegisterAll(void);
 21: SLEPC_EXTERN PetscErrorCode LMEMonitorRegisterAll(void);
 22: SLEPC_EXTERN PetscLogEvent LME_SetUp,LME_Solve,LME_ComputeError;

 24: typedef struct _LMEOps *LMEOps;

 26: struct _LMEOps {
 27:   PetscErrorCode (*solve[sizeof(LMEProblemType)])(LME);
 28:   PetscErrorCode (*setup)(LME);
 29:   PetscErrorCode (*setfromoptions)(LME,PetscOptionItems*);
 30:   PetscErrorCode (*publishoptions)(LME);
 31:   PetscErrorCode (*destroy)(LME);
 32:   PetscErrorCode (*reset)(LME);
 33:   PetscErrorCode (*view)(LME,PetscViewer);
 34: };

 36: /*
 37:      Maximum number of monitors you can run with a single LME
 38: */
 39: #define MAXLMEMONITORS 5

 41: /*
 42:    Defines the LME data structure.
 43: */
 44: struct _p_LME {
 45:   PETSCHEADER(struct _LMEOps);
 46:   /*------------------------- User parameters ---------------------------*/
 47:   Mat            A,B,D,E;        /* the coefficient matrices */
 48:   Mat            C;              /* the right-hand side */
 49:   Mat            X;              /* the solution */
 50:   LMEProblemType problem_type;   /* which kind of equation to be solved */
 51:   PetscInt       max_it;         /* maximum number of iterations */
 52:   PetscInt       ncv;            /* number of basis vectors */
 53:   PetscReal      tol;            /* tolerance */
 54:   PetscBool      errorifnotconverged;    /* error out if LMESolve() does not converge */

 56:   /*-------------- User-provided functions and contexts -----------------*/
 57:   PetscErrorCode (*monitor[MAXLMEMONITORS])(LME,PetscInt,PetscReal,void*);
 58:   PetscErrorCode (*monitordestroy[MAXLMEMONITORS])(void**);
 59:   void           *monitorcontext[MAXLMEMONITORS];
 60:   PetscInt       numbermonitors;

 62:   /*----------------- Child objects and working data -------------------*/
 63:   BV             V;              /* set of basis vectors */
 64:   PetscInt       nwork;          /* number of work vectors */
 65:   Vec            *work;          /* work vectors */
 66:   void           *data;          /* placeholder for solver-specific stuff */

 68:   /* ----------------------- Status variables -------------------------- */
 69:   PetscInt       its;            /* number of iterations so far computed */
 70:   PetscReal      errest;         /* error estimate */
 71:   PetscInt       setupcalled;
 72:   LMEConvergedReason reason;
 73: };

 75: SLEPC_INTERN PetscErrorCode LMEDenseRankSVD(LME,PetscInt,PetscScalar*,PetscInt,PetscScalar*,PetscInt,PetscInt*);

 77: /*
 78:     Macros to test valid LME arguments
 79: */
 80: #if !defined(PETSC_USE_DEBUG)

 82: #define LMECheckCoeff(h,A,mat,eq) do {(void)(h);} while (0)

 84: #else

 86: #define LMECheckCoeff(h,A,mat,eq) \
 87:   do { \
 88:     PetscCheck(A,PetscObjectComm((PetscObject)(h)),PETSC_ERR_ARG_WRONGSTATE,"%s matrix equation requires coefficient matrix %s",eq,mat); \
 89:   } while (0)

 91: #endif

 93: /* functions interfaced from Fortran library SLICOT */
 94: #if defined(SLEPC_HAVE_SLICOT)

 96: #if defined(SLEPC_SLICOT_HAVE_UNDERSCORE)
 97: #define SLEPC_SLICOT(lcase,ucase) lcase##_
 98: #elif defined(SLEPC_SLICOT_HAVE_CAPS)
 99: #define SLEPC_SLICOT(lcase,ucase) ucase
100: #else
101: #define SLEPC_SLICOT(lcase,ucase) lcase
102: #endif

104: #define SLICOTsb03od_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q) SLEPC_SLICOT(sb03od,SB03OD) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),1,1,1)
105: SLEPC_EXTERN void SLEPC_SLICOT(sb03od,SB03OD)(const char*,const char*,const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscScalar*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt,PetscBLASInt);
106: #define SLICOTsb03md_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t) SLEPC_SLICOT(sb03md,SB03MD) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),1,1,1,1)
107: SLEPC_EXTERN void SLEPC_SLICOT(sb03md,SB03MD)(const char*,const char*,const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt,PetscBLASInt,PetscBLASInt);

109: #endif