Actual source code: slepcimpl.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(SLEPCIMPL_H)
 12: #define SLEPCIMPL_H

 14: #include <slepcsys.h>
 15: #include <petsc/private/petscimpl.h>

 17: SLEPC_INTERN PetscBool SlepcBeganPetsc;

 19: /*@C
 20:     SlepcHeaderCreate - Creates a SLEPc object

 22:     Input Parameters:
 23: +   classid - the classid associated with this object
 24: .   class_name - string name of class; should be static
 25: .   descr - string containing short description; should be static
 26: .   mansec - string indicating section in manual pages; should be static
 27: .   comm - the MPI Communicator
 28: .   destroy - the destroy routine for this object
 29: -   view - the view routine for this object

 31:     Output Parameter:
 32: .   h - the newly created object

 34:     Note:
 35:     This is equivalent to PetscHeaderCreate but makes sure that SlepcInitialize
 36:     has been called.

 38:     Level: developer
 39: @*/
 40: #define SlepcHeaderCreate(h,classid,class_name,descr,mansec,comm,destroy,view) \
 41:     ((!SlepcInitializeCalled && \
 42:     PetscError(comm,__LINE__,PETSC_FUNCTION_NAME,__FILE__,1,PETSC_ERROR_INITIAL, \
 43:     "Must call SlepcInitialize instead of PetscInitialize to use SLEPc classes")) ||  \
 44:     PetscHeaderCreate(h,classid,class_name,descr,mansec,comm,destroy,view))

 46: /* context for monitors of type XXXMonitorConverged */
 47: struct _n_SlepcConvMon {
 48:   void     *ctx;
 49:   PetscInt oldnconv;  /* previous value of nconv */
 50: };

 52: /*
 53:   SlepcPrintEigenvalueASCII - Print an eigenvalue on an ASCII viewer.
 54: */
 55: PETSC_STATIC_INLINE PetscErrorCode SlepcPrintEigenvalueASCII(PetscViewer viewer,PetscScalar eigr,PetscScalar eigi)
 56: {
 58:   PetscReal      re,im;

 61: #if defined(PETSC_USE_COMPLEX)
 62:   re = PetscRealPart(eigr);
 63:   im = PetscImaginaryPart(eigr);
 64: #else
 65:   re = eigr;
 66:   im = eigi;
 67: #endif
 68:   /* print zero instead of tiny value */
 69:   if (PetscAbs(im) && PetscAbs(re)/PetscAbs(im)<PETSC_SMALL) re = 0.0;
 70:   if (PetscAbs(re) && PetscAbs(im)/PetscAbs(re)<PETSC_SMALL) im = 0.0;
 71:   /* print as real if imaginary part is zero */
 72:   if (im!=0.0) {
 73:     PetscViewerASCIIPrintf(viewer,"%.5f%+.5fi",(double)re,(double)im);
 74:   } else {
 75:     PetscViewerASCIIPrintf(viewer,"%.5f",(double)re);
 76:   }
 77:   return(0);
 78: }

 80: /* Macros for strings with different value in real and complex */
 81: #if defined(PETSC_USE_COMPLEX)
 82: #define SLEPC_STRING_HERMITIAN "hermitian"
 83: #else
 84: #define SLEPC_STRING_HERMITIAN "symmetric"
 85: #endif

 87: /* Private functions that are shared by several classes */
 88: SLEPC_EXTERN PetscErrorCode SlepcBasisReference_Private(PetscInt,Vec*,PetscInt*,Vec**);
 89: SLEPC_EXTERN PetscErrorCode SlepcBasisDestroy_Private(PetscInt*,Vec**);
 90: SLEPC_EXTERN PetscErrorCode SlepcMonitorMakeKey_Internal(const char[],PetscViewerType,PetscViewerFormat,char[]);
 91: SLEPC_EXTERN PetscErrorCode PetscViewerAndFormatCreate_Internal(PetscViewer,PetscViewerFormat,void*,PetscViewerAndFormat**);

 93: SLEPC_INTERN PetscErrorCode SlepcCitationsInitialize(void);
 94: SLEPC_INTERN PetscErrorCode SlepcInitialize_DynamicLibraries(void);
 95: SLEPC_INTERN PetscErrorCode SlepcInitialize_Packages(void);

 97: #endif