Actual source code: lmeimpl.h

slepc-3.13.0 2020-03-31
Report Typos and Errors
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2020, 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: #if !defined(SLEPCLMEIMPL_H)
 12: #define SLEPCLMEIMPL_H

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

 17: SLEPC_EXTERN PetscBool LMERegisterAllCalled;
 18: SLEPC_EXTERN PetscErrorCode LMERegisterAll(void);
 19: SLEPC_EXTERN PetscLogEvent LME_SetUp,LME_Solve,LME_ComputeError;

 21: typedef struct _LMEOps *LMEOps;

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

 33: /*
 34:      Maximum number of monitors you can run with a single LME
 35: */
 36: #define MAXLMEMONITORS 5

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

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

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

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

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

 74: /*
 75:     Macros to test valid LME arguments
 76: */
 77: #if !defined(PETSC_USE_DEBUG)

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

 81: #else

 83: #define LMECheckCoeff(h,A,mat,eq) \
 84:   do { \
 85:     if (!(A)) SETERRQ2(PetscObjectComm((PetscObject)(h)),PETSC_ERR_ARG_WRONGSTATE,"%s matrix equation requires coefficient matrix %s",eq,mat); \
 86:   } while (0)

 88: #endif

 90: /* functions interfaced from Fortran library SLICOT */
 91: #if defined(SLEPC_HAVE_SLICOT)

 93: #if defined(SLEPC_SLICOT_HAVE_UNDERSCORE)
 94: #define SLEPC_SLICOT(lcase,ucase) lcase##_
 95: #elif defined(SLEPC_SLICOT_HAVE_CAPS)
 96: #define SLEPC_SLICOT(lcase,ucase) ucase
 97: #else
 98: #define SLEPC_SLICOT(lcase,ucase) lcase
 99: #endif

101: #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)
102: 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);
103: #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)
104: 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);

106: #endif

108: #endif