Date: 2021-09-20T09:44:17+00:00

Actual source code: lmeimpl.h
slepc-3.15.2 2021-09-20
Report Typos and Errors

      1: /*
      2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
      4:    Copyright (c) 2002-2021, 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 PetscBool LMEMonitorRegisterAllCalled;
     19: SLEPC_EXTERN PetscErrorCode LMERegisterAll(void);
     20: SLEPC_EXTERN PetscErrorCode LMEMonitorRegisterAll(void);
     21: SLEPC_EXTERN PetscLogEvent LME_SetUp,LME_Solve,LME_ComputeError;

     23: typedef struct _LMEOps *LMEOps;

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

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

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

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

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

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

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

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

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

     83: #else

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

     90: #endif

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

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

    103: #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)
    104: 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);
    105: #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)
    106: 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);

    108: #endif

    110: #endif