| #!/usr/bin/env python |
| import sys |
| if not type(sys.version_info) is tuple and sys.version_info.major > 2: |
| print('Configure does not support Python 3 yet, please run as') |
| print(' python2 ' + ' '.join(["'" + a + "'" for a in sys.argv])) |
| sys.exit(1) |
| import os |
| execfile(os.path.join(os.path.dirname(__file__), 'config', 'configure.py')) |
| SLEPc example matrices |
| ---------------------- |
| Saved in MATMPIAIJ format with a PetscViewerBinary. |
| File Name Description |
| ---------------------------------------------------------------------------- |
| rdb200 Brusselator real unsymmetric, 200 by 200, 1120 entries |
| bfw62a Waveguide real unsymmetric, 62 by 62, 450 entries |
| bfw62b real symmetric indefinite, 62 by 62, 342 entries |
| speaker107m Speaker quadratic eigenvalue problem |
| speaker107c |
| speaker107k |
| /* |
| User interface for SLEPc's quadratic eigenvalue solvers. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| SLEPc - Scalable Library for Eigenvalue Problem Computations |
| Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| This file is part of SLEPc. |
| SLEPc is free software: you can redistribute it and/or modify it under the |
| terms of version 3 of the GNU Lesser General Public License as published by |
| the Free Software Foundation. |
| SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| more details. |
| You should have received a copy of the GNU Lesser General Public License |
| along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| */ |
| #if !defined(__SLEPCQEP_H) |
| #define __SLEPCQEP_H |
| #include "slepcsys.h" |
| #include "slepceps.h" |
| PETSC_EXTERN_CXX_BEGIN |
| extern PetscErrorCode QEPInitializePackage(const char[]); |
| /*S |
| QEP - Abstract SLEPc object that manages all the quadratic eigenvalue |
| problem solvers. |
| Level: beginner |
| .seealso: QEPCreate() |
| S*/ |
| typedef struct _p_QEP* QEP; |
| /*E |
| QEPType - String with the name of a quadratic eigensolver |
| Level: beginner |
| .seealso: QEPSetType(), QEP |
| E*/ |
| #define QEPType char* |
| #define QEPLINEAR "linear" |
| #define QEPQARNOLDI "qarnoldi" |
| /* Logging support */ |
| extern PetscClassId QEP_CLASSID; |
| /*E |
| QEPProblemType - determines the type of the quadratic eigenproblem |
| Level: intermediate |
| .seealso: QEPSetProblemType(), QEPGetProblemType() |
| E*/ |
| typedef enum { QEP_GENERAL=1, |
| QEP_HERMITIAN, /* M, C, K Hermitian */ |
| QEP_GYROSCOPIC /* M, K Hermitian, M>0, C skew-Hermitian */ |
| } QEPProblemType; |
| /*E |
| QEPWhich - determines which part of the spectrum is requested |
| Level: intermediate |
| .seealso: QEPSetWhichEigenpairs(), QEPGetWhichEigenpairs() |
| E*/ |
| typedef enum { QEP_LARGEST_MAGNITUDE=1, |
| QEP_SMALLEST_MAGNITUDE, |
| QEP_LARGEST_REAL, |
| QEP_SMALLEST_REAL, |
| QEP_LARGEST_IMAGINARY, |
| QEP_SMALLEST_IMAGINARY } QEPWhich; |
| extern PetscErrorCode QEPCreate(MPI_Comm,QEP*); |
| extern PetscErrorCode QEPDestroy(QEP*); |
| extern PetscErrorCode QEPReset(QEP); |
| extern PetscErrorCode QEPSetType(QEP,const QEPType); |
| extern PetscErrorCode QEPGetType(QEP,const QEPType*); |
| extern PetscErrorCode QEPSetProblemType(QEP,QEPProblemType); |
| extern PetscErrorCode QEPGetProblemType(QEP,QEPProblemType*); |
| extern PetscErrorCode QEPSetOperators(QEP,Mat,Mat,Mat); |
| extern PetscErrorCode QEPGetOperators(QEP,Mat*,Mat*,Mat*); |
| extern PetscErrorCode QEPSetFromOptions(QEP); |
| extern PetscErrorCode QEPSetUp(QEP); |
| extern PetscErrorCode QEPSolve(QEP); |
| extern PetscErrorCode QEPView(QEP,PetscViewer); |
| extern PetscErrorCode QEPPrintSolution(QEP,PetscViewer); |
| extern PetscErrorCode QEPSetIP(QEP,IP); |
| extern PetscErrorCode QEPGetIP(QEP,IP*); |
| extern PetscErrorCode QEPSetTolerances(QEP,PetscReal,PetscInt); |
| extern PetscErrorCode QEPGetTolerances(QEP,PetscReal*,PetscInt*); |
| extern PetscErrorCode QEPSetConvergenceTest(QEP,PetscErrorCode (*)(QEP,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*),void*); |
| extern PetscErrorCode QEPDefaultConverged(QEP,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*); |
| extern PetscErrorCode QEPAbsoluteConverged(QEP,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*); |
| extern PetscErrorCode QEPSetDimensions(QEP,PetscInt,PetscInt,PetscInt); |
| extern PetscErrorCode QEPGetDimensions(QEP,PetscInt*,PetscInt*,PetscInt*); |
| extern PetscErrorCode QEPSetScaleFactor(QEP,PetscReal); |
| extern PetscErrorCode QEPGetScaleFactor(QEP,PetscReal*); |
| extern PetscErrorCode QEPGetConverged(QEP,PetscInt*); |
| extern PetscErrorCode QEPGetEigenpair(QEP,PetscInt,PetscScalar*,PetscScalar*,Vec,Vec); |
| extern PetscErrorCode QEPComputeRelativeError(QEP,PetscInt,PetscReal*); |
| extern PetscErrorCode QEPComputeResidualNorm(QEP,PetscInt,PetscReal*); |
| extern PetscErrorCode QEPGetErrorEstimate(QEP,PetscInt,PetscReal*); |
| extern PetscErrorCode QEPMonitorSet(QEP,PetscErrorCode (*)(QEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*),void*,PetscErrorCode (*)(void**)); |
| extern PetscErrorCode QEPMonitorCancel(QEP); |
| extern PetscErrorCode QEPGetMonitorContext(QEP,void **); |
| extern PetscErrorCode QEPGetIterationNumber(QEP,PetscInt*); |
| extern PetscErrorCode QEPGetOperationCounters(QEP,PetscInt*,PetscInt*,PetscInt*); |
| extern PetscErrorCode QEPSetInitialSpace(QEP,PetscInt,Vec*); |
| extern PetscErrorCode QEPSetInitialSpaceLeft(QEP,PetscInt,Vec*); |
| extern PetscErrorCode QEPSetWhichEigenpairs(QEP,QEPWhich); |
| extern PetscErrorCode QEPGetWhichEigenpairs(QEP,QEPWhich*); |
| extern PetscErrorCode QEPSetLeftVectorsWanted(QEP,PetscBool); |
| extern PetscErrorCode QEPGetLeftVectorsWanted(QEP,PetscBool*); |
| extern PetscErrorCode QEPSetEigenvalueComparison(QEP,PetscErrorCode (*func)(QEP,PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*,void*),void*); |
| extern PetscErrorCode QEPMonitorAll(QEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*); |
| extern PetscErrorCode QEPMonitorFirst(QEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*); |
| extern PetscErrorCode QEPMonitorConverged(QEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*); |
| extern PetscErrorCode QEPMonitorLG(QEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*); |
| extern PetscErrorCode QEPMonitorLGAll(QEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*); |
| extern PetscErrorCode QEPSetTrackAll(QEP,PetscBool); |
| extern PetscErrorCode QEPGetTrackAll(QEP,PetscBool*); |
| extern PetscErrorCode QEPSetOptionsPrefix(QEP,const char*); |
| extern PetscErrorCode QEPAppendOptionsPrefix(QEP,const char*); |
| extern PetscErrorCode QEPGetOptionsPrefix(QEP,const char*[]); |
| /*E |
| QEPConvergedReason - reason an eigensolver was said to |
| have converged or diverged |
| Level: beginner |
| .seealso: QEPSolve(), QEPGetConvergedReason(), QEPSetTolerances() |
| E*/ |
| typedef enum {/* converged */ |
| QEP_CONVERGED_TOL = 2, |
| /* diverged */ |
| QEP_DIVERGED_ITS = -3, |
| QEP_DIVERGED_BREAKDOWN = -4, |
| QEP_CONVERGED_ITERATING = 0} QEPConvergedReason; |
| extern PetscErrorCode QEPGetConvergedReason(QEP,QEPConvergedReason *); |
| extern PetscErrorCode QEPSortEigenvalues(QEP,PetscInt,PetscScalar*,PetscScalar*,PetscInt*); |
| extern PetscErrorCode QEPSortEigenvaluesReal(QEP,PetscInt,PetscReal*,PetscInt*); |
| extern PetscErrorCode QEPCompareEigenvalues(QEP,PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*); |
| extern PetscErrorCode QEPSortDenseSchur(QEP,PetscInt,PetscInt,PetscScalar*,PetscInt,PetscScalar*,PetscScalar*,PetscScalar*); |
| extern PetscFList QEPList; |
| extern PetscBool QEPRegisterAllCalled; |
| extern PetscErrorCode QEPRegisterAll(const char[]); |
| extern PetscErrorCode QEPRegisterDestroy(void); |
| extern PetscErrorCode QEPRegister(const char[],const char[],const char[],PetscErrorCode(*)(QEP)); |
| /*MC |
| QEPRegisterDynamic - Adds a method to the quadratic eigenproblem solver package. |
| Synopsis: |
| PetscErrorCode QEPRegisterDynamic(const char *name_solver,const char *path,const char *name_create,PetscErrorCode (*routine_create)(QEP)) |
| Not Collective |
| Input Parameters: |
| + name_solver - name of a new user-defined solver |
| . path - path (either absolute or relative) the library containing this solver |
| . name_create - name of routine to create the solver context |
| - routine_create - routine to create the solver context |
| Notes: |
| QEPRegisterDynamic() may be called multiple times to add several user-defined solvers. |
| If dynamic libraries are used, then the fourth input argument (routine_create) |
| is ignored. |
| Sample usage: |
| .vb |
| QEPRegisterDynamic("my_solver",/home/username/my_lib/lib/libO/solaris/mylib.a, |
| "MySolverCreate",MySolverCreate); |
| .ve |
| Then, your solver can be chosen with the procedural interface via |
| $ QEPSetType(qep,"my_solver") |
| or at runtime via the option |
| $ -qep_type my_solver |
| Level: advanced |
| .seealso: QEPRegisterDestroy(), QEPRegisterAll() |
| M*/ |
| #if defined(PETSC_USE_DYNAMIC_LIBRARIES) |
| #define QEPRegisterDynamic(a,b,c,d) QEPRegister(a,b,c,0) |
| #else |
| #define QEPRegisterDynamic(a,b,c,d) QEPRegister(a,b,c,d) |
| #endif |
| /* --------- options specific to particular eigensolvers -------- */ |
| extern PetscErrorCode QEPLinearSetCompanionForm(QEP,PetscInt); |
| extern PetscErrorCode QEPLinearGetCompanionForm(QEP,PetscInt*); |
| extern PetscErrorCode QEPLinearSetExplicitMatrix(QEP,PetscBool); |
| extern PetscErrorCode QEPLinearGetExplicitMatrix(QEP,PetscBool*); |
| extern PetscErrorCode QEPLinearSetEPS(QEP,EPS); |
| extern PetscErrorCode QEPLinearGetEPS(QEP,EPS*); |
| PETSC_EXTERN_CXX_END |
| #endif |
| #if !defined(__SLEPCVERSION_H) |
| #define __SLEPCVERSION_H |
| #define SLEPC_VERSION_RELEASE 1 |
| #define SLEPC_VERSION_MAJOR 3 |
| #define SLEPC_VERSION_MINOR 2 |
| #define SLEPC_VERSION_SUBMINOR 0 |
| #define SLEPC_VERSION_PATCH 5 |
| #define SLEPC_VERSION_DATE "October 28, 2011" |
| #define SLEPC_VERSION_PATCH_DATE "April 4, 2012" |
| #if !defined (SLEPC_VERSION_SVN) |
| #define SLEPC_VERSION_SVN "unknown" |
| #endif |
| #if !defined(SLEPC_VERSION_DATE_SVN) |
| #define SLEPC_VERSION_DATE_SVN "unknown" |
| #endif |
| #define SLEPC_VERSION_(MAJOR,MINOR,SUBMINOR) \ |
| ((SLEPC_VERSION_MAJOR == (MAJOR)) && \ |
| (SLEPC_VERSION_MINOR == (MINOR)) && \ |
| (SLEPC_VERSION_SUBMINOR == (SUBMINOR)) && \ |
| (SLEPC_VERSION_RELEASE == 1)) |
| #endif |
| /* |
| Spectral transformation module for eigenvalue problems. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| SLEPc - Scalable Library for Eigenvalue Problem Computations |
| Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| This file is part of SLEPc. |
| SLEPc is free software: you can redistribute it and/or modify it under the |
| terms of version 3 of the GNU Lesser General Public License as published by |
| the Free Software Foundation. |
| SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| more details. |
| You should have received a copy of the GNU Lesser General Public License |
| along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| */ |
| #if !defined(__SLEPCST_H) |
| #define __SLEPCST_H |
| #include "petscksp.h" |
| PETSC_EXTERN_CXX_BEGIN |
| extern PetscErrorCode STInitializePackage(const char[]); |
| /*S |
| ST - Abstract SLEPc object that manages spectral transformations. |
| This object is accessed only in advanced applications. |
| Level: beginner |
| .seealso: STCreate(), EPS |
| S*/ |
| typedef struct _p_ST* ST; |
| /*E |
| STType - String with the name of a SLEPc spectral transformation |
| Level: beginner |
| .seealso: STSetType(), ST |
| E*/ |
| #define STType char* |
| #define STSHELL "shell" |
| #define STSHIFT "shift" |
| #define STSINVERT "sinvert" |
| #define STCAYLEY "cayley" |
| #define STFOLD "fold" |
| #define STPRECOND "precond" |
| /* Logging support */ |
| extern PetscClassId ST_CLASSID; |
| extern PetscErrorCode STCreate(MPI_Comm,ST*); |
| extern PetscErrorCode STDestroy(ST*); |
| extern PetscErrorCode STReset(ST); |
| extern PetscErrorCode STSetType(ST,const STType); |
| extern PetscErrorCode STGetType(ST,const STType*); |
| extern PetscErrorCode STSetOperators(ST,Mat,Mat); |
| extern PetscErrorCode STGetOperators(ST,Mat*,Mat*); |
| extern PetscErrorCode STSetUp(ST); |
| extern PetscErrorCode STSetFromOptions(ST); |
| extern PetscErrorCode STView(ST,PetscViewer); |
| extern PetscErrorCode STApply(ST,Vec,Vec); |
| extern PetscErrorCode STGetBilinearForm(ST,Mat*); |
| extern PetscErrorCode STApplyTranspose(ST,Vec,Vec); |
| extern PetscErrorCode STComputeExplicitOperator(ST,Mat*); |
| extern PetscErrorCode STPostSolve(ST); |
| extern PetscErrorCode STSetKSP(ST,KSP); |
| extern PetscErrorCode STGetKSP(ST,KSP*); |
| extern PetscErrorCode STSetShift(ST,PetscScalar); |
| extern PetscErrorCode STGetShift(ST,PetscScalar*); |
| extern PetscErrorCode STSetDefaultShift(ST,PetscScalar); |
| extern PetscErrorCode STSetBalanceMatrix(ST,Vec); |
| extern PetscErrorCode STGetBalanceMatrix(ST,Vec*); |
| extern PetscErrorCode STSetOptionsPrefix(ST,const char*); |
| extern PetscErrorCode STAppendOptionsPrefix(ST,const char*); |
| extern PetscErrorCode STGetOptionsPrefix(ST,const char*[]); |
| extern PetscErrorCode STBackTransform(ST,PetscInt,PetscScalar*,PetscScalar*); |
| extern PetscErrorCode STCheckNullSpace(ST,PetscInt,const Vec[]); |
| extern PetscErrorCode STGetOperationCounters(ST,PetscInt*,PetscInt*); |
| extern PetscErrorCode STResetOperationCounters(ST); |
| /*E |
| STMatMode - determines how to handle the coefficient matrix associated |
| to the spectral transformation |
| Level: intermediate |
| .seealso: STSetMatMode(), STGetMatMode() |
| E*/ |
| typedef enum { ST_MATMODE_COPY, |
| ST_MATMODE_INPLACE, |
| ST_MATMODE_SHELL } STMatMode; |
| extern PetscErrorCode STSetMatMode(ST,STMatMode); |
| extern PetscErrorCode STGetMatMode(ST,STMatMode*); |
| extern PetscErrorCode STSetMatStructure(ST,MatStructure); |
| extern PetscErrorCode STGetMatStructure(ST,MatStructure*); |
| extern PetscFList STList; |
| extern PetscBool STRegisterAllCalled; |
| extern PetscErrorCode STRegisterAll(const char[]); |
| extern PetscErrorCode STRegisterDestroy(void); |
| extern PetscErrorCode STRegister(const char[],const char[],const char[],PetscErrorCode(*)(ST)); |
| /*MC |
| STRegisterDynamic - Adds a method to the spectral transformation package. |
| Synopsis: |
| PetscErrorCode STRegisterDynamic(const char *name,const char *path,const char *name_create,PetscErrorCode (*routine_create)(ST)) |
| Not collective |
| Input Parameters: |
| + name - name of a new user-defined transformation |
| . path - path (either absolute or relative) the library containing this solver |
| . name_create - name of routine to create method context |
| - routine_create - routine to create method context |
| Notes: |
| STRegisterDynamic() may be called multiple times to add several user-defined |
| spectral transformations. |
| If dynamic libraries are used, then the fourth input argument (routine_create) |
| is ignored. |
| Sample usage: |
| .vb |
| STRegisterDynamic("my_solver","/home/username/my_lib/lib/libO/solaris/mylib.a", |
| "MySolverCreate",MySolverCreate); |
| .ve |
| Then, your solver can be chosen with the procedural interface via |
| $ STSetType(st,"my_solver") |
| or at runtime via the option |
| $ -st_type my_solver |
| Level: advanced |
| .seealso: STRegisterDestroy(), STRegisterAll() |
| M*/ |
| #if defined(PETSC_USE_DYNAMIC_LIBRARIES) |
| #define STRegisterDynamic(a,b,c,d) STRegister(a,b,c,0) |
| #else |
| #define STRegisterDynamic(a,b,c,d) STRegister(a,b,c,d) |
| #endif |
| /* --------- options specific to particular spectral transformations-------- */ |
| extern PetscErrorCode STShellGetContext(ST st,void **ctx); |
| extern PetscErrorCode STShellSetContext(ST st,void *ctx); |
| extern PetscErrorCode STShellSetApply(ST st,PetscErrorCode (*apply)(ST,Vec,Vec)); |
| extern PetscErrorCode STShellSetApplyTranspose(ST st,PetscErrorCode (*applytrans)(ST,Vec,Vec)); |
| extern PetscErrorCode STShellSetBackTransform(ST st,PetscErrorCode (*backtr)(ST,PetscInt,PetscScalar*,PetscScalar*)); |
| extern PetscErrorCode STCayleyGetAntishift(ST,PetscScalar*); |
| extern PetscErrorCode STCayleySetAntishift(ST,PetscScalar); |
| extern PetscErrorCode STPrecondGetMatForPC(ST st,Mat *mat); |
| extern PetscErrorCode STPrecondSetMatForPC(ST st,Mat mat); |
| extern PetscErrorCode STPrecondGetKSPHasMat(ST st,PetscBool *setmat); |
| extern PetscErrorCode STPrecondSetKSPHasMat(ST st,PetscBool setmat); |
| PETSC_EXTERN_CXX_END |
| #endif |
| /* |
| User interface for the SLEPC eigenproblem solvers. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| SLEPc - Scalable Library for Eigenvalue Problem Computations |
| Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| This file is part of SLEPc. |
| SLEPc is free software: you can redistribute it and/or modify it under the |
| terms of version 3 of the GNU Lesser General Public License as published by |
| the Free Software Foundation. |
| SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| more details. |
| You should have received a copy of the GNU Lesser General Public License |
| along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| */ |
| #if !defined(__SLEPCEPS_H) |
| #define __SLEPCEPS_H |
| #include "slepcsys.h" |
| #include "slepcst.h" |
| #include "slepcip.h" |
| PETSC_EXTERN_CXX_BEGIN |
| extern PetscErrorCode EPSInitializePackage(const char[]); |
| /*S |
| EPS - Abstract SLEPc object that manages all the eigenvalue |
| problem solvers. |
| Level: beginner |
| .seealso: EPSCreate(), ST |
| S*/ |
| typedef struct _p_EPS* EPS; |
| /*E |
| EPSType - String with the name of a SLEPc eigensolver |
| Level: beginner |
| .seealso: EPSSetType(), EPS |
| E*/ |
| #define EPSType char* |
| #define EPSPOWER "power" |
| #define EPSSUBSPACE "subspace" |
| #define EPSARNOLDI "arnoldi" |
| #define EPSLANCZOS "lanczos" |
| #define EPSKRYLOVSCHUR "krylovschur" |
| #define EPSGD "gd" |
| #define EPSJD "jd" |
| #define EPSLAPACK "lapack" |
| /* the next ones are interfaces to external libraries */ |
| #define EPSARPACK "arpack" |
| #define EPSBLZPACK "blzpack" |
| #define EPSTRLAN "trlan" |
| #define EPSBLOPEX "blopex" |
| #define EPSPRIMME "primme" |
| /* Logging support */ |
| extern PetscClassId EPS_CLASSID; |
| /*E |
| EPSProblemType - determines the type of eigenvalue problem |
| Level: beginner |
| .seealso: EPSSetProblemType(), EPSGetProblemType() |
| E*/ |
| typedef enum { EPS_HEP=1, |
| EPS_GHEP, |
| EPS_NHEP, |
| EPS_GNHEP, |
| EPS_PGNHEP} EPSProblemType; |
| /*E |
| EPSExtraction - determines the type of extraction technique employed |
| by the eigensolver |
| Level: beginner |
| .seealso: EPSSetExtraction(), EPSGetExtraction() |
| E*/ |
| typedef enum { EPS_RITZ=1, |
| EPS_HARMONIC, |
| EPS_HARMONIC_RELATIVE, |
| EPS_HARMONIC_RIGHT, |
| EPS_HARMONIC_LARGEST, |
| EPS_REFINED, |
| EPS_REFINED_HARMONIC } EPSExtraction; |
| /*E |
| EPSWhich - determines which part of the spectrum is requested |
| Level: intermediate |
| .seealso: EPSSetWhichEigenpairs(), EPSGetWhichEigenpairs() |
| E*/ |
| typedef enum { EPS_LARGEST_MAGNITUDE=1, |
| EPS_SMALLEST_MAGNITUDE, |
| EPS_LARGEST_REAL, |
| EPS_SMALLEST_REAL, |
| EPS_LARGEST_IMAGINARY, |
| EPS_SMALLEST_IMAGINARY, |
| EPS_TARGET_MAGNITUDE, |
| EPS_TARGET_REAL, |
| EPS_TARGET_IMAGINARY, |
| EPS_ALL, |
| EPS_WHICH_USER } EPSWhich; |
| /*E |
| EPSBalance - the type of balancing used for non-Hermitian problems |
| Level: intermediate |
| .seealso: EPSSetBalance() |
| E*/ |
| typedef enum { EPS_BALANCE_NONE=1, |
| EPS_BALANCE_ONESIDE, |
| EPS_BALANCE_TWOSIDE, |
| EPS_BALANCE_USER } EPSBalance; |
| /*E |
| EPSConv - determines the convergence test |
| Level: intermediate |
| .seealso: EPSSetConvergenceTest(), EPSSetConvergenceTestFunction() |
| E*/ |
| typedef enum { EPS_CONV_ABS=1, |
| EPS_CONV_EIG, |
| EPS_CONV_NORM, |
| EPS_CONV_USER } EPSConv; |
| extern PetscErrorCode EPSCreate(MPI_Comm,EPS *); |
| extern PetscErrorCode EPSDestroy(EPS*); |
| extern PetscErrorCode EPSReset(EPS); |
| extern PetscErrorCode EPSSetType(EPS,const EPSType); |
| extern PetscErrorCode EPSGetType(EPS,const EPSType*); |
| extern PetscErrorCode EPSSetProblemType(EPS,EPSProblemType); |
| extern PetscErrorCode EPSGetProblemType(EPS,EPSProblemType*); |
| extern PetscErrorCode EPSSetExtraction(EPS,EPSExtraction); |
| extern PetscErrorCode EPSGetExtraction(EPS,EPSExtraction*); |
| extern PetscErrorCode EPSSetBalance(EPS,EPSBalance,PetscInt,PetscReal); |
| extern PetscErrorCode EPSGetBalance(EPS,EPSBalance*,PetscInt*,PetscReal*); |
| extern PetscErrorCode EPSSetOperators(EPS,Mat,Mat); |
| extern PetscErrorCode EPSGetOperators(EPS,Mat*,Mat*); |
| extern PetscErrorCode EPSSetFromOptions(EPS); |
| extern PetscErrorCode EPSSetUp(EPS); |
| extern PetscErrorCode EPSSolve(EPS); |
| extern PetscErrorCode EPSView(EPS,PetscViewer); |
| extern PetscErrorCode EPSPrintSolution(EPS,PetscViewer); |
| extern PetscErrorCode EPSSetTarget(EPS,PetscScalar); |
| extern PetscErrorCode EPSGetTarget(EPS,PetscScalar*); |
| extern PetscErrorCode EPSSetInterval(EPS,PetscReal,PetscReal); |
| extern PetscErrorCode EPSGetInterval(EPS,PetscReal*,PetscReal*); |
| extern PetscErrorCode EPSSetST(EPS,ST); |
| extern PetscErrorCode EPSGetST(EPS,ST*); |
| extern PetscErrorCode EPSSetIP(EPS,IP); |
| extern PetscErrorCode EPSGetIP(EPS,IP*); |
| extern PetscErrorCode EPSSetTolerances(EPS,PetscReal,PetscInt); |
| extern PetscErrorCode EPSGetTolerances(EPS,PetscReal*,PetscInt*); |
| extern PetscErrorCode EPSSetConvergenceTestFunction(EPS,PetscErrorCode (*)(EPS,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*),void*); |
| extern PetscErrorCode EPSSetConvergenceTest(EPS eps,EPSConv conv); |
| extern PetscErrorCode EPSGetConvergenceTest(EPS eps,EPSConv *conv); |
| extern PetscErrorCode EPSEigRelativeConverged(EPS,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*); |
| extern PetscErrorCode EPSAbsoluteConverged(EPS,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*); |
| extern PetscErrorCode EPSNormRelativeConverged(EPS,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*); |
| extern PetscErrorCode EPSSetDimensions(EPS,PetscInt,PetscInt,PetscInt); |
| extern PetscErrorCode EPSGetDimensions(EPS,PetscInt*,PetscInt*,PetscInt*); |
| extern PetscErrorCode EPSGetConverged(EPS,PetscInt*); |
| extern PetscErrorCode EPSGetEigenpair(EPS,PetscInt,PetscScalar*,PetscScalar*,Vec,Vec); |
| extern PetscErrorCode EPSGetEigenvalue(EPS,PetscInt,PetscScalar*,PetscScalar*); |
| extern PetscErrorCode EPSGetEigenvector(EPS,PetscInt,Vec,Vec); |
| extern PetscErrorCode EPSGetEigenvectorLeft(EPS,PetscInt,Vec,Vec); |
| extern PetscErrorCode EPSComputeRelativeError(EPS,PetscInt,PetscReal*); |
| extern PetscErrorCode EPSComputeRelativeErrorLeft(EPS,PetscInt,PetscReal*); |
| extern PetscErrorCode EPSComputeResidualNorm(EPS,PetscInt,PetscReal*); |
| extern PetscErrorCode EPSComputeResidualNormLeft(EPS,PetscInt,PetscReal*); |
| extern PetscErrorCode EPSGetInvariantSubspace(EPS,Vec*); |
| extern PetscErrorCode EPSGetInvariantSubspaceLeft(EPS,Vec*); |
| extern PetscErrorCode EPSGetErrorEstimate(EPS,PetscInt,PetscReal*); |
| extern PetscErrorCode EPSGetErrorEstimateLeft(EPS,PetscInt,PetscReal*); |
| extern PetscErrorCode EPSMonitorSet(EPS,PetscErrorCode (*)(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*),void*,PetscErrorCode (*)(void**)); |
| extern PetscErrorCode EPSMonitorCancel(EPS); |
| extern PetscErrorCode EPSGetMonitorContext(EPS,void **); |
| extern PetscErrorCode EPSGetIterationNumber(EPS,PetscInt*); |
| extern PetscErrorCode EPSGetOperationCounters(EPS,PetscInt*,PetscInt*,PetscInt*); |
| extern PetscErrorCode EPSSetWhichEigenpairs(EPS,EPSWhich); |
| extern PetscErrorCode EPSGetWhichEigenpairs(EPS,EPSWhich*); |
| extern PetscErrorCode EPSSetLeftVectorsWanted(EPS,PetscBool); |
| extern PetscErrorCode EPSGetLeftVectorsWanted(EPS,PetscBool*); |
| extern PetscErrorCode EPSSetMatrixNorms(EPS,PetscReal,PetscReal,PetscBool); |
| extern PetscErrorCode EPSGetMatrixNorms(EPS,PetscReal*,PetscReal*,PetscBool*); |
| extern PetscErrorCode EPSSetTrueResidual(EPS,PetscBool); |
| extern PetscErrorCode EPSGetTrueResidual(EPS,PetscBool*); |
| extern PetscErrorCode EPSSetEigenvalueComparison(EPS,PetscErrorCode (*func)(EPS,PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*,void*),void*); |
| extern PetscErrorCode EPSIsGeneralized(EPS,PetscBool*); |
| extern PetscErrorCode EPSIsHermitian(EPS,PetscBool*); |
| extern PetscErrorCode EPSMonitorFirst(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*); |
| extern PetscErrorCode EPSMonitorAll(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*); |
| extern PetscErrorCode EPSMonitorConverged(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*); |
| extern PetscErrorCode EPSMonitorLG(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*); |
| extern PetscErrorCode EPSMonitorLGAll(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*); |
| extern PetscErrorCode EPSSetTrackAll(EPS,PetscBool); |
| extern PetscErrorCode EPSGetTrackAll(EPS,PetscBool*); |
| extern PetscErrorCode EPSSetDeflationSpace(EPS,PetscInt,Vec*); |
| extern PetscErrorCode EPSRemoveDeflationSpace(EPS); |
| extern PetscErrorCode EPSSetInitialSpace(EPS,PetscInt,Vec*); |
| extern PetscErrorCode EPSSetInitialSpaceLeft(EPS,PetscInt,Vec*); |
| extern PetscErrorCode EPSSetOptionsPrefix(EPS,const char*); |
| extern PetscErrorCode EPSAppendOptionsPrefix(EPS,const char*); |
| extern PetscErrorCode EPSGetOptionsPrefix(EPS,const char*[]); |
| /*E |
| EPSConvergedReason - reason an eigensolver was said to |
| have converged or diverged |
| Level: beginner |
| .seealso: EPSSolve(), EPSGetConvergedReason(), EPSSetTolerances() |
| E*/ |
| typedef enum {/* converged */ |
| EPS_CONVERGED_TOL = 2, |
| /* diverged */ |
| EPS_DIVERGED_ITS = -3, |
| EPS_DIVERGED_BREAKDOWN = -4, |
| EPS_CONVERGED_ITERATING = 0} EPSConvergedReason; |
| extern PetscErrorCode EPSGetConvergedReason(EPS,EPSConvergedReason *); |
| extern PetscErrorCode EPSSortEigenvalues(EPS,PetscInt,PetscScalar*,PetscScalar*,PetscInt*); |
| extern PetscErrorCode EPSSortEigenvaluesReal(EPS,PetscInt,PetscReal*,PetscInt*); |
| extern PetscErrorCode EPSCompareEigenvalues(EPS,PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*); |
| extern PetscErrorCode EPSDenseNHEP(PetscInt,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*); |
| extern PetscErrorCode EPSDenseGNHEP(PetscInt,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*); |
| extern PetscErrorCode EPSDenseHEP(PetscInt,PetscScalar*,PetscInt,PetscReal*,PetscScalar*); |
| extern PetscErrorCode EPSDenseGHEP(PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscScalar*); |
| extern PetscErrorCode EPSDenseHessenberg(PetscInt,PetscInt,PetscScalar*,PetscInt,PetscScalar*); |
| extern PetscErrorCode EPSDenseSchur(PetscInt,PetscInt,PetscScalar*,PetscInt,PetscScalar*,PetscScalar*,PetscScalar*); |
| extern PetscErrorCode EPSSortDenseSchur(EPS,PetscInt,PetscInt,PetscScalar*,PetscInt,PetscScalar*,PetscScalar*,PetscScalar*); |
| extern PetscErrorCode EPSSortDenseSchurGeneralized(EPS,PetscInt,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscInt,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*); |
| extern PetscErrorCode EPSDenseTridiagonal(PetscInt,PetscReal*,PetscReal*,PetscReal*,PetscScalar*); |
| extern PetscErrorCode EPSGetStartVector(EPS,PetscInt,Vec,PetscBool*); |
| extern PetscErrorCode EPSGetStartVectorLeft(EPS,PetscInt,Vec,PetscBool*); |
| extern PetscFList EPSList; |
| extern PetscBool EPSRegisterAllCalled; |
| extern PetscErrorCode EPSRegisterAll(const char[]); |
| extern PetscErrorCode EPSRegisterDestroy(void); |
| extern PetscErrorCode EPSRegister(const char[],const char[],const char[],PetscErrorCode(*)(EPS)); |
| /*MC |
| EPSRegisterDynamic - Adds a method to the eigenproblem solver package. |
| Synopsis: |
| PetscErrorCode EPSRegisterDynamic(const char *name_solver,const char *path,const char *name_create,PetscErrorCode (*routine_create)(EPS)) |
| Not Collective |
| Input Parameters: |
| + name_solver - name of a new user-defined solver |
| . path - path (either absolute or relative) the library containing this solver |
| . name_create - name of routine to create the solver context |
| - routine_create - routine to create the solver context |
| Notes: |
| EPSRegisterDynamic() may be called multiple times to add several user-defined solvers. |
| If dynamic libraries are used, then the fourth input argument (routine_create) |
| is ignored. |
| Sample usage: |
| .vb |
| EPSRegisterDynamic("my_solver",/home/username/my_lib/lib/libO/solaris/mylib.a, |
| "MySolverCreate",MySolverCreate); |
| .ve |
| Then, your solver can be chosen with the procedural interface via |
| $ EPSSetType(eps,"my_solver") |
| or at runtime via the option |
| $ -eps_type my_solver |
| Level: advanced |
| .seealso: EPSRegisterDestroy(), EPSRegisterAll() |
| M*/ |
| #if defined(PETSC_USE_DYNAMIC_LIBRARIES) |
| #define EPSRegisterDynamic(a,b,c,d) EPSRegister(a,b,c,0) |
| #else |
| #define EPSRegisterDynamic(a,b,c,d) EPSRegister(a,b,c,d) |
| #endif |
| /* --------- options specific to particular eigensolvers -------- */ |
| /*E |
| EPSPowerShiftType - determines the type of shift used in the Power iteration |
| Level: advanced |
| .seealso: EPSPowerSetShiftType(), EPSPowerGetShiftType() |
| E*/ |
| typedef enum { EPS_POWER_SHIFT_CONSTANT, |
| EPS_POWER_SHIFT_RAYLEIGH, |
| EPS_POWER_SHIFT_WILKINSON } EPSPowerShiftType; |
| extern const char *EPSPowerShiftTypes[]; |
| extern PetscErrorCode EPSPowerSetShiftType(EPS,EPSPowerShiftType); |
| extern PetscErrorCode EPSPowerGetShiftType(EPS,EPSPowerShiftType*); |
| extern PetscErrorCode EPSArnoldiSetDelayed(EPS,PetscBool); |
| extern PetscErrorCode EPSArnoldiGetDelayed(EPS,PetscBool*); |
| /*E |
| EPSLanczosReorthogType - determines the type of reorthogonalization |
| used in the Lanczos method |
| Level: advanced |
| .seealso: EPSLanczosSetReorthog(), EPSLanczosGetReorthog() |
| E*/ |
| typedef enum { EPS_LANCZOS_REORTHOG_LOCAL, |
| EPS_LANCZOS_REORTHOG_FULL, |
| EPS_LANCZOS_REORTHOG_SELECTIVE, |
| EPS_LANCZOS_REORTHOG_PERIODIC, |
| EPS_LANCZOS_REORTHOG_PARTIAL, |
| EPS_LANCZOS_REORTHOG_DELAYED } EPSLanczosReorthogType; |
| extern const char *EPSLanczosReorthogTypes[]; |
| extern PetscErrorCode EPSLanczosSetReorthog(EPS,EPSLanczosReorthogType); |
| extern PetscErrorCode EPSLanczosGetReorthog(EPS,EPSLanczosReorthogType*); |
| extern PetscErrorCode EPSBlzpackSetBlockSize(EPS,PetscInt); |
| extern PetscErrorCode EPSBlzpackSetNSteps(EPS,PetscInt); |
| /*E |
| EPSPRIMMEMethod - determines the method selected in the PRIMME library |
| Level: advanced |
| .seealso: EPSPRIMMESetMethod(), EPSPRIMMEGetMethod() |
| E*/ |
| typedef enum { EPS_PRIMME_DYNAMIC, |
| EPS_PRIMME_DEFAULT_MIN_TIME, |
| EPS_PRIMME_DEFAULT_MIN_MATVECS, |
| EPS_PRIMME_ARNOLDI, |
| EPS_PRIMME_GD, |
| EPS_PRIMME_GD_PLUSK, |
| EPS_PRIMME_GD_OLSEN_PLUSK, |
| EPS_PRIMME_JD_OLSEN_PLUSK, |
| EPS_PRIMME_RQI, |
| EPS_PRIMME_JDQR, |
| EPS_PRIMME_JDQMR, |
| EPS_PRIMME_JDQMR_ETOL, |
| EPS_PRIMME_SUBSPACE_ITERATION, |
| EPS_PRIMME_LOBPCG_ORTHOBASIS, |
| EPS_PRIMME_LOBPCG_ORTHOBASISW } EPSPRIMMEMethod; |
| extern const char *EPSPRIMMEMethods[]; |
| extern PetscErrorCode EPSPRIMMESetBlockSize(EPS eps,PetscInt bs); |
| extern PetscErrorCode EPSPRIMMESetMethod(EPS eps, EPSPRIMMEMethod method); |
| extern PetscErrorCode EPSPRIMMEGetBlockSize(EPS eps,PetscInt *bs); |
| extern PetscErrorCode EPSPRIMMEGetMethod(EPS eps, EPSPRIMMEMethod *method); |
| extern PetscErrorCode EPSGDSetKrylovStart(EPS eps,PetscBool krylovstart); |
| extern PetscErrorCode EPSGDGetKrylovStart(EPS eps,PetscBool *krylovstart); |
| extern PetscErrorCode EPSGDSetBlockSize(EPS eps,PetscInt blocksize); |
| extern PetscErrorCode EPSGDGetBlockSize(EPS eps,PetscInt *blocksize); |
| extern PetscErrorCode EPSGDSetRestart(EPS eps,PetscInt minv,PetscInt plusk); |
| extern PetscErrorCode EPSGDGetRestart(EPS eps,PetscInt *minv,PetscInt *plusk); |
| extern PetscErrorCode EPSGDSetInitialSize(EPS eps,PetscInt initialsize); |
| extern PetscErrorCode EPSGDGetInitialSize(EPS eps,PetscInt *initialsize); |
| extern PetscErrorCode EPSGDSetBOrth(EPS eps,PetscBool borth); |
| extern PetscErrorCode EPSGDGetBOrth(EPS eps,PetscBool *borth); |
| extern PetscErrorCode EPSGDGetWindowSizes(EPS eps,PetscInt *pwindow,PetscInt *qwindow); |
| extern PetscErrorCode EPSGDSetWindowSizes(EPS eps,PetscInt pwindow,PetscInt qwindow); |
| extern PetscErrorCode EPSJDSetKrylovStart(EPS eps,PetscBool krylovstart); |
| extern PetscErrorCode EPSJDGetKrylovStart(EPS eps,PetscBool *krylovstart); |
| extern PetscErrorCode EPSJDSetBlockSize(EPS eps,PetscInt blocksize); |
| extern PetscErrorCode EPSJDGetBlockSize(EPS eps,PetscInt *blocksize); |
| extern PetscErrorCode EPSJDSetRestart(EPS eps,PetscInt minv,PetscInt plusk); |
| extern PetscErrorCode EPSJDGetRestart(EPS eps,PetscInt *minv,PetscInt *plusk); |
| extern PetscErrorCode EPSJDSetInitialSize(EPS eps,PetscInt initialsize); |
| extern PetscErrorCode EPSJDGetInitialSize(EPS eps,PetscInt *initialsize); |
| extern PetscErrorCode EPSJDSetFix(EPS eps,PetscReal fix); |
| extern PetscErrorCode EPSJDGetFix(EPS eps,PetscReal *fix); |
| extern PetscErrorCode EPSJDSetConstantCorrectionTolerance(EPS eps,PetscBool dynamic); |
| extern PetscErrorCode EPSJDGetConstantCorrectionTolerance(EPS eps,PetscBool *dynamic); |
| extern PetscErrorCode EPSJDGetWindowSizes(EPS eps,PetscInt *pwindow,PetscInt *qwindow); |
| extern PetscErrorCode EPSJDSetWindowSizes(EPS eps,PetscInt pwindow,PetscInt qwindow); |
| PETSC_EXTERN_CXX_END |
| #endif |
| /* |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| SLEPc - Scalable Library for Eigenvalue Problem Computations |
| Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| This file is part of SLEPc. |
| SLEPc is free software: you can redistribute it and/or modify it under the |
| terms of version 3 of the GNU Lesser General Public License as published by |
| the Free Software Foundation. |
| SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| more details. |
| You should have received a copy of the GNU Lesser General Public License |
| along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| */ |
| #if !defined(__SLEPCIP_H) |
| #define __SLEPCIP_H |
| #include "slepcsys.h" |
| PETSC_EXTERN_CXX_BEGIN |
| extern PetscErrorCode IPInitializePackage(const char[]); |
| /*S |
| IP - Abstraction of a vector inner product, that can be defined |
| in different ways. Using this object is not required for application |
| programmers. |
| Level: beginner |
| .seealso: IPCreate() |
| S*/ |
| typedef struct _p_IP* IP; |
| /*E |
| IPType - String with the name of the inner product. For complex scalars, |
| it is possible to choose between a sesquilinear form (x,y)=x^H*M*y (the default) |
| or a bilinear form (x,y)=x^T*M*y (without complex conjugation). In the case |
| of real scalars, only the bilinear form (x,y)=x^T*M*y is available. |
| Level: advanced |
| .seealso: IPSetType(), IP |
| E*/ |
| #define IPType char* |
| #define IPBILINEAR "bilinear" |
| #define IPSESQUILINEAR "sesquilinear" |
| /* Logging support */ |
| extern PetscClassId IP_CLASSID; |
| /*E |
| IPOrthogType - determines what type of orthogonalization to use |
| Level: advanced |
| .seealso: IPSetOrthogonalization(), IPGetOrthogonalization(), IPOrthogonalize() |
| E*/ |
| typedef enum { IP_ORTHOG_MGS, |
| IP_ORTHOG_CGS } IPOrthogType; |
| /*E |
| IPOrthogRefineType - determines what type of refinement |
| to use during orthogonalization |
| Level: advanced |
| .seealso: IPSetOrthogonalization(), IPGetOrthogonalization(), IPOrthogonalize() |
| E*/ |
| typedef enum { IP_ORTHOG_REFINE_NEVER, |
| IP_ORTHOG_REFINE_IFNEEDED, |
| IP_ORTHOG_REFINE_ALWAYS } IPOrthogRefineType; |
| extern PetscErrorCode IPCreate(MPI_Comm,IP*); |
| extern PetscErrorCode IPSetType(IP,const IPType); |
| extern PetscErrorCode IPGetType(IP,const IPType*); |
| extern PetscErrorCode IPSetOptionsPrefix(IP,const char *); |
| extern PetscErrorCode IPAppendOptionsPrefix(IP,const char *); |
| extern PetscErrorCode IPGetOptionsPrefix(IP,const char *[]); |
| extern PetscErrorCode IPSetFromOptions(IP); |
| extern PetscErrorCode IPSetOrthogonalization(IP,IPOrthogType,IPOrthogRefineType,PetscReal); |
| extern PetscErrorCode IPGetOrthogonalization(IP,IPOrthogType*,IPOrthogRefineType*,PetscReal*); |
| extern PetscErrorCode IPView(IP,PetscViewer); |
| extern PetscErrorCode IPDestroy(IP*); |
| extern PetscErrorCode IPReset(IP); |
| extern PetscErrorCode IPOrthogonalize(IP,PetscInt,Vec*,PetscInt,PetscBool*,Vec*,Vec,PetscScalar*,PetscReal*,PetscBool*); |
| extern PetscErrorCode IPBOrthogonalize(IP,PetscInt,Vec*,Vec*,PetscInt,PetscBool*,Vec*,Vec*,Vec,Vec,PetscScalar*,PetscReal*,PetscBool*); |
| extern PetscErrorCode IPBiOrthogonalize(IP,PetscInt,Vec*,Vec*,Vec,PetscScalar*,PetscReal*); |
| extern PetscErrorCode IPQRDecomposition(IP,Vec*,PetscInt,PetscInt,PetscScalar*,PetscInt); |
| extern PetscErrorCode IPSetMatrix(IP,Mat); |
| extern PetscErrorCode IPGetMatrix(IP,Mat*); |
| extern PetscErrorCode IPApplyMatrix(IP,Vec,Vec); |
| extern PetscErrorCode IPInnerProduct(IP ip,Vec,Vec,PetscScalar*); |
| extern PetscErrorCode IPInnerProductBegin(IP ip,Vec,Vec,PetscScalar*); |
| extern PetscErrorCode IPInnerProductEnd(IP ip,Vec,Vec,PetscScalar*); |
| extern PetscErrorCode IPMInnerProduct(IP ip,Vec,PetscInt,const Vec[],PetscScalar*); |
| extern PetscErrorCode IPMInnerProductBegin(IP ip,Vec,PetscInt,const Vec[],PetscScalar*); |
| extern PetscErrorCode IPMInnerProductEnd(IP ip,Vec,PetscInt,const Vec[],PetscScalar*); |
| extern PetscErrorCode IPNorm(IP ip,Vec,PetscReal*); |
| extern PetscErrorCode IPNormBegin(IP ip,Vec,PetscReal*); |
| extern PetscErrorCode IPNormEnd(IP ip,Vec,PetscReal*); |
| extern PetscFList IPList; |
| extern PetscBool IPRegisterAllCalled; |
| extern PetscErrorCode IPRegisterAll(const char[]); |
| extern PetscErrorCode IPRegister(const char[],const char[],const char[],PetscErrorCode(*)(IP)); |
| extern PetscErrorCode IPRegisterDestroy(void); |
| /*MC |
| IPRegisterDynamic - Adds an inner product to the IP package. |
| Synopsis: |
| PetscErrorCode IPRegisterDynamic(const char *name,const char *path,const char *name_create,PetscErrorCode (*routine_create)(IP)) |
| Not collective |
| Input Parameters: |
| + name - name of a new user-defined IP |
| . path - path (either absolute or relative) the library containing this solver |
| . name_create - name of routine to create context |
| - routine_create - routine to create context |
| Notes: |
| IPRegisterDynamic() may be called multiple times to add several user-defined inner products. |
| If dynamic libraries are used, then the fourth input argument (routine_create) |
| is ignored. |
| Level: advanced |
| .seealso: IPRegisterDestroy(), IPRegisterAll() |
| M*/ |
| #if defined(PETSC_USE_DYNAMIC_LIBRARIES) |
| #define IPRegisterDynamic(a,b,c,d) IPRegister(a,b,c,0) |
| #else |
| #define IPRegisterDynamic(a,b,c,d) IPRegister(a,b,c,d) |
| #endif |
| extern PetscErrorCode IPGetOperationCounters(IP,PetscInt*); |
| extern PetscErrorCode IPResetOperationCounters(IP); |
| PETSC_EXTERN_CXX_END |
| #endif |
| ! |
| ! Include file for Fortran use of the QEP object in SLEPc |
| ! |
| ! |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! SLEPc - Scalable Library for Eigenvalue Problem Computations |
| ! Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| ! |
| ! This file is part of SLEPc. |
| ! |
| ! SLEPc is free software: you can redistribute it and/or modify it under the |
| ! terms of version 3 of the GNU Lesser General Public License as published by |
| ! the Free Software Foundation. |
| ! |
| ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| ! more details. |
| ! |
| ! You should have received a copy of the GNU Lesser General Public License |
| ! along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! |
| #if !defined(__SLEPCQEP_H) |
| #define __SLEPCQEP_H |
| #include "finclude/slepcipdef.h" |
| #include "finclude/slepcepsdef.h" |
| #if !defined(PETSC_USE_FORTRAN_DATATYPES) |
| #define QEP PetscFortranAddr |
| #endif |
| #define QEPType character*(80) |
| #define QEPProblemType PetscEnum |
| #define QEPWhich PetscEnum |
| #define QEPConvergedReason PetscEnum |
| #define QEPLINEAR 'linear' |
| #define QEPQARNOLDI 'qarnoldi' |
| #endif |
| ! |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! SLEPc - Scalable Library for Eigenvalue Problem Computations |
| ! Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| ! |
| ! This file is part of SLEPc. |
| ! |
| ! SLEPc is free software: you can redistribute it and/or modify it under the |
| ! terms of version 3 of the GNU Lesser General Public License as published by |
| ! the Free Software Foundation. |
| ! |
| ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| ! more details. |
| ! |
| ! You should have received a copy of the GNU Lesser General Public License |
| ! along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! |
| ! |
| ! |
| ! Additional SVD include file for use of SLEPc with Fortran 90/HPF |
| ! |
| #include "finclude/ftn-custom/slepcsvd.h90" |
| #if defined(PETSC_USE_FORTRAN_INTERFACES) |
| interface |
| #include "finclude/ftn-auto/slepcsvd.h90" |
| end interface |
| #endif |
| ! |
| ! Include file for Fortran use of the ST object in SLEPc |
| ! |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! SLEPc - Scalable Library for Eigenvalue Problem Computations |
| ! Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| ! |
| ! This file is part of SLEPc. |
| ! |
| ! SLEPc is free software: you can redistribute it and/or modify it under the |
| ! terms of version 3 of the GNU Lesser General Public License as published by |
| ! the Free Software Foundation. |
| ! |
| ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| ! more details. |
| ! |
| ! You should have received a copy of the GNU Lesser General Public License |
| ! along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! |
| #if !defined(__SLEPCST_H) |
| #define __SLEPCST_H |
| #include "finclude/petsckspdef.h" |
| #if !defined(PETSC_USE_FORTRAN_DATATYPES) |
| #define ST PetscFortranAddr |
| #endif |
| #define STType character*(80) |
| #define STMatMode PetscEnum |
| #define STSHELL 'shell' |
| #define STSHIFT 'shift' |
| #define STSINVERT 'sinvert' |
| #define STCAYLEY 'cayley' |
| #define STFOLD 'fold' |
| #define STPRECOND 'precond' |
| #endif |
| ! |
| ! Include file for Fortran use of the EPS object in SLEPc |
| ! |
| ! |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! SLEPc - Scalable Library for Eigenvalue Problem Computations |
| ! Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| ! |
| ! This file is part of SLEPc. |
| ! |
| ! SLEPc is free software: you can redistribute it and/or modify it under the |
| ! terms of version 3 of the GNU Lesser General Public License as published by |
| ! the Free Software Foundation. |
| ! |
| ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| ! more details. |
| ! |
| ! You should have received a copy of the GNU Lesser General Public License |
| ! along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! |
| #if !defined(__SLEPCEPS_H) |
| #define __SLEPCEPS_H |
| #include "finclude/slepcstdef.h" |
| #include "finclude/slepcipdef.h" |
| #if !defined(PETSC_USE_FORTRAN_DATATYPES) |
| #define EPS PetscFortranAddr |
| #endif |
| #define EPSType character*(80) |
| #define EPSConvergedReason PetscEnum |
| #define EPSProblemType PetscEnum |
| #define EPSWhich PetscEnum |
| #define EPSExtraction PetscEnum |
| #define EPSBalance PetscEnum |
| #define EPSConv PetscEnum |
| #define EPSPowerShiftType PetscEnum |
| #define EPSLanczosReorthogType PetscEnum |
| #define EPSPRIMMEMethod PetscEnum |
| #define EPSPRIMMEPrecond PetscEnum |
| #define EPSPOWER 'power' |
| #define EPSSUBSPACE 'subspace' |
| #define EPSARNOLDI 'arnoldi' |
| #define EPSLANCZOS 'lanczos' |
| #define EPSKRYLOVSCHUR 'krylovschur' |
| #define EPSLAPACK 'lapack' |
| #define EPSARPACK 'arpack' |
| #define EPSBLZPACK 'blzpack' |
| #define EPSTRLAN 'trlan' |
| #define EPSBLOPEX 'blopex' |
| #define EPSPRIMME 'primme' |
| #define EPSGD 'gd' |
| #define EPSJD 'jd' |
| #endif |
| ! |
| ! Include file for Fortran use of the IP object in SLEPc |
| ! |
| ! |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! SLEPc - Scalable Library for Eigenvalue Problem Computations |
| ! Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| ! |
| ! This file is part of SLEPc. |
| ! |
| ! SLEPc is free software: you can redistribute it and/or modify it under the |
| ! terms of version 3 of the GNU Lesser General Public License as published by |
| ! the Free Software Foundation. |
| ! |
| ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| ! more details. |
| ! |
| ! You should have received a copy of the GNU Lesser General Public License |
| ! along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! |
| #include "finclude/slepcipdef.h" |
| PetscEnum IP_ORTHOG_MGS |
| PetscEnum IP_ORTHOG_CGS |
| parameter (IP_ORTHOG_MGS = 0) |
| parameter (IP_ORTHOG_CGS = 1) |
| PetscEnum IP_ORTHOG_REFINE_NEVER |
| PetscEnum IP_ORTHOG_REFINE_IFNEEDED |
| PetscEnum IP_ORTHOG_REFINE_ALWAYS |
| parameter (IP_ORTHOG_REFINE_NEVER = 0) |
| parameter (IP_ORTHOG_REFINE_IFNEEDED = 1) |
| parameter (IP_ORTHOG_REFINE_ALWAYS = 2) |
| ! |
| ! End of Fortran include file for the IP package in SLEPc |
| ! |
| ! |
| ! Include file for Fortran use of the SVD object in SLEPc |
| ! |
| ! |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! SLEPc - Scalable Library for Eigenvalue Problem Computations |
| ! Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| ! |
| ! This file is part of SLEPc. |
| ! |
| ! SLEPc is free software: you can redistribute it and/or modify it under the |
| ! terms of version 3 of the GNU Lesser General Public License as published by |
| ! the Free Software Foundation. |
| ! |
| ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| ! more details. |
| ! |
| ! You should have received a copy of the GNU Lesser General Public License |
| ! along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! |
| #if !defined(__SLEPCSVD_H) |
| #define __SLEPCSVD_H |
| #include "finclude/slepcipdef.h" |
| #include "finclude/slepcepsdef.h" |
| #if !defined(PETSC_USE_FORTRAN_DATATYPES) |
| #define SVD PetscFortranAddr |
| #endif |
| #define SVDType character*(80) |
| #define SVDTransposeMode PetscEnum |
| #define SVDWhich PetscEnum |
| #define SVDConvergedReason PetscEnum |
| #define SVDCROSS 'cross' |
| #define SVDCYCLIC 'cyclic' |
| #define SVDLAPACK 'lapack' |
| #define SVDLANCZOS 'lanczos' |
| #define SVDTRLANCZOS 'trlanczos' |
| #endif |
| ! |
| ! Include file for Fortran use of the SLEPc package |
| ! |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! SLEPc - Scalable Library for Eigenvalue Problem Computations |
| ! Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| ! |
| ! This file is part of SLEPc. |
| ! |
| ! SLEPc is free software: you can redistribute it and/or modify it under the |
| ! terms of version 3 of the GNU Lesser General Public License as published by |
| ! the Free Software Foundation. |
| ! |
| ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| ! more details. |
| ! |
| ! You should have received a copy of the GNU Lesser General Public License |
| ! along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! |
| #include "petscconf.h" |
| #include "finclude/petscdef.h" |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! SLEPc - Scalable Library for Eigenvalue Problem Computations |
| ! Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| ! |
| ! This file is part of SLEPc. |
| ! |
| ! SLEPc is free software: you can redistribute it and/or modify it under the |
| ! terms of version 3 of the GNU Lesser General Public License as published by |
| ! the Free Software Foundation. |
| ! |
| ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| ! more details. |
| ! |
| ! You should have received a copy of the GNU Lesser General Public License |
| ! along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! |
| ! Single Fortran include file for all of SLEPc |
| ! |
| #include "finclude/slepcsys.h" |
| #include "finclude/slepceps.h" |
| #include "finclude/slepcip.h" |
| #include "finclude/slepcst.h" |
| #include "finclude/slepcsvd.h" |
| #include "finclude/slepcqep.h" |
| ! |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! SLEPc - Scalable Library for Eigenvalue Problem Computations |
| ! Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| ! |
| ! This file is part of SLEPc. |
| ! |
| ! SLEPc is free software: you can redistribute it and/or modify it under the |
| ! terms of version 3 of the GNU Lesser General Public License as published by |
| ! the Free Software Foundation. |
| ! |
| ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| ! more details. |
| ! |
| ! You should have received a copy of the GNU Lesser General Public License |
| ! along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! |
| ! |
| ! |
| ! Additional IP include file for use of SLEPc with Fortran 90/HPF |
| ! |
| #include "finclude/ftn-custom/slepcip.h90" |
| #if defined(PETSC_USE_FORTRAN_INTERFACES) |
| interface |
| #include "finclude/ftn-auto/slepcip.h90" |
| end interface |
| #endif |
| ! |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! SLEPc - Scalable Library for Eigenvalue Problem Computations |
| ! Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| ! |
| ! This file is part of SLEPc. |
| ! |
| ! SLEPc is free software: you can redistribute it and/or modify it under the |
| ! terms of version 3 of the GNU Lesser General Public License as published by |
| ! the Free Software Foundation. |
| ! |
| ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| ! more details. |
| ! |
| ! You should have received a copy of the GNU Lesser General Public License |
| ! along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! |
| #if !defined(__SLEPCSVDDEF_H90) |
| #define __SLEPCSVDDEF_H90 |
| #if defined(PETSC_USE_FORTRAN_DATATYPES) |
| type SVD |
| PetscFortranAddr:: v |
| end type SVD |
| #endif |
| #endif |
| ! |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! SLEPc - Scalable Library for Eigenvalue Problem Computations |
| ! Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| ! |
| ! This file is part of SLEPc. |
| ! |
| ! SLEPc is free software: you can redistribute it and/or modify it under the |
| ! terms of version 3 of the GNU Lesser General Public License as published by |
| ! the Free Software Foundation. |
| ! |
| ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| ! more details. |
| ! |
| ! You should have received a copy of the GNU Lesser General Public License |
| ! along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! |
| #if !defined(PETSC_USE_FORTRAN_MODULES) |
| #include "finclude/ftn-custom/slepcsvddef.h90" |
| #endif |
| #if defined(PETSC_USE_FORTRAN_DATATYPES) && !defined(SVD_HIDE) |
| #define SVD_HIDE type(SVD) |
| #elif !defined(SVD_HIDE) |
| #define SVD_HIDE SVD |
| #endif |
| ! |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! SLEPc - Scalable Library for Eigenvalue Problem Computations |
| ! Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| ! |
| ! This file is part of SLEPc. |
| ! |
| ! SLEPc is free software: you can redistribute it and/or modify it under the |
| ! terms of version 3 of the GNU Lesser General Public License as published by |
| ! the Free Software Foundation. |
| ! |
| ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| ! more details. |
| ! |
| ! You should have received a copy of the GNU Lesser General Public License |
| ! along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! |
| #if !defined(__SLEPCQEPDEF_H90) |
| #define __SLEPCQEPDEF_H90 |
| #if defined(PETSC_USE_FORTRAN_DATATYPES) |
| type QEP |
| PetscFortranAddr:: v |
| end type QEP |
| #endif |
| #endif |
| ! |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! SLEPc - Scalable Library for Eigenvalue Problem Computations |
| ! Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| ! |
| ! This file is part of SLEPc. |
| ! |
| ! SLEPc is free software: you can redistribute it and/or modify it under the |
| ! terms of version 3 of the GNU Lesser General Public License as published by |
| ! the Free Software Foundation. |
| ! |
| ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| ! more details. |
| ! |
| ! You should have received a copy of the GNU Lesser General Public License |
| ! along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! |
| #if !defined(PETSC_USE_FORTRAN_MODULES) |
| #include "finclude/ftn-custom/slepcqepdef.h90" |
| #endif |
| #if defined(PETSC_USE_FORTRAN_DATATYPES) && !defined(QEP_HIDE) |
| #define QEP_HIDE type(QEP) |
| #elif !defined(QEP_HIDE) |
| #define QEP_HIDE QEP |
| #endif |
| ! |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! SLEPc - Scalable Library for Eigenvalue Problem Computations |
| ! Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| ! |
| ! This file is part of SLEPc. |
| ! |
| ! SLEPc is free software: you can redistribute it and/or modify it under the |
| ! terms of version 3 of the GNU Lesser General Public License as published by |
| ! the Free Software Foundation. |
| ! |
| ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| ! more details. |
| ! |
| ! You should have received a copy of the GNU Lesser General Public License |
| ! along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! |
| #if !defined(__SLEPCSTDEF_H90) |
| #define __SLEPCSTDEF_H90 |
| #if defined(PETSC_USE_FORTRAN_DATATYPES) |
| type ST |
| PetscFortranAddr:: v |
| end type ST |
| #endif |
| #endif |
| ! |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! SLEPc - Scalable Library for Eigenvalue Problem Computations |
| ! Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| ! |
| ! This file is part of SLEPc. |
| ! |
| ! SLEPc is free software: you can redistribute it and/or modify it under the |
| ! terms of version 3 of the GNU Lesser General Public License as published by |
| ! the Free Software Foundation. |
| ! |
| ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| ! more details. |
| ! |
| ! You should have received a copy of the GNU Lesser General Public License |
| ! along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! |
| #if !defined(__SLEPCEPSDEF_H90) |
| #define __SLEPCEPSDEF_H90 |
| #if defined(PETSC_USE_FORTRAN_DATATYPES) |
| type EPS |
| PetscFortranAddr:: v |
| end type EPS |
| #endif |
| #endif |
| ! |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! SLEPc - Scalable Library for Eigenvalue Problem Computations |
| ! Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| ! |
| ! This file is part of SLEPc. |
| ! |
| ! SLEPc is free software: you can redistribute it and/or modify it under the |
| ! terms of version 3 of the GNU Lesser General Public License as published by |
| ! the Free Software Foundation. |
| ! |
| ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| ! more details. |
| ! |
| ! You should have received a copy of the GNU Lesser General Public License |
| ! along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! |
| #if !defined(PETSC_USE_FORTRAN_MODULES) |
| #include "finclude/ftn-custom/slepcstdef.h90" |
| #endif |
| #if defined(PETSC_USE_FORTRAN_DATATYPES) && !defined(ST_HIDE) |
| #define ST_HIDE type(ST) |
| #elif !defined(ST_HIDE) |
| #define ST_HIDE ST |
| #endif |
| # |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # SLEPc - Scalable Library for Eigenvalue Problem Computations |
| # Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| # |
| # This file is part of SLEPc. |
| # |
| # SLEPc is free software: you can redistribute it and/or modify it under the |
| # terms of version 3 of the GNU Lesser General Public License as published by |
| # the Free Software Foundation. |
| # |
| # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| # more details. |
| # |
| # You should have received a copy of the GNU Lesser General Public License |
| # along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # |
| include ${SLEPC_DIR}/conf/slepc_common |
| ! |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! SLEPc - Scalable Library for Eigenvalue Problem Computations |
| ! Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| ! |
| ! This file is part of SLEPc. |
| ! |
| ! SLEPc is free software: you can redistribute it and/or modify it under the |
| ! terms of version 3 of the GNU Lesser General Public License as published by |
| ! the Free Software Foundation. |
| ! |
| ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| ! more details. |
| ! |
| ! You should have received a copy of the GNU Lesser General Public License |
| ! along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! |
| #if !defined(PETSC_USE_FORTRAN_MODULES) |
| #include "finclude/ftn-custom/slepcepsdef.h90" |
| #endif |
| #if defined(PETSC_USE_FORTRAN_DATATYPES) && !defined(EPS_HIDE) |
| #define EPS_HIDE type(EPS) |
| #elif !defined(EPS_HIDE) |
| #define EPS_HIDE EPS |
| #endif |
| ! |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! SLEPc - Scalable Library for Eigenvalue Problem Computations |
| ! Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| ! |
| ! This file is part of SLEPc. |
| ! |
| ! SLEPc is free software: you can redistribute it and/or modify it under the |
| ! terms of version 3 of the GNU Lesser General Public License as published by |
| ! the Free Software Foundation. |
| ! |
| ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| ! more details. |
| ! |
| ! You should have received a copy of the GNU Lesser General Public License |
| ! along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! |
| #if !defined(__SLEPCIPDEF_H90) |
| #define __SLEPCIPDEF_H90 |
| #if defined(PETSC_USE_FORTRAN_DATATYPES) |
| type IP |
| PetscFortranAddr:: v |
| end type IP |
| #endif |
| #endif |
| ! |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! SLEPc - Scalable Library for Eigenvalue Problem Computations |
| ! Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| ! |
| ! This file is part of SLEPc. |
| ! |
| ! SLEPc is free software: you can redistribute it and/or modify it under the |
| ! terms of version 3 of the GNU Lesser General Public License as published by |
| ! the Free Software Foundation. |
| ! |
| ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| ! more details. |
| ! |
| ! You should have received a copy of the GNU Lesser General Public License |
| ! along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! |
| #if !defined(PETSC_USE_FORTRAN_MODULES) |
| #include "finclude/ftn-custom/slepcipdef.h90" |
| #endif |
| #if defined(PETSC_USE_FORTRAN_DATATYPES) && !defined(IP_HIDE) |
| #define IP_HIDE type(IP) |
| #elif !defined(IP_HIDE) |
| #define IP_HIDE IP |
| #endif |
| ! |
| ! Include file for Fortran use of the QEP object in SLEPc |
| ! |
| ! |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! SLEPc - Scalable Library for Eigenvalue Problem Computations |
| ! Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| ! |
| ! This file is part of SLEPc. |
| ! |
| ! SLEPc is free software: you can redistribute it and/or modify it under the |
| ! terms of version 3 of the GNU Lesser General Public License as published by |
| ! the Free Software Foundation. |
| ! |
| ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| ! more details. |
| ! |
| ! You should have received a copy of the GNU Lesser General Public License |
| ! along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! |
| #include "finclude/slepcqepdef.h" |
| ! Convergence flags. |
| ! They should match the flags in $SLEPC_DIR/include/slepcqep.h |
| PetscEnum QEP_CONVERGED_TOL |
| PetscEnum QEP_DIVERGED_ITS |
| PetscEnum QEP_DIVERGED_BREAKDOWN |
| PetscEnum QEP_CONVERGED_ITERATING |
| parameter (QEP_CONVERGED_TOL = 2) |
| parameter (QEP_DIVERGED_ITS = -3) |
| parameter (QEP_DIVERGED_BREAKDOWN = -4) |
| parameter (QEP_CONVERGED_ITERATING = 0) |
| PetscEnum QEP_GENERAL |
| PetscEnum QEP_HERMITIAN |
| PetscEnum QEP_GYROSCOPIC |
| parameter (QEP_GENERAL = 1) |
| parameter (QEP_HERMITIAN = 2) |
| parameter (QEP_GYROSCOPIC = 3) |
| PetscEnum QEP_LARGEST_MAGNITUDE |
| PetscEnum QEP_SMALLEST_MAGNITUDE |
| PetscEnum QEP_LARGEST_REAL |
| PetscEnum QEP_SMALLEST_REAL |
| PetscEnum QEP_LARGEST_IMAGINARY |
| PetscEnum QEP_SMALLEST_IMAGINARY |
| parameter (QEP_LARGEST_MAGNITUDE = 1) |
| parameter (QEP_SMALLEST_MAGNITUDE = 2) |
| parameter (QEP_LARGEST_REAL = 3) |
| parameter (QEP_SMALLEST_REAL = 4) |
| parameter (QEP_LARGEST_IMAGINARY = 5) |
| parameter (QEP_SMALLEST_IMAGINARY = 6) |
| ! |
| ! Possible arguments to QEPMonitorSet() |
| ! |
| external QEPMONITORALL |
| external QEPMONITORLG |
| external QEPMONITORLGALL |
| external QEPMONITORCONVERGED |
| external QEPMONITORFIRST |
| ! |
| ! End of Fortran include file for the QEP package in SLEPc |
| ! |
| ! |
| ! Include file for Fortran use of the ST object in SLEPc |
| ! |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! SLEPc - Scalable Library for Eigenvalue Problem Computations |
| ! Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| ! |
| ! This file is part of SLEPc. |
| ! |
| ! SLEPc is free software: you can redistribute it and/or modify it under the |
| ! terms of version 3 of the GNU Lesser General Public License as published by |
| ! the Free Software Foundation. |
| ! |
| ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| ! more details. |
| ! |
| ! You should have received a copy of the GNU Lesser General Public License |
| ! along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! |
| #include "finclude/slepcstdef.h" |
| PetscEnum ST_MATMODE_COPY |
| PetscEnum ST_MATMODE_INPLACE |
| PetscEnum ST_MATMODE_SHELL |
| parameter (ST_MATMODE_COPY = 0) |
| parameter (ST_MATMODE_INPLACE = 1) |
| parameter (ST_MATMODE_SHELL = 2) |
| ! |
| ! End of Fortran include file for the ST package in SLEPc |
| ! |
| ! |
| ! Include file for Fortran use of the EPS object in SLEPc |
| ! |
| ! |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! SLEPc - Scalable Library for Eigenvalue Problem Computations |
| ! Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| ! |
| ! This file is part of SLEPc. |
| ! |
| ! SLEPc is free software: you can redistribute it and/or modify it under the |
| ! terms of version 3 of the GNU Lesser General Public License as published by |
| ! the Free Software Foundation. |
| ! |
| ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| ! more details. |
| ! |
| ! You should have received a copy of the GNU Lesser General Public License |
| ! along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! |
| #include "finclude/slepcepsdef.h" |
| ! Convergence flags. |
| ! They sould match the flags in $SLEPC_DIR/include/slepceps.h |
| PetscEnum EPS_CONVERGED_TOL |
| PetscEnum EPS_DIVERGED_ITS |
| PetscEnum EPS_DIVERGED_BREAKDOWN |
| PetscEnum EPS_CONVERGED_ITERATING |
| parameter (EPS_CONVERGED_TOL = 2) |
| parameter (EPS_DIVERGED_ITS = -3) |
| parameter (EPS_DIVERGED_BREAKDOWN = -4) |
| parameter (EPS_CONVERGED_ITERATING = 0) |
| PetscEnum EPS_HEP |
| PetscEnum EPS_GHEP |
| PetscEnum EPS_NHEP |
| PetscEnum EPS_GNHEP |
| PetscEnum EPS_PGNHEP |
| parameter (EPS_HEP = 1) |
| parameter (EPS_GHEP = 2) |
| parameter (EPS_NHEP = 3) |
| parameter (EPS_GNHEP = 4) |
| parameter (EPS_PGNHEP = 5) |
| PetscEnum EPS_LARGEST_MAGNITUDE |
| PetscEnum EPS_SMALLEST_MAGNITUDE |
| PetscEnum EPS_LARGEST_REAL |
| PetscEnum EPS_SMALLEST_REAL |
| PetscEnum EPS_LARGEST_IMAGINARY |
| PetscEnum EPS_SMALLEST_IMAGINARY |
| PetscEnum EPS_TARGET_MAGNITUDE |
| PetscEnum EPS_TARGET_REAL |
| PetscEnum EPS_TARGET_IMAGINARY |
| PetscEnum EPS_ALL |
| PetscEnum EPS_WHICH_USER |
| parameter (EPS_LARGEST_MAGNITUDE = 1) |
| parameter (EPS_SMALLEST_MAGNITUDE = 2) |
| parameter (EPS_LARGEST_REAL = 3) |
| parameter (EPS_SMALLEST_REAL = 4) |
| parameter (EPS_LARGEST_IMAGINARY = 5) |
| parameter (EPS_SMALLEST_IMAGINARY = 6) |
| parameter (EPS_TARGET_MAGNITUDE = 7) |
| parameter (EPS_TARGET_REAL = 8) |
| parameter (EPS_TARGET_IMAGINARY = 9) |
| parameter (EPS_ALL = 10) |
| parameter (EPS_WHICH_USER = 11) |
| PetscEnum EPS_BALANCE_NONE |
| PetscEnum EPS_BALANCE_ONESIDE |
| PetscEnum EPS_BALANCE_TWOSIDE |
| PetscEnum EPS_BALANCE_USER |
| parameter (EPS_BALANCE_NONE = 1) |
| parameter (EPS_BALANCE_ONESIDE = 2) |
| parameter (EPS_BALANCE_TWOSIDE = 3) |
| parameter (EPS_BALANCE_USER = 4) |
| PetscEnum EPS_POWER_SHIFT_CONSTANT |
| PetscEnum EPS_POWER_SHIFT_RAYLEIGH |
| PetscEnum EPS_POWER_SHIFT_WILKINSON |
| parameter (EPS_POWER_SHIFT_CONSTANT = 0) |
| parameter (EPS_POWER_SHIFT_RAYLEIGH = 1) |
| parameter (EPS_POWER_SHIFT_WILKINSON = 2) |
| PetscEnum EPS_ONE_SIDE |
| PetscEnum EPS_TWO_SIDE |
| parameter (EPS_ONE_SIDE = 0) |
| parameter (EPS_TWO_SIDE = 1) |
| PetscEnum EPS_RITZ |
| PetscEnum EPS_HARMONIC |
| PetscEnum EPS_HARMONIC_RELATIVE |
| PetscEnum EPS_HARMONIC_RIGHT |
| PetscEnum EPS_HARMONIC_LARGEST |
| PetscEnum EPS_REFINED |
| PetscEnum EPS_REFINED_HARMONIC |
| parameter (EPS_RITZ = 1) |
| parameter (EPS_HARMONIC = 2) |
| parameter (EPS_HARMONIC_RELATIVE = 3) |
| parameter (EPS_HARMONIC_RIGHT = 4) |
| parameter (EPS_HARMONIC_LARGEST = 5) |
| parameter (EPS_REFINED = 6) |
| parameter (EPS_REFINED_HARMONIC = 7) |
| PetscEnum EPS_CONV_ABS |
| PetscEnum EPS_CONV_EIG |
| PetscEnum EPS_CONV_NORM |
| parameter (EPS_CONV_ABS = 1) |
| parameter (EPS_CONV_EIG = 2) |
| parameter (EPS_CONV_NORM = 3) |
| PetscEnum EPS_LANCZOS_REORTHOG_LOCAL |
| PetscEnum EPS_LANCZOS_REORTHOG_FULL |
| PetscEnum EPS_LANCZOS_REORTHOG_SELECTIVE |
| PetscEnum EPS_LANCZOS_REORTHOG_PERIODIC |
| PetscEnum EPS_LANCZOS_REORTHOG_PARTIAL |
| parameter (EPS_LANCZOS_REORTHOG_LOCAL = 0) |
| parameter (EPS_LANCZOS_REORTHOG_FULL = 1) |
| parameter (EPS_LANCZOS_REORTHOG_SELECTIVE = 2) |
| parameter (EPS_LANCZOS_REORTHOG_PERIODIC = 3) |
| parameter (EPS_LANCZOS_REORTHOG_PARTIAL = 4) |
| PetscEnum EPS_PRIMME_DYNAMIC |
| PetscEnum EPS_PRIMME_DEFAULT_MIN_TIME |
| PetscEnum EPS_PRIMME_DEFAULT_MIN_MATVECS |
| PetscEnum EPS_PRIMME_ARNOLDI |
| PetscEnum EPS_PRIMME_GD |
| PetscEnum EPS_PRIMME_GD_PLUSK |
| PetscEnum EPS_PRIMME_GD_OLSEN_PLUSK |
| PetscEnum EPS_PRIMME_JD_OLSEN_PLUSK |
| PetscEnum EPS_PRIMME_RQI |
| PetscEnum EPS_PRIMME_JDQR |
| PetscEnum EPS_PRIMME_JDQMR |
| PetscEnum EPS_PRIMME_JDQMR_ETOL |
| PetscEnum EPS_PRIMME_SUBSPACE_ITERATION |
| PetscEnum EPS_PRIMME_LOBPCG_ORTHOBASIS |
| PetscEnum EPS_PRIMME_LOBPCG_ORTHOBASISW |
| parameter (EPS_PRIMME_DYNAMIC = 0) |
| parameter (EPS_PRIMME_DEFAULT_MIN_TIME = 1) |
| parameter (EPS_PRIMME_DEFAULT_MIN_MATVECS = 2) |
| parameter (EPS_PRIMME_ARNOLDI = 3) |
| parameter (EPS_PRIMME_GD = 4) |
| parameter (EPS_PRIMME_GD_PLUSK = 5) |
| parameter (EPS_PRIMME_GD_OLSEN_PLUSK = 7) |
| parameter (EPS_PRIMME_JD_OLSEN_PLUSK = 8) |
| parameter (EPS_PRIMME_RQI = 9) |
| parameter (EPS_PRIMME_JDQR = 10) |
| parameter (EPS_PRIMME_JDQMR = 11) |
| parameter (EPS_PRIMME_JDQMR_ETOL = 12) |
| parameter (EPS_PRIMME_SUBSPACE_ITERATION = 13) |
| parameter (EPS_PRIMME_LOBPCG_ORTHOBASIS = 14) |
| parameter (EPS_PRIMME_LOBPCG_ORTHOBASISW = 15) |
| PetscEnum EPS_PRIMME_PRECOND_NONE |
| PetscEnum EPS_PRIMME_PRECOND_DIAGONAL |
| parameter (EPS_PRIMME_PRECOND_NONE = 0) |
| parameter (EPS_PRIMME_PRECOND_DIAGONAL = 1) |
| ! |
| ! Possible arguments to EPSMonitorSet() |
| ! |
| external EPSMONITORALL |
| external EPSMONITORLG |
| external EPSMONITORLGALL |
| external EPSMONITORCONVERGED |
| external EPSMONITORFIRST |
| ! |
| ! End of Fortran include file for the EPS package in SLEPc |
| ! |
| ! |
| ! Include file for Fortran use of the IP object in SLEPc |
| ! |
| ! |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! SLEPc - Scalable Library for Eigenvalue Problem Computations |
| ! Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| ! |
| ! This file is part of SLEPc. |
| ! |
| ! SLEPc is free software: you can redistribute it and/or modify it under the |
| ! terms of version 3 of the GNU Lesser General Public License as published by |
| ! the Free Software Foundation. |
| ! |
| ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| ! more details. |
| ! |
| ! You should have received a copy of the GNU Lesser General Public License |
| ! along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! |
| #if !defined(__SLEPCIP_H) |
| #define __SLEPCIP_H |
| #if !defined(PETSC_USE_FORTRAN_DATATYPES) |
| #define IP PetscFortranAddr |
| #endif |
| #define IPOrthogType PetscEnum |
| #define IPOrthogRefineType PetscEnum |
| #endif |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! SLEPc - Scalable Library for Eigenvalue Problem Computations |
| ! Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| ! |
| ! This file is part of SLEPc. |
| ! |
| ! SLEPc is free software: you can redistribute it and/or modify it under the |
| ! terms of version 3 of the GNU Lesser General Public License as published by |
| ! the Free Software Foundation. |
| ! |
| ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| ! more details. |
| ! |
| ! You should have received a copy of the GNU Lesser General Public License |
| ! along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! |
| ! Single Fortran 90 include file |
| ! |
| #include "finclude/slepcsys.h" |
| #include "finclude/slepceps.h90" |
| #include "finclude/slepcip.h90" |
| #include "finclude/slepcst.h90" |
| #include "finclude/slepcsvd.h90" |
| #include "finclude/slepcqep.h90" |
| ! |
| ! Include file for Fortran use of the SVD object in SLEPc |
| ! |
| ! |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! SLEPc - Scalable Library for Eigenvalue Problem Computations |
| ! Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| ! |
| ! This file is part of SLEPc. |
| ! |
| ! SLEPc is free software: you can redistribute it and/or modify it under the |
| ! terms of version 3 of the GNU Lesser General Public License as published by |
| ! the Free Software Foundation. |
| ! |
| ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| ! more details. |
| ! |
| ! You should have received a copy of the GNU Lesser General Public License |
| ! along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! |
| #include "finclude/slepcsvddef.h" |
| ! Convergence flags. |
| ! They sould match the flags in $SLEPC_DIR/include/slepcsvd.h |
| PetscEnum SVD_CONVERGED_TOL |
| PetscEnum SVD_DIVERGED_ITS |
| PetscEnum SVD_DIVERGED_BREAKDOWN |
| PetscEnum SVD_CONVERGED_ITERATING |
| parameter (SVD_CONVERGED_TOL = 2) |
| parameter (SVD_DIVERGED_ITS = -3) |
| parameter (SVD_DIVERGED_BREAKDOWN = -4) |
| parameter (SVD_CONVERGED_ITERATING = 0) |
| PetscEnum SVD_TRANSPOSE_EXPLICIT |
| PetscEnum SVD_TRANSPOSE_IMPLICIT |
| parameter (SVD_TRANSPOSE_EXPLICIT = 0) |
| parameter (SVD_TRANSPOSE_IMPLICIT = 1) |
| integer SVD_LARGEST |
| integer SVD_SMALLEST |
| parameter (SVD_LARGEST = 0) |
| parameter (SVD_SMALLEST = 1) |
| ! |
| ! Possible arguments to SVDMonitorSet() |
| ! |
| external SVDMONITORALL |
| external SVDMONITORLG |
| external SVDMONITORLGALL |
| external SVDMONITORCONVERGED |
| external SVDMONITORFIRST |
| ! |
| ! End of Fortran include file for the SVD package in SLEPc |
| ! |
| ! |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! SLEPc - Scalable Library for Eigenvalue Problem Computations |
| ! Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| ! |
| ! This file is part of SLEPc. |
| ! |
| ! SLEPc is free software: you can redistribute it and/or modify it under the |
| ! terms of version 3 of the GNU Lesser General Public License as published by |
| ! the Free Software Foundation. |
| ! |
| ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| ! more details. |
| ! |
| ! You should have received a copy of the GNU Lesser General Public License |
| ! along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! |
| ! |
| ! |
| ! Additional QEP include file for use of SLEPc with Fortran 90/HPF |
| ! |
| #include "finclude/ftn-custom/slepcqep.h90" |
| #if defined(PETSC_USE_FORTRAN_INTERFACES) |
| interface |
| #include "finclude/ftn-auto/slepcqep.h90" |
| end interface |
| #endif |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! SLEPc - Scalable Library for Eigenvalue Problem Computations |
| ! Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| ! |
| ! This file is part of SLEPc. |
| ! |
| ! SLEPc is free software: you can redistribute it and/or modify it under the |
| ! terms of version 3 of the GNU Lesser General Public License as published by |
| ! the Free Software Foundation. |
| ! |
| ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| ! more details. |
| ! |
| ! You should have received a copy of the GNU Lesser General Public License |
| ! along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! |
| ! Single Fortran include file for all of SLEPc |
| ! |
| #include "finclude/slepcepsdef.h" |
| #include "finclude/slepcipdef.h" |
| #include "finclude/slepcstdef.h" |
| #include "finclude/slepcsvddef.h" |
| #include "finclude/slepcqepdef.h" |
| ! |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! SLEPc - Scalable Library for Eigenvalue Problem Computations |
| ! Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| ! |
| ! This file is part of SLEPc. |
| ! |
| ! SLEPc is free software: you can redistribute it and/or modify it under the |
| ! terms of version 3 of the GNU Lesser General Public License as published by |
| ! the Free Software Foundation. |
| ! |
| ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| ! more details. |
| ! |
| ! You should have received a copy of the GNU Lesser General Public License |
| ! along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! |
| ! |
| ! |
| ! Additional ST include file for use of SLEPc with Fortran 90/HPF |
| ! |
| #include "finclude/ftn-custom/slepcst.h90" |
| #if defined(PETSC_USE_FORTRAN_INTERFACES) |
| interface |
| #include "finclude/ftn-auto/slepcst.h90" |
| end interface |
| #endif |
| ! |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! SLEPc - Scalable Library for Eigenvalue Problem Computations |
| ! Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| ! |
| ! This file is part of SLEPc. |
| ! |
| ! SLEPc is free software: you can redistribute it and/or modify it under the |
| ! terms of version 3 of the GNU Lesser General Public License as published by |
| ! the Free Software Foundation. |
| ! |
| ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| ! more details. |
| ! |
| ! You should have received a copy of the GNU Lesser General Public License |
| ! along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| ! |
| ! |
| ! |
| ! Additional EPS include file for use of SLEPc with Fortran 90/HPF |
| ! |
| #include "finclude/ftn-custom/slepceps.h90" |
| #if defined(PETSC_USE_FORTRAN_INTERFACES) |
| interface |
| #include "finclude/ftn-auto/slepceps.h90" |
| end interface |
| #endif |
| # |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # SLEPc - Scalable Library for Eigenvalue Problem Computations |
| # Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| # |
| # This file is part of SLEPc. |
| # |
| # SLEPc is free software: you can redistribute it and/or modify it under the |
| # terms of version 3 of the GNU Lesser General Public License as published by |
| # the Free Software Foundation. |
| # |
| # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| # more details. |
| # |
| # You should have received a copy of the GNU Lesser General Public License |
| # along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # |
| CFLAGS = |
| FFLAGS = |
| SOURCEC = |
| SOURCEF = |
| SOURCEH = slepc.h slepceps.h slepcst.h slepcsvd.h slepcip.h |
| OBJSC = |
| OBJSF = |
| LIBBASE = libslepc |
| DIRS = |
| MANSEC = |
| LOCDIR = include/finclude/ |
| include ${SLEPC_DIR}/conf/slepc_common |
| runexamples: |
| /* |
| User interface for the SLEPC singular value solvers. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| SLEPc - Scalable Library for Eigenvalue Problem Computations |
| Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| This file is part of SLEPc. |
| SLEPc is free software: you can redistribute it and/or modify it under the |
| terms of version 3 of the GNU Lesser General Public License as published by |
| the Free Software Foundation. |
| SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| more details. |
| You should have received a copy of the GNU Lesser General Public License |
| along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| */ |
| #if !defined(__SLEPCSVD_H) |
| #define __SLEPCSVD_H |
| #include "slepcsys.h" |
| #include "slepceps.h" |
| PETSC_EXTERN_CXX_BEGIN |
| extern PetscErrorCode SVDInitializePackage(const char[]); |
| /*S |
| SVD - Abstract SLEPc object that manages all the singular value |
| problem solvers. |
| Level: beginner |
| .seealso: SVDCreate() |
| S*/ |
| typedef struct _p_SVD* SVD; |
| /*E |
| SVDType - String with the name of a SLEPc singular value solver |
| Level: beginner |
| .seealso: SVDSetType(), SVD |
| E*/ |
| #define SVDType char* |
| #define SVDCROSS "cross" |
| #define SVDCYCLIC "cyclic" |
| #define SVDLAPACK "lapack" |
| #define SVDLANCZOS "lanczos" |
| #define SVDTRLANCZOS "trlanczos" |
| /* Logging support */ |
| extern PetscClassId SVD_CLASSID; |
| /*E |
| SVDTransposeMode - determines how to handle the transpose of the matrix |
| Level: advanced |
| .seealso: SVDSetTransposeMode(), SVDGetTransposeMode() |
| E*/ |
| typedef enum { SVD_TRANSPOSE_EXPLICIT, |
| SVD_TRANSPOSE_IMPLICIT } SVDTransposeMode; |
| /*E |
| SVDWhich - determines whether largest or smallest singular triplets |
| are to be computed |
| Level: intermediate |
| .seealso: SVDSetWhichSingularTriplets(), SVDGetWhichSingularTriplets() |
| E*/ |
| typedef enum { SVD_LARGEST, |
| SVD_SMALLEST } SVDWhich; |
| /*E |
| SVDConvergedReason - reason a singular value solver was said to |
| have converged or diverged |
| Level: beginner |
| .seealso: SVDSolve(), SVDGetConvergedReason(), SVDSetTolerances() |
| E*/ |
| typedef enum {/* converged */ |
| SVD_CONVERGED_TOL = 2, |
| /* diverged */ |
| SVD_DIVERGED_ITS = -3, |
| SVD_DIVERGED_BREAKDOWN = -4, |
| SVD_CONVERGED_ITERATING = 0 } SVDConvergedReason; |
| extern PetscErrorCode SVDCreate(MPI_Comm,SVD*); |
| extern PetscErrorCode SVDSetIP(SVD,IP); |
| extern PetscErrorCode SVDGetIP(SVD,IP*); |
| extern PetscErrorCode SVDSetType(SVD,const SVDType); |
| extern PetscErrorCode SVDGetType(SVD,const SVDType*); |
| extern PetscErrorCode SVDSetOperator(SVD,Mat); |
| extern PetscErrorCode SVDGetOperator(SVD,Mat*); |
| extern PetscErrorCode SVDSetInitialSpace(SVD,PetscInt,Vec*); |
| extern PetscErrorCode SVDSetTransposeMode(SVD,SVDTransposeMode); |
| extern PetscErrorCode SVDGetTransposeMode(SVD,SVDTransposeMode*); |
| extern PetscErrorCode SVDSetDimensions(SVD,PetscInt,PetscInt,PetscInt); |
| extern PetscErrorCode SVDGetDimensions(SVD,PetscInt*,PetscInt*,PetscInt*); |
| extern PetscErrorCode SVDSetTolerances(SVD,PetscReal,PetscInt); |
| extern PetscErrorCode SVDGetTolerances(SVD,PetscReal*,PetscInt*); |
| extern PetscErrorCode SVDSetWhichSingularTriplets(SVD,SVDWhich); |
| extern PetscErrorCode SVDGetWhichSingularTriplets(SVD,SVDWhich*); |
| extern PetscErrorCode SVDSetFromOptions(SVD); |
| extern PetscErrorCode SVDSetOptionsPrefix(SVD,const char*); |
| extern PetscErrorCode SVDAppendOptionsPrefix(SVD,const char*); |
| extern PetscErrorCode SVDGetOptionsPrefix(SVD,const char*[]); |
| extern PetscErrorCode SVDSetUp(SVD); |
| extern PetscErrorCode SVDSolve(SVD); |
| extern PetscErrorCode SVDGetIterationNumber(SVD,PetscInt*); |
| extern PetscErrorCode SVDGetConvergedReason(SVD,SVDConvergedReason*); |
| extern PetscErrorCode SVDGetConverged(SVD,PetscInt*); |
| extern PetscErrorCode SVDGetSingularTriplet(SVD,PetscInt,PetscReal*,Vec,Vec); |
| extern PetscErrorCode SVDComputeResidualNorms(SVD,PetscInt,PetscReal*,PetscReal*); |
| extern PetscErrorCode SVDComputeRelativeError(SVD,PetscInt,PetscReal*); |
| extern PetscErrorCode SVDGetOperationCounters(SVD,PetscInt*,PetscInt*); |
| extern PetscErrorCode SVDView(SVD,PetscViewer); |
| extern PetscErrorCode SVDPrintSolution(SVD,PetscViewer); |
| extern PetscErrorCode SVDDestroy(SVD*); |
| extern PetscErrorCode SVDReset(SVD); |
| extern PetscErrorCode SVDMonitorSet(SVD,PetscErrorCode (*)(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,void*),void*,PetscErrorCode (*)(void**)); |
| extern PetscErrorCode SVDMonitorCancel(SVD); |
| extern PetscErrorCode SVDGetMonitorContext(SVD,void **); |
| extern PetscErrorCode SVDMonitorAll(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,void*); |
| extern PetscErrorCode SVDMonitorFirst(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,void*); |
| extern PetscErrorCode SVDMonitorConverged(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,void*); |
| extern PetscErrorCode SVDMonitorLG(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,void*); |
| extern PetscErrorCode SVDMonitorLGAll(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,void*); |
| extern PetscErrorCode SVDSetTrackAll(SVD,PetscBool); |
| extern PetscErrorCode SVDGetTrackAll(SVD,PetscBool*); |
| extern PetscErrorCode SVDDense(PetscInt,PetscInt,PetscScalar*,PetscReal*,PetscScalar*,PetscScalar*); |
| extern PetscErrorCode SVDCrossSetEPS(SVD,EPS); |
| extern PetscErrorCode SVDCrossGetEPS(SVD,EPS*); |
| extern PetscErrorCode SVDCyclicSetExplicitMatrix(SVD,PetscBool); |
| extern PetscErrorCode SVDCyclicGetExplicitMatrix(SVD,PetscBool*); |
| extern PetscErrorCode SVDCyclicSetEPS(SVD,EPS); |
| extern PetscErrorCode SVDCyclicGetEPS(SVD,EPS*); |
| extern PetscErrorCode SVDLanczosSetOneSide(SVD,PetscBool); |
| extern PetscErrorCode SVDLanczosGetOneSide(SVD,PetscBool*); |
| extern PetscErrorCode SVDTRLanczosSetOneSide(SVD,PetscBool); |
| extern PetscErrorCode SVDTRLanczosGetOneSide(SVD,PetscBool*); |
| extern PetscFList SVDList; |
| extern PetscBool SVDRegisterAllCalled; |
| extern PetscErrorCode SVDRegisterAll(const char[]); |
| extern PetscErrorCode SVDRegisterDestroy(void); |
| extern PetscErrorCode SVDRegister(const char[],const char[],const char[],PetscErrorCode(*)(SVD)); |
| /*MC |
| SVDRegisterDynamic - Adds a method to the singular value solver package. |
| Synopsis: |
| PetscErrorCode SVDRegisterDynamic(const char *name_solver,const char *path,const char *name_create,PetscErrorCode (*routine_create)(SVD)) |
| Not Collective |
| Input Parameters: |
| + name_solver - name of a new user-defined solver |
| . path - path (either absolute or relative) the library containing this solver |
| . name_create - name of routine to create the solver context |
| - routine_create - routine to create the solver context |
| Notes: |
| SVDRegisterDynamic() may be called multiple times to add several user-defined solvers. |
| If dynamic libraries are used, then the fourth input argument (routine_create) |
| is ignored. |
| Sample usage: |
| .vb |
| SVDRegisterDynamic("my_solver",/home/username/my_lib/lib/libO/solaris/mylib.a, |
| "MySolverCreate",MySolverCreate); |
| .ve |
| Then, your solver can be chosen with the procedural interface via |
| $ SVDSetType(svd,"my_solver") |
| or at runtime via the option |
| $ -svd_type my_solver |
| Level: advanced |
| .seealso: SVDRegisterDestroy(), SVDRegisterAll() |
| M*/ |
| #if defined(PETSC_USE_DYNAMIC_LIBRARIES) |
| #define SVDRegisterDynamic(a,b,c,d) SVDRegister(a,b,c,0) |
| #else |
| #define SVDRegisterDynamic(a,b,c,d) SVDRegister(a,b,c,d) |
| #endif |
| PETSC_EXTERN_CXX_END |
| #endif |
| /* |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| SLEPc - Scalable Library for Eigenvalue Problem Computations |
| Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| This file is part of SLEPc. |
| SLEPc is free software: you can redistribute it and/or modify it under the |
| terms of version 3 of the GNU Lesser General Public License as published by |
| the Free Software Foundation. |
| SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| more details. |
| You should have received a copy of the GNU Lesser General Public License |
| along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| */ |
| #ifndef _EPSIMPL |
| #define _EPSIMPL |
| #include <slepceps.h> |
| extern PetscFList EPSList; |
| extern PetscLogEvent EPS_SetUp, EPS_Solve, EPS_Dense; |
| typedef struct _EPSOps *EPSOps; |
| struct _EPSOps { |
| PetscErrorCode (*solve)(EPS); |
| PetscErrorCode (*setup)(EPS); |
| PetscErrorCode (*setfromoptions)(EPS); |
| PetscErrorCode (*publishoptions)(EPS); |
| PetscErrorCode (*destroy)(EPS); |
| PetscErrorCode (*reset)(EPS); |
| PetscErrorCode (*view)(EPS,PetscViewer); |
| PetscErrorCode (*backtransform)(EPS); |
| PetscErrorCode (*computevectors)(EPS); |
| }; |
| /* |
| Maximum number of monitors you can run with a single EPS |
| */ |
| #define MAXEPSMONITORS 5 |
| /* |
| Defines the EPS data structure. |
| */ |
| struct _p_EPS { |
| PETSCHEADER(struct _EPSOps); |
| /*------------------------- User parameters --------------------------*/ |
| PetscInt max_it, /* maximum number of iterations */ |
| nev, /* number of eigenvalues to compute */ |
| ncv, /* number of basis vectors */ |
| mpd, /* maximum dimension of projected problem */ |
| nini, ninil, /* number of initial vectors (negative means not copied yet) */ |
| nds; /* number of basis vectors of deflation space */ |
| PetscScalar target; /* target value */ |
| PetscReal tol; /* tolerance */ |
| EPSConv conv; /* convergence test */ |
| PetscErrorCode (*conv_func)(EPS,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*); |
| void *conv_ctx; |
| EPSWhich which; /* which part of the spectrum to be sought */ |
| PetscBool leftvecs; /* if left eigenvectors are requested */ |
| PetscErrorCode (*which_func)(EPS,PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*,void*); |
| void *which_ctx; |
| PetscReal inta, intb; /* interval [a,b] for spectrum slicing */ |
| EPSProblemType problem_type; /* which kind of problem to be solved */ |
| EPSExtraction extraction; /* which kind of extraction to be applied */ |
| EPSBalance balance; /* the balancing method */ |
| PetscInt balance_its; /* number of iterations of the balancing method */ |
| PetscReal balance_cutoff; /* cutoff value for balancing */ |
| PetscReal nrma, nrmb; /* matrix norms */ |
| PetscBool adaptive; /* whether matrix norms are adaptively improved */ |
| PetscBool trueres; /* whether the true residual norm must be computed */ |
| PetscBool trackall; /* whether all the residuals must be computed */ |
| /*------------------------- Working data --------------------------*/ |
| Vec D, /* diagonal matrix for balancing */ |
| *V, /* set of basis vectors and computed eigenvectors */ |
| *W, /* set of left basis vectors and computed left eigenvectors */ |
| *IS, *ISL, /* placeholder for references to user-provided initial space */ |
| *DS; /* deflation space */ |
| PetscScalar *eigr, *eigi, /* real and imaginary parts of eigenvalues */ |
| *T, *Tl; /* projected matrices */ |
| PetscReal *errest, /* error estimates */ |
| *errest_left; /* left error estimates */ |
| ST OP; /* spectral transformation object */ |
| IP ip; /* innerproduct object */ |
| void *data; /* placeholder for misc stuff associated |
| with a particular solver */ |
| PetscInt nconv, /* number of converged eigenvalues */ |
| its, /* number of iterations so far computed */ |
| *perm, /* permutation for eigenvalue ordering */ |
| nv, /* size of current Schur decomposition */ |
| n, nloc, /* problem dimensions (global, local) */ |
| allocated_ncv; /* number of basis vectors allocated */ |
| PetscBool evecsavailable; /* computed eigenvectors */ |
| PetscRandom rand; /* random number generator */ |
| Vec t; /* template vector */ |
| /* ---------------- Default work-area and status vars -------------------- */ |
| PetscInt nwork; |
| Vec *work; |
| PetscBool ds_ortho; /* if DS vectors have been stored and orthonormalized */ |
| PetscInt setupcalled; |
| PetscBool isgeneralized, |
| ispositive, |
| ishermitian; |
| EPSConvergedReason reason; |
| PetscErrorCode (*monitor[MAXEPSMONITORS])(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*); |
| PetscErrorCode (*monitordestroy[MAXEPSMONITORS])(void**); |
| void *monitorcontext[MAXEPSMONITORS]; |
| PetscInt numbermonitors; |
| }; |
| extern PetscErrorCode EPSMonitor(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt); |
| extern PetscErrorCode EPSReset_Default(EPS); |
| extern PetscErrorCode EPSDefaultGetWork(EPS,PetscInt); |
| extern PetscErrorCode EPSDefaultFreeWork(EPS); |
| extern PetscErrorCode EPSDefaultSetWhich(EPS); |
| extern PetscErrorCode EPSAllocateSolution(EPS); |
| extern PetscErrorCode EPSFreeSolution(EPS); |
| extern PetscErrorCode EPSBackTransform_Default(EPS); |
| extern PetscErrorCode EPSComputeVectors_Default(EPS); |
| extern PetscErrorCode EPSComputeVectors_Hermitian(EPS); |
| extern PetscErrorCode EPSComputeVectors_Schur(EPS); |
| extern PetscErrorCode EPSComputeResidualNorm_Private(EPS,PetscScalar,PetscScalar,Vec,Vec,PetscReal*); |
| extern PetscErrorCode EPSComputeRelativeError_Private(EPS,PetscScalar,PetscScalar,Vec,Vec,PetscReal*); |
| extern PetscErrorCode EPSComputeTrueResidual(EPS,PetscScalar,PetscScalar,PetscScalar*,Vec*,PetscInt,PetscReal*); |
| /* Private functions of the solver implementations */ |
| extern PetscErrorCode EPSBasicArnoldi(EPS,PetscBool,PetscScalar*,PetscInt,Vec*,PetscInt,PetscInt*,Vec,PetscReal*,PetscBool*); |
| extern PetscErrorCode EPSDelayedArnoldi(EPS,PetscScalar*,PetscInt,Vec*,PetscInt,PetscInt*,Vec,PetscReal*,PetscBool*); |
| extern PetscErrorCode EPSDelayedArnoldi1(EPS,PetscScalar*,PetscInt,Vec*,PetscInt,PetscInt*,Vec,PetscReal*,PetscBool*); |
| extern PetscErrorCode EPSKrylovConvergence(EPS,PetscBool,PetscBool,PetscInt,PetscInt,PetscScalar*,PetscInt,PetscScalar*,Vec*,PetscInt,PetscReal,PetscReal,PetscInt*,PetscScalar*); |
| extern PetscErrorCode EPSFullLanczos(EPS,PetscReal*,PetscReal*,Vec*,PetscInt,PetscInt*,Vec,PetscBool*); |
| extern PetscErrorCode EPSTranslateHarmonic(PetscInt,PetscScalar*,PetscInt,PetscScalar,PetscScalar,PetscScalar*,PetscScalar*); |
| extern PetscErrorCode EPSBuildBalance_Krylov(EPS); |
| extern PetscErrorCode EPSProjectedKSNonsym(EPS,PetscInt,PetscScalar*,PetscInt,PetscScalar*,PetscInt); |
| #endif |
| /* |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| SLEPc - Scalable Library for Eigenvalue Problem Computations |
| Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| This file is part of SLEPc. |
| SLEPc is free software: you can redistribute it and/or modify it under the |
| terms of version 3 of the GNU Lesser General Public License as published by |
| the Free Software Foundation. |
| SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| more details. |
| You should have received a copy of the GNU Lesser General Public License |
| along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| */ |
| #ifndef _IPIMPL |
| #define _IPIMPL |
| #include <slepcip.h> |
| extern PetscLogEvent IP_InnerProduct,IP_Orthogonalize,IP_ApplyMatrix; |
| typedef struct _IPOps *IPOps; |
| struct _IPOps { |
| PetscErrorCode (*normbegin)(IP,Vec,PetscReal*); |
| PetscErrorCode (*normend)(IP,Vec,PetscReal*); |
| PetscErrorCode (*innerproductbegin)(IP,Vec,Vec,PetscScalar*); |
| PetscErrorCode (*innerproductend)(IP,Vec,Vec,PetscScalar*); |
| PetscErrorCode (*minnerproductbegin)(IP,Vec,PetscInt,const Vec[],PetscScalar*); |
| PetscErrorCode (*minnerproductend)(IP,Vec,PetscInt,const Vec[],PetscScalar*); |
| }; |
| struct _p_IP { |
| PETSCHEADER(struct _IPOps); |
| IPOrthogType orthog_type; /* which orthogonalization to use */ |
| IPOrthogRefineType orthog_ref; /* refinement method */ |
| PetscReal orthog_eta; /* refinement threshold */ |
| Mat matrix; |
| PetscInt innerproducts; |
| /*------------------------- Cache Bx product -------------------*/ |
| PetscInt xid; |
| PetscInt xstate; |
| Vec Bx; |
| }; |
| extern PetscErrorCode IPSetDefaultType_Private(IP); |
| extern PetscErrorCode IPApplyMatrix_Private(IP,Vec); |
| extern PetscErrorCode IPOrthogonalizeCGS1(IP,PetscInt,Vec*,PetscInt,PetscBool*,Vec*,Vec,PetscScalar*,PetscReal*,PetscReal*); |
| #endif |
| /* |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| SLEPc - Scalable Library for Eigenvalue Problem Computations |
| Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| This file is part of SLEPc. |
| SLEPc is free software: you can redistribute it and/or modify it under the |
| terms of version 3 of the GNU Lesser General Public License as published by |
| the Free Software Foundation. |
| SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| more details. |
| You should have received a copy of the GNU Lesser General Public License |
| along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| */ |
| #ifndef _SVDIMPL |
| #define _SVDIMPL |
| #include <slepcsvd.h> |
| #include <slepcip.h> |
| extern PetscFList SVDList; |
| extern PetscLogEvent SVD_SetUp, SVD_Solve, SVD_Dense; |
| typedef struct _SVDOps *SVDOps; |
| struct _SVDOps { |
| PetscErrorCode (*solve)(SVD); |
| PetscErrorCode (*setup)(SVD); |
| PetscErrorCode (*setfromoptions)(SVD); |
| PetscErrorCode (*publishoptions)(SVD); |
| PetscErrorCode (*destroy)(SVD); |
| PetscErrorCode (*reset)(SVD); |
| PetscErrorCode (*view)(SVD,PetscViewer); |
| }; |
| /* |
| Maximum number of monitors you can run with a single SVD |
| */ |
| #define MAXSVDMONITORS 5 |
| /* |
| Defines the SVD data structure. |
| */ |
| struct _p_SVD { |
| PETSCHEADER(struct _SVDOps); |
| Mat OP; /* problem matrix */ |
| Mat A; /* problem matrix (m>n) */ |
| Mat AT; /* transposed matrix */ |
| SVDTransposeMode transmode; /* transpose mode */ |
| PetscReal *sigma; /* singular values */ |
| PetscInt *perm; /* permutation for singular value ordering */ |
| Vec *U,*V; /* left and right singular vectors */ |
| Vec *IS; /* placeholder for references to user-provided initial space */ |
| PetscInt n; /* maximun size of descomposition */ |
| SVDWhich which; /* which singular values are computed */ |
| PetscInt nconv; /* number of converged values */ |
| PetscInt nsv; /* number of requested values */ |
| PetscInt ncv; /* basis size */ |
| PetscInt mpd; /* maximum dimension of projected problem */ |
| PetscInt nini; /* number of initial vectors (negative means not copied yet) */ |
| PetscInt its; /* iteration counter */ |
| PetscInt max_it; /* max iterations */ |
| PetscReal tol; /* tolerance */ |
| PetscReal *errest; /* error estimates */ |
| PetscRandom rand; /* random number generator */ |
| Vec tl,tr; /* template vectors */ |
| void *data; /* placeholder for misc stuff associated |
| with a particular solver */ |
| PetscInt setupcalled; |
| SVDConvergedReason reason; |
| IP ip; |
| PetscBool trackall; |
| PetscErrorCode (*monitor[MAXSVDMONITORS])(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,void*); |
| PetscErrorCode (*monitordestroy[MAXSVDMONITORS])(void**); |
| void *monitorcontext[MAXSVDMONITORS]; |
| PetscInt numbermonitors; |
| PetscInt matvecs; |
| }; |
| extern PetscErrorCode SVDMonitor(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt); |
| extern PetscErrorCode SVDMatMult(SVD,PetscBool,Vec,Vec); |
| extern PetscErrorCode SVDMatGetVecs(SVD,Vec*,Vec*); |
| extern PetscErrorCode SVDMatGetSize(SVD,PetscInt*,PetscInt*); |
| extern PetscErrorCode SVDMatGetLocalSize(SVD,PetscInt*,PetscInt*); |
| extern PetscErrorCode SVDTwoSideLanczos(SVD,PetscReal*,PetscReal*,Vec*,Vec,Vec*,PetscInt,PetscInt,PetscScalar*); |
| #endif |
| /* |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| SLEPc - Scalable Library for Eigenvalue Problem Computations |
| Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| This file is part of SLEPc. |
| SLEPc is free software: you can redistribute it and/or modify it under the |
| terms of version 3 of the GNU Lesser General Public License as published by |
| the Free Software Foundation. |
| SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| more details. |
| You should have received a copy of the GNU Lesser General Public License |
| along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| */ |
| #ifndef _VECIMPLSLEPC |
| #define _VECIMPLSLEPC |
| #include <slepcvec.h> |
| extern PetscLogEvent SLEPC_UpdateVectors, SLEPC_VecMAXPBY; |
| /* context for the storage of contiguous Vecs */ |
| typedef struct { |
| PetscScalar *array; /* pointer to common storage */ |
| PetscInt nvecs; /* number of vectors that share this array */ |
| } Vecs_Contiguous; |
| #if !defined(PETSC_USE_DEBUG) |
| #define SlepcValidVecsContiguous(V,m,arg) do {} while (0) |
| #define PetscValidVecComp(y) do {} while (0) |
| #else |
| #define SlepcValidVecsContiguous(V,m,arg) \ |
| do { \ |
| PetscErrorCode __ierr; \ |
| PetscInt __i; \ |
| PetscContainer __container; \ |
| for (__i=0;__i<(m);__i++) { \ |
| PetscValidHeaderSpecific((V)[__i],VEC_CLASSID,(arg)); \ |
| __ierr = PetscObjectQuery((PetscObject)((V)[__i]),"contiguous",(PetscObject*)&__container);CHKERRQ(__ierr); \ |
| if (!__container && (m)>1) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Contiguous check failed in argument # %d",(arg)); \ |
| } \ |
| } while (0) |
| #define PetscValidVecComp(y) \ |
| do { \ |
| if (((Vec_Comp*)(y)->data)->nx < ((Vec_Comp*)(y)->data)->n->n) \ |
| SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Invalid number of subvectors required!"); \ |
| } while (0) |
| #endif |
| /* Contexts for VecComp */ |
| typedef struct { |
| PetscInt n, /* number of active subvectors */ |
| N, /* virtual global size */ |
| lN, /* virtual local size */ |
| friends; /* number of vectors sharing this structure */ |
| } Vec_Comp_N; |
| typedef struct { |
| Vec *x; /* the vectors */ |
| PetscInt nx; /* number of available subvectors */ |
| Vec_Comp_N *n; /* structure shared by friend vectors */ |
| } Vec_Comp; |
| /* Operations implemented in VecComp */ |
| PetscErrorCode VecDuplicate_Comp(Vec win,Vec *V); |
| PetscErrorCode VecDestroy_Comp(Vec v); |
| PetscErrorCode VecSet_Comp(Vec v,PetscScalar alpha); |
| PetscErrorCode VecView_Comp(Vec v,PetscViewer viewer); |
| PetscErrorCode VecScale_Comp(Vec v,PetscScalar alpha); |
| PetscErrorCode VecCopy_Comp(Vec v,Vec w); |
| PetscErrorCode VecSwap_Comp(Vec v,Vec w); |
| PetscErrorCode VecAXPY_Comp(Vec v,PetscScalar alpha,Vec w); |
| PetscErrorCode VecAYPX_Comp(Vec v,PetscScalar alpha,Vec w); |
| PetscErrorCode VecAXPBY_Comp(Vec v,PetscScalar alpha,PetscScalar beta,Vec w); |
| PetscErrorCode VecMAXPY_Comp(Vec v,PetscInt n,const PetscScalar *alpha,Vec *w); |
| PetscErrorCode VecWAXPY_Comp(Vec v,PetscScalar alpha,Vec w,Vec z); |
| PetscErrorCode VecAXPBYPCZ_Comp(Vec v,PetscScalar alpha,PetscScalar beta,PetscScalar gamma,Vec w,Vec z); |
| PetscErrorCode VecPointwiseMult_Comp(Vec v,Vec w,Vec z); |
| PetscErrorCode VecPointwiseDivide_Comp(Vec v,Vec w,Vec z); |
| PetscErrorCode VecGetSize_Comp(Vec v,PetscInt *size); |
| PetscErrorCode VecGetLocalSize_Comp(Vec v,PetscInt *size); |
| PetscErrorCode VecMax_Comp(Vec v,PetscInt *idx,PetscReal *z); |
| PetscErrorCode VecMin_Comp(Vec v,PetscInt *idx,PetscReal *z); |
| PetscErrorCode VecSetRandom_Comp(Vec v,PetscRandom r); |
| PetscErrorCode VecConjugate_Comp(Vec v); |
| PetscErrorCode VecReciprocal_Comp(Vec v); |
| PetscErrorCode VecMaxPointwiseDivide_Comp(Vec v,Vec w,PetscReal *m); |
| PetscErrorCode VecPointwiseMax_Comp(Vec v,Vec w,Vec z); |
| PetscErrorCode VecPointwiseMaxAbs_Comp(Vec v,Vec w,Vec z); |
| PetscErrorCode VecPointwiseMin_Comp(Vec v,Vec w,Vec z); |
| PetscErrorCode VecDotNorm2_Comp_Seq(Vec v,Vec w,PetscScalar *dp,PetscScalar *nm); |
| PetscErrorCode VecDotNorm2_Comp_MPI(Vec v,Vec w,PetscScalar *dp,PetscScalar *nm); |
| PetscErrorCode VecSqrtAbs_Comp(Vec v); |
| PetscErrorCode VecAbs_Comp(Vec v); |
| PetscErrorCode VecExp_Comp(Vec v); |
| PetscErrorCode VecLog_Comp(Vec v); |
| PetscErrorCode VecShift_Comp(Vec v,PetscScalar alpha); |
| #endif |
| # |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # SLEPc - Scalable Library for Eigenvalue Problem Computations |
| # Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| # |
| # This file is part of SLEPc. |
| # |
| # SLEPc is free software: you can redistribute it and/or modify it under the |
| # terms of version 3 of the GNU Lesser General Public License as published by |
| # the Free Software Foundation. |
| # |
| # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| # more details. |
| # |
| # You should have received a copy of the GNU Lesser General Public License |
| # along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # |
| CFLAGS = |
| FFLAGS = |
| SOURCEC = |
| SOURCEF = |
| SOURCEH = epsimpl.h stimpl.h svdimpl.h ipimpl.h qepimpl.h slepcimpl.h |
| OBJSC = |
| OBJSF = |
| LIBBASE = libslepc |
| DIRS = |
| LOCDIR = include/ |
| MANSEC = |
| include ${SLEPC_DIR}/conf/slepc_common |
| /* |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| SLEPc - Scalable Library for Eigenvalue Problem Computations |
| Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| This file is part of SLEPc. |
| SLEPc is free software: you can redistribute it and/or modify it under the |
| terms of version 3 of the GNU Lesser General Public License as published by |
| the Free Software Foundation. |
| SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| more details. |
| You should have received a copy of the GNU Lesser General Public License |
| along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| */ |
| #ifndef _QEPIMPL |
| #define _QEPIMPL |
| #include <slepcqep.h> |
| extern PetscFList QEPList; |
| extern PetscLogEvent QEP_SetUp, QEP_Solve, QEP_Dense; |
| typedef struct _QEPOps *QEPOps; |
| struct _QEPOps { |
| PetscErrorCode (*solve)(QEP); |
| PetscErrorCode (*setup)(QEP); |
| PetscErrorCode (*setfromoptions)(QEP); |
| PetscErrorCode (*publishoptions)(QEP); |
| PetscErrorCode (*destroy)(QEP); |
| PetscErrorCode (*reset)(QEP); |
| PetscErrorCode (*view)(QEP,PetscViewer); |
| }; |
| /* |
| Maximum number of monitors you can run with a single QEP |
| */ |
| #define MAXQEPMONITORS 5 |
| /* |
| Defines the QEP data structure. |
| */ |
| struct _p_QEP { |
| PETSCHEADER(struct _QEPOps); |
| /*------------------------- User parameters --------------------------*/ |
| PetscInt max_it, /* maximum number of iterations */ |
| nev, /* number of eigenvalues to compute */ |
| ncv, /* number of basis vectors */ |
| mpd, /* maximum dimension of projected problem */ |
| nini, ninil, /* number of initial vectors (negative means not copied yet) */ |
| allocated_ncv; /* number of basis vectors allocated */ |
| PetscReal tol; /* tolerance */ |
| PetscReal sfactor; /* scaling factor of the quadratic problem */ |
| PetscErrorCode (*conv_func)(QEP,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*); |
| void *conv_ctx; |
| QEPWhich which; /* which part of the spectrum to be sought */ |
| PetscBool leftvecs; /* if left eigenvectors are requested */ |
| PetscErrorCode (*which_func)(QEP,PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*,void*); |
| void *which_ctx; |
| QEPProblemType problem_type; /* which kind of problem to be solved */ |
| PetscBool trackall; /* whether all the residuals must be computed */ |
| /*------------------------- Working data --------------------------*/ |
| Mat M,C,K; /* problem matrices */ |
| Vec *V, /* set of basis vectors and computed eigenvectors */ |
| *W, /* set of left basis vectors and computed left eigenvectors */ |
| *IS, *ISL; /* placeholder for references to user-provided initial space */ |
| PetscScalar *eigr, *eigi, /* real and imaginary parts of eigenvalues */ |
| *T; /* matrix for projected eigenproblem */ |
| PetscReal *errest; /* error estimates */ |
| IP ip; /* innerproduct object */ |
| void *data; /* placeholder for misc stuff associated |
| with a particular solver */ |
| PetscInt nconv, /* number of converged eigenvalues */ |
| its, /* number of iterations so far computed */ |
| *perm, /* permutation for eigenvalue ordering */ |
| matvecs, linits, /* operation counters */ |
| n, nloc; /* problem dimensions (global, local) */ |
| PetscRandom rand; /* random number generator */ |
| Vec t; /* template vector */ |
| /* ---------------- Default work-area and status vars -------------------- */ |
| PetscInt nwork; |
| Vec *work; |
| PetscInt setupcalled; |
| QEPConvergedReason reason; |
| PetscErrorCode (*monitor[MAXQEPMONITORS])(QEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*); |
| PetscErrorCode (*monitordestroy[MAXQEPMONITORS])(void**); |
| void *monitorcontext[MAXQEPMONITORS]; |
| PetscInt numbermonitors; |
| }; |
| extern PetscErrorCode QEPMonitor(QEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt); |
| extern PetscErrorCode QEPDefaultGetWork(QEP,PetscInt); |
| extern PetscErrorCode QEPDefaultFreeWork(QEP); |
| extern PetscErrorCode QEPAllocateSolution(QEP); |
| extern PetscErrorCode QEPFreeSolution(QEP); |
| extern PetscErrorCode QEPComputeVectors_Schur(QEP); |
| extern PetscErrorCode QEPComputeResidualNorm_Private(QEP,PetscScalar,PetscScalar,Vec,Vec,PetscReal*); |
| extern PetscErrorCode QEPComputeRelativeError_Private(QEP,PetscScalar,PetscScalar,Vec,Vec,PetscReal*); |
| extern PetscErrorCode QEPKrylovConvergence(QEP,PetscInt,PetscInt,PetscScalar*,PetscInt,PetscScalar*,PetscInt,PetscReal,PetscInt*,PetscScalar*); |
| #endif |
| /* |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| SLEPc - Scalable Library for Eigenvalue Problem Computations |
| Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| This file is part of SLEPc. |
| SLEPc is free software: you can redistribute it and/or modify it under the |
| terms of version 3 of the GNU Lesser General Public License as published by |
| the Free Software Foundation. |
| SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| more details. |
| You should have received a copy of the GNU Lesser General Public License |
| along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| */ |
| #ifndef _SLEPCIMPL |
| #define _SLEPCIMPL |
| #include <slepcsys.h> |
| /* context for monitors of type XXXMonitorConverged */ |
| struct _n_SlepcConvMonitor { |
| PetscViewer viewer; |
| PetscInt oldnconv; |
| }; |
| typedef struct _n_SlepcConvMonitor* SlepcConvMonitor; |
| /* Private functions that are shared by several classes */ |
| extern PetscErrorCode DenseSelectedEvec(PetscScalar*,PetscInt,PetscScalar*,PetscScalar*,PetscInt,PetscBool,PetscInt,PetscScalar*); |
| extern PetscErrorCode SlepcConvMonitorDestroy(SlepcConvMonitor *ctx); |
| #endif |
| /* |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| SLEPc - Scalable Library for Eigenvalue Problem Computations |
| Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| This file is part of SLEPc. |
| SLEPc is free software: you can redistribute it and/or modify it under the |
| terms of version 3 of the GNU Lesser General Public License as published by |
| the Free Software Foundation. |
| SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| more details. |
| You should have received a copy of the GNU Lesser General Public License |
| along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| */ |
| #ifndef _STIMPL |
| #define _STIMPL |
| #include <slepcst.h> |
| extern PetscLogEvent ST_SetUp,ST_Apply,ST_ApplyB,ST_ApplyTranspose; |
| extern PetscFList STList; |
| typedef struct _STOps *STOps; |
| struct _STOps { |
| PetscErrorCode (*setup)(ST); |
| PetscErrorCode (*apply)(ST,Vec,Vec); |
| PetscErrorCode (*getbilinearform)(ST,Mat*); |
| PetscErrorCode (*applytrans)(ST,Vec,Vec); |
| PetscErrorCode (*setshift)(ST,PetscScalar); |
| PetscErrorCode (*setfromoptions)(ST); |
| PetscErrorCode (*postsolve)(ST); |
| PetscErrorCode (*backtr)(ST,PetscInt,PetscScalar*,PetscScalar*); |
| PetscErrorCode (*destroy)(ST); |
| PetscErrorCode (*reset)(ST); |
| PetscErrorCode (*view)(ST,PetscViewer); |
| PetscErrorCode (*checknullspace)(ST,PetscInt,const Vec[]); |
| }; |
| struct _p_ST { |
| PETSCHEADER(struct _STOps); |
| /*------------------------- User parameters --------------------------*/ |
| Mat A,B; /* Matrices which define the eigensystem */ |
| PetscScalar sigma; /* Value of the shift */ |
| PetscBool sigma_set; /* whether the user provided the shift or not */ |
| PetscScalar defsigma; /* Default value of the shift */ |
| STMatMode shift_matrix; |
| MatStructure str; /* whether matrices have the same pattern or not */ |
| Mat mat; |
| /*------------------------- Misc data --------------------------*/ |
| KSP ksp; |
| Vec w; |
| Vec D; /* diagonal matrix for balancing */ |
| Vec wb; /* balancing requires an extra work vector */ |
| void *data; |
| PetscInt setupcalled; |
| PetscInt lineariterations; |
| PetscInt applys; |
| }; |
| extern PetscErrorCode STGetBilinearForm_Default(ST,Mat*); |
| extern PetscErrorCode STAssociatedKSPSolve(ST,Vec,Vec); |
| extern PetscErrorCode STAssociatedKSPSolveTranspose(ST,Vec,Vec); |
| extern PetscErrorCode STCheckNullSpace_Default(ST,PetscInt,const Vec[]); |
| extern PetscErrorCode STMatShellCreate(ST st,Mat *mat); |
| #endif |
| /* |
| Necessary routines in BLAS and LAPACK not included in petscblaslapack.f |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| SLEPc - Scalable Library for Eigenvalue Problem Computations |
| Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| This file is part of SLEPc. |
| SLEPc is free software: you can redistribute it and/or modify it under the |
| terms of version 3 of the GNU Lesser General Public License as published by |
| the Free Software Foundation. |
| SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| more details. |
| You should have received a copy of the GNU Lesser General Public License |
| along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| */ |
| #if !defined(__SLEPCBLASLAPACK_H) |
| #define __SLEPCBLASLAPACK_H |
| #include "petscblaslapack.h" |
| /* Macros for building LAPACK names */ |
| #if defined(PETSC_BLASLAPACK_UNDERSCORE) |
| #if defined(PETSC_USE_REAL_SINGLE) |
| #define SLEPC_BLASLAPACKREAL(lcase,ucase) s##lcase##_ |
| #if defined(PETSC_USE_COMPLEX) |
| #define SLEPC_BLASLAPACK(lcase,ucase) c##lcase##_ |
| #else |
| #define SLEPC_BLASLAPACK(lcase,ucase) s##lcase##_ |
| #endif |
| #elif defined(PETSC_USE_REAL___FLOAT128) |
| #define SLEPC_BLASLAPACKREAL(lcase,ucase) q##lcase##_ |
| #if defined(PETSC_USE_COMPLEX) |
| #define SLEPC_BLASLAPACK(lcase,ucase) w##lcase##_ |
| #else |
| #define SLEPC_BLASLAPACK(lcase,ucase) q##lcase##_ |
| #endif |
| #else |
| #define SLEPC_BLASLAPACKREAL(lcase,ucase) d##lcase##_ |
| #if defined(PETSC_USE_COMPLEX) |
| #define SLEPC_BLASLAPACK(lcase,ucase) z##lcase##_ |
| #else |
| #define SLEPC_BLASLAPACK(lcase,ucase) d##lcase##_ |
| #endif |
| #endif |
| #elif defined(PETSC_BLASLAPACK_CAPS) || defined(PETSC_BLASLAPACK_STDCALL) |
| #if defined(PETSC_USE_REAL_SINGLE) |
| #define SLEPC_BLASLAPACKREAL(lcase,ucase) S##ucase |
| #if defined(PETSC_USE_COMPLEX) |
| #define SLEPC_BLASLAPACK(lcase,ucase) C##ucase |
| #else |
| #define SLEPC_BLASLAPACK(lcase,ucase) S##ucase |
| #endif |
| #elif defined(PETSC_USE_REAL___FLOAT128) |
| #define SLEPC_BLASLAPACKREAL(lcase,ucase) Q##ucase |
| #if defined(PETSC_USE_COMPLEX) |
| #define SLEPC_BLASLAPACK(lcase,ucase) W##ucase |
| #else |
| #define SLEPC_BLASLAPACK(lcase,ucase) Q##ucase |
| #endif |
| #else |
| #define SLEPC_BLASLAPACKREAL(lcase,ucase) D##ucase |
| #if defined(PETSC_USE_COMPLEX) |
| #define SLEPC_BLASLAPACK(lcase,ucase) Z##ucase |
| #else |
| #define SLEPC_BLASLAPACK(lcase,ucase) D##ucase |
| #endif |
| #endif |
| #else |
| #if defined(PETSC_USE_REAL_SINGLE) |
| #define SLEPC_BLASLAPACKREAL(lcase,ucase) s##lcase |
| #if defined(PETSC_USE_COMPLEX) |
| #define SLEPC_BLASLAPACK(lcase,ucase) c##lcase |
| #else |
| #define SLEPC_BLASLAPACK(lcase,ucase) s##lcase |
| #endif |
| #elif defined(PETSC_USE_REAL___FLOAT128) |
| #define SLEPC_BLASLAPACKREAL(lcase,ucase) q##lcase |
| #if defined(PETSC_USE_COMPLEX) |
| #define SLEPC_BLASLAPACK(lcase,ucase) w##lcase |
| #else |
| #define SLEPC_BLASLAPACK(lcase,ucase) q##lcase |
| #endif |
| #else |
| #define SLEPC_BLASLAPACKREAL(lcase,ucase) d##lcase |
| #if defined(PETSC_USE_COMPLEX) |
| #define SLEPC_BLASLAPACK(lcase,ucase) z##lcase |
| #else |
| #define SLEPC_BLASLAPACK(lcase,ucase) d##lcase |
| #endif |
| #endif |
| #endif |
| /* LAPACK functions without string parameters */ |
| #define LAPACKlaev2_ SLEPC_BLASLAPACK(laev2,LAEV2) |
| #define LAPACKgehrd_ SLEPC_BLASLAPACK(gehrd,GEHRD) |
| #define LAPACKgetri_ SLEPC_BLASLAPACK(getri,GETRI) |
| #define LAPACKgelqf_ SLEPC_BLASLAPACK(gelqf,GELQF) |
| #if !defined(PETSC_USE_COMPLEX) |
| #define LAPACKorghr_ SLEPC_BLASLAPACK(orghr,ORGHR) |
| #else |
| #define LAPACKorghr_ SLEPC_BLASLAPACK(unghr,UNGHR) |
| #endif |
| #if !defined(PETSC_USE_COMPLEX) |
| #define LAPACKorgqr_ SLEPC_BLASLAPACK(orgqr,ORGQR) |
| #else |
| #define LAPACKorgqr_ SLEPC_BLASLAPACK(ungqr,UNGQR) |
| #endif |
| #define LAPACKtgexc_ SLEPC_BLASLAPACK(tgexc,TGEXC) |
| #define LAPACKlag2_ SLEPC_BLASLAPACKREAL(lag2,LAG2) |
| #define LAPACKlasv2_ SLEPC_BLASLAPACKREAL(lasv2,LASV2) |
| /* the next one needs a special treatment due to the special names: |
| srot, drot, csrot, zdrot */ |
| #if !defined(PETSC_USE_COMPLEX) |
| #define BLASrot_ SLEPC_BLASLAPACK(rot,ROT) |
| #else |
| #if defined(PETSC_USE_REAL_SINGLE) |
| #define BLASrot_ SLEPC_BLASLAPACK(srot,SROT) |
| #elif defined(PETSC_USE_REAL___FLOAT128) |
| #define BLASrot_ SLEPC_BLASLAPACK(qrot,QROT) |
| #else |
| #define BLASrot_ SLEPC_BLASLAPACK(drot,DROT) |
| #endif |
| #endif |
| /* LAPACK functions with string parameters */ |
| #if !defined(PETSC_BLASLAPACK_STDCALL) |
| #define BLAStrsm_(a,b,c,d,e,f,g,h,i,j,k) SLEPC_BLASLAPACK(trsm,TRSM) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),1,1,1,1) |
| #define BLASsymm_(a,b,c,d,e,f,g,h,i,j,k,l) SLEPC_BLASLAPACK(symm,SYMM) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),1,1) |
| #define LAPACKlanhs_(a,b,c,d,e) SLEPC_BLASLAPACK(lanhs,LANHS) ((a),(b),(c),(d),(e),1) |
| #define LAPACKlange_(a,b,c,d,e,f) SLEPC_BLASLAPACK(lange,LANGE) ((a),(b),(c),(d),(e),(f),1) |
| #define LAPACKstevr_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t) SLEPC_BLASLAPACKREAL(stevr,STEVR) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),1,1) |
| #define LAPACKbdsdc_(a,b,c,d,e,f,g,h,i,j,k,l,m,n) SLEPC_BLASLAPACKREAL(bdsdc,BDSDC) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),1,1) |
| #define LAPACKggevx_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,aa,ab,ac) SLEPC_BLASLAPACK(ggevx,GGEVX) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),(u),(v),(w),(x),(y),(z),(aa),(ab),(ac),1,1,1,1) |
| #define LAPACKggev_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q) SLEPC_BLASLAPACK(ggev,GGEV) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),1,1) |
| #define LAPACKsteqr_(a,b,c,d,e,f,g,h) SLEPC_BLASLAPACKREAL(steqr,STEQR) ((a),(b),(c),(d),(e),(f),(g),(h),1) |
| #define LAPACKorgtr_(a,b,c,d,e,f,g,h) SLEPC_BLASLAPACKREAL(orgtr,ORGTR) ((a),(b),(c),(d),(e),(f),(g),(h),1) |
| #define LAPACKsytrd_(a,b,c,d,e,f,g,h,i,j) SLEPC_BLASLAPACKREAL(sytrd,SYTRD) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),1) |
| #define LAPACKpbtrf_(a,b,c,d,e,f) SLEPC_BLASLAPACK(pbtrf,PBTRF) ((a),(b),(c),(d),(e),(f),1) |
| #define LAPACKlamch_(a) SLEPC_BLASLAPACKREAL(lamch,LAMCH) ((a),1) |
| #if !defined(PETSC_USE_COMPLEX) |
| #define BLAShemm_(a,b,c,d,e,f,g,h,i,j,k,l) SLEPC_BLASLAPACK(symm,SYMM) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),1,1) |
| #define LAPACKsyevr_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u) SLEPC_BLASLAPACK(syevr,SYEVR) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),(u),1,1,1) |
| #define LAPACKsygvd_(a,b,c,d,e,f,g,h,i,j,k,l,m,n) SLEPC_BLASLAPACK(sygvd,SYGVD) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),1,1) |
| #define LAPACKormlq_(a,b,c,d,e,f,g,h,i,j,k,l,m) SLEPC_BLASLAPACK(ormlq,ORMLQ) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),1,1) |
| #define LAPACKtrevc_(a,b,c,d,e,f,g,h,i,j,k,l,m,n) SLEPC_BLASLAPACK(trevc,TREVC) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),1,1) |
| #define LAPACKgeevx_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w) SLEPC_BLASLAPACK(geevx,GEEVX) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),(u),(v),(w),1,1,1,1) |
| #define LAPACKtrexc_(a,b,c,d,e,f,g,h,i,j) SLEPC_BLASLAPACK(trexc,TREXC) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),1) |
| #define LAPACKgesdd_(a,b,c,d,e,f,g,h,i,j,k,l,m,n) SLEPC_BLASLAPACK(gesdd,GESDD) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),1) |
| #define LAPACKtgevc_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) SLEPC_BLASLAPACK(tgevc,TGEVC) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),1,1) |
| #else |
| #define BLAShemm_(a,b,c,d,e,f,g,h,i,j,k,l) SLEPC_BLASLAPACK(hemm,HEMM) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),1,1) |
| #define LAPACKsyevr_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w) SLEPC_BLASLAPACK(heevr,HEEVR) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),(u),(v),(w),1,1,1) |
| #define LAPACKsygvd_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) SLEPC_BLASLAPACK(hegvd,HEGVD) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),1,1) |
| #define LAPACKormlq_(a,b,c,d,e,f,g,h,i,j,k,l,m) SLEPC_BLASLAPACK(unmlq,UNMLQ) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),1,1) |
| #define LAPACKtrevc_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) SLEPC_BLASLAPACK(trevc,TREVC) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),1,1) |
| #define LAPACKgeevx_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v) SLEPC_BLASLAPACK(geevx,GEEVX) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),(u),(v),1,1,1,1) |
| #define LAPACKtrexc_(a,b,c,d,e,f,g,h,i) SLEPC_BLASLAPACK(trexc,TREXC) ((a),(b),(c),(d),(e),(f),(g),(h),(i),1) |
| #define LAPACKgesdd_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) SLEPC_BLASLAPACK(gesdd,GESDD) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),1) |
| #define LAPACKtgevc_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q) SLEPC_BLASLAPACK(tgevc,TGEVC) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),1,1) |
| #endif |
| #else /* PETSC_BLASLAPACK_STDCALL */ |
| #define BLAStrsm_(a,b,c,d,e,f,g,h,i,j,k) SLEPC_BLASLAPACK(trsm,TRSM) ((a),1,(b),1,(c),1,(d),1,(e),(f),(g),(h),(i),(j),(k)) |
| #define BLASsymm_(a,b,c,d,e,f,g,h,i,j,k,l) SLEPC_BLASLAPACK(symm,SYMM) ((a),1,(b),1,(c),(d),(e),(f),(g),(h),(i),(j),(k),(l)) |
| #define LAPACKlanhs_(a,b,c,d,e) SLEPC_BLASLAPACK(lanhs,LANHS) ((a),1,(b),(c),(d),(e)) |
| #define LAPACKlange_(a,b,c,d,e,f) SLEPC_BLASLAPACK(lange,LANGE) ((a),1,(b),(c),(d),(e),(f)) |
| #define LAPACKstevr_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t) SLEPC_BLASLAPACKREAL(stevr,STEVR) ((a),1,(b),1,(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t)) |
| #define LAPACKbdsdc_(a,b,c,d,e,f,g,h,i,j,k,l,m,n) SLEPC_BLASLAPACKREAL(bdsdc,BDSDC) ((a),1,(b),1,(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n)) |
| #define LAPACKggevx_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,aa,ab,ac) SLEPC_BLASLAPACK(ggevx,GGEVX) ((a),1,(b),1,(c),1,(d),1,(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),(u),(v),(w),(x),(y),(z),(aa),(ab),(ac)) |
| #define LAPACKggev_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q) SLEPC_BLASLAPACK(ggev,GGEV) ((a),1,(b),1,(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q)) |
| #define LAPACKsteqr_(a,b,c,d,e,f,g,h) SLEPC_BLASLAPACKREAL(steqr,STEQR) ((a),1,(b),(c),(d),(e),(f),(g),(h)) |
| #define LAPACKorgtr_(a,b,c,d,e,f,g,h) SLEPC_BLASLAPACKREAL(orgtr,ORGTR) ((a),1,(b),(c),(d),(e),(f),(g),(h)) |
| #define LAPACKsytrd_(a,b,c,d,e,f,g,h,i,j) SLEPC_BLASLAPACKREAL(sytrd,SYTRD) ((a),1,(b),(c),(d),(e),(f),(g),(h),(i),(j)) |
| #define LAPACKpbtrf_(a,b,c,d,e,f) SLEPC_BLASLAPACK(pbtrf,PBTRF) ((a),1,(b),(c),(d),(e),(f)) |
| #define LAPACKlamch_(a) SLEPC_BLASLAPACKREAL(lamch,LAMCH) ((a),1) |
| #if !defined(PETSC_USE_COMPLEX) |
| #define BLAShemm_(a,b,c,d,e,f,g,h,i,j,k,l) SLEPC_BLASLAPACK(symm,SYMM) ((a),1,(b),1,(c),(d),(e),(f),(g),(h),(i),(j),(k),(l)) |
| #define LAPACKsyevr_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u) SLEPC_BLASLAPACK(syevr,SYEVR) ((a),1,(b),1,(c),1,(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),(u)) |
| #define LAPACKsygvd_(a,b,c,d,e,f,g,h,i,j,k,l,m,n) SLEPC_BLASLAPACK(sygvd,SYGVD) ((a),(b),1,(c),1,(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n)) |
| #define LAPACKormlq_(a,b,c,d,e,f,g,h,i,j,k,l,m) SLEPC_BLASLAPACK(ormlq,ORMLQ) ((a),1,(b),1,(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m)) |
| #define LAPACKtrevc_(a,b,c,d,e,f,g,h,i,j,k,l,m,n) SLEPC_BLASLAPACK(trevc,TREVC) ((a),1,(b),1,(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n)) |
| #define LAPACKgeevx_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w) SLEPC_BLASLAPACK(geevx,GEEVX) ((a),1,(b),1,(c),1,(d),1,(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),(u),(v),(w)) |
| #define LAPACKtrexc_(a,b,c,d,e,f,g,h,i,j) SLEPC_BLASLAPACK(trexc,TREXC) ((a),1,(b),(c),(d),(e),(f),(g),(h),(i),(j)) |
| #define LAPACKgesdd_(a,b,c,d,e,f,g,h,i,j,k,l,m,n) SLEPC_BLASLAPACK(gesdd,GESDD) ((a),1,(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n)) |
| #define LAPACKtgevc_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) SLEPC_BLASLAPACK(tgevc,TGEVC) ((a),1,(b),1,(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p)) |
| #else |
| #define BLAShemm_(a,b,c,d,e,f,g,h,i,j,k,l) SLEPC_BLASLAPACK(hemm,HEMM) ((a),1,(b),1,(c),(d),(e),(f),(g),(h),(i),(j),(k),(l)) |
| #define LAPACKsyevr_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w) SLEPC_BLASLAPACK(heevr,HEEVR) ((a),1,(b),1,(c),1,(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),(u),(v),(w)) |
| #define LAPACKsygvd_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) SLEPC_BLASLAPACK(hegvd,HEGVD) ((a),(b),1,(c),1,(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p)) |
| #define LAPACKormlq_(a,b,c,d,e,f,g,h,i,j,k,l,m) SLEPC_BLASLAPACK(unmlq,UNMLQ) ((a),1,(b),1,(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m)) |
| #define LAPACKtrevc_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) SLEPC_BLASLAPACK(trevc,TREVC) ((a),1,(b),1,(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o)) |
| #define LAPACKgeevx_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v) SLEPC_BLASLAPACK(geevx,GEEVX) ((a),1,(b),1,(c),1,(d),1,(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),(u),(v)) |
| #define LAPACKtrexc_(a,b,c,d,e,f,g,h,i) SLEPC_BLASLAPACK(trexc,TREXC) ((a),1,(b),(c),(d),(e),(f),(g),(h),(i)) |
| #define LAPACKgesdd_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) SLEPC_BLASLAPACK(gesdd,GESDD) ((a),1,(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o)) |
| #define LAPACKtgevc_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q) SLEPC_BLASLAPACK(tgevc,TGEVC) ((a),1,(b),1,(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q)) |
| #endif |
| #endif |
| PETSC_EXTERN_CXX_BEGIN |
| EXTERN_C_BEGIN |
| #if !defined(PETSC_BLASLAPACK_STDCALL) |
| /* LAPACK functions without string parameters */ |
| extern void SLEPC_BLASLAPACK(laev2,LAEV2) (PetscScalar*,PetscScalar*,PetscScalar*,PetscReal*,PetscReal*,PetscReal*,PetscScalar*); |
| extern void SLEPC_BLASLAPACK(gehrd,GEHRD) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); |
| extern void SLEPC_BLASLAPACK(getri,GETRI) (PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); |
| extern void SLEPC_BLASLAPACK(gelqf,GELQF) (PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); |
| #if !defined(PETSC_USE_COMPLEX) |
| extern void SLEPC_BLASLAPACK(orghr,ORGHR) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); |
| extern void SLEPC_BLASLAPACK(tgexc,TGEXC) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); |
| #else |
| extern void SLEPC_BLASLAPACK(unghr,UNGHR) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); |
| extern void SLEPC_BLASLAPACK(tgexc,TGEXC) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*); |
| #endif |
| #if !defined(PETSC_USE_COMPLEX) |
| extern void SLEPC_BLASLAPACK(orgqr,ORGQR) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); |
| #else |
| extern void SLEPC_BLASLAPACK(ungqr,UNGQR) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); |
| #endif |
| #if !defined(PETSC_USE_COMPLEX) |
| extern void SLEPC_BLASLAPACK(tgexc,TGEXC) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); |
| #else |
| extern void SLEPC_BLASLAPACK(tgexc,TGEXC) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*); |
| #endif |
| extern void SLEPC_BLASLAPACKREAL(lag2,LAG2) (PetscReal*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*); |
| extern void SLEPC_BLASLAPACKREAL(lasv2,LASV2) (PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*); |
| extern void BLASrot_(PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscReal*); |
| /* LAPACK functions with string parameters */ |
| extern void SLEPC_BLASLAPACK(trsm,TRSM) (const char*,const char*,const char*,const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt,PetscBLASInt,PetscBLASInt,PetscBLASInt); |
| extern void SLEPC_BLASLAPACK(symm,SYMM) (const char*,const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*, PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt,PetscBLASInt); |
| extern PetscReal SLEPC_BLASLAPACK(lanhs,LANHS) (const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt); |
| extern PetscReal SLEPC_BLASLAPACK(lange,LANGE) (const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt); |
| extern void SLEPC_BLASLAPACKREAL(stevr,STEVR) (const char*,const char*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt); |
| extern void SLEPC_BLASLAPACKREAL(bdsdc,BDSDC) (const char*,const char*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt); |
| extern void SLEPC_BLASLAPACKREAL(steqr,STEQR) (const char*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt); |
| extern void SLEPC_BLASLAPACKREAL(orgtr,ORGTR) (const char*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt); |
| extern void SLEPC_BLASLAPACKREAL(sytrd,SYTRD) (const char*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt); |
| extern PetscReal SLEPC_BLASLAPACK(pbtrf,PBTRF) (const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt); |
| extern PetscReal SLEPC_BLASLAPACKREAL(lamch,LAMCH) (const char*,PetscBLASInt); |
| #if !defined(PETSC_USE_COMPLEX) |
| extern void SLEPC_BLASLAPACK(trexc,TREXC) (const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt); |
| extern void SLEPC_BLASLAPACK(trevc,TREVC) (const char*,const char*,PetscBool*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt,PetscBLASInt); |
| extern void SLEPC_BLASLAPACK(geevx,GEEVX) (const char*,const char*,const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt,PetscBLASInt,PetscBLASInt); |
| extern void SLEPC_BLASLAPACK(ggevx,GGEVX) (const char*,const char*,const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt,PetscBLASInt,PetscBLASInt); |
| extern void SLEPC_BLASLAPACK(ggev,GGEV) (const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt); |
| extern void SLEPC_BLASLAPACK(syevr,SYEVR) (const char*,const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt,PetscBLASInt); |
| extern void SLEPC_BLASLAPACK(sygvd,SYGVD) (PetscBLASInt*,const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt); |
| extern void SLEPC_BLASLAPACK(gesdd,GESDD) (const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt); |
| extern void SLEPC_BLASLAPACK(ormlq,ORMLQ) (const char*,const char*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt); |
| extern void SLEPC_BLASLAPACK(tgevc,TGEVC) (const char*,const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt,PetscBLASInt); |
| #else |
| extern void SLEPC_BLASLAPACK(hemm,HEMM) (const char*,const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*, PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt,PetscBLASInt); |
| extern void SLEPC_BLASLAPACK(trexc,TREXC) (const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt); |
| extern void SLEPC_BLASLAPACK(trevc,TREVC) (const char*,const char*,PetscBool*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscReal*,PetscBLASInt*,PetscBLASInt,PetscBLASInt); |
| extern void SLEPC_BLASLAPACK(geevx,GEEVX) (const char*,const char*,const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt,PetscBLASInt,PetscBLASInt,PetscBLASInt); |
| extern void SLEPC_BLASLAPACK(ggevx,GGEVX) (const char*,const char*,const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*, PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscScalar*, PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt,PetscBLASInt,PetscBLASInt); |
| extern void SLEPC_BLASLAPACK(ggev,GGEV) (const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt,PetscBLASInt); |
| extern void SLEPC_BLASLAPACK(heevr,HEEVR) (const char *,const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscBLASInt*, PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt,PetscBLASInt); |
| extern void SLEPC_BLASLAPACK(hegvd,HEGVD) (PetscBLASInt*,const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt); |
| extern void SLEPC_BLASLAPACK(gesdd,GESDD) (const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt); |
| extern void SLEPC_BLASLAPACK(unmlq,UNMLQ) (const char*,const char*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt); |
| extern void SLEPC_BLASLAPACK(ungtr,UNGTR) (const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt); |
| extern void SLEPC_BLASLAPACK(hetrd,HETRD) (const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscReal*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt); |
| extern void SLEPC_BLASLAPACK(tgevc,TGEVC) (const char*,const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscReal*,PetscBLASInt*,PetscBLASInt,PetscBLASInt); |
| #endif |
| #else /* PETSC_BLASLAPACK_STDCALL */ |
| /* LAPACK functions without string parameters */ |
| extern void PETSC_STDCALL SLEPC_BLASLAPACK(laev2,LAEV2) (PetscScalar*,PetscScalar*,PetscScalar*,PetscReal*,PetscReal*,PetscReal*,PetscScalar*); |
| extern void PETSC_STDCALL SLEPC_BLASLAPACK(gehrd,GEHRD) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); |
| extern void PETSC_STDCALL SLEPC_BLASLAPACK(getri,GETRI) (PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); |
| extern void PETSC_STDCALL SLEPC_BLASLAPACK(gelqf,GELQF) (PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); |
| #if !defined(PETSC_USE_COMPLEX) |
| extern void PETSC_STDCALL SLEPC_BLASLAPACK(orghr,ORGHR) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); |
| extern void PETSC_STDCALL SLEPC_BLASLAPACK(tgexc,TGEXC) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); |
| #else |
| extern void PETSC_STDCALL SLEPC_BLASLAPACK(unghr,UNGHR) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); |
| extern void PETSC_STDCALL SLEPC_BLASLAPACK(tgexc,TGEXC) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*); |
| #endif |
| #if !defined(PETSC_USE_COMPLEX) |
| extern void PETSC_STDCALL SLEPC_BLASLAPACK(orgqr,ORGQR) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); |
| #else |
| extern void PETSC_STDCALL SLEPC_BLASLAPACK(ungqr,UNGQR) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); |
| #endif |
| #if !defined(PETSC_USE_COMPLEX) |
| extern void PETSC_STDCALL SLEPC_BLASLAPACK(tgexc,TGEXC) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); |
| #else |
| extern void PETSC_STDCALL SLEPC_BLASLAPACK(tgexc,TGEXC) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*); |
| #endif |
| extern void PETSC_STDCALL SLEPC_BLASLAPACKREAL(lag2,LAG2) (PetscReal*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*); |
| extern void PETSC_STDCALL SLEPC_BLASLAPACKREAL(lasv2,LASV2) (PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*); |
| extern void PETSC_STDCALL BLASrot_(PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscReal*); |
| /* LAPACK functions with string parameters */ |
| extern void PETSC_STDCALL SLEPC_BLASLAPACK(trsm,TRSM) (const char*,PetscBLASInt,const char*,PetscBLASInt,const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*); |
| extern void SLEPC_BLASLAPACK(symm,SYMM) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*, PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*); |
| extern PetscReal PETSC_STDCALL SLEPC_BLASLAPACK(lanhs,LANHS) (const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*); |
| extern PetscReal PETSC_STDCALL SLEPC_BLASLAPACK(lange,LANGE) (const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*); |
| extern void PETSC_STDCALL SLEPC_BLASLAPACKREAL(stevr,STEVR) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*); |
| extern void PETSC_STDCALL SLEPC_BLASLAPACKREAL(bdsdc,BDSDC) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*); |
| extern void PETSC_STDCALL SLEPC_BLASLAPACKREAL(steqr,STEQR) (const char*,PetscBLASInt,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscBLASInt*,PetscReal*,PetscBLASInt*); |
| extern void PETSC_STDCALL SLEPC_BLASLAPACKREAL(orgtr,ORGTR) (const char*,PetscBLASInt,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscReal*,PetscBLASInt*,PetscBLASInt*); |
| extern void PETSC_STDCALL SLEPC_BLASLAPACKREAL(sytrd,SYTRD) (const char*,PetscBLASInt,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscBLASInt*,PetscBLASInt*); |
| extern PetscReal PETSC_STDCALL SLEPC_BLASLAPACK(pbtrf,PBTRF) (const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); |
| extern PetscReal SLEPC_BLASLAPACKREAL(lamch,LAMCH) (const char*,PetscBLASInt); |
| #if !defined(PETSC_USE_COMPLEX) |
| extern void PETSC_STDCALL SLEPC_BLASLAPACK(trexc,TREXC) (const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*); |
| extern void PETSC_STDCALL SLEPC_BLASLAPACK(trevc,TREVC) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBool*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*); |
| extern void PETSC_STDCALL SLEPC_BLASLAPACK(geevx,GEEVX) (const char*,PetscBLASInt,const char*,PetscBLASInt,const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*); |
| extern void PETSC_STDCALL SLEPC_BLASLAPACK(ggevx,GGEVX) (const char*,PetscBLASInt,const char*,PetscBLASInt,const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*); |
| extern void PETSC_STDCALL SLEPC_BLASLAPACK(ggev,GGEV) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); |
| extern void PETSC_STDCALL SLEPC_BLASLAPACK(syevr,SYEVR) (const char*,PetscBLASInt,const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*); |
| extern void PETSC_STDCALL SLEPC_BLASLAPACK(sygvd,SYGVD) (PetscBLASInt*,const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*); |
| extern void PETSC_STDCALL SLEPC_BLASLAPACK(gesdd,GESDD) (const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*); |
| extern void PETSC_STDCALL SLEPC_BLASLAPACK(ormlq,ORMLQ) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); |
| extern void PETSC_STDCALL SLEPC_BLASLAPACK(tgevc,TGEVC) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*); |
| #else |
| extern void SLEPC_BLASLAPACK(hemm,HEMM) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*, PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*); |
| extern void PETSC_STDCALL SLEPC_BLASLAPACK(trexc,TREXC) (const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*); |
| extern void PETSC_STDCALL SLEPC_BLASLAPACK(trevc,TREVC) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBool*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscReal*,PetscBLASInt*); |
| extern void PETSC_STDCALL SLEPC_BLASLAPACK(geevx,GEEVX) (const char*,PetscBLASInt,const char*,PetscBLASInt,const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*); |
| extern void PETSC_STDCALL SLEPC_BLASLAPACK(ggevx,GGEVX) (const char*,PetscBLASInt,const char*,PetscBLASInt,const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*, PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscScalar*, PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*); |
| extern void PETSC_STDCALL SLEPC_BLASLAPACK(ggev,GGEV) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*); |
| extern void PETSC_STDCALL SLEPC_BLASLAPACK(heevr,HEEVR) (const char*,PetscBLASInt,const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscBLASInt*, PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*); |
| extern void PETSC_STDCALL SLEPC_BLASLAPACK(hegvd,HEGVD) (PetscBLASInt*,const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*); |
| extern void PETSC_STDCALL SLEPC_BLASLAPACK(gesdd,GESDD) (const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*); |
| extern void PETSC_STDCALL SLEPC_BLASLAPACK(unmlq,UNMLQ) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); |
| extern void PETSC_STDCALL SLEPC_BLASLAPACK(ungtr,UNGTR) (const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); |
| extern void PETSC_STDCALL SLEPC_BLASLAPACK(hetrd,HETRD) (const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscReal*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); |
| extern void PETSC_STDCALL SLEPC_BLASLAPACK(tgevc,TGEVC) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscReal*,PetscBLASInt*); |
| #endif |
| #endif |
| EXTERN_C_END |
| PETSC_EXTERN_CXX_END |
| #endif |
| /* |
| User interface for various vector operations added in SLEPc. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| SLEPc - Scalable Library for Eigenvalue Problem Computations |
| Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| This file is part of SLEPc. |
| SLEPc is free software: you can redistribute it and/or modify it under the |
| terms of version 3 of the GNU Lesser General Public License as published by |
| the Free Software Foundation. |
| SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| more details. |
| You should have received a copy of the GNU Lesser General Public License |
| along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| */ |
| #if !defined(__SLEPCVEC_H) |
| #define __SLEPCVEC_H |
| #include "petscmat.h" |
| #include "petscvec.h" |
| PETSC_EXTERN_CXX_BEGIN |
| /* VecComp: Vec composed of several smaller Vecs */ |
| #define VECCOMP "comp" |
| extern PetscErrorCode VecRegister_Comp(const char[]); |
| extern PetscErrorCode VecCreateComp(MPI_Comm,PetscInt*,PetscInt,const VecType,Vec,Vec*); |
| extern PetscErrorCode VecCreateCompWithVecs(Vec*,PetscInt,Vec,Vec*); |
| extern PetscErrorCode VecCompGetSubVecs(Vec,PetscInt*,const Vec**); |
| extern PetscErrorCode VecCompSetSubVecs(Vec,PetscInt,Vec*); |
| /* Vecs with contiguous array storage */ |
| extern PetscErrorCode SlepcVecSetTemplate(Vec); |
| extern PetscErrorCode SlepcMatGetVecsTemplate(Mat,Vec*,Vec*); |
| /* Vec-related operations that have two versions, for contiguous and regular Vecs */ |
| extern PetscErrorCode SlepcUpdateVectors(PetscInt,Vec*,PetscInt,PetscInt,const PetscScalar*,PetscInt,PetscBool); |
| extern PetscErrorCode SlepcUpdateStrideVectors(PetscInt n_,Vec *V,PetscInt s,PetscInt d,PetscInt e,const PetscScalar *Q,PetscInt ldq_,PetscBool qtrans); |
| extern PetscErrorCode SlepcVecMAXPBY(Vec,PetscScalar,PetscScalar,PetscInt,PetscScalar*,Vec*); |
| /* Miscellaneous functions related to Vec */ |
| extern PetscErrorCode SlepcVecSetRandom(Vec,PetscRandom); |
| extern PetscErrorCode SlepcVecNormalize(Vec,Vec,PetscBool,PetscReal*); |
| PETSC_EXTERN_CXX_END |
| #endif |
| /* |
| This include file contains definitions of system functions. It is included |
| by all other SLEPc include files. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| SLEPc - Scalable Library for Eigenvalue Problem Computations |
| Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| This file is part of SLEPc. |
| SLEPc is free software: you can redistribute it and/or modify it under the |
| terms of version 3 of the GNU Lesser General Public License as published by |
| the Free Software Foundation. |
| SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| more details. |
| You should have received a copy of the GNU Lesser General Public License |
| along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| */ |
| #if !defined(__SLEPC_H) |
| #define __SLEPC_H |
| /* ========================================================================== */ |
| /* |
| slepcconf.h is created by the configure script and placed in ${PETSC_ARCH}/include. |
| It contains macro definitions set at configure time. |
| */ |
| #include "slepcconf.h" |
| /* ========================================================================== */ |
| /* |
| Current SLEPc version number and release date |
| */ |
| #include "slepcversion.h" |
| #define SLEPC_AUTHOR_INFO " The SLEPc Team\n slepc-maint@grycap.upv.es\n http://www.grycap.upv.es/slepc\n" |
| #if (SLEPC_VERSION_RELEASE == 1) |
| #define SlepcGetVersion(version,len) PetscSNPrintf(version,len,"SLEPc Release Version %d.%d, Patch %d, %s", \ |
| SLEPC_VERSION_MAJOR,SLEPC_VERSION_MINOR, \ |
| SLEPC_VERSION_PATCH,SLEPC_VERSION_PATCH_DATE) |
| #else |
| #define SlepcGetVersion(version,len) PetscSNPrintf(version,len,"SLEPc Development SVN revision: %d SVN Date: %s", \ |
| SLEPC_VERSION_SVN, SLEPC_VERSION_DATE_SVN) |
| #endif |
| /*MC |
| SlepcGetVersion - Gets the SLEPc version information in a string. |
| Input Parameter: |
| . len - length of the string |
| Output Parameter: |
| . version - version string |
| Level: developer |
| Usage: |
| char version[256]; |
| ierr = SlepcGetVersion(version,256);CHKERRQ(ierr) |
| Fortran Note: |
| This routine is not supported in Fortran. |
| M*/ |
| /* ========================================================================== */ |
| /* |
| The PETSc include files. |
| */ |
| #include "petscsys.h" |
| #include "petscvec.h" |
| #include "petscmat.h" |
| /* |
| slepcvec.h contains extensions to PETSc Vec's |
| */ |
| #include "slepcvec.h" |
| /* |
| slepcimpl.h contains definitions common to all SLEPc objects |
| */ |
| #include "private/slepcimpl.h" |
| /* |
| Default tolerance for the different solvers, depending on the precision |
| */ |
| #if defined(PETSC_USE_REAL_SINGLE) |
| # define SLEPC_DEFAULT_TOL 1e-6 |
| #elif defined(PETSC_USE_REAL_DOUBLE) |
| # define SLEPC_DEFAULT_TOL 1e-8 |
| #elif defined(PETSC_USE_REAL___FLOAT128) |
| # define SLEPC_DEFAULT_TOL 1e-16 |
| #else |
| # define SLEPC_DEFAULT_TOL 1e-7 |
| #endif |
| PETSC_EXTERN_CXX_BEGIN |
| /* |
| Initialization of SLEPc and other system routines |
| */ |
| extern PetscErrorCode SlepcInitialize(int*,char***,const char[],const char[]); |
| extern PetscErrorCode SlepcFinalize(void); |
| extern PetscErrorCode SlepcInitializeFortran(void); |
| extern PetscErrorCode SlepcInitialized(PetscBool*); |
| #undef __FUNCT__ |
| #define __FUNCT__ "SlepcAbs" |
| /*@C |
| SlepcAbs - Returns sqrt(x**2+y**2), taking care not to cause unnecessary |
| overflow. It is based on LAPACK's DLAPY2. |
| Not Collective |
| Input parameters: |
| . x,y - the real numbers |
| Output parameter: |
| . return - the result |
| Level: developer |
| @*/ |
| PETSC_STATIC_INLINE PetscReal SlepcAbs(PetscReal x,PetscReal y) |
| { |
| PetscReal w,z,t,xabs=PetscAbs(x),yabs=PetscAbs(y); |
| w = PetscMax(xabs,yabs); |
| z = PetscMin(xabs,yabs); |
| if (z == 0.0) return w; |
| t = z/w; |
| return w*PetscSqrtReal(1.0+t*t); |
| } |
| /*MC |
| SlepcAbsEigenvalue - Returns the absolute value of a complex number given |
| its real and imaginary parts. |
| Synopsis: |
| PetscReal SlepcAbsEigenvalue(PetscScalar x,PetscScalar y) |
| Not Collective |
| Input parameters: |
| + x - the real part of the complex number |
| - y - the imaginary part of the complex number |
| Notes: |
| This function computes sqrt(x**2+y**2), taking care not to cause unnecessary |
| overflow. It is based on LAPACK's DLAPY2. |
| Level: developer |
| M*/ |
| #if !defined(PETSC_USE_COMPLEX) |
| #define SlepcAbsEigenvalue(x,y) SlepcAbs(x,y) |
| #else |
| #define SlepcAbsEigenvalue(x,y) PetscAbsScalar(x) |
| #endif |
| extern PetscErrorCode SlepcMatConvertSeqDense(Mat,Mat*); |
| extern PetscErrorCode SlepcMatTile(PetscScalar,Mat,PetscScalar,Mat,PetscScalar,Mat,PetscScalar,Mat,Mat*); |
| extern PetscErrorCode SlepcCheckOrthogonality(Vec*,PetscInt,Vec *,PetscInt,Mat,PetscReal*); |
| extern PetscBool SlepcInitializeCalled; |
| PETSC_EXTERN_CXX_END |
| #endif |
| /* |
| This is the main SLEPc include file (for C and C++). It is included |
| by all other SLEPc include files, so it almost never has to be |
| specifically included. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| SLEPc - Scalable Library for Eigenvalue Problem Computations |
| Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| This file is part of SLEPc. |
| SLEPc is free software: you can redistribute it and/or modify it under the |
| terms of version 3 of the GNU Lesser General Public License as published by |
| the Free Software Foundation. |
| SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| more details. |
| You should have received a copy of the GNU Lesser General Public License |
| along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| */ |
| /* |
| Include all top-level SLEPc functionality |
| */ |
| #include "slepcsys.h" |
| #include "slepcsvd.h" |
| #include "slepcqep.h" |
| # |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # SLEPc - Scalable Library for Eigenvalue Problem Computations |
| # Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| # |
| # This file is part of SLEPc. |
| # |
| # SLEPc is free software: you can redistribute it and/or modify it under the |
| # terms of version 3 of the GNU Lesser General Public License as published by |
| # the Free Software Foundation. |
| # |
| # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| # more details. |
| # |
| # You should have received a copy of the GNU Lesser General Public License |
| # along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # |
| CFLAGS = |
| FFLAGS = |
| SOURCEC = |
| SOURCEF = |
| SOURCEH = slepc.h slepcsys.h slepceps.h slepcst.h slepcsvd.h slepcip.h slepcversion.h slepcblaslapack.h |
| OBJSC = |
| OBJSF = |
| LIBBASE = libslepc |
| DIRS = finclude private |
| LOCDIR = include/ |
| MANSEC = |
| include ${SLEPC_DIR}/conf/slepc_common |
| GNU LESSER GENERAL PUBLIC LICENSE |
| Version 3, 29 June 2007 |
| Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> |
| Everyone is permitted to copy and distribute verbatim copies |
| of this license document, but changing it is not allowed. |
| This version of the GNU Lesser General Public License incorporates |
| the terms and conditions of version 3 of the GNU General Public |
| License, supplemented by the additional permissions listed below. |
| 0. Additional Definitions. |
| As used herein, "this License" refers to version 3 of the GNU Lesser |
| General Public License, and the "GNU GPL" refers to version 3 of the GNU |
| General Public License. |
| "The Library" refers to a covered work governed by this License, |
| other than an Application or a Combined Work as defined below. |
| An "Application" is any work that makes use of an interface provided |
| by the Library, but which is not otherwise based on the Library. |
| Defining a subclass of a class defined by the Library is deemed a mode |
| of using an interface provided by the Library. |
| A "Combined Work" is a work produced by combining or linking an |
| Application with the Library. The particular version of the Library |
| with which the Combined Work was made is also called the "Linked |
| Version". |
| The "Minimal Corresponding Source" for a Combined Work means the |
| Corresponding Source for the Combined Work, excluding any source code |
| for portions of the Combined Work that, considered in isolation, are |
| based on the Application, and not on the Linked Version. |
| The "Corresponding Application Code" for a Combined Work means the |
| object code and/or source code for the Application, including any data |
| and utility programs needed for reproducing the Combined Work from the |
| Application, but excluding the System Libraries of the Combined Work. |
| 1. Exception to Section 3 of the GNU GPL. |
| You may convey a covered work under sections 3 and 4 of this License |
| without being bound by section 3 of the GNU GPL. |
| 2. Conveying Modified Versions. |
| If you modify a copy of the Library, and, in your modifications, a |
| facility refers to a function or data to be supplied by an Application |
| that uses the facility (other than as an argument passed when the |
| facility is invoked), then you may convey a copy of the modified |
| version: |
| a) under this License, provided that you make a good faith effort to |
| ensure that, in the event an Application does not supply the |
| function or data, the facility still operates, and performs |
| whatever part of its purpose remains meaningful, or |
| b) under the GNU GPL, with none of the additional permissions of |
| this License applicable to that copy. |
| 3. Object Code Incorporating Material from Library Header Files. |
| The object code form of an Application may incorporate material from |
| a header file that is part of the Library. You may convey such object |
| code under terms of your choice, provided that, if the incorporated |
| material is not limited to numerical parameters, data structure |
| layouts and accessors, or small macros, inline functions and templates |
| (ten or fewer lines in length), you do both of the following: |
| a) Give prominent notice with each copy of the object code that the |
| Library is used in it and that the Library and its use are |
| covered by this License. |
| b) Accompany the object code with a copy of the GNU GPL and this license |
| document. |
| 4. Combined Works. |
| You may convey a Combined Work under terms of your choice that, |
| taken together, effectively do not restrict modification of the |
| portions of the Library contained in the Combined Work and reverse |
| engineering for debugging such modifications, if you also do each of |
| the following: |
| a) Give prominent notice with each copy of the Combined Work that |
| the Library is used in it and that the Library and its use are |
| covered by this License. |
| b) Accompany the Combined Work with a copy of the GNU GPL and this license |
| document. |
| c) For a Combined Work that displays copyright notices during |
| execution, include the copyright notice for the Library among |
| these notices, as well as a reference directing the user to the |
| copies of the GNU GPL and this license document. |
| d) Do one of the following: |
| 0) Convey the Minimal Corresponding Source under the terms of this |
| License, and the Corresponding Application Code in a form |
| suitable for, and under terms that permit, the user to |
| recombine or relink the Application with a modified version of |
| the Linked Version to produce a modified Combined Work, in the |
| manner specified by section 6 of the GNU GPL for conveying |
| Corresponding Source. |
| 1) Use a suitable shared library mechanism for linking with the |
| Library. A suitable mechanism is one that (a) uses at run time |
| a copy of the Library already present on the user's computer |
| system, and (b) will operate properly with a modified version |
| of the Library that is interface-compatible with the Linked |
| Version. |
| e) Provide Installation Information, but only if you would otherwise |
| be required to provide such information under section 6 of the |
| GNU GPL, and only to the extent that such information is |
| necessary to install and execute a modified version of the |
| Combined Work produced by recombining or relinking the |
| Application with a modified version of the Linked Version. (If |
| you use option 4d0, the Installation Information must accompany |
| the Minimal Corresponding Source and Corresponding Application |
| Code. If you use option 4d1, you must provide the Installation |
| Information in the manner specified by section 6 of the GNU GPL |
| for conveying Corresponding Source.) |
| 5. Combined Libraries. |
| You may place library facilities that are a work based on the |
| Library side by side in a single library together with other library |
| facilities that are not Applications and are not covered by this |
| License, and convey such a combined library under terms of your |
| choice, if you do both of the following: |
| a) Accompany the combined library with a copy of the same work based |
| on the Library, uncombined with any other library facilities, |
| conveyed under the terms of this License. |
| b) Give prominent notice with the combined library that part of it |
| is a work based on the Library, and explaining where to find the |
| accompanying uncombined form of the same work. |
| 6. Revised Versions of the GNU Lesser General Public License. |
| The Free Software Foundation may publish revised and/or new versions |
| of the GNU Lesser General Public License from time to time. Such new |
| versions will be similar in spirit to the present version, but may |
| differ in detail to address new problems or concerns. |
| Each version is given a distinguishing version number. If the |
| Library as you received it specifies that a certain numbered version |
| of the GNU Lesser General Public License "or any later version" |
| applies to it, you have the option of following the terms and |
| conditions either of that published version or of any later version |
| published by the Free Software Foundation. If the Library as you |
| received it does not specify a version number of the GNU Lesser |
| General Public License, you may choose any version of the GNU Lesser |
| General Public License ever published by the Free Software Foundation. |
| If the Library as you received it specifies that a proxy can decide |
| whether future versions of the GNU Lesser General Public License shall |
| apply, that proxy's public statement of acceptance of any version is |
| permanent authorization for you to choose that version for the |
| Library. |
| # |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # SLEPc - Scalable Library for Eigenvalue Problem Computations |
| # Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| # |
| # This file is part of SLEPc. |
| # |
| # SLEPc is free software: you can redistribute it and/or modify it under the |
| # terms of version 3 of the GNU Lesser General Public License as published by |
| # the Free Software Foundation. |
| # |
| # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| # more details. |
| # |
| # You should have received a copy of the GNU Lesser General Public License |
| # along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # |
| chkslepc_dir: |
| @mypwd=`pwd`; cd ${SLEPC_DIR} 2>&1 > /dev/null; true_SLEPC_DIR=`pwd`; cd $${mypwd} 2>&1 >/dev/null; \ |
| newpwd=`echo $${mypwd} | sed "s+$${true_SLEPC_DIR}+DUMMY+g"`;\ |
| hasslepc=`echo $${mypwd} | sed "s+slepc-+DUMMY+g"`;\ |
| if [ $${mypwd} = $${newpwd} -a $${hasslepc} != $${mypwd} ]; then \ |
| echo "*********************Warning*************************" ; \ |
| echo "Your SLEPC_DIR may not match the directory you are in";\ |
| echo "SLEPC_DIR " $${true_SLEPC_DIR} "Current directory" $${mypwd};\ |
| echo "******************************************************" ; \ |
| fi |
| slepc_manualpages: |
| -@if [ "${MANSEC}" != "" ] ; then \ |
| DOCTEXT_PATH=${PETSC_DIR}/src/docs/tex/doctext; export DOCTEXT_PATH; \ |
| ${DOCTEXT} -html \ |
| -mpath ${LOC}/docs/manualpages/${MANSEC} -heading SLEPc \ |
| -defn ${SLEPC_DIR}/src/docs/tex/doctext/html.def \ |
| -locdir ${LOCDIR} -mapref ${LOC}/docs/manualpages/manualpages.cit \ |
| ${SOURCEC} ${SOURCEH}; \ |
| chmod -f g+w ${LOC}/docs/manualpages/${MANSEC}/* ; fi |
| slepc_manexamples: |
| -@base=`basename ${LOCDIR}`; \ |
| if [ "$${base}" = "tutorials" ] ; then \ |
| echo "Generating manual example links" ; \ |
| for i in ${EXAMPLESC} ${EXAMPLESF} foo ; do \ |
| if [ "$$i" != "foo" ] ; then \ |
| a=`cat $$i | ${MAPNAMES} -map ${LOC}/docs/manualpages/manualpages.cit \ |
| -printmatch -o /dev/null | sort | uniq` ; \ |
| for j in $$a ; do \ |
| b=`ls ${LOC}/docs/manualpages/*/$${j}.html | cut -f9` ; \ |
| l=`grep tutorials $${b} | wc -l`; \ |
| if [ $$l -le 10 ] ; then \ |
| if [ $$l -eq 0 ] ; then \ |
| echo "<P><H3><FONT COLOR=\"#883300\">Examples</FONT></H3>" >> $$b; \ |
| fi; \ |
| echo "<A HREF=\"../../../BB\">BB</A><BR>" | sed s?BB?${LOCDIR}$$i.html?g >> $$b; \ |
| grep -v /BODY $$b > ltmp; \ |
| echo "</BODY></HTML>" >> ltmp; \ |
| mv -f ltmp $$b; \ |
| fi; \ |
| done; \ |
| fi; \ |
| done; \ |
| fi |
| slepc_html: |
| -@sed -e s?man+../?man+ROOT/docs/manualpages/? ${LOC}/docs/manualpages/manualpages.cit > /tmp/$$USER.htmlmap |
| -@cat ${PETSC_DIR}/src/docs/mpi.www.index >> /tmp/$$USER.htmlmap |
| -@ROOT=`echo ${LOCDIR} | sed -e s?/[a-z]*?/..?g -e s?src/??g -e s?include/??g` ;\ |
| loc=`pwd | sed -e s?\$${PETSC_DIR}?$${LOC}/?g -e s?/disks??g`; \ |
| ${MKDIR} -p $${loc} ;\ |
| for i in ${SOURCEC} ${SOURCEF} ${SOURCEH} ${EXAMPLESC} ${EXAMPLESF} ${EXAMPLESCH} ${EXAMPLESFH} ${EXAMPLESMATLAB} foo ; do\ |
| if [ -f $$i ]; then \ |
| iroot=`echo $$i | sed -e "s?[a-z.]*/??g"`;\ |
| IROOT=`echo $${i} | sed -e s?[.][.]??g` ;\ |
| if [ "$${IROOT}" != "$${i}" ] ; then \ |
| IROOT=".."; \ |
| else \ |
| IROOT=$${ROOT};\ |
| fi;\ |
| ${RM} $${loc}/$$i.html; \ |
| echo "<center><a href=\"$${iroot}\">Actual source code: $${iroot}</a></center><br>" > $${loc}/$$i.html; \ |
| sed -e "s/CHKERRQ(ierr);//g" -e "s/PetscFunctionReturn(0)/return(0)/g" \ |
| -e "s/ierr [ ]*= //g" $$i | ${C2HTML} -n | ${PETSC_DIR}/bin/maint/fixinclude $$i $${ROOT} | \ |
| egrep -v '(PetscValid|PetscFunctionBegin|PetscCheck|PetscErrorCode ierr;|#if !defined\(__|#define __|#undef __|EXTERN_C )' | \ |
| ${MAPNAMES} -map /tmp/$$USER.htmlmap -inhtml | sed -e s?ROOT?$${IROOT}?g >> $${loc}/$$i.html ; \ |
| fi; \ |
| done |
| -@ROOT=`echo ${LOCDIR} | sed -e s?/[a-z]*?/..?g -e s?src/??g -e s?include/??g` ;\ |
| loc=`pwd | sed -e s?\$${PETSC_DIR}?$${LOC}/?g -e s?/disks??g`; ${RM} $${loc}/index.html; \ |
| cat ${SLEPC_DIR}/src/docs/manualpages-sec/header_${MANSEC} | sed -e "s?<A HREF=\"PETSC_DIR[a-z/]*\">Examples</A>?<A HREF=\"$${ROOT}/docs/manualpages/${MANSEC}\">Manual pages</A>?g" -e "s?PETSC_DIR?$${ROOT}/?g"> $${loc}/index.html; \ |
| echo "<p>" >> $${loc}/index.html |
| -@loc=`pwd | sed -e s?\$${PETSC_DIR}?$${LOC}/?g -e s?/disks??g`;\ |
| if [ "${EXAMPLESC}" != "" ] ; then \ |
| for file in ${EXAMPLESC} foo ; do \ |
| if [ -f $$file ]; then \ |
| cmess=`grep "static char help" $${file} | cut -d\" -f2 | cut -d\. -f1`; \ |
| echo "<a href=\"$${file}.html\">$${file}: $${cmess}</a><br>" >> $${loc}/index.html;\ |
| fi; \ |
| done ;\ |
| else \ |
| for file in ${DIRS} foo; do \ |
| if [ -d $$file ]; then \ |
| echo "<a href=\"$${file}/\">$${file}/</a><br>" >> $${loc}/index.html; \ |
| fi; \ |
| done; \ |
| echo " " >> $${loc}/index.html; \ |
| for file in ${SOURCEH} ${SOURCEC} ${SOURCEF} foo ; do \ |
| if [ -f $$file ]; then \ |
| echo "<a href=\"$${file}.html\">$${file}</a><br>" >> $${loc}/index.html; \ |
| fi; \ |
| done; \ |
| fi ;\ |
| echo " " >> $${loc}/index.html; \ |
| echo "<a href=\"makefile.html\">makefile</a><br>" >> $${loc}/index.html |
| -@loc=`pwd | sed -e s?\$${PETSC_DIR}?$${LOC}/?g -e s?/disks??g`; \ |
| cat makefile | ${C2HTML} | ${MAPNAMES} -map /tmp/$$USER.htmlmap -inhtml > $${loc}/makefile.html |
| -@${RM} /tmp/$$USER.htmlmap tmp |
| slepc_tree: ${ACTION} |
| -@for dir in ${DIRS} ftn-auto ftn-custom f90-custom; do \ |
| if [ -d $$dir ]; then \ |
| if [ "${PETSC_ARCH}" = "arch-installed-petsc" ]; then \ |
| PETSCCONF="${PETSC_DIR}/include/petscconf.h" ; \ |
| else \ |
| PETSCCONF="${PETSC_DIR}/${PETSC_ARCH}/include/petscconf.h" ; \ |
| fi; \ |
| r=`grep -w requirespackage $$dir/makefile`; \ |
| if [ "$$?" = 0 ]; then \ |
| PKGFLG=`echo $$r | cut -d \' -f2`;\ |
| grep -w "#define $${PKGFLG}" $${PETSCCONF} > /dev/null; \ |
| if [ "$$?" = 1 ]; then \ |
| continue; \ |
| fi; \ |
| fi; \ |
| r=`grep -w requiresfunction $$dir/makefile`; \ |
| if [ "$$?" = 0 ]; then \ |
| PKGFLG=`echo $$r | cut -d \' -f2`;\ |
| grep -w "#define $${PKGFLG}" $${PETSCCONF} > /dev/null; \ |
| if [ "$$?" = 1 ]; then \ |
| continue; \ |
| fi; \ |
| fi; \ |
| r=`grep -w requiresdefine $$dir/makefile`; \ |
| if [ "$$?" = 0 ]; then \ |
| PKGFLG=`echo $$r | cut -d \' -f2`;\ |
| grep -w "#define $${PKGFLG}" ${SLEPC_DIR}/${PETSC_ARCH}/include/slepcconf.h > /dev/null; \ |
| if [ "$$?" = 1 ]; then \ |
| grep -w "#define $${PKGFLG}" $${PETSCCONF} > /dev/null; \ |
| if [ "$$?" = 1 ]; then \ |
| continue; \ |
| fi; \ |
| fi; \ |
| fi; \ |
| r=`grep -w requireslanguage $$dir/makefile`; \ |
| if [ "$$?" = 0 ]; then \ |
| echo $$r | grep -w ${PETSC_LANGUAGE} > /dev/null; \ |
| if [ "$$?" = 1 ]; then \ |
| continue; \ |
| fi; \ |
| fi; \ |
| r=`grep -w requiresscalar $$dir/makefile`; \ |
| if [ "$$?" = 0 ]; then \ |
| echo $$r | grep -w ${PETSC_SCALAR} > /dev/null; \ |
| if [ "$$?" = 1 ]; then \ |
| continue; \ |
| fi; \ |
| fi; \ |
| r=`grep -w requiresprecision $$dir/makefile`; \ |
| if [ "$$?" = 0 ]; then \ |
| echo $$r | grep -w ${PETSC_PRECISION} > /dev/null; \ |
| if [ "$$?" = 1 ]; then \ |
| continue; \ |
| fi; \ |
| fi; \ |
| else \ |
| continue; \ |
| fi; \ |
| (cd $$dir ; \ |
| echo ${ACTION} in: `pwd`; \ |
| ${OMAKE} slepc_tree ACTION=${ACTION} PETSC_ARCH=${PETSC_ARCH} LOC=${LOC} DATAFILESPATH=${DATAFILESPATH} BASE_DIR=${BASE_DIR});\ |
| done |
| # builds the SLEPc shared library |
| slepc_shared: |
| -@${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} SLEPC_DIR=${SLEPC_DIR} OTHERSHAREDLIBS="${PETSC_KSP_LIB} ${SLEPC_EXTERNAL_LIB}" shared_nomesg |
| # uses the cmake infrastructure to build/rebuild the libraries |
| slepc_cmake: |
| @if [ "${SLEPC_BUILD_USING_CMAKE}" != "" ]; then \ |
| ${OMAKE} -j ${MAKE_NP} -C ${SLEPC_DIR}/${PETSC_ARCH}; \ |
| else \ |
| echo "CMake builds are disabled"; \ |
| fi |
| include ${PETSC_DIR}/conf/rules |
| include ${SLEPC_DIR}/${PETSC_ARCH}/conf/slepcrules |
| # |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # SLEPc - Scalable Library for Eigenvalue Problem Computations |
| # Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| # |
| # This file is part of SLEPc. |
| # |
| # SLEPc is free software: you can redistribute it and/or modify it under the |
| # terms of version 3 of the GNU Lesser General Public License as published by |
| # the Free Software Foundation. |
| # |
| # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| # more details. |
| # |
| # You should have received a copy of the GNU Lesser General Public License |
| # along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # |
| include ${PETSC_DIR}/conf/test |
| testexamples_BLOPEX: ${TESTEXAMPLES_BLOPEX} |
| slepc_alltests: alltests |
| @[ `grep Possible ${PETSC_ARCH}/conf/alltests.log | wc -l` -le 4 ] |
| # |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # SLEPc - Scalable Library for Eigenvalue Problem Computations |
| # Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| # |
| # This file is part of SLEPc. |
| # |
| # SLEPc is free software: you can redistribute it and/or modify it under the |
| # terms of version 3 of the GNU Lesser General Public License as published by |
| # the Free Software Foundation. |
| # |
| # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| # more details. |
| # |
| # You should have received a copy of the GNU Lesser General Public License |
| # along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # |
| # |
| # SLEPc uses the portable makefile system provided by the PETSc library. |
| # The following include files set customized site, optimization, and version |
| # options. Do NOT remove any of these include files! |
| # |
| # |
| # a dummy target which does nothing - just in case |
| # 'ALL: get mapped into this file' |
| # |
| all_dummy: |
| -@true |
| include ${SLEPC_DIR}/conf/slepc_variables |
| include ${SLEPC_DIR}/conf/slepc_rules |
| include ${SLEPC_DIR}/conf/slepc_test |
| # |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # SLEPc - Scalable Library for Eigenvalue Problem Computations |
| # Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| # |
| # This file is part of SLEPc. |
| # |
| # SLEPc is free software: you can redistribute it and/or modify it under the |
| # terms of version 3 of the GNU Lesser General Public License as published by |
| # the Free Software Foundation. |
| # |
| # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| # more details. |
| # |
| # You should have received a copy of the GNU Lesser General Public License |
| # along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # |
| include ${PETSC_DIR}/conf/variables |
| include ${SLEPC_DIR}/${PETSC_ARCH}/conf/slepcvariables |
| SLEPC_LIB_DIR = ${SLEPC_DIR}/${PETSC_ARCH}/lib |
| SLEPC_INCLUDE = -I${SLEPC_DIR} -I${SLEPC_DIR}/${PETSC_ARCH}/include -I${SLEPC_DIR}/include |
| CC_INCLUDES = ${PETSC_INCLUDE} ${SLEPC_INCLUDE} |
| FC_INCLUDES = ${PETSC_INCLUDE} ${SLEPC_INCLUDE} |
| SLEPC_EXTERNAL_LIB = ${ARPACK_LIB} ${BLZPACK_LIB} ${TRLAN_LIB} ${PRIMME_LIB} ${BLOPEX_LIB} |
| INSTALL_LIB_DIR = ${SLEPC_LIB_DIR} |
| CCPPFLAGS = ${PETSC_CCPPFLAGS} ${SLEPC_INCLUDE} |
| FCPPFLAGS = ${PETSC_FCPPFLAGS} ${SLEPC_INCLUDE} |
| SLEPC_LIB = ${CC_LINKER_SLFLAG}${SLEPC_LIB_DIR} -L${SLEPC_LIB_DIR} -lslepc ${SLEPC_EXTERNAL_LIB} ${PETSC_KSP_LIB} |
| # no longer required |
| SLEPC_FORTRAN_LIB = |
| SHLIBS = libslepc |
| LIBNAME = ${INSTALL_LIB_DIR}/${LIBBASE}.${AR_LIB_SUFFIX} |
| # |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # SLEPc - Scalable Library for Eigenvalue Problem Computations |
| # Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| # |
| # This file is part of SLEPc. |
| # |
| # SLEPc is free software: you can redistribute it and/or modify it under the |
| # terms of version 3 of the GNU Lesser General Public License as published by |
| # the Free Software Foundation. |
| # |
| # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| # more details. |
| # |
| # You should have received a copy of the GNU Lesser General Public License |
| # along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # |
| import os |
| import sys |
| import log |
| import petscconf |
| import urllib |
| import urlparse |
| import commands |
| def Install(conf,vars,cmake,tmpdir,url,archdir): |
| ''' |
| Download and uncompress the BLOPEX tarball |
| ''' |
| log.write('='*80) |
| log.Println('Installing BLOPEX...') |
| if petscconf.PRECISION == 'single': |
| log.Exit('ERROR: BLOPEX does not support single precision.') |
| # Create externalpackages directory |
| externdir = 'externalpackages' |
| if not os.path.exists(externdir): |
| try: |
| os.mkdir(externdir) |
| except: |
| sys.exit('ERROR: cannot create directory ' + externdir) |
| # Download tarball |
| packagename = 'blopex-1.1.2' |
| if url=='': |
| url = 'http://www.grycap.upv.es/slepc/download/external/'+packagename+'.tar.gz' |
| archiveZip = 'blopex.tar.gz' |
| localFile = os.sep.join([externdir,archiveZip]) |
| log.Println('Downloading '+url+' to '+localFile) |
| if os.path.exists(localFile): |
| os.remove(localFile) |
| try: |
| urllib.urlretrieve(url, localFile) |
| except Exception, e: |
| name = 'blopex' |
| filename = os.path.basename(urlparse.urlparse(url)[2]) |
| failureMessage = '''\ |
| Unable to download package %s from: %s |
| * If your network is disconnected - please reconnect and rerun config/configure.py |
| * Alternatively, you can download the above URL manually, to /yourselectedlocation/%s |
| and use the configure option: |
| --download-%s=/yourselectedlocation/%s |
| ''' % (name, url, filename, name, filename) |
| raise RuntimeError(failureMessage) |
| # Uncompress tarball |
| destDir = os.sep.join([externdir,packagename]) |
| log.Println('Uncompressing '+localFile+' to directory '+destDir) |
| if os.path.exists(destDir): |
| for root, dirs, files in os.walk(destDir, topdown=False): |
| for name in files: |
| os.remove(os.path.join(root, name)) |
| for name in dirs: |
| os.rmdir(os.path.join(root, name)) |
| try: |
| if sys.version_info >= (2,5): |
| import tarfile |
| tar = tarfile.open(localFile, "r:gz") |
| tar.extractall(path=externdir) |
| tar.close() |
| os.remove(localFile) |
| else: |
| result,output = commands.getstatusoutput('cd '+externdir+'; gunzip '+archiveZip+'; tar -xf '+archiveZip.split('.gz')[0]) |
| os.remove(localFile.split('.gz')[0]) |
| except RuntimeError, e: |
| raise RuntimeError('Error uncompressing '+archiveZip+': '+str(e)) |
| # Configure |
| g = open(os.path.join(destDir,'Makefile.inc'),'w') |
| g.write('CC = '+petscconf.CC+'\n') |
| if petscconf.IND64: blopexint = ' -DBlopexInt="long long" ' |
| else: blopexint = '' |
| g.write('CFLAGS = '+petscconf.CC_FLAGS.replace('-Wall','').replace('-Wshadow','')+blopexint+'\n') |
| g.write('AR = '+petscconf.AR+' '+petscconf.AR_FLAGS+'\n') |
| g.write('AR_LIB_SUFFIX = '+petscconf.AR_LIB_SUFFIX+'\n') |
| g.write('RANLIB = '+petscconf.RANLIB+'\n') |
| g.write('TARGET_ARCH = \n') |
| g.close() |
| # Build package |
| result,output = commands.getstatusoutput('cd '+destDir+'&&'+petscconf.MAKE+' clean &&'+petscconf.MAKE) |
| log.write(output) |
| # Move files |
| incDir = os.sep.join([archdir,'include']) |
| libDir = os.sep.join([archdir,'lib']) |
| os.rename(os.path.join(destDir,'lib/libBLOPEX.'+petscconf.AR_LIB_SUFFIX),os.path.join(libDir,'libBLOPEX.'+petscconf.AR_LIB_SUFFIX)) |
| for root, dirs, files in os.walk(os.path.join(destDir,'include')): |
| for name in files: |
| os.rename(os.path.join(destDir,'include/'+name),os.path.join(incDir,name)) |
| # Write configuration files |
| conf.write('#ifndef SLEPC_HAVE_BLOPEX\n#define SLEPC_HAVE_BLOPEX 1\n#endif\n\n') |
| vars.write('BLOPEX_LIB = -L' + libDir + ' -lBLOPEX\n') |
| cmake.write('set (SLEPC_HAVE_BLOPEX YES)\n') |
| cmake.write('find_library (BLOPEX_LIB BLOPEX HINTS '+ libDir +')\n') |
| return ['-L' + libDir] + ['-I' + incDir] |
| # |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # SLEPc - Scalable Library for Eigenvalue Problem Computations |
| # Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| # |
| # This file is part of SLEPc. |
| # |
| # SLEPc is free software: you can redistribute it and/or modify it under the |
| # terms of version 3 of the GNU Lesser General Public License as published by |
| # the Free Software Foundation. |
| # |
| # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| # more details. |
| # |
| # You should have received a copy of the GNU Lesser General Public License |
| # along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # |
| import os |
| import sys |
| import petscconf |
| import log |
| import check |
| def Check(conf,vars,cmake,tmpdir,directory,libs): |
| log.write('='*80) |
| log.Println('Checking PRIMME library...') |
| if petscconf.PRECISION == 'single': |
| log.Exit('ERROR: PRIMME does not support single precision.') |
| functions_base = ['primme_set_method','primme_Free','primme_initialize'] |
| if directory: |
| dirs = [directory] |
| else: |
| dirs = check.GenerateGuesses('Primme') |
| include = 'PRIMMESRC/COMMONSRC' |
| if not libs: |
| libs = ['-lprimme'] |
| if petscconf.SCALAR == 'real': |
| functions = functions_base + ['dprimme'] |
| else: |
| functions = functions_base + ['zprimme'] |
| for d in dirs: |
| if d: |
| l = ['-L' + d] + libs |
| f = ['-I' + d + '/' + include] |
| else: |
| l = libs |
| f = [] |
| if check.Link(tmpdir,functions,[],l+f): |
| conf.write('#ifndef SLEPC_HAVE_PRIMME\n#define SLEPC_HAVE_PRIMME 1\n#endif\n\n') |
| vars.write('PRIMME_LIB = ' + str.join(' ', l) + '\n') |
| vars.write('PRIMME_FLAGS = ' + str.join(' ', f) + '\n') |
| cmake.write('set (SLEPC_HAVE_PRIMME YES)\n') |
| cmake.write('find_library (PRIMME_LIB primme HINTS '+ d +')\n') |
| cmake.write('find_path (PRIMME_INCLUDE primme.h ' + d + '/PRIMMESRC/COMMONSRC)\n') |
| return l+f |
| log.Println('ERROR: Unable to link with PRIMME library') |
| log.Println('ERROR: In directories '+''.join([s+' ' for s in dirs])) |
| log.Println('ERROR: With flags '+''.join([s+' ' for s in libs])) |
| log.Exit('') |
| # |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # SLEPc - Scalable Library for Eigenvalue Problem Computations |
| # Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| # |
| # This file is part of SLEPc. |
| # |
| # SLEPc is free software: you can redistribute it and/or modify it under the |
| # terms of version 3 of the GNU Lesser General Public License as published by |
| # the Free Software Foundation. |
| # |
| # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| # more details. |
| # |
| # You should have received a copy of the GNU Lesser General Public License |
| # along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # |
| import os |
| import sys |
| import petscconf |
| import log |
| import check |
| def Check(conf,vars,cmake,tmpdir): |
| log.write('='*80) |
| log.Println('Checking LAPACK library...') |
| # LAPACK standard functions |
| l = ['laev2','gehrd','lanhs','lange','getri','trexc','trevc','geevx','ggevx','gelqf','gesdd','tgexc','tgevc','ggev'] |
| # LAPACK functions with different real and complex versions |
| if petscconf.SCALAR == 'real': |
| l += ['orghr','syevr','sygvd','ormlq','rot'] |
| if petscconf.PRECISION == 'single': |
| prefix = 's' |
| if petscconf.PRECISION == '__float128': |
| prefix = 'q' |
| else: |
| prefix = 'd' |
| else: |
| l += ['unghr','heevr','hegvd','unmlq','ungtr','hetrd'] |
| if petscconf.PRECISION == 'single': |
| prefix = 'c' |
| l += ['srot'] |
| if petscconf.PRECISION == '__float128': |
| prefix = 'w' |
| l += ['qrot'] |
| else: |
| prefix = 'z' |
| l += ['drot'] |
| # add prefix to LAPACK names |
| functions = [] |
| for i in l: |
| functions.append(prefix + i) |
| # LAPACK functions which are always used in real version |
| if petscconf.PRECISION == 'single': |
| functions += ['sstevr','sbdsdc','ssteqr','sorgtr','ssytrd','slamch','slag2','slasv2'] |
| elif petscconf.PRECISION == '__float128': |
| functions += ['qstevr','qbdsdc','qsteqr','qorgtr','qsytrd','qlamch','qlag2','qlasv2'] |
| else: |
| functions += ['dstevr','dbdsdc','dsteqr','dorgtr','dsytrd','dlamch','dlag2','dlasv2'] |
| # check for all functions at once |
| all = [] |
| for i in functions: |
| f = '#if defined(PETSC_BLASLAPACK_UNDERSCORE)\n' |
| f += i + '_\n' |
| f += '#elif defined(PETSC_BLASLAPACK_CAPS) || defined(PETSC_BLASLAPACK_STDCALL)\n' |
| f += i.upper() + '\n' |
| f += '#else\n' |
| f += i + '\n' |
| f += '#endif\n' |
| all.append(f) |
| log.write('=== Checking all LAPACK functions...') |
| if check.Link(tmpdir,all,[],[]): |
| return [] |
| # check functions one by one |
| missing = [] |
| for i in functions: |
| f = '#if defined(PETSC_BLASLAPACK_UNDERSCORE)\n' |
| f += i + '_\n' |
| f += '#elif defined(PETSC_BLASLAPACK_CAPS) || defined(PETSC_BLASLAPACK_STDCALL)\n' |
| f += i.upper() + '\n' |
| f += '#else\n' |
| f += i + '\n' |
| f += '#endif\n' |
| log.write('=== Checking LAPACK '+i+' function...') |
| if not check.Link(tmpdir,[f],[],[]): |
| missing.append(i) |
| conf.write('#ifndef SLEPC_MISSING_LAPACK_' + i[1:].upper() + '\n#define SLEPC_MISSING_LAPACK_' + i[1:].upper() + ' 1\n#endif\n\n') |
| cmake.write('set (SLEPC_MISSING_LAPACK_' + i[1:].upper() + ' YES)\n') |
| if missing: |
| cmake.write('mark_as_advanced (' + ''.join([s.upper()+' ' for s in missing]) + ')\n') |
| return missing |
| # |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # SLEPc - Scalable Library for Eigenvalue Problem Computations |
| # Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| # |
| # This file is part of SLEPc. |
| # |
| # SLEPc is free software: you can redistribute it and/or modify it under the |
| # terms of version 3 of the GNU Lesser General Public License as published by |
| # the Free Software Foundation. |
| # |
| # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| # more details. |
| # |
| # You should have received a copy of the GNU Lesser General Public License |
| # along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # |
| import os |
| import sys |
| import petscconf |
| import check |
| def Check(conf,vars,cmake,tmpdir,directory,libs): |
| if petscconf.SCALAR == 'real': |
| if petscconf.PRECISION == 'single': |
| functions = ['psnaupd','psneupd','pssaupd','psseupd'] |
| else: |
| functions = ['pdnaupd','pdneupd','pdsaupd','pdseupd'] |
| else: |
| if petscconf.PRECISION == 'single': |
| functions = ['pcnaupd','pcneupd'] |
| else: |
| functions = ['pznaupd','pzneupd'] |
| if libs: |
| libs = [libs] |
| else: |
| libs = [['-lparpack','-larpack'],['-lparpack_MPI','-larpack'],['-lparpack_MPI-LINUX','-larpack_LINUX'],['-lparpack_MPI-SUN4','-larpack_SUN4']] |
| if directory: |
| dirs = [directory] |
| else: |
| dirs = check.GenerateGuesses('Arpack') |
| return check.FortranLib(tmpdir,conf,vars,cmake,'ARPACK',dirs,libs,functions) |
| # |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # SLEPc - Scalable Library for Eigenvalue Problem Computations |
| # Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| # |
| # This file is part of SLEPc. |
| # |
| # SLEPc is free software: you can redistribute it and/or modify it under the |
| # terms of version 3 of the GNU Lesser General Public License as published by |
| # the Free Software Foundation. |
| # |
| # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| # more details. |
| # |
| # You should have received a copy of the GNU Lesser General Public License |
| # along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # |
| import os |
| import sys |
| import log |
| import petscconf |
| import urllib |
| import urlparse |
| import tarfile |
| def Install(): |
| ''' |
| Download and uncompress the slepc4py tarball |
| ''' |
| log.write('='*80) |
| log.Println('Installing slepc4py...') |
| # Test whether PETSc was installed with petsc4py |
| petscdir = os.environ['PETSC_DIR'] |
| petscconf.Load(petscdir) |
| archdir = os.sep.join([petscdir,petscconf.ARCH]) |
| if petscconf.ISINSTALL: |
| petsc4pydir = os.sep.join([petscdir,'lib/petsc4py']) |
| else: |
| petsc4pydir = os.sep.join([archdir,'lib/petsc4py']) |
| if not os.path.exists(petsc4pydir): |
| sys.exit('ERROR: current PETSc configuration does not include petsc4py support' + petsc4pydir) |
| # Create externalpackages directory |
| externdir = 'externalpackages' |
| if not os.path.exists(externdir): |
| try: |
| os.mkdir(externdir) |
| except: |
| sys.exit('ERROR: cannot create directory ' + externdir) |
| # Download tarball |
| packagename = 'slepc4py-1.0.0' |
| url = 'http://slepc4py.googlecode.com/files/'+packagename+'.tar.gz' |
| archiveZip = 'slepc4py.tgz' |
| localFile = os.sep.join([externdir,archiveZip]) |
| log.Println('Downloading '+url+' to '+localFile) |
| if os.path.exists(localFile): |
| os.remove(localFile) |
| try: |
| urllib.urlretrieve(url, localFile) |
| except Exception, e: |
| name = 'slepc4py' |
| filename = os.path.basename(urlparse.urlparse(url)[2]) |
| failureMessage = '''\ |
| Unable to download package %s from: %s |
| * If your network is disconnected - please reconnect and rerun config/configure.py |
| * Alternatively, you can download the above URL manually, to /yourselectedlocation/%s |
| and use the configure option: |
| --download-%s=/yourselectedlocation/%s |
| ''' % (name, url, filename, name, filename) |
| raise RuntimeError(failureMessage) |
| # Uncompress tarball |
| destDir = os.sep.join([externdir,packagename]) |
| log.Println('Uncompressing '+localFile+' to directory '+destDir) |
| if os.path.exists(destDir): |
| for root, dirs, files in os.walk(destDir, topdown=False): |
| for name in files: |
| os.remove(os.path.join(root, name)) |
| for name in dirs: |
| os.rmdir(os.path.join(root, name)) |
| try: |
| tar = tarfile.open(localFile, "r:gz") |
| tar.extractall(path=externdir) |
| tar.close() |
| except RuntimeError, e: |
| raise RuntimeError('Error uncompressing '+archiveZip+': '+str(e)) |
| os.remove(localFile) |
| def addMakeRule(slepcrules,installdir,prefixinstall,getslepc4py): |
| ''' |
| Add a rule to the makefile in order to build slepc4py |
| ''' |
| if getslepc4py: |
| target = 'slepc4py' |
| slepcrules.write(target+':\n') |
| externdir = 'externalpackages' |
| packagename = 'slepc4py-1.0.0' |
| destDir = os.sep.join([externdir,packagename]) |
| cmd = '@cd '+destDir |
| slepcrules.write('\t'+cmd+'; \\\n') |
| cmd = 'python setup.py clean --all' |
| slepcrules.write('\t'+cmd+'; \\\n') |
| cmd = 'python setup.py install --install-lib='+os.path.join(installdir,'lib') |
| slepcrules.write('\t'+cmd+'\n') |
| cmd = '@echo "====================================="' |
| slepcrules.write('\t'+cmd+'\n') |
| cmd = '@echo "To use slepc4py, add '+os.path.join(installdir,'lib')+' to PYTHONPATH"' |
| slepcrules.write('\t'+cmd+'\n') |
| cmd = '@echo "====================================="' |
| slepcrules.write('\t'+cmd+'\n') |
| else: |
| if prefixinstall: |
| target = 'slepc4py' |
| slepcrules.write(target+':\n') |
| cmd = '@echo " "' |
| slepcrules.write('\t'+cmd+'\n') |
| target = 'slepc4py_noinstall' |
| if getslepc4py and not prefixinstall: |
| slepcrules.write(target+': slepc4py\n') |
| else: |
| slepcrules.write(target+':\n') |
| #!/usr/bin/env python |
| import os,sys,string |
| from collections import deque |
| sys.path.insert(0, os.path.join(os.environ['PETSC_DIR'], 'config')) |
| sys.path.insert(0, os.path.join(os.environ['PETSC_DIR'], 'config', 'BuildSystem')) |
| import script |
| def noCheck(command, status, output, error): |
| return |
| def quoteIfNeeded(path): |
| "Don't need quotes unless the path has bits that would confuse the shell" |
| safe = string.letters + string.digits + os.path.sep + os.path.pardir + '-_' |
| if set(path).issubset(safe): |
| return path |
| else: |
| return '"' + path + '"' |
| class StdoutLogger(object): |
| def write(self,str): |
| print(str) |
| class PETScMaker(script.Script): |
| def __init__(self, slepcdir, petscdir, petscarch, argDB = None, framework = None): |
| import RDict |
| if not argDB: |
| argDB = RDict.RDict(None, None, 0, 0, readonly = True) |
| argDB.saveFilename = os.path.join(petscdir,petscarch,'conf','RDict.db') |
| argDB.load() |
| script.Script.__init__(self, argDB = argDB) |
| self.framework = framework |
| self.slepcdir = slepcdir |
| def __str__(self): |
| return '' |
| def setupModules(self): |
| self.mpi = self.framework.require('config.packages.MPI', None) |
| self.base = self.framework.require('config.base', None) |
| self.setCompilers = self.framework.require('config.setCompilers', None) |
| self.arch = self.framework.require('PETSc.utilities.arch', None) |
| self.petscdir = self.framework.require('PETSc.utilities.petscdir', None) |
| self.languages = self.framework.require('PETSc.utilities.languages', None) |
| self.debugging = self.framework.require('PETSc.utilities.debugging', None) |
| self.make = self.framework.require('config.programs', None) |
| self.cmake = self.framework.require('PETSc.utilities.CMake', None) |
| self.CHUD = self.framework.require('PETSc.utilities.CHUD', None) |
| self.compilers = self.framework.require('config.compilers', None) |
| self.types = self.framework.require('config.types', None) |
| self.headers = self.framework.require('config.headers', None) |
| self.functions = self.framework.require('config.functions', None) |
| self.libraries = self.framework.require('config.libraries', None) |
| self.scalarType = self.framework.require('PETSc.utilities.scalarTypes', None) |
| self.memAlign = self.framework.require('PETSc.utilities.memAlign', None) |
| self.libraryOptions= self.framework.require('PETSc.utilities.libraryOptions', None) |
| self.compilerFlags = self.framework.require('config.compilerFlags', self) |
| return |
| def setup(self): |
| script.Script.setup(self) |
| if not self.framework: |
| self.framework = self.loadConfigure() |
| self.setupModules() |
| def cmakeboot(self, args, log): |
| self.setup() |
| if not hasattr(self.cmake,'cmake'): return |
| options = deque() |
| langlist = [('C','C')] |
| if hasattr(self.compilers,'FC'): |
| langlist.append(('FC','Fortran')) |
| if (self.languages.clanguage == 'Cxx'): |
| langlist.append(('Cxx','CXX')) |
| win32fe = None |
| for petsclanguage,cmakelanguage in langlist: |
| self.setCompilers.pushLanguage(petsclanguage) |
| compiler = self.setCompilers.getCompiler() |
| flags = [self.setCompilers.getCompilerFlags(), |
| self.setCompilers.CPPFLAGS, |
| self.CHUD.CPPFLAGS] |
| if compiler.split()[0].endswith('win32fe'): # Hack to support win32fe without changing the rest of configure |
| win32fe = compiler.split()[0] + '.exe' |
| compiler = ' '.join(compiler.split()[1:]) |
| options.append('-DCMAKE_'+cmakelanguage+'_FLAGS=' + ''.join(flags)) |
| options.append('-DCMAKE_'+cmakelanguage+'_COMPILER=' + compiler) |
| self.setCompilers.popLanguage() |
| if win32fe: |
| options.append('-DPETSC_WIN32FE:FILEPATH=%s'%win32fe) |
| # Default on Windows is to generate Visual Studio project files, but |
| # 1. the build process for those is different, need to give different build instructions |
| # 2. the current WIN32FE workaround does not work with VS project files |
| options.append('-GUnix Makefiles') |
| cmd = [self.cmake.cmake, self.slepcdir] + map(lambda x:x.strip(), options) + args |
| archdir = os.path.join(self.slepcdir, self.arch.arch) |
| log.write('Invoking: %s\n' % cmd) |
| output,error,retcode = self.executeShellCommand(cmd, checkCommand = noCheck, log=log, cwd=archdir) |
| if retcode: |
| self.logPrintBox('CMake process failed with status %d. Proceeding..' % (retcode,)) |
| return False |
| else: |
| return True |
| return |
| def main(slepcdir, petscdir, petscarch, argDB=None, framework=None, log=StdoutLogger(), args=[]): |
| # This can be called as a stand-alone program, or by importing it from |
| # python. The latter functionality is needed because argDB does not |
| # get written until the very end of configure, but we want to run this |
| # automatically during configure (if CMake is available). |
| # |
| # Strangely, we can't store log in the PETScMaker because |
| # (somewhere) it creeps into framework (which I don't want to modify) |
| # and makes the result unpickleable. This is not a problem when run |
| # as a standalone program (because the database is read-only), but is |
| # not okay when called from configure. |
| return PETScMaker(slepcdir,petscdir,petscarch,argDB,framework).cmakeboot(args,log) |
| if __name__ == "__main__": |
| main(slepcdir=os.environ['SLEPC_DIR'], petscdir=os.environ['PETSC_DIR'], petscarch=os.environ['PETSC_ARCH'], args=sys.argv[1:]) |
| #!/usr/bin/env python |
| #!/bin/env python |
| # |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # SLEPc - Scalable Library for Eigenvalue Problem Computations |
| # Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| # |
| # This file is part of SLEPc. |
| # |
| # SLEPc is free software: you can redistribute it and/or modify it under the |
| # terms of version 3 of the GNU Lesser General Public License as published by |
| # the Free Software Foundation. |
| # |
| # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| # more details. |
| # |
| # You should have received a copy of the GNU Lesser General Public License |
| # along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # |
| # Generates fortran stubs for PETSc using Sowings bfort program |
| # |
| import os |
| # |
| # Opens all generated files and fixes them |
| # |
| def FixFile(filename): |
| import re |
| ff = open(filename) |
| data = ff.read() |
| ff.close() |
| # gotta be a better way to do this |
| data = re.subn('\nvoid ','\nvoid PETSC_STDCALL ',data)[0] |
| data = re.subn('\nPetscErrorCode ','\nvoid PETSC_STDCALL ',data)[0] |
| data = re.subn('Petsc([ToRm]*)Pointer\(int\)','Petsc\\1Pointer(void*)',data)[0] |
| data = re.subn('PetscToPointer\(a\) \(a\)','PetscToPointer(a) (*(long *)(a))',data)[0] |
| data = re.subn('PetscFromPointer\(a\) \(int\)\(a\)','PetscFromPointer(a) (long)(a)',data)[0] |
| data = re.subn('PetscToPointer\( \*\(int\*\)','PetscToPointer(',data)[0] |
| data = re.subn('MPI_Comm comm','MPI_Comm *comm',data)[0] |
| data = re.subn('\(MPI_Comm\)PetscToPointer\( \(comm\) \)','MPI_Comm_f2c(*(MPI_Fint*)(comm))',data)[0] |
| data = re.subn('\(PetscInt\* \)PetscToPointer','',data)[0] |
| match = re.compile(r"""\b(PETSC)(_DLL|VEC_DLL|MAT_DLL|DM_DLL|KSP_DLL|SNES_DLL|TS_DLL|FORTRAN_DLL)(EXPORT)""") |
| data = match.sub(r'',data) |
| ff = open(filename, 'w') |
| ff.write('#include "petscsys.h"\n#include "petscfix.h"\n#include "private/fortranimpl.h"\n'+data) |
| ff.close() |
| return |
| def FixDir(petscdir,dir): |
| mansec = 'unknown' |
| cnames = [] |
| hnames = [] |
| parentdir =os.path.abspath(os.path.join(dir,'..')) |
| for f in os.listdir(dir): |
| ext = os.path.splitext(f)[1] |
| if ext == '.c': |
| FixFile(os.path.join(dir, f)) |
| cnames.append(f) |
| elif ext == '.h90': |
| hnames.append(f) |
| if (cnames != [] or hnames != []): |
| mfile=os.path.abspath(os.path.join(parentdir,'makefile')) |
| try: |
| fd=open(mfile,'r') |
| except: |
| print 'Error! missing file:', mfile |
| return |
| inbuf = fd.read() |
| fd.close() |
| cppflags = "" |
| libbase = "" |
| locdir = "" |
| for line in inbuf.splitlines(): |
| if line.find('CPPFLAGS') >=0: |
| cppflags = line |
| if line.find('LIBBASE') >=0: |
| libbase = line |
| elif line.find('LOCDIR') >=0: |
| locdir = line.rstrip() + 'ftn-auto/' |
| elif line.find('MANSEC') >=0: |
| mansec = line.split('=')[1].lower().strip() |
| # now assemble the makefile |
| outbuf = '\n' |
| outbuf += "#requiresdefine 'PETSC_HAVE_FORTRAN'\n" |
| outbuf += 'ALL: lib\n' |
| outbuf += cppflags + '\n' |
| outbuf += 'CFLAGS =\n' |
| outbuf += 'FFLAGS =\n' |
| outbuf += 'SOURCEC = ' +' '.join(cnames)+ '\n' |
| outbuf += 'OBJSC = ' +' '.join(cnames).replace('.c','.o')+ '\n' |
| outbuf += 'SOURCEF =\n' |
| outbuf += 'SOURCEH = ' +' '.join(hnames)+ '\n' |
| outbuf += 'DIRS =\n' |
| outbuf += libbase + '\n' |
| outbuf += locdir + '\n' |
| outbuf += 'include ${SLEPC_DIR}/conf/slepc_common \n' |
| ff = open(os.path.join(dir, 'makefile'), 'w') |
| ff.write(outbuf) |
| ff.close() |
| # if dir is empty - remove it |
| if os.path.exists(dir) and os.path.isdir(dir) and os.listdir(dir) == []: |
| os.rmdir(dir) |
| # save Fortran interface file generated (it is merged with others in a post-processing step) |
| modfile = os.path.join(parentdir,'f90module.f90') |
| if os.path.exists(modfile): |
| fd = open(modfile) |
| txt = fd.read() |
| fd.close() |
| if txt and mansec == 'unknown': |
| print 'makefile has missing MANSEC',parentdir |
| elif txt: |
| ftype = 'w' |
| f90inc = os.path.join(petscdir,'include','finclude','ftn-auto','slepc'+mansec+'.h90') |
| if os.path.exists(f90inc): ftype = 'a' |
| fd = open(f90inc,ftype) |
| fd.write(txt) |
| fd.close() |
| os.remove(modfile) |
| return |
| def PrepFtnDir(dir): |
| if os.path.exists(dir) and not os.path.isdir(dir): |
| raise RuntimeError('Error - specified path is not a dir: ' + dir) |
| elif not os.path.exists(dir): |
| os.mkdir(dir) |
| else: |
| files = os.listdir(dir) |
| for file in files: |
| os.remove(os.path.join(dir,file)) |
| return |
| def processDir(arg,dirname,names): |
| import commands |
| petscdir = arg[0] |
| bfort = arg[1] |
| newls = [] |
| outdir = os.path.join(dirname,'ftn-auto') |
| # skip include/finclude/ftn-auto - as this is processed separately |
| if os.path.realpath(os.path.join(petscdir,'include','finclude','ftn-auto')) == os.path.realpath(outdir): return |
| for l in names: |
| if os.path.splitext(l)[1] =='.c' or os.path.splitext(l)[1] == '.h': |
| newls.append(l) |
| if newls: |
| PrepFtnDir(outdir) |
| options = ['-dir '+outdir, '-mnative', '-ansi', '-nomsgs', '-noprofile', '-anyname', '-mapptr', |
| '-mpi', '-mpi2', '-ferr', '-ptrprefix Petsc', '-ptr64 PETSC_USE_POINTER_CONVERSION', |
| '-fcaps PETSC_HAVE_FORTRAN_CAPS', '-fuscore PETSC_HAVE_FORTRAN_UNDERSCORE', |
| '-f90mod_skip_header','-f90modfile','f90module.f90'] |
| (status,output) = commands.getstatusoutput('cd '+dirname+';'+bfort+' '+' '.join(options+newls)) |
| if status: |
| raise RuntimeError('Error running bfort '+output) |
| FixDir(petscdir,outdir) |
| for name in ['.hg','SCCS', 'output', 'BitKeeper', 'examples', 'externalpackages', 'bilinear', 'ftn-auto','fortran','bin','maint','ftn-custom','config','f90-custom']: |
| if name in names: |
| names.remove(name) |
| # check for configure generated PETSC_ARCHes |
| rmnames=[] |
| for name in names: |
| if os.path.isdir(os.path.join(name,'conf')): |
| rmnames.append(name) |
| for rmname in rmnames: |
| names.remove(rmname) |
| return |
| def main(bfort): |
| petscdir = os.getcwd() |
| tmpdir = os.path |
| ftnautoinc = os.path.join(petscdir,'include','finclude','ftn-auto') |
| PrepFtnDir(ftnautoinc) |
| os.path.walk(petscdir, processDir, [petscdir, bfort]) |
| FixDir(petscdir,ftnautoinc) |
| return |
| # |
| # The classes in this file can also be used in other python-programs by using 'import' |
| # |
| if __name__ == '__main__': |
| import sys |
| if len(sys.argv) < 2: |
| sys.exit('Must give the BFORT program as the first argument') |
| main(sys.argv[1]) |
| #!/usr/bin/env python |
| from __future__ import with_statement # For python-2.5 |
| import os |
| from collections import defaultdict, deque |
| # Run with --verbose |
| VERBOSE = False |
| def cmakeconditional(key,val): |
| def unexpected(): |
| raise RuntimeError('Unexpected') |
| if key in ['package', 'function', 'define']: |
| return val |
| if key == 'precision': |
| if val == 'double': |
| return 'PETSC_USE_REAL_DOUBLE' |
| elif val == 'single': |
| return 'PETSC_USE_REAL_SINGLE' |
| raise RuntimeError('Unexpected precision: %r'%val) |
| if key == 'scalar': |
| if val == 'real': |
| return 'NOT PETSC_USE_COMPLEX' |
| if val == 'complex': |
| return 'PETSC_USE_COMPLEX' |
| raise RuntimeError('Unexpected scalar: %r'%val) |
| if key == 'language': |
| if val == 'CXXONLY': |
| return 'PETSC_CLANGUAGE_Cxx' |
| if val == 'CONLY': |
| return 'PETSC_CLANGUAGE_C' |
| raise RuntimeError('Unexpected language: %r'%val) |
| raise RuntimeException('Unhandled case: %r=%r'%(key,val)) |
| def pkgsources(pkg): |
| ''' |
| Walks the source tree associated with 'pkg', analyzes the conditional written into the makefiles, |
| and returns a list of sources associated with each unique conditional (as a dictionary). |
| ''' |
| from distutils.sysconfig import parse_makefile |
| autodirs = set('ftn-auto ftn-custom f90-custom'.split()) # Automatically recurse into these, if they exist |
| skipdirs = set('examples benchmarks'.split()) # Skip these during the build |
| def compareDirLists(mdirs,dirs): |
| if not VERBOSE: return |
| smdirs = set(mdirs) |
| sdirs = set(dirs).difference(autodirs) |
| if smdirs != sdirs: |
| from sys import stderr |
| print >>stderr, ('Directory mismatch at %s:\n\t%s: %r\n\t%s: %r\n\t%s: %r' |
| % (root, |
| 'in makefile ',sorted(smdirs), |
| 'on filesystem ',sorted(sdirs), |
| 'symmetric diff',sorted(smdirs.symmetric_difference(sdirs)))) |
| def compareSourceLists(msources, files): |
| if not VERBOSE: return |
| smsources = set(msources) |
| ssources = set(f for f in files if os.path.splitext(f)[1] in ['.c', '.cxx', '.cc', '.cpp', '.F']) |
| if smsources != ssources: |
| from sys import stderr |
| print >>stderr, ('Source mismatch at %s:\n\t%s: %r\n\t%s: %r\n\t%s: %r' |
| % (root, |
| 'in makefile ',sorted(smsources), |
| 'on filesystem ',sorted(ssources), |
| 'symmetric diff',sorted(smsources.symmetric_difference(ssources)))) |
| allconditions = defaultdict(set) |
| sources = defaultdict(deque) |
| for root,dirs,files in os.walk(os.path.join('src',pkg)): |
| conditions = allconditions[os.path.dirname(root)].copy() |
| makefile = os.path.join(root,'makefile') |
| if not os.path.exists(makefile): |
| continue |
| makevars = parse_makefile(makefile) |
| mdirs = makevars.get('DIRS','').split() # Directories specified in the makefile |
| compareDirLists(mdirs,dirs) # diagnostic output to find unused directories |
| candidates = set(mdirs).union(autodirs).difference(skipdirs) |
| dirs[:] = list(candidates.intersection(dirs)) |
| with open(makefile) as lines: |
| def stripsplit(line): |
| return filter(lambda c: c!="'", line[len('#requires'):]).split() |
| conditions.update(set(tuple(stripsplit(line)) for line in lines if line.startswith('#requires'))) |
| def relpath(filename): |
| return os.path.join(root,filename) |
| sourcec = makevars.get('SOURCEC','').split() |
| sourcef = makevars.get('SOURCEF','').split() |
| compareSourceLists(sourcec+sourcef, files) # Diagnostic output about unused source files |
| sources[repr(sorted(conditions))].extend(relpath(f) for f in sourcec + sourcef) |
| allconditions[root] = conditions |
| return sources |
| def writeRoot(f,petscdir,petscarch): |
| f.write(r'''cmake_minimum_required (VERSION 2.6.2) |
| project (SLEPc C) |
| set (PETSc_SOURCE_DIR %s) |
| set (PETSc_BINARY_DIR %s) |
| include (${PETSc_BINARY_DIR}/conf/PETScConfig.cmake) |
| include (${SLEPc_BINARY_DIR}/conf/SLEPcConfig.cmake) |
| if (PETSC_HAVE_FORTRAN) |
| enable_language (Fortran) |
| endif () |
| if (PETSC_CLANGUAGE_Cxx) |
| enable_language (CXX) |
| endif () |
| include_directories ("${PETSc_SOURCE_DIR}/include" "${PETSc_BINARY_DIR}/include") |
| include_directories ("${SLEPc_SOURCE_DIR}/include" "${SLEPc_BINARY_DIR}/include") |
| add_definitions (-D__INSDIR__= ) # CMake always uses the absolute path |
| set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${SLEPc_BINARY_DIR}/lib" CACHE PATH "Output directory for SLEPc archives") |
| set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "${SLEPc_BINARY_DIR}/lib" CACHE PATH "Output directory for SLEPc libraries") |
| set (CMAKE_Fortran_MODULE_DIRECTORY "${SLEPc_BINARY_DIR}/include" CACHE PATH "Output directory for fortran *.mod files") |
| mark_as_advanced (CMAKE_ARCHIVE_OUTPUT_DIRECTORY CMAKE_LIBRARY_OUTPUT_DIRECTORY CMAKE_Fortran_MODULE_DIRECTORY) |
| set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") |
| set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) |
| ################### The following describes the build #################### |
| ''' % (petscdir,os.sep.join([petscdir,petscarch]))) |
| def writePackage(f,pkg,pkgdeps): |
| for conds, srcs in pkgsources(pkg).items(): |
| conds = eval(conds) |
| def body(indentlevel): |
| indent = ' '*(indentlevel+2) |
| lfindent = '\n'+indent |
| return ' '*indentlevel + 'list (APPEND SLEPC' + pkg.upper() + '_SRCS' + lfindent + lfindent.join(srcs) + lfindent + ')\n' |
| if conds: |
| f.write('if (%s)\n%sendif ()\n' % (' AND '.join(cmakeconditional(*c) for c in conds), body(2))) |
| else: |
| f.write(body(0)) |
| def main(slepcdir,petscdir,petscarch): |
| import tempfile, shutil |
| written = False # We delete the temporary file if it wasn't finished, otherwise rename (atomic) |
| fd,tmplists = tempfile.mkstemp(prefix='CMakeLists.txt.',dir=slepcdir,text=True) |
| try: |
| with os.fdopen(fd,'w') as f: |
| writeRoot(f,petscdir,petscarch) |
| f.write('include_directories (${PETSC_PACKAGE_INCLUDES} ${SLEPC_PACKAGE_INCLUDES})\n') |
| pkglist = [('sys' , ''), |
| ('vec' , 'sys'), |
| ('ip' , 'sys'), |
| ('st' , 'ip sys'), |
| ('eps' , 'ip st vec sys'), |
| ('svd' , 'eps ip sys'), |
| ('qep' , 'eps ip sys')] |
| for pkg,deps in pkglist: |
| writePackage(f,pkg,deps.split()) |
| f.write (''' |
| add_library (slepc %s) |
| target_link_libraries (slepc ${PETSC_LIB} ${SLEPC_PACKAGE_LIBS} ${PETSC_PACKAGE_LIBS}) |
| if (PETSC_WIN32FE) |
| set_target_properties (slepc PROPERTIES RULE_LAUNCH_COMPILE "${PETSC_WIN32FE}") |
| set_target_properties (slepc PROPERTIES RULE_LAUNCH_LINK "${PETSC_WIN32FE}") |
| endif () |
| ''' % (' '.join([r'${SLEPC' + pkg.upper() + r'_SRCS}' for pkg,deps in pkglist]),)) |
| f.write(''' |
| if (PETSC_CLANGUAGE_Cxx) |
| foreach (file IN LISTS %s) |
| if (file MATCHES "^.*\\\\.c$") |
| set_source_files_properties(${file} PROPERTIES LANGUAGE CXX) |
| endif () |
| endforeach () |
| endif()''' % ('\n '.join([r'SLEPC' + pkg.upper() + r'_SRCS' for (pkg,_) in pkglist]))) |
| written = True |
| finally: |
| if written: |
| shutil.move(tmplists,os.path.join(slepcdir,'CMakeLists.txt')) |
| else: |
| os.remove(tmplists) |
| if __name__ == "__main__": |
| import optparse |
| parser = optparse.OptionParser() |
| parser.add_option('--verbose', help='Show mismatches between makefiles and the filesystem', dest='verbose', action='store_true', default=False) |
| (opts, extra_args) = parser.parse_args() |
| if opts.verbose: |
| VERBOSE = True |
| main(slepcdir=os.environ['SLEPC_DIR'],petscdir=os.environ['PETSC_DIR'],petscarch=os.environ['PETSC_ARCH']) |
| # |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # SLEPc - Scalable Library for Eigenvalue Problem Computations |
| # Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| # |
| # This file is part of SLEPc. |
| # |
| # SLEPc is free software: you can redistribute it and/or modify it under the |
| # terms of version 3 of the GNU Lesser General Public License as published by |
| # the Free Software Foundation. |
| # |
| # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| # more details. |
| # |
| # You should have received a copy of the GNU Lesser General Public License |
| # along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # |
| import os |
| import sys |
| import commands |
| import petscconf |
| import log |
| def LinkWithOutput(tmpdir,functions,callbacks,flags): |
| code = '#include "petscksp.h"\n' |
| code += 'EXTERN_C_BEGIN\n' |
| for f in functions: |
| code += 'extern int\n' + f + '();\n' |
| code += 'EXTERN_C_END\n' |
| for c in callbacks: |
| code += 'int '+ c + '() { return 0; } \n' |
| code += 'int main() {\n' |
| code += 'PetscInitialize(PETSC_NULL,PETSC_NULL,PETSC_NULL,PETSC_NULL);\n' |
| code += 'VecCreate(PETSC_NULL,PETSC_NULL);\n' |
| code += 'MatCreate(PETSC_NULL,PETSC_NULL);\n' |
| code += 'KSPCreate(PETSC_NULL,PETSC_NULL);\n' |
| for f in functions: |
| code += f + '();\n' |
| code += 'return 0;\n}\n' |
| cfile = open(os.sep.join([tmpdir,'checklink.c']),'w') |
| cfile.write(code) |
| cfile.close() |
| (result, output) = commands.getstatusoutput(petscconf.MAKE + ' -C ' + tmpdir + ' checklink TESTFLAGS="'+str.join(' ',flags)+'"') |
| try: os.remove('checklink.c') |
| except OSError: pass |
| if result: |
| return (0,code + output) |
| else: |
| return (1,code + output) |
| def Link(tmpdir,functions,callbacks,flags): |
| (result, output) = LinkWithOutput(tmpdir,functions,callbacks,flags) |
| log.write(output) |
| return result |
| def FortranLink(tmpdir,functions,callbacks,flags): |
| output = '\n=== With linker flags: '+str.join(' ',flags) |
| f = [] |
| for i in functions: |
| f.append(i+'_') |
| c = [] |
| for i in callbacks: |
| c.append(i+'_') |
| (result, output1) = LinkWithOutput(tmpdir,f,c,flags) |
| output1 = '\n====== With underscore Fortran names\n' + output1 |
| if result: return ('UNDERSCORE',output1) |
| f = [] |
| for i in functions: |
| f.append(i.upper()) |
| c = [] |
| for i in callbacks: |
| c.append(i.upper()) |
| (result, output2) = LinkWithOutput(tmpdir,f,c,flags) |
| output2 = '\n====== With capital Fortran names\n' + output2 |
| if result: return ('CAPS',output2) |
| (result, output3) = LinkWithOutput(tmpdir,functions,callbacks,flags) |
| output3 = '\n====== With unmodified Fortran names\n' + output3 |
| if result: return ('STDCALL',output3) |
| return ('',output + output1 + output2 + output3) |
| def GenerateGuesses(name): |
| installdirs = ['/usr/local','/opt'] |
| if 'HOME' in os.environ: |
| installdirs.insert(0,os.environ['HOME']) |
| dirs = [] |
| for i in installdirs: |
| dirs = dirs + [i + '/lib'] |
| for d in [name,name.upper(),name.lower()]: |
| dirs = dirs + [i + '/' + d] |
| dirs = dirs + [i + '/' + d + '/lib'] |
| dirs = dirs + [i + '/lib/' + d] |
| for d in dirs[:]: |
| if not os.path.exists(d): |
| dirs.remove(d) |
| dirs = [''] + dirs |
| return dirs |
| def FortranLib(tmpdir,conf,vars,cmake,name,dirs,libs,functions,callbacks = []): |
| log.write('='*80) |
| log.Println('Checking '+name+' library...') |
| error = '' |
| mangling = '' |
| for d in dirs: |
| for l in libs: |
| if d: |
| flags = ['-L' + d] + l |
| else: |
| flags = l |
| (mangling, output) = FortranLink(tmpdir,functions,callbacks,flags) |
| error += output |
| if mangling: break |
| if mangling: break |
| if mangling: |
| log.write(output) |
| else: |
| log.write(error) |
| log.Println('ERROR: Unable to link with library '+ name) |
| log.Println('ERROR: In directories '+''.join([s+' ' for s in dirs])) |
| log.Println('ERROR: With flags '+''.join([s+' ' for s in flags])) |
| log.Exit('') |
| conf.write('#ifndef SLEPC_HAVE_' + name + '\n#define SLEPC_HAVE_' + name + ' 1\n#define SLEPC_' + name + '_HAVE_'+mangling+' 1\n#endif\n\n') |
| vars.write(name + '_LIB = '+str.join(' ',flags)+'\n') |
| cmake.write('set (SLEPC_HAVE_' + name + ' YES)\n') |
| libname = ''.join([s.lstrip('-l')+' ' for s in l]) |
| cmake.write('set (' + name + '_LIB "")\nforeach (libname ' + libname + ')\n string (TOUPPER ${libname} LIBNAME)\n find_library (${LIBNAME}LIB ${libname} HINTS '+ d +')\n list (APPEND ' + name + '_LIB "${${LIBNAME}LIB}")\nendforeach()\n') |
| return flags |
| # |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # SLEPc - Scalable Library for Eigenvalue Problem Computations |
| # Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| # |
| # This file is part of SLEPc. |
| # |
| # SLEPc is free software: you can redistribute it and/or modify it under the |
| # terms of version 3 of the GNU Lesser General Public License as published by |
| # the Free Software Foundation. |
| # |
| # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| # more details. |
| # |
| # You should have received a copy of the GNU Lesser General Public License |
| # along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # |
| import os |
| import sys |
| import petscconf |
| import check |
| def Check(conf,vars,cmake,tmpdir,directory,libs): |
| if petscconf.SCALAR == 'complex': |
| sys.exit('ERROR: TRLAN does not support complex numbers.') |
| if petscconf.PRECISION == 'single': |
| sys.exit('ERROR: TRLAN does not support single precision.') |
| functions = ['trlan77'] |
| if libs: |
| libs = [libs] |
| else: |
| libs = [['-ltrlan_mpi']] |
| if directory: |
| dirs = [directory] |
| else: |
| dirs = check.GenerateGuesses('TRLan') |
| return check.FortranLib(tmpdir,conf,vars,cmake,'TRLAN',dirs,libs,functions) |
| #!/usr/bin/env python |
| # |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # SLEPc - Scalable Library for Eigenvalue Problem Computations |
| # Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| # |
| # This file is part of SLEPc. |
| # |
| # SLEPc is free software: you can redistribute it and/or modify it under the |
| # terms of version 3 of the GNU Lesser General Public License as published by |
| # the Free Software Foundation. |
| # |
| # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| # more details. |
| # |
| # You should have received a copy of the GNU Lesser General Public License |
| # along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # |
| import os |
| import sys |
| import time |
| import commands |
| import tempfile |
| import shutil |
| # Use en_US as language so that compiler messages are in English |
| if 'LC_LOCAL' in os.environ and os.environ['LC_LOCAL'] != '' and os.environ['LC_LOCAL'] != 'en_US' and os.environ['LC_LOCAL']!= 'en_US.UTF-8': os.environ['LC_LOCAL'] = 'en_US.UTF-8' |
| if 'LANG' in os.environ and os.environ['LANG'] != '' and os.environ['LANG'] != 'en_US' and os.environ['LANG'] != 'en_US.UTF-8': os.environ['LANG'] = 'en_US.UTF-8' |
| # should be run from the toplevel |
| configDir = os.path.abspath('config') |
| if not os.path.isdir(configDir): |
| raise RuntimeError('Run configure from $SLEPC_DIR, not '+os.path.abspath('.')) |
| sys.path.insert(0, configDir) |
| import petscversion |
| import petscconf |
| import log |
| import check |
| import arpack |
| import blzpack |
| import trlan |
| import lapack |
| import primme |
| import blopex |
| import slepc4py |
| if not hasattr(sys, 'version_info') or not sys.version_info[1] >= 2: |
| print '**** You must have Python version 2.2 or higher to run config/configure.py ******' |
| print '* Python is easy to install for end users or sys-admin. *' |
| print '* http://www.python.org/download/ *' |
| print '* *' |
| print '* You CANNOT configure SLEPc without Python *' |
| print '*********************************************************************************' |
| sys.exit(4) |
| # support a few standard configure option types |
| for l in range(1,len(sys.argv)): |
| name = sys.argv[l] |
| if name.startswith('--enable'): |
| sys.argv[l] = name.replace('--enable','--with') |
| if name.find('=') == -1: sys.argv[l] += '=1' |
| if name.startswith('--disable'): |
| sys.argv[l] = name.replace('--disable','--with') |
| if name.find('=') == -1: sys.argv[l] += '=0' |
| elif name.endswith('=1'): sys.argv[l].replace('=1','=0') |
| if name.startswith('--without'): |
| sys.argv[l] = name.replace('--without','--with') |
| if name.find('=') == -1: sys.argv[l] += '=0' |
| elif name.endswith('=1'): sys.argv[l].replace('=1','=0') |
| # Check configure parameters |
| havearpack = 0 |
| arpackdir = '' |
| arpacklibs = [] |
| haveblzpack = 0 |
| blzpackdir = '' |
| blzpacklibs = [] |
| havetrlan = 0 |
| trlandir = '' |
| trlanlibs = [] |
| haveprimme = 0 |
| primmedir = '' |
| primmelibs = [] |
| getblopex = 0 |
| haveblopex = 0 |
| blopexurl = '' |
| getslepc4py = 0 |
| prefixdir = '' |
| for i in sys.argv[1:]: |
| if i.startswith('--with-arpack-dir='): |
| arpackdir = i.split('=')[1] |
| havearpack = 1 |
| elif i.startswith('--with-arpack-flags='): |
| arpacklibs = i.split('=')[1].split(',') |
| havearpack = 1 |
| elif i.startswith('--with-arpack'): |
| havearpack = not i.endswith('=0') |
| elif i.startswith('--with-blzpack-dir='): |
| blzpackdir = i.split('=')[1] |
| haveblzpack = 1 |
| elif i.startswith('--with-blzpack-flags='): |
| blzpacklibs = i.split('=')[1].split(',') |
| haveblzpack = 1 |
| elif i.startswith('--with-blzpack'): |
| haveblzpack = not i.endswith('=0') |
| elif i.startswith('--with-trlan-dir='): |
| trlandir = i.split('=')[1] |
| havetrlan = 1 |
| elif i.startswith('--with-trlan-flags='): |
| trlanlibs = i.split('=')[1].split(',') |
| havetrlan = 1 |
| elif i.startswith('--with-trlan'): |
| havetrlan = not i.endswith('=0') |
| elif i.startswith('--with-primme-dir'): |
| primmedir = i.split('=')[1] |
| haveprimme = 1 |
| elif i.startswith('--with-primme-flags='): |
| primmelibs = i.split('=')[1].split(',') |
| haveprimme = 1 |
| elif i.startswith('--with-primme'): |
| haveprimme = not i.endswith('=0') |
| elif i.startswith('--download-blopex'): |
| getblopex = not i.endswith('=0') |
| try: blopexurl = i.split('=')[1] |
| except IndexError: pass |
| elif i.startswith('--download-slepc4py'): |
| getslepc4py = not i.endswith('=0') |
| elif i.startswith('--prefix='): |
| prefixdir = i.split('=')[1] |
| elif i.startswith('--h') or i.startswith('-h') or i.startswith('-?'): |
| print 'SLEPc Configure Help' |
| print '-'*80 |
| print ' --prefix=<dir> : Specify location to install SLEPc (e.g., /usr/local)' |
| print 'ARPACK:' |
| print ' --with-arpack : Indicate if you wish to test for ARPACK (PARPACK)' |
| print ' --with-arpack-dir=<dir> : Indicate the directory for ARPACK libraries' |
| print ' --with-arpack-flags=<flags> : Indicate comma-separated flags for linking ARPACK' |
| print 'BLZPACK:' |
| print ' --with-blzpack : Indicate if you wish to test for BLZPACK' |
| print ' --with-blzpack-dir=<dir> : Indicate the directory for BLZPACK libraries' |
| print ' --with-blzpack-flags=<flags> : Indicate comma-separated flags for linking BLZPACK' |
| print 'TRLAN:' |
| print ' --with-trlan : Indicate if you wish to test for TRLAN' |
| print ' --with-trlan-dir=<dir> : Indicate the directory for TRLAN libraries' |
| print ' --with-trlan-flags=<flags> : Indicate comma-separated flags for linking TRLAN' |
| print 'PRIMME:' |
| print ' --with-primme : Indicate if you wish to test for PRIMME' |
| print ' --with-primme-dir=<dir> : Indicate the directory for PRIMME libraries' |
| print ' --with-primme-flags=<flags> : Indicate comma-separated flags for linking PRIMME' |
| print 'BLOPEX:' |
| print ' --download-blopex : Download and install BLOPEX in SLEPc directory' |
| print 'slepc4py:' |
| print ' --download-slepc4py : Download and install slepc4py in SLEPc directory' |
| sys.exit(0) |
| else: |
| sys.exit('ERROR: Invalid argument ' + i +'. Use -h for help') |
| prefixinstall = not prefixdir=='' |
| # Check if enviroment is ok |
| print 'Checking environment...' |
| if 'SLEPC_DIR' in os.environ: |
| slepcdir = os.environ['SLEPC_DIR'] |
| if not os.path.exists(slepcdir) or not os.path.exists(os.sep.join([slepcdir,'config'])): |
| sys.exit('ERROR: SLEPC_DIR enviroment variable is not valid') |
| if os.path.realpath(os.getcwd()) != os.path.realpath(slepcdir): |
| sys.exit('ERROR: SLEPC_DIR is not the current directory') |
| else: |
| slepcdir = os.getcwd(); |
| if not os.path.exists(os.sep.join([slepcdir,'config'])): |
| sys.exit('ERROR: Current directory is not valid') |
| if 'PETSC_DIR' in os.environ: |
| petscdir = os.environ['PETSC_DIR'] |
| if not os.path.exists(petscdir): |
| sys.exit('ERROR: PETSC_DIR enviroment variable is not valid') |
| else: |
| if prefixdir: |
| petscdir = prefixdir |
| os.environ['PETSC_DIR'] = petscdir |
| else: |
| sys.exit('ERROR: PETSC_DIR enviroment variable is not set') |
| # Check PETSc version |
| petscversion.Load(petscdir) |
| if petscversion.VERSION < '3.2': |
| sys.exit('ERROR: This SLEPc version is not compatible with PETSc version '+petscversion.VERSION) |
| # Check some information about PETSc configuration |
| petscconf.Load(petscdir) |
| if not petscconf.PRECISION in ['double','single','__float128']: |
| sys.exit('ERROR: This SLEPc version does not work with '+petscconf.PRECISION+' precision') |
| if prefixinstall and not petscconf.ISINSTALL: |
| sys.exit('ERROR: SLEPc cannot be configured for non-source installation if PETSc is not configured in the same way.') |
| # Check whether this is a working copy of the Subversion repository |
| subversion = 0 |
| if os.path.exists(os.sep.join([slepcdir,'src','docs'])) and os.path.exists(os.sep.join([slepcdir,'.svn'])): |
| (result, output) = commands.getstatusoutput('svn info') |
| if result: |
| print 'WARNING: SLEPC_DIR appears to be a subversion working copy, but svn is not found in PATH' |
| else: |
| subversion = 1 |
| svnrev = '-1' |
| svndate = '-1' |
| for line in output.split('\n'): |
| if line.startswith('Last Changed Rev: '): |
| svnrev = line.split('Rev: ')[-1] |
| if line.startswith('Last Changed Date: '): |
| svndate = line.split('Date: ')[-1] |
| # Create architecture directory and configuration files |
| archdir = os.sep.join([slepcdir,petscconf.ARCH]) |
| if not os.path.exists(archdir): |
| try: |
| os.mkdir(archdir) |
| except: |
| sys.exit('ERROR: cannot create architecture directory ' + archdir) |
| confdir = os.sep.join([archdir,'conf']) |
| if not os.path.exists(confdir): |
| try: |
| os.mkdir(confdir) |
| except: |
| sys.exit('ERROR: cannot create configuration directory ' + confdir) |
| incdir = os.sep.join([archdir,'include']) |
| if not os.path.exists(incdir): |
| try: |
| os.mkdir(incdir) |
| except: |
| sys.exit('ERROR: cannot create include directory ' + incdir) |
| libdir = os.sep.join([archdir,'lib']) |
| if not os.path.exists(libdir): |
| try: |
| os.mkdir(libdir) |
| except: |
| sys.exit('ERROR: cannot create lib directory ' + libdir) |
| try: |
| slepcvars = open(os.sep.join([confdir,'slepcvariables']),'w') |
| if not prefixdir: |
| prefixdir = archdir |
| slepcvars.write('SLEPC_DESTDIR = ' + prefixdir +'\n') |
| testruns = set(petscconf.TEST_RUNS.split()) |
| testruns = testruns.intersection(set(['C','F90','Fortran','C_NoComplex','Fortran_NoComplex'])) |
| slepcvars.write('TEST_RUNS = ' + ' '.join(testruns) +'\n') |
| except: |
| sys.exit('ERROR: cannot create configuration file in ' + confdir) |
| try: |
| slepcrules = open(os.sep.join([confdir,'slepcrules']),'w') |
| except: |
| sys.exit('ERROR: cannot create rules file in ' + confdir) |
| try: |
| slepcconf = open(os.sep.join([incdir,'slepcconf.h']),'w') |
| slepcconf.write('#if !defined(__SLEPCCONF_H)\n') |
| slepcconf.write('#define __SLEPCCONF_H\n\n') |
| if subversion: |
| slepcconf.write('#ifndef SLEPC_VERSION_SVN\n#define SLEPC_VERSION_SVN ' + svnrev + '\n#endif\n\n') |
| slepcconf.write('#ifndef SLEPC_VERSION_DATE_SVN\n#define SLEPC_VERSION_DATE_SVN "' + svndate + '"\n#endif\n\n') |
| slepcconf.write('#ifndef SLEPC_LIB_DIR\n#define SLEPC_LIB_DIR "' + prefixdir + '/lib"\n#endif\n\n') |
| except: |
| sys.exit('ERROR: cannot create configuration header in ' + confdir) |
| try: |
| cmake = open(os.sep.join([confdir,'SLEPcConfig.cmake']),'w') |
| except: |
| sys.exit('ERROR: cannot create CMake configuration file in ' + confdir) |
| if prefixinstall and os.path.isfile(os.sep.join([prefixdir,'include','slepc.h'])): |
| sys.exit('ERROR: prefix directory ' + prefixdir + ' contains files from a previous installation') |
| # Create temporary directory and makefile for running tests |
| try: |
| tmpdir = tempfile.mkdtemp(prefix='slepc-') |
| if not os.path.isdir(tmpdir): os.mkdir(tmpdir) |
| except: |
| sys.exit('ERROR: cannot create temporary directory') |
| try: |
| makefile = open(os.sep.join([tmpdir,'makefile']),'w') |
| makefile.write('checklink: checklink.o chkopts\n') |
| makefile.write('\t${CLINKER} -o checklink checklink.o ${TESTFLAGS} ${PETSC_KSP_LIB}\n') |
| makefile.write('\t@${RM} -f checklink checklink.o\n') |
| makefile.write('LOCDIR = ./\n') |
| makefile.write('include ${PETSC_DIR}/conf/variables\n') |
| makefile.write('include ${PETSC_DIR}/conf/rules\n') |
| makefile.close() |
| except: |
| sys.exit('ERROR: cannot create makefile in temporary directory') |
| # Open log file |
| log.Open(os.sep.join([confdir,'configure.log'])) |
| log.write('='*80) |
| log.write('Starting Configure Run at '+time.ctime(time.time())) |
| log.write('Configure Options: '+str.join(' ',sys.argv)) |
| log.write('Working directory: '+os.getcwd()) |
| log.write('Python version:\n' + sys.version) |
| log.write('make: ' + petscconf.MAKE) |
| log.write('PETSc source directory: ' + petscdir) |
| log.write('PETSc install directory: ' + petscconf.DESTDIR) |
| log.write('PETSc version: ' + petscversion.VERSION) |
| log.write('PETSc architecture: ' + petscconf.ARCH) |
| log.write('SLEPc source directory: ' + slepcdir) |
| log.write('SLEPc install directory: ' + prefixdir) |
| log.write('='*80) |
| # Check if PETSc is working |
| log.Println('Checking PETSc installation...') |
| if petscversion.VERSION > '3.2': |
| log.Println('WARNING: PETSc version '+petscversion.VERSION+' is newer than SLEPc version') |
| if petscversion.RELEASE != '1': |
| log.Println('WARNING: using PETSc development version') |
| if petscconf.ISINSTALL: |
| if os.path.realpath(petscconf.DESTDIR) != os.path.realpath(petscdir): |
| log.Println('WARNING: PETSC_DIR does not point to PETSc installation path') |
| if not check.Link(tmpdir,[],[],[]): |
| log.Exit('ERROR: Unable to link with PETSc') |
| # Check for external packages |
| if havearpack: |
| arpacklibs = arpack.Check(slepcconf,slepcvars,cmake,tmpdir,arpackdir,arpacklibs) |
| if haveblzpack: |
| blzpacklibs = blzpack.Check(slepcconf,slepcvars,cmake,tmpdir,blzpackdir,blzpacklibs) |
| if havetrlan: |
| trlanlibs = trlan.Check(slepcconf,slepcvars,cmake,tmpdir,trlandir,trlanlibs) |
| if haveprimme: |
| primmelibs = primme.Check(slepcconf,slepcvars,cmake,tmpdir,primmedir,primmelibs) |
| if getblopex: |
| blopexlibs = blopex.Install(slepcconf,slepcvars,cmake,tmpdir,blopexurl,archdir) |
| haveblopex = 1 |
| # Check for missing LAPACK functions |
| missing = lapack.Check(slepcconf,slepcvars,cmake,tmpdir) |
| # Download and install slepc4py |
| if getslepc4py: |
| slepc4py.Install() |
| slepc4py.addMakeRule(slepcrules,prefixdir,prefixinstall,getslepc4py) |
| # Make Fortran stubs if necessary |
| if subversion and hasattr(petscconf,'FC'): |
| try: |
| import generatefortranstubs |
| generatefortranstubs.main(petscconf.BFORT) |
| except AttributeError: |
| sys.exit('ERROR: cannot generate Fortran stubs; try configuring PETSc with --download-sowing or use a mercurial version of PETSc') |
| # CMake stuff |
| cmake.write('set (SLEPC_PACKAGE_LIBS "${ARPACK_LIB}" "${BLZPACK_LIB}" "${TRLAN_LIB}" "${PRIMME_LIB}" "${BLOPEX_LIB}" )\n') |
| cmake.write('set (SLEPC_PACKAGE_INCLUDES "${PRIMME_INCLUDE}")\n') |
| cmake.write('find_library (PETSC_LIB petsc HINTS ${PETSc_BINARY_DIR}/lib )\n') |
| cmake.close() |
| cmakeok = False |
| if sys.version_info >= (2,5) and not petscconf.ISINSTALL and petscconf.BUILD_USING_CMAKE: |
| import cmakegen |
| try: |
| cmakegen.main(slepcdir,petscdir,petscarch=petscconf.ARCH) |
| except (OSError), e: |
| log.Exit('ERROR: Generating CMakeLists.txt failed:\n' + str(e)) |
| import cmakeboot |
| try: |
| cmakeok = cmakeboot.main(slepcdir,petscdir,petscarch=petscconf.ARCH,log=log) |
| except (OSError), e: |
| log.Exit('ERROR: Booting CMake in PETSC_ARCH failed:\n' + str(e)) |
| except (ImportError, KeyError), e: |
| log.Exit('ERROR: Importing cmakeboot failed:\n' + str(e)) |
| # remove files created by PETSc's script |
| for f in ['build.log','build.log.bkp','RDict.log']: |
| try: os.remove(f) |
| except OSError: pass |
| if cmakeok: |
| slepcvars.write('SLEPC_BUILD_USING_CMAKE = 1\n') |
| # Finish with configuration files |
| slepcvars.close() |
| slepcrules.close() |
| slepcconf.write('#endif\n') |
| slepcconf.close() |
| shutil.rmtree(tmpdir) |
| # Print summary |
| log.Println('') |
| log.Println('='*79) |
| log.Println('SLEPc Configuration') |
| log.Println('='*79) |
| log.Println('') |
| log.Println('SLEPc directory:') |
| log.Println(' '+slepcdir) |
| if archdir != prefixdir: |
| log.Println('SLEPc prefix directory:') |
| log.Println(' '+prefixdir) |
| log.Println('PETSc directory:') |
| log.Println(' '+petscdir) |
| log.Println('Architecture "'+petscconf.ARCH+'" with '+petscconf.PRECISION+' precision '+petscconf.SCALAR+' numbers') |
| if havearpack: |
| log.Println('ARPACK library flags:') |
| log.Println(' '+str.join(' ',arpacklibs)) |
| if haveblzpack: |
| log.Println('BLZPACK library flags:') |
| log.Println(' '+str.join(' ',blzpacklibs)) |
| if havetrlan: |
| log.Println('TRLAN library flags:') |
| log.Println(' '+str.join(' ',trlanlibs)) |
| if haveprimme: |
| log.Println('PRIMME library flags:') |
| log.Println(' '+str.join(' ',primmelibs)) |
| if haveblopex: |
| log.Println('BLOPEX library flags:') |
| log.Println(' '+str.join(' ',blopexlibs)) |
| if missing: |
| log.Println('LAPACK missing functions:') |
| log.Print(' ') |
| for i in missing: log.Print(i) |
| log.Println('') |
| log.Println('') |
| log.Println('WARNING: Some SLEPc functionality will not be available') |
| log.Println('PLEASE reconfigure and recompile PETSc with a full LAPACK implementation') |
| print 'xxx'+'='*73+'xxx' |
| if cmakeok: buildtype = 'cmake' |
| else: buildtype = 'legacy' |
| print ' Configure stage complete. Now build the SLEPc library with ('+buildtype+' build):' |
| print ' make SLEPC_DIR=$PWD PETSC_DIR='+petscdir+' PETSC_ARCH='+petscconf.ARCH |
| print 'xxx'+'='*73+'xxx' |
| # |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # SLEPc - Scalable Library for Eigenvalue Problem Computations |
| # Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| # |
| # This file is part of SLEPc. |
| # |
| # SLEPc is free software: you can redistribute it and/or modify it under the |
| # terms of version 3 of the GNU Lesser General Public License as published by |
| # the Free Software Foundation. |
| # |
| # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| # more details. |
| # |
| # You should have received a copy of the GNU Lesser General Public License |
| # along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # |
| import sys |
| import petscconf |
| def Open(filename): |
| global f |
| f = open(filename,'w') |
| return |
| def Println(string): |
| print string |
| f.write(string) |
| f.write('\n') |
| def Print(string): |
| print string, |
| f.write(string+' ') |
| def write(string): |
| f.write(string) |
| f.write('\n') |
| def Exit(string): |
| f.write(string) |
| f.write('\n') |
| f.close() |
| print string |
| sys.exit('ERROR: See "' + petscconf.ARCH + '/conf/configure.log" file for details') |
| include makefile |
| include config/makefile |
| recursive-include config *.py *.c |
| recursive-include bin/matlab * |
| recursive-include conf * |
| recursive-include include * |
| recursive-include src * |
| recursive-exclude src/docs * |
| exclude conf/slepcvariables |
| recursive-exclude src/*/examples/* *.* |
| recursive-exclude include *.o |
| recursive-exclude src *.o |
| # |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # SLEPc - Scalable Library for Eigenvalue Problem Computations |
| # Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| # |
| # This file is part of SLEPc. |
| # |
| # SLEPc is free software: you can redistribute it and/or modify it under the |
| # terms of version 3 of the GNU Lesser General Public License as published by |
| # the Free Software Foundation. |
| # |
| # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| # more details. |
| # |
| # You should have received a copy of the GNU Lesser General Public License |
| # along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # |
| import os |
| import sys |
| def Load(petscdir): |
| global ARCH,DIR,MAKE,SCALAR,PRECISION,ISINSTALL,DESTDIR,BFORT,TEST_RUNS,CC,CC_FLAGS,FC,AR,AR_FLAGS,AR_LIB_SUFFIX,RANLIB,IND64,BUILD_USING_CMAKE |
| if 'PETSC_ARCH' in os.environ: |
| ISINSTALL = 0 |
| ARCH = os.environ['PETSC_ARCH'] |
| PETSCVARIABLES = os.sep.join([petscdir,ARCH,'conf','petscvariables']) |
| PETSCCONF_H = os.sep.join([petscdir,ARCH,'include','petscconf.h']) |
| else: |
| ISINSTALL = 1 |
| ARCH = 'arch-installed-petsc' |
| PETSCVARIABLES = os.sep.join([petscdir,'conf','petscvariables']) |
| PETSCCONF_H = os.sep.join([petscdir,'include','petscconf.h']) |
| BUILD_USING_CMAKE = 0 |
| try: |
| f = open(PETSCVARIABLES) |
| for l in f.readlines(): |
| (k,v) = l.split('=',1) |
| k = k.strip() |
| v = v.strip() |
| if k == 'PETSC_SCALAR': |
| SCALAR = v |
| elif k == 'PETSC_PRECISION': |
| PRECISION = v |
| elif k == 'MAKE': |
| MAKE = v |
| elif k == 'DESTDIR': |
| DESTDIR = v |
| elif k == 'BFORT': |
| BFORT = v |
| elif k == 'TEST_RUNS': |
| TEST_RUNS = v |
| elif k == 'CC': |
| CC = v |
| elif k == 'CC_FLAGS': |
| CC_FLAGS = v |
| elif k == 'FC' and not v=='': |
| FC = v |
| elif k == 'AR': |
| AR = v |
| elif k == 'AR_FLAGS': |
| AR_FLAGS = v |
| elif k == 'AR_LIB_SUFFIX': |
| AR_LIB_SUFFIX = v |
| elif k == 'RANLIB': |
| RANLIB = v |
| elif k == 'PETSC_BUILD_USING_CMAKE': |
| BUILD_USING_CMAKE = v |
| f.close() |
| except: |
| sys.exit('ERROR: PETSc is not configured for architecture ' + ARCH) |
| IND64 = 0 |
| try: |
| f = open(PETSCCONF_H) |
| for l in f.readlines(): |
| l = l.split() |
| if len(l)==3 and l[0]=='#define' and l[1]=='PETSC_USE_64BIT_INDICES' and l[2]=='1': |
| IND64 = 1 |
| f.close() |
| except: |
| sys.exit('ERROR: cannot open petscconf.h') |
| # |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # SLEPc - Scalable Library for Eigenvalue Problem Computations |
| # Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| # |
| # This file is part of SLEPc. |
| # |
| # SLEPc is free software: you can redistribute it and/or modify it under the |
| # terms of version 3 of the GNU Lesser General Public License as published by |
| # the Free Software Foundation. |
| # |
| # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| # more details. |
| # |
| # You should have received a copy of the GNU Lesser General Public License |
| # along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # |
| import os |
| import sys |
| def Load(petscdir): |
| global VERSION,RELEASE,PATCHLEVEL |
| try: |
| f = open(os.sep.join([petscdir,'include','petscversion.h'])) |
| for l in f.readlines(): |
| l = l.split() |
| if len(l) == 3: |
| if l[1] == 'PETSC_VERSION_RELEASE': |
| RELEASE = l[2] |
| if l[1] == 'PETSC_VERSION_MAJOR': |
| major = l[2] |
| elif l[1] == 'PETSC_VERSION_MINOR': |
| minor = l[2] |
| elif l[1] == 'PETSC_VERSION_SUBMINOR': |
| subminor = l[2] |
| elif l[1] == 'PETSC_VERSION_PATCH': |
| PATCHLEVEL = l[2] |
| f.close() |
| VERSION = major + '.' + minor |
| except: |
| sys.exit('ERROR: file error while reading PETSC version') |
| # |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # SLEPc - Scalable Library for Eigenvalue Problem Computations |
| # Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| # |
| # This file is part of SLEPc. |
| # |
| # SLEPc is free software: you can redistribute it and/or modify it under the |
| # terms of version 3 of the GNU Lesser General Public License as published by |
| # the Free Software Foundation. |
| # |
| # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| # more details. |
| # |
| # You should have received a copy of the GNU Lesser General Public License |
| # along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # |
| import os |
| import sys |
| import petscconf |
| import check |
| def Check(conf,vars,cmake,tmpdir,directory,libs): |
| if petscconf.SCALAR == 'complex': |
| sys.exit('ERROR: BLZPACK does not support complex numbers.') |
| if petscconf.PRECISION == 'single': |
| functions = ['blzdrs'] |
| else: |
| functions = ['blzdrd'] |
| if libs: |
| libs = [libs] |
| else: |
| libs = [['-lblzpack']] |
| if directory: |
| dirs = [directory] |
| else: |
| dirs = check.GenerateGuesses('Blzpack') |
| return check.FortranLib(tmpdir,conf,vars,cmake,'BLZPACK',dirs,libs,functions) |
| #!/usr/bin/env python |
| """ |
| SLEPc: Scalable Library for Eigenvalue Problem Computations |
| =========================================================== |
| SLEPc is a software library for the solution of large scale sparse |
| eigenvalue problems on parallel computers. It is an extension of PETSc |
| and can be used for either standard or generalized eigenproblems, with |
| real or complex arithmetic. It can also be used for computing a |
| partial SVD of a large, sparse, rectangular matrix, and to solve |
| quadratic eigenvalue problems |
| .. tip:: |
| You can also install `slepc-dev`_ with:: |
| $ pip install slepc==dev petsc==dev |
| .. _petsc-dev: http://www.grycap.upv.es/slepc/ |
| svn/trunk/#egg=slepc-dev |
| """ |
| import sys, os |
| from distutils.core import setup |
| from distutils.util import get_platform |
| from distutils.spawn import find_executable |
| from distutils.command.build import build as _build |
| if 'setuptools' in sys.modules: |
| from setuptools.command.install import install as _install |
| else: |
| from distutils.command.install import install as _install |
| from distutils.command.sdist import sdist as _sdist |
| from distutils import log |
| init_py = """\ |
| # Author: SLEPc Team |
| # Contact: slepc-maint@grycap.upv.es |
| def get_slepc_dir(): |
| import os |
| return os.path.dirname(__file__) |
| def get_config(): |
| conf = {} |
| conf['SLEPC_DIR'] = get_slepc_dir() |
| return conf |
| """ |
| metadata = { |
| 'provides' : ['slepc'], |
| 'requires' : [], |
| } |
| def bootstrap(): |
| from os.path import join, isdir, abspath |
| # Set SLEPC_DIR |
| SLEPC_DIR = abspath(os.getcwd()) |
| os.environ['SLEPC_DIR'] = SLEPC_DIR |
| # Check PETSC_DIR/PETSC_ARCH |
| PETSC_DIR = os.environ.get('PETSC_DIR', "") |
| PETSC_ARCH = os.environ.get('PETSC_ARCH', "") |
| if not (PETSC_DIR and isdir(PETSC_DIR)): |
| PETSC_DIR = None |
| try: del os.environ['PETSC_DIR'] |
| except KeyError: pass |
| PETSC_ARCH = None |
| try: del os.environ['PETSC_ARCH'] |
| except KeyError: pass |
| elif not isdir(join(PETSC_DIR, PETSC_ARCH)): |
| PETSC_ARCH = None |
| try: del os.environ['PETSC_ARCH'] |
| except KeyError: pass |
| # Generate package __init__.py file |
| from distutils.dir_util import mkpath |
| pkgdir = os.path.join('config', 'pypi') |
| pkgfile = os.path.join(pkgdir, '__init__.py') |
| if not os.path.exists(pkgdir): mkpath(pkgdir) |
| fh = open(pkgfile, 'wt') |
| fh.write(init_py) |
| fh.close() |
| if ('setuptools' in sys.modules): |
| metadata['zip_safe'] = False |
| if not PETSC_DIR: |
| metadata['install_requires']= ['petsc>=3.2,<3.3'] |
| def get_petsc_dir(): |
| PETSC_DIR = os.environ.get('PETSC_DIR') |
| if PETSC_DIR: return PETSC_DIR |
| try: |
| import petsc |
| PETSC_DIR = petsc.get_petsc_dir() |
| except ImportError: |
| log.warn("PETSC_DIR not specified") |
| PETSC_DIR = os.path.join(os.path.sep, 'usr', 'local', 'petsc') |
| return PETSC_DIR |
| def get_petsc_arch(): |
| PETSC_ARCH = os.environ.get('PETSC_ARCH') or 'arch-installed-petsc' |
| return PETSC_ARCH |
| def config(dry_run=False): |
| log.info('SLEPc: configure') |
| if dry_run: return |
| # PETSc |
| # Run SLEPc configure |
| os.environ['PETSC_DIR'] = get_petsc_dir() |
| status = os.system(" ".join(( |
| find_executable('python'), |
| os.path.join('config', 'configure.py'), |
| ))) |
| if status != 0: raise RuntimeError(status) |
| def build(dry_run=False): |
| log.info('SLEPc: build') |
| if dry_run: return |
| # Run SLEPc build |
| status = os.system(" ".join(( |
| find_executable('make'), |
| 'PETSC_DIR='+get_petsc_dir(), |
| 'PETSC_ARCH='+get_petsc_arch(), |
| 'all', |
| ))) |
| if status != 0: raise RuntimeError |
| def install(dest_dir, prefix=None, dry_run=False): |
| log.info('SLEPc: install') |
| if dry_run: return |
| if prefix is None: |
| prefix = dest_dir |
| PETSC_ARCH = get_petsc_arch() |
| # Run SLEPc install |
| status = os.system(" ".join(( |
| find_executable('make'), |
| 'PETSC_DIR='+get_petsc_dir(), |
| 'PETSC_ARCH='+get_petsc_arch(), |
| 'SLEPC_DESTDIR='+dest_dir, |
| 'install', |
| ))) |
| if status != 0: raise RuntimeError |
| slepcvariables = os.path.join(dest_dir, 'conf', 'slepcvariables') |
| fh = open(slepcvariables, 'a') |
| fh.write('SLEPC_DESTDIR=%s\n' % prefix) |
| fh.close() |
| class context: |
| def __init__(self): |
| self.sys_argv = sys.argv[:] |
| self.wdir = os.getcwd() |
| def enter(self): |
| del sys.argv[1:] |
| pdir = os.environ['SLEPC_DIR'] |
| os.chdir(pdir) |
| return self |
| def exit(self): |
| sys.argv[:] = self.sys_argv |
| os.chdir(self.wdir) |
| class cmd_build(_build): |
| def initialize_options(self): |
| _build.initialize_options(self) |
| PETSC_ARCH = os.environ.get('PETSC_ARCH', 'arch-installed-petsc') |
| self.build_base = os.path.join(PETSC_ARCH, 'build-python') |
| def run(self): |
| _build.run(self) |
| ctx = context().enter() |
| try: |
| config(self.dry_run) |
| build(self.dry_run) |
| finally: |
| ctx.exit() |
| class cmd_install(_install): |
| def initialize_options(self): |
| _install.initialize_options(self) |
| self.optimize = 1 |
| def run(self): |
| root_dir = self.install_platlib |
| dest_dir = os.path.join(root_dir, 'slepc') |
| bdist_base = self.get_finalized_command('bdist').bdist_base |
| if dest_dir.startswith(bdist_base): |
| prefix = dest_dir[len(bdist_base)+1:] |
| prefix = prefix[prefix.index(os.path.sep):] |
| else: |
| prefix = dest_dir |
| dest_dir = os.path.abspath(dest_dir) |
| prefix = os.path.abspath(prefix) |
| # |
| _install.run(self) |
| ctx = context().enter() |
| try: |
| install(dest_dir, prefix, self.dry_run) |
| finally: |
| ctx.exit() |
| class cmd_sdist(_sdist): |
| def initialize_options(self): |
| _sdist.initialize_options(self) |
| self.force_manifest = 1 |
| self.template = os.path.join('config', 'manifest.in') |
| def version(): |
| import re |
| version_re = { |
| 'major' : re.compile(r"#define\s+SLEPC_VERSION_MAJOR\s+(\d+)"), |
| 'minor' : re.compile(r"#define\s+SLEPC_VERSION_MINOR\s+(\d+)"), |
| 'micro' : re.compile(r"#define\s+SLEPC_VERSION_SUBMINOR\s+(\d+)"), |
| 'patch' : re.compile(r"#define\s+SLEPC_VERSION_PATCH\s+(\d+)"), |
| 'release': re.compile(r"#define\s+SLEPC_VERSION_RELEASE\s+(\d+)"), |
| } |
| slepcversion_h = os.path.join('include','slepcversion.h') |
| data = open(slepcversion_h, 'rt').read() |
| major = int(version_re['major'].search(data).groups()[0]) |
| minor = int(version_re['minor'].search(data).groups()[0]) |
| micro = int(version_re['micro'].search(data).groups()[0]) |
| patch = int(version_re['patch'].search(data).groups()[0]) |
| release = int(version_re['release'].search(data).groups()[0]) |
| if release: |
| v = "%d.%d" % (major, minor) |
| if micro > 0: |
| v += ".%d" % micro |
| if patch > 0: |
| v += ".%d" % patch |
| else: |
| v = "%d.%d.dev%d" % (major, minor+1, 0) |
| return v |
| def tarball(): |
| VERSION = version() |
| if '.dev' in VERSION: |
| return None |
| bits = VERSION.split('.') |
| if len(bits) == 2: bits.append('0') |
| VERSION = '.'.join(bits[:-1]) + '-p' + bits[-1] |
| return ('http://www.grycap.upv.es/slepc/download/distrib/' + |
| 'slepc-%s.tar.gz' % VERSION) |
| description = __doc__.split('\n')[1:-1]; del description[1:3] |
| classifiers = """ |
| License :: Public Domain |
| Operating System :: POSIX |
| Intended Audience :: Developers |
| Intended Audience :: Science/Research |
| Programming Language :: C |
| Programming Language :: C++ |
| Programming Language :: Fortran |
| Programming Language :: Python |
| Topic :: Scientific/Engineering |
| Topic :: Software Development :: Libraries |
| """ |
| bootstrap() |
| setup(name='slepc', |
| version=version(), |
| description=description.pop(0), |
| long_description='\n'.join(description), |
| classifiers= classifiers.split('\n')[1:-1], |
| keywords = ['SLEPc','PETSc', 'MPI'], |
| platforms=['POSIX'], |
| license='LGPL', |
| url='http://www.grycap.upv.es/slepc/', |
| download_url=tarball(), |
| author='SLEPc Team', |
| author_email='slepc-maint@grycap.upv.es', |
| maintainer='Lisandro Dalcin', |
| maintainer_email='dalcinl@gmail.com', |
| packages = ['slepc'], |
| package_dir = {'slepc': 'config/pypi'}, |
| cmdclass={ |
| 'build': cmd_build, |
| 'install': cmd_install, |
| 'sdist': cmd_sdist, |
| }, |
| **metadata) |
| /* |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| SLEPc - Scalable Library for Eigenvalue Problem Computations |
| Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| This file is part of SLEPc. |
| SLEPc is free software: you can redistribute it and/or modify it under the |
| terms of version 3 of the GNU Lesser General Public License as published by |
| the Free Software Foundation. |
| SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| more details. |
| You should have received a copy of the GNU Lesser General Public License |
| along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| */ |
| #include <private/fortranimpl.h> |
| #include <private/qepimpl.h> |
| #if defined(PETSC_HAVE_FORTRAN_CAPS) |
| #define qepdestroy_ QEPDESTROY |
| #define qepview_ QEPVIEW |
| #define qepsetoptionsprefix_ QEPSETOPTIONSPREFIX |
| #define qepappendoptionsprefix_ QEPAPPENDOPTIONSPREFIX |
| #define qepgetoptionsprefix_ QEPGETOPTIONSPREFIX |
| #define qepcreate_ QEPCREATE |
| #define qepsettype_ QEPSETTYPE |
| #define qepgettype_ QEPGETTYPE |
| #define qepmonitorall_ QEPMONITORALL |
| #define qepmonitorlg_ QEPMONITORLG |
| #define qepmonitorlgall_ QEPMONITORLGALL |
| #define qepmonitorset_ QEPMONITORSET |
| #define qepmonitorconverged_ QEPMONITORCONVERGED |
| #define qepmonitorfirst_ QEPMONITORFIRST |
| #define qepgetip_ QEPGETIP |
| #define qepgetwhicheigenpairs_ QEPGETWHICHEIGENPAIRS |
| #define qepgetproblemtype_ QEPGETPROBLEMTYPE |
| #define qepgetconvergedreason_ QEPGETCONVERGEDREASON |
| #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) |
| #define qepdestroy_ qepdestroy |
| #define qepview_ qepview |
| #define qepsetoptionsprefix_ qepsetoptionsprefix |
| #define qepappendoptionsprefix_ qepappendoptionsprefix |
| #define qepgetoptionsprefix_ qepgetoptionsprefix |
| #define qepcreate_ qepcreate |
| #define qepsettype_ qepsettype |
| #define qepgettype_ qepgettype |
| #define qepmonitorall_ qepmonitorall |
| #define qepmonitorlg_ qepmonitorlg |
| #define qepmonitorlgall_ qepmonitorlgall |
| #define qepmonitorset_ qepmonitorset |
| #define qepmonitorconverged_ qepmonitorconverged |
| #define qepmonitorfirst_ qepmonitorfirst |
| #define qepgetip_ qepgetip |
| #define qepgetwhicheigenpairs_ qepgetwhicheigenpairs |
| #define qepgetproblemtype_ qepgetproblemtype |
| #define qepgetconvergedreason_ qepgetconvergedreason |
| #endif |
| EXTERN_C_BEGIN |
| /* |
| These are not usually called from Fortran but allow Fortran users |
| to transparently set these monitors from .F code, hence no STDCALL |
| */ |
| void qepmonitorall_(QEP *qep,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,void *ctx,PetscErrorCode *ierr) |
| { |
| *ierr = QEPMonitorAll(*qep,*it,*nconv,eigr,eigi,errest,*nest,ctx); |
| } |
| void qepmonitorlg_(QEP *qep,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,void *ctx,PetscErrorCode *ierr) |
| { |
| *ierr = QEPMonitorLG(*qep,*it,*nconv,eigr,eigi,errest,*nest,ctx); |
| } |
| void qepmonitorlgall_(QEP *qep,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,void *ctx,PetscErrorCode *ierr) |
| { |
| *ierr = QEPMonitorLGAll(*qep,*it,*nconv,eigr,eigi,errest,*nest,ctx); |
| } |
| void qepmonitorconverged_(QEP *qep,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,void *ctx,PetscErrorCode *ierr) |
| { |
| *ierr = QEPMonitorConverged(*qep,*it,*nconv,eigr,eigi,errest,*nest,ctx); |
| } |
| void qepmonitorfirst_(QEP *qep,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,void *ctx,PetscErrorCode *ierr) |
| { |
| *ierr = QEPMonitorFirst(*qep,*it,*nconv,eigr,eigi,errest,*nest,ctx); |
| } |
| EXTERN_C_END |
| /* These are not extern C because they are passed into non-extern C user level functions */ |
| static PetscErrorCode ourmonitor(QEP qep,PetscInt i,PetscInt nc,PetscScalar *er,PetscScalar *ei,PetscReal *d,PetscInt l,void* ctx) |
| { |
| PetscErrorCode ierr = 0; |
| void *mctx = (void*) ((PetscObject)qep)->fortran_func_pointers[1]; |
| (*(void (PETSC_STDCALL *)(QEP*,PetscInt*,PetscInt*,PetscScalar*,PetscScalar*,PetscReal*,PetscInt*,void*,PetscErrorCode*)) |
| (((PetscObject)qep)->fortran_func_pointers[0]))(&qep,&i,&nc,er,ei,d,&l,mctx,&ierr);CHKERRQ(ierr); |
| return 0; |
| } |
| static PetscErrorCode ourdestroy(void** ctx) |
| { |
| PetscErrorCode ierr = 0; |
| QEP qep = *(QEP*)ctx; |
| void *mctx = (void*) ((PetscObject)qep)->fortran_func_pointers[1]; |
| (*(void (PETSC_STDCALL *)(void*,PetscErrorCode*))(((PetscObject)qep)->fortran_func_pointers[2]))(mctx,&ierr);CHKERRQ(ierr); |
| return 0; |
| } |
| EXTERN_C_BEGIN |
| void PETSC_STDCALL qepdestroy_(QEP *qep, PetscErrorCode *ierr) |
| { |
| *ierr = QEPDestroy(qep); |
| } |
| void PETSC_STDCALL qepview_(QEP *qep,PetscViewer *viewer, PetscErrorCode *ierr) |
| { |
| PetscViewer v; |
| PetscPatchDefaultViewers_Fortran(viewer,v); |
| *ierr = QEPView(*qep,v); |
| } |
| void PETSC_STDCALL qepsettype_(QEP *qep,CHAR type PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) |
| { |
| char *t; |
| FIXCHAR(type,len,t); |
| *ierr = QEPSetType(*qep,t); |
| FREECHAR(type,t); |
| } |
| void PETSC_STDCALL qepgettype_(QEP *qep,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) |
| { |
| const QEPType tname; |
| *ierr = QEPGetType(*qep,&tname);if (*ierr) return; |
| *ierr = PetscStrncpy(name,tname,len); |
| FIXRETURNCHAR(PETSC_TRUE,name,len); |
| } |
| void PETSC_STDCALL qepsetoptionsprefix_(QEP *qep,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) |
| { |
| char *t; |
| FIXCHAR(prefix,len,t); |
| *ierr = QEPSetOptionsPrefix(*qep,t); |
| FREECHAR(prefix,t); |
| } |
| void PETSC_STDCALL qepappendoptionsprefix_(QEP *qep,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) |
| { |
| char *t; |
| FIXCHAR(prefix,len,t); |
| *ierr = QEPAppendOptionsPrefix(*qep,t); |
| FREECHAR(prefix,t); |
| } |
| void PETSC_STDCALL qepcreate_(MPI_Fint *comm,QEP *qep,PetscErrorCode *ierr) |
| { |
| *ierr = QEPCreate(MPI_Comm_f2c(*(comm)),qep); |
| } |
| void PETSC_STDCALL qepmonitorset_(QEP *qep,void (PETSC_STDCALL *monitor)(QEP*,PetscInt*,PetscInt*,PetscScalar*,PetscScalar*,PetscReal*,PetscInt*,void*,PetscErrorCode*),void *mctx,void (PETSC_STDCALL *monitordestroy)(void *,PetscErrorCode *),PetscErrorCode *ierr) |
| { |
| SlepcConvMonitor ctx; |
| CHKFORTRANNULLFUNCTION(monitordestroy); |
| PetscObjectAllocateFortranPointers(*qep,3); |
| if ((PetscVoidFunction)monitor == (PetscVoidFunction)qepmonitorall_) { |
| *ierr = QEPMonitorSet(*qep,QEPMonitorAll,0,0); |
| } else if ((PetscVoidFunction)monitor == (PetscVoidFunction)qepmonitorlg_) { |
| *ierr = QEPMonitorSet(*qep,QEPMonitorLG,0,0); |
| } else if ((PetscVoidFunction)monitor == (PetscVoidFunction)qepmonitorlgall_) { |
| *ierr = QEPMonitorSet(*qep,QEPMonitorLGAll,0,0); |
| } else if ((PetscVoidFunction)monitor == (PetscVoidFunction)qepmonitorconverged_) { |
| if (!FORTRANNULLOBJECT(mctx)) { PetscError(((PetscObject)*qep)->comm,__LINE__,"qepmonitorset_",__FILE__,__SDIR__,PETSC_ERR_ARG_WRONG,PETSC_ERROR_INITIAL,"Must provide PETSC_NULL_OBJECT as a context in the Fortran interface to QEPMonitorSet"); *ierr = 1; return; } |
| *ierr = PetscNew(struct _n_SlepcConvMonitor,&ctx); |
| if (*ierr) return; |
| ctx->viewer = PETSC_NULL; |
| *ierr = QEPMonitorSet(*qep,QEPMonitorConverged,ctx,(PetscErrorCode (*)(void**))SlepcConvMonitorDestroy); |
| } else if ((PetscVoidFunction)monitor == (PetscVoidFunction)qepmonitorfirst_) { |
| *ierr = QEPMonitorSet(*qep,QEPMonitorFirst,0,0); |
| } else { |
| ((PetscObject)*qep)->fortran_func_pointers[0] = (PetscVoidFunction)monitor; |
| ((PetscObject)*qep)->fortran_func_pointers[1] = (PetscVoidFunction)mctx; |
| if (!monitordestroy) { |
| *ierr = QEPMonitorSet(*qep,ourmonitor,*qep,0); |
| } else { |
| ((PetscObject)*qep)->fortran_func_pointers[2] = (PetscVoidFunction)monitordestroy; |
| *ierr = QEPMonitorSet(*qep,ourmonitor,*qep,ourdestroy); |
| } |
| } |
| } |
| void PETSC_STDCALL qepgetoptionsprefix_(QEP *qep,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) |
| { |
| const char *tname; |
| *ierr = QEPGetOptionsPrefix(*qep,&tname); if (*ierr) return; |
| *ierr = PetscStrncpy(prefix,tname,len); |
| } |
| void PETSC_STDCALL qepgetip_(QEP *qep,IP *ip,PetscErrorCode *ierr) |
| { |
| *ierr = QEPGetIP(*qep,ip); |
| } |
| void PETSC_STDCALL qepgetwhicheigenpairs_(QEP *qep,QEPWhich *which,PetscErrorCode *ierr) |
| { |
| *ierr = QEPGetWhichEigenpairs(*qep,which); |
| } |
| void PETSC_STDCALL qepgetproblemtype_(QEP *qep,QEPProblemType *type,PetscErrorCode *ierr) |
| { |
| *ierr = QEPGetProblemType(*qep,type); |
| } |
| void PETSC_STDCALL qepgetconvergedreason_(QEP *qep,QEPConvergedReason *reason,PetscErrorCode *ierr) |
| { |
| *ierr = QEPGetConvergedReason(*qep,reason); |
| } |
| EXTERN_C_END |
| # |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # SLEPc - Scalable Library for Eigenvalue Problem Computations |
| # Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| # |
| # This file is part of SLEPc. |
| # |
| # SLEPc is free software: you can redistribute it and/or modify it under the |
| # terms of version 3 of the GNU Lesser General Public License as published by |
| # the Free Software Foundation. |
| # |
| # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| # more details. |
| # |
| # You should have received a copy of the GNU Lesser General Public License |
| # along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # |
| #requiresdefine 'PETSC_HAVE_FORTRAN' |
| ALL: lib |
| CFLAGS = |
| FFLAGS = |
| SOURCEC = zqepf.c |
| OBJSC = zqepf.o |
| SOURCEF = |
| SOURCEH = |
| DIRS = |
| LIBBASE = libslepc |
| LOCDIR = src/qep/interface/ftn-custom/ |
| include ${SLEPC_DIR}/conf/slepc_common |
| /* |
| QEP routines related to the solution process. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| SLEPc - Scalable Library for Eigenvalue Problem Computations |
| Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| This file is part of SLEPc. |
| SLEPc is free software: you can redistribute it and/or modify it under the |
| terms of version 3 of the GNU Lesser General Public License as published by |
| the Free Software Foundation. |
| SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| more details. |
| You should have received a copy of the GNU Lesser General Public License |
| along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| */ |
| #include <private/qepimpl.h> /*I "slepcqep.h" I*/ |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPSolve" |
| /*@ |
| QEPSolve - Solves the quadratic eigensystem. |
| Collective on QEP |
| Input Parameter: |
| . qep - eigensolver context obtained from QEPCreate() |
| Options Database: |
| + -qep_view - print information about the solver used |
| . -qep_view_binary - save the matrices to the default binary file |
| - -qep_plot_eigs - plot computed eigenvalues |
| Level: beginner |
| .seealso: QEPCreate(), QEPSetUp(), QEPDestroy(), QEPSetTolerances() |
| @*/ |
| PetscErrorCode QEPSolve(QEP qep) |
| { |
| PetscErrorCode ierr; |
| PetscInt i; |
| PetscReal re,im; |
| PetscBool flg; |
| PetscViewer viewer; |
| PetscDraw draw; |
| PetscDrawSP drawsp; |
| char filename[PETSC_MAX_PATH_LEN]; |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| flg = PETSC_FALSE; |
| ierr = PetscOptionsGetBool(((PetscObject)qep)->prefix,"-qep_view_binary",&flg,PETSC_NULL);CHKERRQ(ierr); |
| if (flg) { |
| ierr = MatView(qep->M,PETSC_VIEWER_BINARY_(((PetscObject)qep)->comm));CHKERRQ(ierr); |
| ierr = MatView(qep->C,PETSC_VIEWER_BINARY_(((PetscObject)qep)->comm));CHKERRQ(ierr); |
| ierr = MatView(qep->K,PETSC_VIEWER_BINARY_(((PetscObject)qep)->comm));CHKERRQ(ierr); |
| } |
| /* reset the convergence flag from the previous solves */ |
| qep->reason = QEP_CONVERGED_ITERATING; |
| if (!qep->ip) { ierr = QEPGetIP(qep,&qep->ip);CHKERRQ(ierr); } |
| if (!qep->setupcalled){ ierr = QEPSetUp(qep);CHKERRQ(ierr); } |
| qep->nconv = 0; |
| qep->its = 0; |
| for (i=0;i<qep->ncv;i++) qep->eigr[i]=qep->eigi[i]=qep->errest[i]=0.0; |
| ierr = QEPMonitor(qep,qep->its,qep->nconv,qep->eigr,qep->eigi,qep->errest,qep->ncv);CHKERRQ(ierr); |
| ierr = PetscLogEventBegin(QEP_Solve,qep,0,0,0);CHKERRQ(ierr); |
| ierr = (*qep->ops->solve)(qep);CHKERRQ(ierr); |
| ierr = PetscLogEventEnd(QEP_Solve,qep,0,0,0);CHKERRQ(ierr); |
| if (!qep->reason) { |
| SETERRQ(((PetscObject)qep)->comm,1,"Internal error, solver returned without setting converged reason"); |
| } |
| #if !defined(PETSC_USE_COMPLEX) |
| /* reorder conjugate eigenvalues (positive imaginary first) */ |
| for (i=0;i<qep->nconv-1;i++) { |
| if (qep->eigi[i] != 0) { |
| if (qep->eigi[i] < 0) { |
| qep->eigi[i] = -qep->eigi[i]; |
| qep->eigi[i+1] = -qep->eigi[i+1]; |
| ierr = VecScale(qep->V[i+1],-1.0);CHKERRQ(ierr); |
| } |
| i++; |
| } |
| } |
| #endif |
| /* sort eigenvalues according to qep->which parameter */ |
| ierr = PetscFree(qep->perm);CHKERRQ(ierr); |
| if (qep->nconv > 0) { |
| ierr = PetscMalloc(sizeof(PetscInt)*qep->nconv,&qep->perm);CHKERRQ(ierr); |
| ierr = QEPSortEigenvalues(qep,qep->nconv,qep->eigr,qep->eigi,qep->perm);CHKERRQ(ierr); |
| } |
| ierr = PetscOptionsGetString(((PetscObject)qep)->prefix,"-qep_view",filename,PETSC_MAX_PATH_LEN,&flg);CHKERRQ(ierr); |
| if (flg && !PetscPreLoadingOn) { |
| ierr = PetscViewerASCIIOpen(((PetscObject)qep)->comm,filename,&viewer);CHKERRQ(ierr); |
| ierr = QEPView(qep,viewer);CHKERRQ(ierr); |
| ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); |
| } |
| flg = PETSC_FALSE; |
| ierr = PetscOptionsGetBool(((PetscObject)qep)->prefix,"-qep_plot_eigs",&flg,PETSC_NULL);CHKERRQ(ierr); |
| if (flg) { |
| ierr = PetscViewerDrawOpen(PETSC_COMM_SELF,0,"Computed Eigenvalues", |
| PETSC_DECIDE,PETSC_DECIDE,300,300,&viewer);CHKERRQ(ierr); |
| ierr = PetscViewerDrawGetDraw(viewer,0,&draw);CHKERRQ(ierr); |
| ierr = PetscDrawSPCreate(draw,1,&drawsp);CHKERRQ(ierr); |
| for(i=0;i<qep->nconv;i++) { |
| #if defined(PETSC_USE_COMPLEX) |
| re = PetscRealPart(qep->eigr[i]); |
| im = PetscImaginaryPart(qep->eigi[i]); |
| #else |
| re = qep->eigr[i]; |
| im = qep->eigi[i]; |
| #endif |
| ierr = PetscDrawSPAddPoint(drawsp,&re,&im);CHKERRQ(ierr); |
| } |
| ierr = PetscDrawSPDraw(drawsp);CHKERRQ(ierr); |
| ierr = PetscDrawSPDestroy(&drawsp);CHKERRQ(ierr); |
| ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); |
| } |
| /* Remove the initial subspace */ |
| qep->nini = 0; |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPGetIterationNumber" |
| /*@ |
| QEPGetIterationNumber - Gets the current iteration number. If the |
| call to QEPSolve() is complete, then it returns the number of iterations |
| carried out by the solution method. |
| Not Collective |
| Input Parameter: |
| . qep - the quadratic eigensolver context |
| Output Parameter: |
| . its - number of iterations |
| Level: intermediate |
| Note: |
| During the i-th iteration this call returns i-1. If QEPSolve() is |
| complete, then parameter "its" contains either the iteration number at |
| which convergence was successfully reached, or failure was detected. |
| Call QEPGetConvergedReason() to determine if the solver converged or |
| failed and why. |
| .seealso: QEPGetConvergedReason(), QEPSetTolerances() |
| @*/ |
| PetscErrorCode QEPGetIterationNumber(QEP qep,PetscInt *its) |
| { |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| PetscValidIntPointer(its,2); |
| *its = qep->its; |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPGetConverged" |
| /*@ |
| QEPGetConverged - Gets the number of converged eigenpairs. |
| Not Collective |
| Input Parameter: |
| . qep - the quadratic eigensolver context |
| Output Parameter: |
| . nconv - number of converged eigenpairs |
| Note: |
| This function should be called after QEPSolve() has finished. |
| Level: beginner |
| .seealso: QEPSetDimensions(), QEPSolve() |
| @*/ |
| PetscErrorCode QEPGetConverged(QEP qep,PetscInt *nconv) |
| { |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| PetscValidIntPointer(nconv,2); |
| *nconv = qep->nconv; |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPGetConvergedReason" |
| /*@C |
| QEPGetConvergedReason - Gets the reason why the QEPSolve() iteration was |
| stopped. |
| Not Collective |
| Input Parameter: |
| . qep - the quadratic eigensolver context |
| Output Parameter: |
| . reason - negative value indicates diverged, positive value converged |
| Possible values for reason: |
| + QEP_CONVERGED_TOL - converged up to tolerance |
| . QEP_DIVERGED_ITS - required more than its to reach convergence |
| - QEP_DIVERGED_BREAKDOWN - generic breakdown in method |
| Note: |
| Can only be called after the call to QEPSolve() is complete. |
| Level: intermediate |
| .seealso: QEPSetTolerances(), QEPSolve(), QEPConvergedReason |
| @*/ |
| PetscErrorCode QEPGetConvergedReason(QEP qep,QEPConvergedReason *reason) |
| { |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| PetscValidPointer(reason,2); |
| *reason = qep->reason; |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPGetEigenpair" |
| /*@ |
| QEPGetEigenpair - Gets the i-th solution of the eigenproblem as computed by |
| QEPSolve(). The solution consists in both the eigenvalue and the eigenvector. |
| Not Collective, but vectors are shared by all processors that share the QEP |
| Input Parameters: |
| + qep - quadratic eigensolver context |
| - i - index of the solution |
| Output Parameters: |
| + eigr - real part of eigenvalue |
| . eigi - imaginary part of eigenvalue |
| . Vr - real part of eigenvector |
| - Vi - imaginary part of eigenvector |
| Notes: |
| If the eigenvalue is real, then eigi and Vi are set to zero. If PETSc is |
| configured with complex scalars the eigenvalue is stored |
| directly in eigr (eigi is set to zero) and the eigenvector in Vr (Vi is |
| set to zero). |
| The index i should be a value between 0 and nconv-1 (see QEPGetConverged()). |
| Eigenpairs are indexed according to the ordering criterion established |
| with QEPSetWhichEigenpairs(). |
| Level: beginner |
| .seealso: QEPSolve(), QEPGetConverged(), QEPSetWhichEigenpairs() |
| @*/ |
| PetscErrorCode QEPGetEigenpair(QEP qep,PetscInt i,PetscScalar *eigr,PetscScalar *eigi,Vec Vr,Vec Vi) |
| { |
| PetscInt k; |
| PetscErrorCode ierr; |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| if (Vr) { PetscValidHeaderSpecific(Vr,VEC_CLASSID,6); PetscCheckSameComm(qep,1,Vr,6); } |
| if (Vi) { PetscValidHeaderSpecific(Vi,VEC_CLASSID,7); PetscCheckSameComm(qep,1,Vi,7); } |
| if (!qep->eigr || !qep->eigi || !qep->V) { |
| SETERRQ(((PetscObject)qep)->comm,PETSC_ERR_ARG_WRONGSTATE,"QEPSolve must be called first"); |
| } |
| if (i<0 || i>=qep->nconv) { |
| SETERRQ(((PetscObject)qep)->comm,PETSC_ERR_ARG_OUTOFRANGE,"Argument 2 out of range"); |
| } |
| if (!qep->perm) k = i; |
| else k = qep->perm[i]; |
| /* eigenvalue */ |
| #if defined(PETSC_USE_COMPLEX) |
| if (eigr) *eigr = qep->eigr[k]; |
| if (eigi) *eigi = 0; |
| #else |
| if (eigr) *eigr = qep->eigr[k]; |
| if (eigi) *eigi = qep->eigi[k]; |
| #endif |
| /* eigenvector */ |
| #if defined(PETSC_USE_COMPLEX) |
| if (Vr) { ierr = VecCopy(qep->V[k],Vr);CHKERRQ(ierr); } |
| if (Vi) { ierr = VecSet(Vi,0.0);CHKERRQ(ierr); } |
| #else |
| if (qep->eigi[k]>0) { /* first value of conjugate pair */ |
| if (Vr) { ierr = VecCopy(qep->V[k],Vr);CHKERRQ(ierr); } |
| if (Vi) { ierr = VecCopy(qep->V[k+1],Vi);CHKERRQ(ierr); } |
| } else if (qep->eigi[k]<0) { /* second value of conjugate pair */ |
| if (Vr) { ierr = VecCopy(qep->V[k-1],Vr);CHKERRQ(ierr); } |
| if (Vi) { |
| ierr = VecCopy(qep->V[k],Vi);CHKERRQ(ierr); |
| ierr = VecScale(Vi,-1.0);CHKERRQ(ierr); |
| } |
| } else { /* real eigenvalue */ |
| if (Vr) { ierr = VecCopy(qep->V[k],Vr);CHKERRQ(ierr); } |
| if (Vi) { ierr = VecSet(Vi,0.0);CHKERRQ(ierr); } |
| } |
| #endif |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPGetErrorEstimate" |
| /*@ |
| QEPGetErrorEstimate - Returns the error estimate associated to the i-th |
| computed eigenpair. |
| Not Collective |
| Input Parameter: |
| + qep - quadratic eigensolver context |
| - i - index of eigenpair |
| Output Parameter: |
| . errest - the error estimate |
| Notes: |
| This is the error estimate used internally by the eigensolver. The actual |
| error bound can be computed with QEPComputeRelativeError(). See also the users |
| manual for details. |
| Level: advanced |
| .seealso: QEPComputeRelativeError() |
| @*/ |
| PetscErrorCode QEPGetErrorEstimate(QEP qep,PetscInt i,PetscReal *errest) |
| { |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| PetscValidPointer(errest,3); |
| if (!qep->eigr || !qep->eigi) { |
| SETERRQ(((PetscObject)qep)->comm,PETSC_ERR_ARG_WRONGSTATE,"QEPSolve must be called first"); |
| } |
| if (i<0 || i>=qep->nconv) { |
| SETERRQ(((PetscObject)qep)->comm,PETSC_ERR_ARG_OUTOFRANGE,"Argument 2 out of range"); |
| } |
| if (qep->perm) i = qep->perm[i]; |
| if (errest) *errest = qep->errest[i]; |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPComputeResidualNorm_Private" |
| /* |
| QEPComputeResidualNorm_Private - Computes the norm of the residual vector |
| associated with an eigenpair. |
| */ |
| PetscErrorCode QEPComputeResidualNorm_Private(QEP qep,PetscScalar kr,PetscScalar ki,Vec xr,Vec xi,PetscReal *norm) |
| { |
| PetscErrorCode ierr; |
| Vec u,w; |
| Mat M=qep->M,C=qep->C,K=qep->K; |
| #if !defined(PETSC_USE_COMPLEX) |
| Vec v,y,z; |
| PetscReal ni,nr; |
| PetscScalar a1,a2; |
| #endif |
| PetscFunctionBegin; |
| ierr = VecDuplicate(qep->V[0],&u);CHKERRQ(ierr); |
| ierr = VecDuplicate(u,&w);CHKERRQ(ierr); |
| #if !defined(PETSC_USE_COMPLEX) |
| if (ki == 0 || |
| PetscAbsScalar(ki) < PetscAbsScalar(kr*PETSC_MACHINE_EPSILON)) { |
| #endif |
| ierr = MatMult(K,xr,u);CHKERRQ(ierr); /* u=K*x */ |
| if (PetscAbsScalar(kr) > PETSC_MACHINE_EPSILON) { |
| ierr = MatMult(C,xr,w);CHKERRQ(ierr); /* w=C*x */ |
| ierr = VecAXPY(u,kr,w);CHKERRQ(ierr); /* u=l*C*x+K*x */ |
| ierr = MatMult(M,xr,w);CHKERRQ(ierr); /* w=M*x */ |
| ierr = VecAXPY(u,kr*kr,w);CHKERRQ(ierr); /* u=l^2*M*x+l*C*x+K*x */ |
| } |
| ierr = VecNorm(u,NORM_2,norm);CHKERRQ(ierr); |
| #if !defined(PETSC_USE_COMPLEX) |
| } else { |
| ierr = VecDuplicate(u,&v);CHKERRQ(ierr); |
| ierr = VecDuplicate(u,&y);CHKERRQ(ierr); |
| ierr = VecDuplicate(u,&z);CHKERRQ(ierr); |
| a1 = kr*kr-ki*ki; |
| a2 = 2.0*kr*ki; |
| ierr = MatMult(K,xr,u);CHKERRQ(ierr); /* u=K*xr */ |
| if (SlepcAbsEigenvalue(kr,ki) > PETSC_MACHINE_EPSILON) { |
| ierr = MatMult(C,xr,v);CHKERRQ(ierr); /* v=C*xr */ |
| ierr = MatMult(C,xi,w);CHKERRQ(ierr); /* w=C*xi */ |
| ierr = MatMult(M,xr,y);CHKERRQ(ierr); /* y=M*xr */ |
| ierr = MatMult(M,xi,z);CHKERRQ(ierr); /* z=M*xi */ |
| ierr = VecAXPY(u,kr,v);CHKERRQ(ierr); /* u=kr*C*xr+K*xr */ |
| ierr = VecAXPY(u,-ki,w);CHKERRQ(ierr); /* u=kr*C*xr-ki*C*xi+K*xr */ |
| ierr = VecAXPY(u,a1,y);CHKERRQ(ierr); /* u=a1*M*xr+kr*C*xr-ki*C*xi+K*xr */ |
| ierr = VecAXPY(u,-a2,z);CHKERRQ(ierr); /* u=a1*M*xr-a2*M*xi+kr*C*xr-ki*C*xi+K*xr */ |
| } |
| ierr = VecNorm(u,NORM_2,&nr);CHKERRQ(ierr); |
| ierr = MatMult(K,xi,u);CHKERRQ(ierr); /* u=K*xi */ |
| if (SlepcAbsEigenvalue(kr,ki) > PETSC_MACHINE_EPSILON) { |
| ierr = VecAXPY(u,kr,w);CHKERRQ(ierr); /* u=kr*C*xi+K*xi */ |
| ierr = VecAXPY(u,ki,v);CHKERRQ(ierr); /* u=kr*C*xi+ki*C*xi+K*xi */ |
| ierr = VecAXPY(u,a1,z);CHKERRQ(ierr); /* u=a1*M*xi+kr*C*xi+ki*C*xi+K*xi */ |
| ierr = VecAXPY(u,a2,y);CHKERRQ(ierr); /* u=a1*M*xi+a2*M*ki+kr*C*xi+ki*C*xi+K*xi */ |
| } |
| ierr = VecNorm(u,NORM_2,&ni);CHKERRQ(ierr); |
| *norm = SlepcAbsEigenvalue(nr,ni); |
| ierr = VecDestroy(&v);CHKERRQ(ierr); |
| ierr = VecDestroy(&y);CHKERRQ(ierr); |
| ierr = VecDestroy(&z);CHKERRQ(ierr); |
| } |
| #endif |
| ierr = VecDestroy(&w);CHKERRQ(ierr); |
| ierr = VecDestroy(&u);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPComputeResidualNorm" |
| /*@ |
| QEPComputeResidualNorm - Computes the norm of the residual vector associated with |
| the i-th computed eigenpair. |
| Collective on QEP |
| Input Parameter: |
| . qep - the quadratic eigensolver context |
| . i - the solution index |
| Output Parameter: |
| . norm - the residual norm, computed as ||(l^2*M+l*C+K)x||_2 where l is the |
| eigenvalue and x is the eigenvector. |
| If l=0 then the residual norm is computed as ||Kx||_2. |
| Notes: |
| The index i should be a value between 0 and nconv-1 (see QEPGetConverged()). |
| Eigenpairs are indexed according to the ordering criterion established |
| with QEPSetWhichEigenpairs(). |
| Level: beginner |
| .seealso: QEPSolve(), QEPGetConverged(), QEPSetWhichEigenpairs() |
| @*/ |
| PetscErrorCode QEPComputeResidualNorm(QEP qep,PetscInt i,PetscReal *norm) |
| { |
| PetscErrorCode ierr; |
| Vec xr,xi; |
| PetscScalar kr,ki; |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| PetscValidLogicalCollectiveInt(qep,i,2); |
| PetscValidPointer(norm,3); |
| ierr = VecDuplicate(qep->V[0],&xr);CHKERRQ(ierr); |
| ierr = VecDuplicate(qep->V[0],&xi);CHKERRQ(ierr); |
| ierr = QEPGetEigenpair(qep,i,&kr,&ki,xr,xi);CHKERRQ(ierr); |
| ierr = QEPComputeResidualNorm_Private(qep,kr,ki,xr,xi,norm);CHKERRQ(ierr); |
| ierr = VecDestroy(&xr);CHKERRQ(ierr); |
| ierr = VecDestroy(&xi);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPComputeRelativeError_Private" |
| /* |
| QEPComputeRelativeError_Private - Computes the relative error bound |
| associated with an eigenpair. |
| */ |
| PetscErrorCode QEPComputeRelativeError_Private(QEP qep,PetscScalar kr,PetscScalar ki,Vec xr,Vec xi,PetscReal *error) |
| { |
| PetscErrorCode ierr; |
| PetscReal norm,er; |
| #if !defined(PETSC_USE_COMPLEX) |
| PetscReal ei; |
| #endif |
| PetscFunctionBegin; |
| ierr = QEPComputeResidualNorm_Private(qep,kr,ki,xr,xi,&norm);CHKERRQ(ierr); |
| #if !defined(PETSC_USE_COMPLEX) |
| if (ki == 0 || |
| PetscAbsScalar(ki) < PetscAbsScalar(kr*PETSC_MACHINE_EPSILON)) { |
| #endif |
| ierr = VecNorm(xr,NORM_2,&er);CHKERRQ(ierr); |
| if (PetscAbsScalar(kr) > norm) { |
| *error = norm/(PetscAbsScalar(kr)*er); |
| } else { |
| *error = norm/er; |
| } |
| #if !defined(PETSC_USE_COMPLEX) |
| } else { |
| ierr = VecNorm(xr,NORM_2,&er);CHKERRQ(ierr); |
| ierr = VecNorm(xi,NORM_2,&ei);CHKERRQ(ierr); |
| if (SlepcAbsEigenvalue(kr,ki) > norm) { |
| *error = norm/(SlepcAbsEigenvalue(kr,ki)*SlepcAbsEigenvalue(er,ei)); |
| } else { |
| *error = norm/SlepcAbsEigenvalue(er,ei); |
| } |
| } |
| #endif |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPComputeRelativeError" |
| /*@ |
| QEPComputeRelativeError - Computes the relative error bound associated |
| with the i-th computed eigenpair. |
| Collective on QEP |
| Input Parameter: |
| . qep - the quadratic eigensolver context |
| . i - the solution index |
| Output Parameter: |
| . error - the relative error bound, computed as ||(l^2*M+l*C+K)x||_2/||lx||_2 where |
| l is the eigenvalue and x is the eigenvector. |
| If l=0 the relative error is computed as ||Kx||_2/||x||_2. |
| Level: beginner |
| .seealso: QEPSolve(), QEPComputeResidualNorm(), QEPGetErrorEstimate() |
| @*/ |
| PetscErrorCode QEPComputeRelativeError(QEP qep,PetscInt i,PetscReal *error) |
| { |
| PetscErrorCode ierr; |
| Vec xr,xi; |
| PetscScalar kr,ki; |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| PetscValidLogicalCollectiveInt(qep,i,2); |
| PetscValidPointer(error,3); |
| ierr = VecDuplicate(qep->V[0],&xr);CHKERRQ(ierr); |
| ierr = VecDuplicate(qep->V[0],&xi);CHKERRQ(ierr); |
| ierr = QEPGetEigenpair(qep,i,&kr,&ki,xr,xi);CHKERRQ(ierr); |
| ierr = QEPComputeRelativeError_Private(qep,kr,ki,xr,xi,error);CHKERRQ(ierr); |
| ierr = VecDestroy(&xr);CHKERRQ(ierr); |
| ierr = VecDestroy(&xi);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPSortEigenvalues" |
| /*@ |
| QEPSortEigenvalues - Sorts a list of eigenvalues according to the criterion |
| specified via QEPSetWhichEigenpairs(). |
| Not Collective |
| Input Parameters: |
| + qep - the quadratic eigensolver context |
| . n - number of eigenvalues in the list |
| . eigr - pointer to the array containing the eigenvalues |
| - eigi - imaginary part of the eigenvalues (only when using real numbers) |
| Output Parameter: |
| . perm - resulting permutation |
| Note: |
| The result is a list of indices in the original eigenvalue array |
| corresponding to the first nev eigenvalues sorted in the specified |
| criterion. |
| Level: developer |
| .seealso: QEPSortEigenvaluesReal(), QEPSetWhichEigenpairs() |
| @*/ |
| PetscErrorCode QEPSortEigenvalues(QEP qep,PetscInt n,PetscScalar *eigr,PetscScalar *eigi,PetscInt *perm) |
| { |
| PetscErrorCode ierr; |
| PetscScalar re,im; |
| PetscInt i,j,result,tmp; |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| PetscValidScalarPointer(eigr,3); |
| PetscValidScalarPointer(eigi,4); |
| PetscValidIntPointer(perm,5); |
| for (i=0; i<n; i++) { perm[i] = i; } |
| /* insertion sort */ |
| for (i=n-1; i>=0; i--) { |
| re = eigr[perm[i]]; |
| im = eigi[perm[i]]; |
| j = i + 1; |
| #if !defined(PETSC_USE_COMPLEX) |
| if (im != 0) { |
| /* complex eigenvalue */ |
| i--; |
| im = eigi[perm[i]]; |
| } |
| #endif |
| while (j<n) { |
| ierr = QEPCompareEigenvalues(qep,re,im,eigr[perm[j]],eigi[perm[j]],&result);CHKERRQ(ierr); |
| if (result >= 0) break; |
| #if !defined(PETSC_USE_COMPLEX) |
| /* keep together every complex conjugated eigenpair */ |
| if (im == 0) { |
| if (eigi[perm[j]] == 0) { |
| #endif |
| tmp = perm[j-1]; perm[j-1] = perm[j]; perm[j] = tmp; |
| j++; |
| #if !defined(PETSC_USE_COMPLEX) |
| } else { |
| tmp = perm[j-1]; perm[j-1] = perm[j]; perm[j] = perm[j+1]; perm[j+1] = tmp; |
| j+=2; |
| } |
| } else { |
| if (eigi[perm[j]] == 0) { |
| tmp = perm[j-2]; perm[j-2] = perm[j]; perm[j] = perm[j-1]; perm[j-1] = tmp; |
| j++; |
| } else { |
| tmp = perm[j-2]; perm[j-2] = perm[j]; perm[j] = tmp; |
| tmp = perm[j-1]; perm[j-1] = perm[j+1]; perm[j+1] = tmp; |
| j+=2; |
| } |
| } |
| #endif |
| } |
| } |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPSortEigenvaluesReal" |
| /*@ |
| QEPSortEigenvaluesReal - Sorts a list of eigenvalues according to a certain |
| criterion (version for real eigenvalues only). |
| Not Collective |
| Input Parameters: |
| + qep - the quadratic eigensolver context |
| . n - number of eigenvalue in the list |
| - eig - pointer to the array containing the eigenvalues (real) |
| Output Parameter: |
| . perm - resulting permutation |
| Note: |
| The result is a list of indices in the original eigenvalue array |
| corresponding to the first nev eigenvalues sorted in the specified |
| criterion. |
| Level: developer |
| .seealso: QEPSortEigenvalues(), QEPSetWhichEigenpairs(), QEPCompareEigenvalues() |
| @*/ |
| PetscErrorCode QEPSortEigenvaluesReal(QEP qep,PetscInt n,PetscReal *eig,PetscInt *perm) |
| { |
| PetscErrorCode ierr; |
| PetscScalar re; |
| PetscInt i,j,result,tmp; |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| PetscValidScalarPointer(eig,3); |
| PetscValidIntPointer(perm,4); |
| for (i=0; i<n; i++) { perm[i] = i; } |
| /* insertion sort */ |
| for (i=1; i<n; i++) { |
| re = eig[perm[i]]; |
| j = i-1; |
| ierr = QEPCompareEigenvalues(qep,re,0.0,eig[perm[j]],0.0,&result);CHKERRQ(ierr); |
| while (result>0 && j>=0) { |
| tmp = perm[j]; perm[j] = perm[j+1]; perm[j+1] = tmp; j--; |
| if (j>=0) { |
| ierr = QEPCompareEigenvalues(qep,re,0.0,eig[perm[j]],0.0,&result);CHKERRQ(ierr); |
| } |
| } |
| } |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPCompareEigenvalues" |
| /*@ |
| QEPCompareEigenvalues - Compares two (possibly complex) eigenvalues according |
| to a certain criterion. |
| Not Collective |
| Input Parameters: |
| + qep - the quadratic eigensolver context |
| . ar - real part of the 1st eigenvalue |
| . ai - imaginary part of the 1st eigenvalue |
| . br - real part of the 2nd eigenvalue |
| - bi - imaginary part of the 2nd eigenvalue |
| Output Parameter: |
| . res - result of comparison |
| Notes: |
| Returns an integer less than, equal to, or greater than zero if the first |
| eigenvalue is considered to be respectively less than, equal to, or greater |
| than the second one. |
| The criterion of comparison is related to the 'which' parameter set with |
| QEPSetWhichEigenpairs(). |
| Level: developer |
| .seealso: QEPSortEigenvalues(), QEPSetWhichEigenpairs() |
| @*/ |
| PetscErrorCode QEPCompareEigenvalues(QEP qep,PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *result) |
| { |
| PetscReal a,b; |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| PetscValidIntPointer(result,6); |
| switch(qep->which) { |
| case QEP_LARGEST_MAGNITUDE: |
| case QEP_SMALLEST_MAGNITUDE: |
| a = SlepcAbsEigenvalue(ar,ai); |
| b = SlepcAbsEigenvalue(br,bi); |
| break; |
| case QEP_LARGEST_REAL: |
| case QEP_SMALLEST_REAL: |
| a = PetscRealPart(ar); |
| b = PetscRealPart(br); |
| break; |
| case QEP_LARGEST_IMAGINARY: |
| case QEP_SMALLEST_IMAGINARY: |
| #if defined(PETSC_USE_COMPLEX) |
| a = PetscImaginaryPart(ar); |
| b = PetscImaginaryPart(br); |
| #else |
| a = PetscAbsReal(ai); |
| b = PetscAbsReal(bi); |
| #endif |
| break; |
| default: SETERRQ(((PetscObject)qep)->comm,1,"Wrong value of which"); |
| } |
| switch(qep->which) { |
| case QEP_LARGEST_MAGNITUDE: |
| case QEP_LARGEST_REAL: |
| case QEP_LARGEST_IMAGINARY: |
| if (a<b) *result = -1; |
| else if (a>b) *result = 1; |
| else *result = 0; |
| break; |
| default: |
| if (a>b) *result = -1; |
| else if (a<b) *result = 1; |
| else *result = 0; |
| } |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPGetOperationCounters" |
| /*@ |
| QEPGetOperationCounters - Gets the total number of matrix-vector products, dot |
| products, and linear solve iterations used by the QEP object during the last |
| QEPSolve() call. |
| Not Collective |
| Input Parameter: |
| . qep - quadratic eigensolver context |
| Output Parameter: |
| + matvecs - number of matrix-vector product operations |
| . dots - number of dot product operations |
| - lits - number of linear iterations |
| Notes: |
| These counters are reset to zero at each successive call to QEPSolve(). |
| Level: intermediate |
| @*/ |
| PetscErrorCode QEPGetOperationCounters(QEP qep,PetscInt* matvecs,PetscInt* dots,PetscInt* lits) |
| { |
| PetscErrorCode ierr; |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| if (matvecs) *matvecs = qep->matvecs; |
| if (dots) { |
| if (!qep->ip) { ierr = QEPGetIP(qep,&qep->ip);CHKERRQ(ierr); } |
| ierr = IPGetOperationCounters(qep->ip,dots);CHKERRQ(ierr); |
| } |
| if (lits) *lits = qep->linits; |
| PetscFunctionReturn(0); |
| } |
| /* |
| QEP routines related to monitors. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| SLEPc - Scalable Library for Eigenvalue Problem Computations |
| Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| This file is part of SLEPc. |
| SLEPc is free software: you can redistribute it and/or modify it under the |
| terms of version 3 of the GNU Lesser General Public License as published by |
| the Free Software Foundation. |
| SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| more details. |
| You should have received a copy of the GNU Lesser General Public License |
| along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| */ |
| #include <private/qepimpl.h> /*I "slepcqep.h" I*/ |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPMonitor" |
| /* |
| Runs the user provided monitor routines, if any. |
| */ |
| PetscErrorCode QEPMonitor(QEP qep,PetscInt it,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest) |
| { |
| PetscErrorCode ierr; |
| PetscInt i,n = qep->numbermonitors; |
| PetscFunctionBegin; |
| for (i=0;i<n;i++) { |
| ierr = (*qep->monitor[i])(qep,it,nconv,eigr,eigi,errest,nest,qep->monitorcontext[i]);CHKERRQ(ierr); |
| } |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPMonitorSet" |
| /*@C |
| QEPMonitorSet - Sets an ADDITIONAL function to be called at every |
| iteration to monitor the error estimates for each requested eigenpair. |
| Logically Collective on QEP |
| Input Parameters: |
| + qep - eigensolver context obtained from QEPCreate() |
| . monitor - pointer to function (if this is PETSC_NULL, it turns off monitoring) |
| . mctx - [optional] context for private data for the |
| monitor routine (use PETSC_NULL if no context is desired) |
| - monitordestroy - [optional] routine that frees monitor context |
| (may be PETSC_NULL) |
| Calling Sequence of monitor: |
| $ monitor (QEP qep, int its, int nconv, PetscScalar *eigr, PetscScalar *eigi, PetscReal* errest, int nest, void *mctx) |
| + qep - quadratic eigensolver context obtained from QEPCreate() |
| . its - iteration number |
| . nconv - number of converged eigenpairs |
| . eigr - real part of the eigenvalues |
| . eigi - imaginary part of the eigenvalues |
| . errest - relative error estimates for each eigenpair |
| . nest - number of error estimates |
| - mctx - optional monitoring context, as set by QEPMonitorSet() |
| Options Database Keys: |
| + -qep_monitor - print only the first error estimate |
| . -qep_monitor_all - print error estimates at each iteration |
| . -qep_monitor_conv - print the eigenvalue approximations only when |
| convergence has been reached |
| . -qep_monitor_draw - sets line graph monitor for the first unconverged |
| approximate eigenvalue |
| . -qep_monitor_draw_all - sets line graph monitor for all unconverged |
| approximate eigenvalue |
| - -qep_monitor_cancel - cancels all monitors that have been hardwired into |
| a code by calls to QEPMonitorSet(), but does not cancel those set via |
| the options database. |
| Notes: |
| Several different monitoring routines may be set by calling |
| QEPMonitorSet() multiple times; all will be called in the |
| order in which they were set. |
| Level: intermediate |
| .seealso: QEPMonitorFirst(), QEPMonitorAll(), QEPMonitorCancel() |
| @*/ |
| PetscErrorCode QEPMonitorSet(QEP qep,PetscErrorCode (*monitor)(QEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*),void *mctx,PetscErrorCode (*monitordestroy)(void**)) |
| { |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| if (qep->numbermonitors >= MAXQEPMONITORS) { |
| SETERRQ(((PetscObject)qep)->comm,PETSC_ERR_ARG_OUTOFRANGE,"Too many QEP monitors set"); |
| } |
| qep->monitor[qep->numbermonitors] = monitor; |
| qep->monitorcontext[qep->numbermonitors] = (void*)mctx; |
| qep->monitordestroy[qep->numbermonitors++] = monitordestroy; |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPMonitorCancel" |
| /*@ |
| QEPMonitorCancel - Clears all monitors for a QEP object. |
| Logically Collective on QEP |
| Input Parameters: |
| . qep - eigensolver context obtained from QEPCreate() |
| Options Database Key: |
| . -qep_monitor_cancel - Cancels all monitors that have been hardwired |
| into a code by calls to QEPMonitorSet(), |
| but does not cancel those set via the options database. |
| Level: intermediate |
| .seealso: QEPMonitorSet() |
| @*/ |
| PetscErrorCode QEPMonitorCancel(QEP qep) |
| { |
| PetscErrorCode ierr; |
| PetscInt i; |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| for (i=0; i<qep->numbermonitors; i++) { |
| if (qep->monitordestroy[i]) { |
| ierr = (*qep->monitordestroy[i])(&qep->monitorcontext[i]);CHKERRQ(ierr); |
| } |
| } |
| qep->numbermonitors = 0; |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPGetMonitorContext" |
| /*@C |
| QEPGetMonitorContext - Gets the monitor context, as set by |
| QEPMonitorSet() for the FIRST monitor only. |
| Not Collective |
| Input Parameter: |
| . qep - eigensolver context obtained from QEPCreate() |
| Output Parameter: |
| . ctx - monitor context |
| Level: intermediate |
| .seealso: QEPMonitorSet(), QEPDefaultMonitor() |
| @*/ |
| PetscErrorCode QEPGetMonitorContext(QEP qep,void **ctx) |
| { |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| *ctx = (qep->monitorcontext[0]); |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPMonitorAll" |
| /*@C |
| QEPMonitorAll - Print the current approximate values and |
| error estimates at each iteration of the quadratic eigensolver. |
| Collective on QEP |
| Input Parameters: |
| + qep - quadratic eigensolver context |
| . its - iteration number |
| . nconv - number of converged eigenpairs so far |
| . eigr - real part of the eigenvalues |
| . eigi - imaginary part of the eigenvalues |
| . errest - error estimates |
| . nest - number of error estimates to display |
| - monctx - monitor context (contains viewer, can be PETSC_NULL) |
| Level: intermediate |
| .seealso: QEPMonitorSet(), QEPMonitorFirst(), QEPMonitorConverged() |
| @*/ |
| PetscErrorCode QEPMonitorAll(QEP qep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *monctx) |
| { |
| PetscErrorCode ierr; |
| PetscInt i; |
| PetscViewer viewer = monctx? (PetscViewer)monctx: PETSC_VIEWER_STDOUT_(((PetscObject)qep)->comm); |
| PetscFunctionBegin; |
| if (its) { |
| ierr = PetscViewerASCIIAddTab(viewer,((PetscObject)qep)->tablevel);CHKERRQ(ierr); |
| ierr = PetscViewerASCIIPrintf(viewer,"%3D QEP nconv=%D Values (Errors)",its,nconv);CHKERRQ(ierr); |
| for (i=0;i<nest;i++) { |
| #if defined(PETSC_USE_COMPLEX) |
| ierr = PetscViewerASCIIPrintf(viewer," %G%+Gi",PetscRealPart(eigr[i]),PetscImaginaryPart(eigr[i]));CHKERRQ(ierr); |
| #else |
| ierr = PetscViewerASCIIPrintf(viewer," %G",eigr[i]);CHKERRQ(ierr); |
| if (eigi[i]!=0.0) { ierr = PetscViewerASCIIPrintf(viewer,"%+Gi",eigi[i]);CHKERRQ(ierr); } |
| #endif |
| ierr = PetscViewerASCIIPrintf(viewer," (%10.8e)",(double)errest[i]);CHKERRQ(ierr); |
| } |
| ierr = PetscViewerASCIIPrintf(viewer,"\n");CHKERRQ(ierr); |
| ierr = PetscViewerASCIISubtractTab(viewer,((PetscObject)qep)->tablevel);CHKERRQ(ierr); |
| } |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPMonitorFirst" |
| /*@C |
| QEPMonitorFirst - Print the first unconverged approximate value and |
| error estimate at each iteration of the quadratic eigensolver. |
| Collective on QEP |
| Input Parameters: |
| + qep - quadratic eigensolver context |
| . its - iteration number |
| . nconv - number of converged eigenpairs so far |
| . eigr - real part of the eigenvalues |
| . eigi - imaginary part of the eigenvalues |
| . errest - error estimates |
| . nest - number of error estimates to display |
| - monctx - monitor context (contains viewer, can be PETSC_NULL) |
| Level: intermediate |
| .seealso: QEPMonitorSet(), QEPMonitorAll(), QEPMonitorConverged() |
| @*/ |
| PetscErrorCode QEPMonitorFirst(QEP qep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *monctx) |
| { |
| PetscErrorCode ierr; |
| PetscViewer viewer = monctx? (PetscViewer)monctx: PETSC_VIEWER_STDOUT_(((PetscObject)qep)->comm); |
| PetscFunctionBegin; |
| if (its && nconv<nest) { |
| ierr = PetscViewerASCIIAddTab(viewer,((PetscObject)qep)->tablevel);CHKERRQ(ierr); |
| ierr = PetscViewerASCIIPrintf(viewer,"%3D QEP nconv=%D first unconverged value (error)",its,nconv);CHKERRQ(ierr); |
| #if defined(PETSC_USE_COMPLEX) |
| ierr = PetscViewerASCIIPrintf(viewer," %G%+Gi",PetscRealPart(eigr[nconv]),PetscImaginaryPart(eigr[nconv]));CHKERRQ(ierr); |
| #else |
| ierr = PetscViewerASCIIPrintf(viewer," %G",eigr[nconv]);CHKERRQ(ierr); |
| if (eigi[nconv]!=0.0) { ierr = PetscViewerASCIIPrintf(viewer,"%+Gi",eigi[nconv]);CHKERRQ(ierr); } |
| #endif |
| ierr = PetscViewerASCIIPrintf(viewer," (%10.8e)\n",(double)errest[nconv]);CHKERRQ(ierr); |
| ierr = PetscViewerASCIISubtractTab(viewer,((PetscObject)qep)->tablevel);CHKERRQ(ierr); |
| } |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPMonitorConverged" |
| /*@C |
| QEPMonitorConverged - Print the approximate values and |
| error estimates as they converge. |
| Collective on QEP |
| Input Parameters: |
| + qep - quadratic eigensolver context |
| . its - iteration number |
| . nconv - number of converged eigenpairs so far |
| . eigr - real part of the eigenvalues |
| . eigi - imaginary part of the eigenvalues |
| . errest - error estimates |
| . nest - number of error estimates to display |
| - monctx - monitor context |
| Level: intermediate |
| Note: |
| The monitor context must contain a struct with a PetscViewer and a |
| PetscInt. In Fortran, pass a PETSC_NULL_OBJECT. |
| .seealso: QEPMonitorSet(), QEPMonitorFirst(), QEPMonitorAll() |
| @*/ |
| PetscErrorCode QEPMonitorConverged(QEP qep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *monctx) |
| { |
| PetscErrorCode ierr; |
| PetscInt i; |
| PetscViewer viewer; |
| SlepcConvMonitor ctx = (SlepcConvMonitor)monctx; |
| PetscFunctionBegin; |
| if (!monctx) SETERRQ(((PetscObject)qep)->comm,PETSC_ERR_ARG_WRONG,"Must provide a context for QEPMonitorConverged"); |
| if (!its) { |
| ctx->oldnconv = 0; |
| } else { |
| viewer = ctx->viewer? ctx->viewer: PETSC_VIEWER_STDOUT_(((PetscObject)qep)->comm); |
| for (i=ctx->oldnconv;i<nconv;i++) { |
| ierr = PetscViewerASCIIAddTab(viewer,((PetscObject)qep)->tablevel);CHKERRQ(ierr); |
| ierr = PetscViewerASCIIPrintf(viewer,"%3D QEP converged value (error) #%D",its,i);CHKERRQ(ierr); |
| #if defined(PETSC_USE_COMPLEX) |
| ierr = PetscViewerASCIIPrintf(viewer," %G%+Gi",PetscRealPart(eigr[i]),PetscImaginaryPart(eigr[i]));CHKERRQ(ierr); |
| #else |
| ierr = PetscViewerASCIIPrintf(viewer," %G",eigr[i]);CHKERRQ(ierr); |
| if (eigi[i]!=0.0) { ierr = PetscViewerASCIIPrintf(viewer,"%+Gi",eigi[i]);CHKERRQ(ierr); } |
| #endif |
| ierr = PetscViewerASCIIPrintf(viewer," (%10.8e)\n",(double)errest[i]);CHKERRQ(ierr); |
| ierr = PetscViewerASCIISubtractTab(viewer,((PetscObject)qep)->tablevel);CHKERRQ(ierr); |
| } |
| ctx->oldnconv = nconv; |
| } |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPMonitorLG" |
| PetscErrorCode QEPMonitorLG(QEP qep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *monctx) |
| { |
| PetscViewer viewer = (PetscViewer) monctx; |
| PetscDraw draw; |
| PetscDrawLG lg; |
| PetscErrorCode ierr; |
| PetscReal x,y; |
| PetscFunctionBegin; |
| if (!viewer) { viewer = PETSC_VIEWER_DRAW_(((PetscObject)qep)->comm); } |
| ierr = PetscViewerDrawGetDraw(viewer,0,&draw);CHKERRQ(ierr); |
| ierr = PetscViewerDrawGetDrawLG(viewer,0,&lg);CHKERRQ(ierr); |
| if (!its) { |
| ierr = PetscDrawSetTitle(draw,"Error estimates");CHKERRQ(ierr); |
| ierr = PetscDrawSetDoubleBuffer(draw);CHKERRQ(ierr); |
| ierr = PetscDrawLGSetDimension(lg,1);CHKERRQ(ierr); |
| ierr = PetscDrawLGReset(lg);CHKERRQ(ierr); |
| ierr = PetscDrawLGSetLimits(lg,0,1.0,log10(qep->tol)-2,0.0);CHKERRQ(ierr); |
| } |
| x = (PetscReal) its; |
| if (errest[nconv] > 0.0) y = log10(errest[nconv]); else y = 0.0; |
| ierr = PetscDrawLGAddPoint(lg,&x,&y);CHKERRQ(ierr); |
| ierr = PetscDrawLGDraw(lg);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPMonitorLGAll" |
| PetscErrorCode QEPMonitorLGAll(QEP qep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *monctx) |
| { |
| PetscViewer viewer = (PetscViewer) monctx; |
| PetscDraw draw; |
| PetscDrawLG lg; |
| PetscErrorCode ierr; |
| PetscReal *x,*y; |
| PetscInt i,n = PetscMin(qep->nev,255); |
| PetscFunctionBegin; |
| if (!viewer) { viewer = PETSC_VIEWER_DRAW_(((PetscObject)qep)->comm); } |
| ierr = PetscViewerDrawGetDraw(viewer,0,&draw);CHKERRQ(ierr); |
| ierr = PetscViewerDrawGetDrawLG(viewer,0,&lg);CHKERRQ(ierr); |
| if (!its) { |
| ierr = PetscDrawSetTitle(draw,"Error estimates");CHKERRQ(ierr); |
| ierr = PetscDrawSetDoubleBuffer(draw);CHKERRQ(ierr); |
| ierr = PetscDrawLGSetDimension(lg,n);CHKERRQ(ierr); |
| ierr = PetscDrawLGReset(lg);CHKERRQ(ierr); |
| ierr = PetscDrawLGSetLimits(lg,0,1.0,log10(qep->tol)-2,0.0);CHKERRQ(ierr); |
| } |
| ierr = PetscMalloc(sizeof(PetscReal)*n,&x);CHKERRQ(ierr); |
| ierr = PetscMalloc(sizeof(PetscReal)*n,&y);CHKERRQ(ierr); |
| for (i=0;i<n;i++) { |
| x[i] = (PetscReal) its; |
| if (i < nest && errest[i] > 0.0) y[i] = log10(errest[i]); |
| else y[i] = 0.0; |
| } |
| ierr = PetscDrawLGAddPoint(lg,x,y);CHKERRQ(ierr); |
| ierr = PetscDrawLGDraw(lg);CHKERRQ(ierr); |
| ierr = PetscFree(x);CHKERRQ(ierr); |
| ierr = PetscFree(y);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| /* |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| SLEPc - Scalable Library for Eigenvalue Problem Computations |
| Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| This file is part of SLEPc. |
| SLEPc is free software: you can redistribute it and/or modify it under the |
| terms of version 3 of the GNU Lesser General Public License as published by |
| the Free Software Foundation. |
| SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| more details. |
| You should have received a copy of the GNU Lesser General Public License |
| along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| */ |
| #include <private/qepimpl.h> /*I "slepcqep.h" I*/ |
| EXTERN_C_BEGIN |
| extern PetscErrorCode QEPCreate_Linear(QEP); |
| extern PetscErrorCode QEPCreate_QArnoldi(QEP); |
| EXTERN_C_END |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPRegisterAll" |
| /*@C |
| QEPRegisterAll - Registers all the solvers in the QEP package. |
| Not Collective |
| Level: advanced |
| .seealso: QEPRegisterDynamic() |
| @*/ |
| PetscErrorCode QEPRegisterAll(const char *path) |
| { |
| PetscErrorCode ierr; |
| PetscFunctionBegin; |
| QEPRegisterAllCalled = PETSC_TRUE; |
| ierr = QEPRegisterDynamic(QEPLINEAR,path,"QEPCreate_Linear",QEPCreate_Linear);CHKERRQ(ierr); |
| ierr = QEPRegisterDynamic(QEPQARNOLDI,path,"QEPCreate_QArnoldi",QEPCreate_QArnoldi);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| /* |
| This file contains routines for handling small-size dense quadratic problems. |
| All routines are based on calls to LAPACK routines. Matrices passed in |
| as arguments are assumed to be square matrices stored in column-major |
| format with a leading dimension equal to the number of rows. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| SLEPc - Scalable Library for Eigenvalue Problem Computations |
| Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| This file is part of SLEPc. |
| SLEPc is free software: you can redistribute it and/or modify it under the |
| terms of version 3 of the GNU Lesser General Public License as published by |
| the Free Software Foundation. |
| SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| more details. |
| You should have received a copy of the GNU Lesser General Public License |
| along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| */ |
| #include <private/qepimpl.h> /*I "slepcqep.h" I*/ |
| #include <slepcblaslapack.h> |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPSortDenseSchur" |
| /*@ |
| QEPSortDenseSchur - Reorders the Schur decomposition computed by |
| EPSDenseSchur(). |
| Not Collective |
| Input Parameters: |
| + qep - the qep solver context |
| . n - dimension of the matrix |
| . k - first active column |
| - ldt - leading dimension of T |
| Input/Output Parameters: |
| + T - the upper (quasi-)triangular matrix |
| . Q - the orthogonal matrix of Schur vectors |
| . wr - pointer to the array to store the computed eigenvalues |
| - wi - imaginary part of the eigenvalues (only when using real numbers) |
| Notes: |
| This function reorders the eigenvalues in wr,wi located in positions k |
| to n according to the sort order specified in EPSetWhicheigenpairs. |
| The Schur decomposition Z*T*Z^T, is also reordered by means of rotations |
| so that eigenvalues in the diagonal blocks of T follow the same order. |
| Both T and Q are overwritten. |
| This routine uses LAPACK routines xTREXC. |
| Level: developer |
| .seealso: EPSDenseHessenberg(), EPSDenseSchur(), EPSDenseTridiagonal() |
| @*/ |
| PetscErrorCode QEPSortDenseSchur(QEP qep,PetscInt n_,PetscInt k,PetscScalar *T,PetscInt ldt_,PetscScalar *Q,PetscScalar *wr,PetscScalar *wi) |
| { |
| #if defined(SLEPC_MISSING_LAPACK_TREXC) |
| PetscFunctionBegin; |
| SETERRQ(((PetscObject)qep)->comm,PETSC_ERR_SUP,"TREXC - Lapack routine is unavailable."); |
| #else |
| PetscErrorCode ierr; |
| PetscScalar re,im; |
| PetscInt i,j,pos,result; |
| PetscBLASInt ifst,ilst,info,n,ldt; |
| #if !defined(PETSC_USE_COMPLEX) |
| PetscScalar *work; |
| #endif |
| PetscFunctionBegin; |
| ierr = PetscLogEventBegin(QEP_Dense,0,0,0,0);CHKERRQ(ierr); |
| n = PetscBLASIntCast(n_); |
| ldt = PetscBLASIntCast(ldt_); |
| #if !defined(PETSC_USE_COMPLEX) |
| ierr = PetscMalloc(n*sizeof(PetscScalar),&work);CHKERRQ(ierr); |
| #endif |
| /* selection sort */ |
| for (i=k;i<n-1;i++) { |
| re = wr[i]; |
| im = wi[i]; |
| pos = 0; |
| j=i+1; /* j points to the next eigenvalue */ |
| #if !defined(PETSC_USE_COMPLEX) |
| if (im != 0) j=i+2; |
| #endif |
| /* find minimum eigenvalue */ |
| for (;j<n;j++) { |
| ierr = QEPCompareEigenvalues(qep,re,im,wr[j],wi[j],&result);CHKERRQ(ierr); |
| if (result < 0) { |
| re = wr[j]; |
| im = wi[j]; |
| pos = j; |
| } |
| #if !defined(PETSC_USE_COMPLEX) |
| if (wi[j] != 0) j++; |
| #endif |
| } |
| if (pos) { |
| /* interchange blocks */ |
| ifst = PetscBLASIntCast(pos + 1); |
| ilst = PetscBLASIntCast(i + 1); |
| #if !defined(PETSC_USE_COMPLEX) |
| LAPACKtrexc_("V",&n,T,&ldt,Q,&n,&ifst,&ilst,work,&info); |
| #else |
| LAPACKtrexc_("V",&n,T,&ldt,Q,&n,&ifst,&ilst,&info); |
| #endif |
| if (info) SETERRQ1(((PetscObject)qep)->comm,PETSC_ERR_LIB,"Error in Lapack xTREXC %d",info); |
| /* recover original eigenvalues from T matrix */ |
| for (j=i;j<n;j++) { |
| wr[j] = T[j*ldt+j]; |
| #if !defined(PETSC_USE_COMPLEX) |
| if (j<n-1 && T[j*ldt+j+1] != 0.0) { |
| /* complex conjugate eigenvalue */ |
| wi[j] = PetscSqrtReal(PetscAbsReal(T[j*ldt+j+1])) * |
| PetscSqrtReal(PetscAbsReal(T[(j+1)*ldt+j])); |
| wr[j+1] = wr[j]; |
| wi[j+1] = -wi[j]; |
| j++; |
| } else |
| #endif |
| wi[j] = 0.0; |
| } |
| } |
| #if !defined(PETSC_USE_COMPLEX) |
| if (wi[i] != 0) i++; |
| #endif |
| } |
| #if !defined(PETSC_USE_COMPLEX) |
| ierr = PetscFree(work);CHKERRQ(ierr); |
| #endif |
| ierr = PetscLogEventEnd(QEP_Dense,0,0,0,0);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| #endif |
| } |
| /* |
| QEP routines related to problem setup. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| SLEPc - Scalable Library for Eigenvalue Problem Computations |
| Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| This file is part of SLEPc. |
| SLEPc is free software: you can redistribute it and/or modify it under the |
| terms of version 3 of the GNU Lesser General Public License as published by |
| the Free Software Foundation. |
| SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| more details. |
| You should have received a copy of the GNU Lesser General Public License |
| along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| */ |
| #include <private/qepimpl.h> /*I "slepcqep.h" I*/ |
| #include <private/ipimpl.h> |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPSetUp" |
| /*@ |
| QEPSetUp - Sets up all the internal data structures necessary for the |
| execution of the QEP solver. |
| Collective on QEP |
| Input Parameter: |
| . qep - solver context |
| Notes: |
| This function need not be called explicitly in most cases, since QEPSolve() |
| calls it. It can be useful when one wants to measure the set-up time |
| separately from the solve time. |
| Level: advanced |
| .seealso: QEPCreate(), QEPSolve(), QEPDestroy() |
| @*/ |
| PetscErrorCode QEPSetUp(QEP qep) |
| { |
| PetscErrorCode ierr; |
| PetscInt i,k; |
| PetscBool khas,mhas,lindep; |
| PetscReal knorm,mnorm,norm; |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| if (qep->setupcalled) PetscFunctionReturn(0); |
| ierr = PetscLogEventBegin(QEP_SetUp,qep,0,0,0);CHKERRQ(ierr); |
| /* Set default solver type (QEPSetFromOptions was not called) */ |
| if (!((PetscObject)qep)->type_name) { |
| ierr = QEPSetType(qep,QEPLINEAR);CHKERRQ(ierr); |
| } |
| if (!qep->ip) { ierr = QEPGetIP(qep,&qep->ip);CHKERRQ(ierr); } |
| if (!((PetscObject)qep->ip)->type_name) { |
| ierr = IPSetDefaultType_Private(qep->ip);CHKERRQ(ierr); |
| } |
| if (!((PetscObject)qep->rand)->type_name) { |
| ierr = PetscRandomSetFromOptions(qep->rand);CHKERRQ(ierr); |
| } |
| /* Check matrices */ |
| if (!qep->M || !qep->C || !qep->K) |
| SETERRQ(((PetscObject)qep)->comm,PETSC_ERR_ARG_WRONGSTATE,"QEPSetOperators must be called first"); |
| /* Set problem dimensions */ |
| ierr = MatGetSize(qep->M,&qep->n,PETSC_NULL);CHKERRQ(ierr); |
| ierr = MatGetLocalSize(qep->M,&qep->nloc,PETSC_NULL);CHKERRQ(ierr); |
| ierr = VecDestroy(&qep->t);CHKERRQ(ierr); |
| ierr = SlepcMatGetVecsTemplate(qep->M,&qep->t,PETSC_NULL);CHKERRQ(ierr); |
| /* Set default problem type */ |
| if (!qep->problem_type) { |
| ierr = QEPSetProblemType(qep,QEP_GENERAL);CHKERRQ(ierr); |
| } |
| /* Compute scaling factor if not set by user */ |
| if (qep->sfactor==0.0) { |
| ierr = MatHasOperation(qep->K,MATOP_NORM,&khas);CHKERRQ(ierr); |
| ierr = MatHasOperation(qep->M,MATOP_NORM,&mhas);CHKERRQ(ierr); |
| if (khas && mhas) { |
| ierr = MatNorm(qep->K,NORM_INFINITY,&knorm);CHKERRQ(ierr); |
| ierr = MatNorm(qep->M,NORM_INFINITY,&mnorm);CHKERRQ(ierr); |
| qep->sfactor = PetscSqrtReal(knorm/mnorm); |
| } |
| else qep->sfactor = 1.0; |
| } |
| /* Call specific solver setup */ |
| ierr = (*qep->ops->setup)(qep);CHKERRQ(ierr); |
| /* set tolerance if not yet set */ |
| if (qep->tol==PETSC_DEFAULT) qep->tol = SLEPC_DEFAULT_TOL; |
| if (qep->ncv > 2*qep->n) |
| SETERRQ(((PetscObject)qep)->comm,PETSC_ERR_ARG_OUTOFRANGE,"ncv must be twice the problem size at most"); |
| if (qep->nev > qep->ncv) |
| SETERRQ(((PetscObject)qep)->comm,PETSC_ERR_ARG_OUTOFRANGE,"nev bigger than ncv"); |
| /* process initial vectors */ |
| if (qep->nini<0) { |
| qep->nini = -qep->nini; |
| if (qep->nini>qep->ncv) SETERRQ(((PetscObject)qep)->comm,1,"The number of initial vectors is larger than ncv"); |
| k = 0; |
| for (i=0;i<qep->nini;i++) { |
| ierr = VecCopy(qep->IS[i],qep->V[k]);CHKERRQ(ierr); |
| ierr = VecDestroy(&qep->IS[i]);CHKERRQ(ierr); |
| ierr = IPOrthogonalize(qep->ip,0,PETSC_NULL,k,PETSC_NULL,qep->V,qep->V[k],PETSC_NULL,&norm,&lindep);CHKERRQ(ierr); |
| if (norm==0.0 || lindep) PetscInfo(qep,"Linearly dependent initial vector found, removing...\n"); |
| else { |
| ierr = VecScale(qep->V[k],1.0/norm);CHKERRQ(ierr); |
| k++; |
| } |
| } |
| qep->nini = k; |
| ierr = PetscFree(qep->IS);CHKERRQ(ierr); |
| } |
| if (qep->ninil<0) { |
| if (!qep->leftvecs) PetscInfo(qep,"Ignoring initial left vectors\n"); |
| else { |
| qep->ninil = -qep->ninil; |
| if (qep->ninil>qep->ncv) SETERRQ(((PetscObject)qep)->comm,1,"The number of initial left vectors is larger than ncv"); |
| k = 0; |
| for (i=0;i<qep->ninil;i++) { |
| ierr = VecCopy(qep->ISL[i],qep->W[k]);CHKERRQ(ierr); |
| ierr = VecDestroy(&qep->ISL[i]);CHKERRQ(ierr); |
| ierr = IPOrthogonalize(qep->ip,0,PETSC_NULL,k,PETSC_NULL,qep->W,qep->W[k],PETSC_NULL,&norm,&lindep);CHKERRQ(ierr); |
| if (norm==0.0 || lindep) PetscInfo(qep,"Linearly dependent initial left vector found, removing...\n"); |
| else { |
| ierr = VecScale(qep->W[k],1.0/norm);CHKERRQ(ierr); |
| k++; |
| } |
| } |
| qep->ninil = k; |
| ierr = PetscFree(qep->ISL);CHKERRQ(ierr); |
| } |
| } |
| ierr = PetscLogEventEnd(QEP_SetUp,qep,0,0,0);CHKERRQ(ierr); |
| qep->setupcalled = 1; |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPSetOperators" |
| /*@ |
| QEPSetOperators - Sets the matrices associated with the quadratic eigenvalue problem. |
| Collective on QEP and Mat |
| Input Parameters: |
| + qep - the eigenproblem solver context |
| . M - the first coefficient matrix |
| . C - the second coefficient matrix |
| - K - the third coefficient matrix |
| Notes: |
| The quadratic eigenproblem is defined as (l^2*M + l*C + K)*x = 0, where l is |
| the eigenvalue and x is the eigenvector. |
| Level: beginner |
| .seealso: QEPSolve(), QEPGetOperators() |
| @*/ |
| PetscErrorCode QEPSetOperators(QEP qep,Mat M,Mat C,Mat K) |
| { |
| PetscErrorCode ierr; |
| PetscInt m,n,m0; |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| PetscValidHeaderSpecific(M,MAT_CLASSID,2); |
| PetscValidHeaderSpecific(C,MAT_CLASSID,3); |
| PetscValidHeaderSpecific(K,MAT_CLASSID,4); |
| PetscCheckSameComm(qep,1,M,2); |
| PetscCheckSameComm(qep,1,C,3); |
| PetscCheckSameComm(qep,1,K,4); |
| /* Check for square matrices */ |
| ierr = MatGetSize(M,&m,&n);CHKERRQ(ierr); |
| if (m!=n) { SETERRQ(((PetscObject)qep)->comm,1,"M is a non-square matrix"); } |
| m0=m; |
| ierr = MatGetSize(C,&m,&n);CHKERRQ(ierr); |
| if (m!=n) { SETERRQ(((PetscObject)qep)->comm,1,"C is a non-square matrix"); } |
| if (m!=m0) { SETERRQ(((PetscObject)qep)->comm,1,"Dimensions of M and C do not match"); } |
| ierr = MatGetSize(K,&m,&n);CHKERRQ(ierr); |
| if (m!=n) { SETERRQ(((PetscObject)qep)->comm,1,"K is a non-square matrix"); } |
| if (m!=m0) { SETERRQ(((PetscObject)qep)->comm,1,"Dimensions of M and K do not match"); } |
| /* Store a copy of the matrices */ |
| if (qep->setupcalled) { ierr = QEPReset(qep);CHKERRQ(ierr); } |
| ierr = PetscObjectReference((PetscObject)M);CHKERRQ(ierr); |
| ierr = MatDestroy(&qep->M);CHKERRQ(ierr); |
| qep->M = M; |
| ierr = PetscObjectReference((PetscObject)C);CHKERRQ(ierr); |
| ierr = MatDestroy(&qep->C);CHKERRQ(ierr); |
| qep->C = C; |
| ierr = PetscObjectReference((PetscObject)K);CHKERRQ(ierr); |
| ierr = MatDestroy(&qep->K);CHKERRQ(ierr); |
| qep->K = K; |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPGetOperators" |
| /*@ |
| QEPGetOperators - Gets the matrices associated with the quadratic eigensystem. |
| Collective on QEP and Mat |
| Input Parameter: |
| . qep - the QEP context |
| Output Parameters: |
| + M - the first coefficient matrix |
| . C - the second coefficient matrix |
| - K - the third coefficient matrix |
| Level: intermediate |
| .seealso: QEPSolve(), QEPSetOperators() |
| @*/ |
| PetscErrorCode QEPGetOperators(QEP qep,Mat *M,Mat *C,Mat *K) |
| { |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| if (M) { PetscValidPointer(M,2); *M = qep->M; } |
| if (C) { PetscValidPointer(C,3); *C = qep->C; } |
| if (K) { PetscValidPointer(K,4); *K = qep->K; } |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPSetInitialSpace" |
| /*@ |
| QEPSetInitialSpace - Specify a basis of vectors that constitute the initial |
| space, that is, the subspace from which the solver starts to iterate. |
| Collective on QEP and Vec |
| Input Parameter: |
| + qep - the quadratic eigensolver context |
| . n - number of vectors |
| - is - set of basis vectors of the initial space |
| Notes: |
| Some solvers start to iterate on a single vector (initial vector). In that case, |
| the other vectors are ignored. |
| These vectors do not persist from one QEPSolve() call to the other, so the |
| initial space should be set every time. |
| The vectors do not need to be mutually orthonormal, since they are explicitly |
| orthonormalized internally. |
| Common usage of this function is when the user can provide a rough approximation |
| of the wanted eigenspace. Then, convergence may be faster. |
| Level: intermediate |
| .seealso: QEPSetInitialSpaceLeft() |
| @*/ |
| PetscErrorCode QEPSetInitialSpace(QEP qep,PetscInt n,Vec *is) |
| { |
| PetscErrorCode ierr; |
| PetscInt i; |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| PetscValidLogicalCollectiveInt(qep,n,2); |
| if (n<0) SETERRQ(((PetscObject)qep)->comm,PETSC_ERR_ARG_OUTOFRANGE,"Argument n cannot be negative"); |
| /* free previous non-processed vectors */ |
| if (qep->nini<0) { |
| for (i=0;i<-qep->nini;i++) { |
| ierr = VecDestroy(&qep->IS[i]);CHKERRQ(ierr); |
| } |
| ierr = PetscFree(qep->IS);CHKERRQ(ierr); |
| } |
| /* get references of passed vectors */ |
| ierr = PetscMalloc(n*sizeof(Vec),&qep->IS);CHKERRQ(ierr); |
| for (i=0;i<n;i++) { |
| ierr = PetscObjectReference((PetscObject)is[i]);CHKERRQ(ierr); |
| qep->IS[i] = is[i]; |
| } |
| qep->nini = -n; |
| qep->setupcalled = 0; |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPSetInitialSpaceLeft" |
| /*@ |
| QEPSetInitialSpaceLeft - Specify a basis of vectors that constitute the initial |
| left space, that is, the subspace from which the solver starts to iterate for |
| building the left subspace (in methods that work with two subspaces). |
| Collective on QEP and Vec |
| Input Parameter: |
| + qep - the quadratic eigensolver context |
| . n - number of vectors |
| - is - set of basis vectors of the initial left space |
| Notes: |
| Some solvers start to iterate on a single vector (initial left vector). In that case, |
| the other vectors are ignored. |
| These vectors do not persist from one QEPSolve() call to the other, so the |
| initial left space should be set every time. |
| The vectors do not need to be mutually orthonormal, since they are explicitly |
| orthonormalized internally. |
| Common usage of this function is when the user can provide a rough approximation |
| of the wanted left eigenspace. Then, convergence may be faster. |
| Level: intermediate |
| .seealso: QEPSetInitialSpace() |
| @*/ |
| PetscErrorCode QEPSetInitialSpaceLeft(QEP qep,PetscInt n,Vec *is) |
| { |
| PetscErrorCode ierr; |
| PetscInt i; |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| PetscValidLogicalCollectiveInt(qep,n,2); |
| if (n<0) SETERRQ(((PetscObject)qep)->comm,PETSC_ERR_ARG_OUTOFRANGE,"Argument n cannot be negative"); |
| /* free previous non-processed vectors */ |
| if (qep->ninil<0) { |
| for (i=0;i<-qep->ninil;i++) { |
| ierr = VecDestroy(&qep->ISL[i]);CHKERRQ(ierr); |
| } |
| ierr = PetscFree(qep->ISL);CHKERRQ(ierr); |
| } |
| /* get references of passed vectors */ |
| ierr = PetscMalloc(n*sizeof(Vec),&qep->ISL);CHKERRQ(ierr); |
| for (i=0;i<n;i++) { |
| ierr = PetscObjectReference((PetscObject)is[i]);CHKERRQ(ierr); |
| qep->ISL[i] = is[i]; |
| } |
| qep->ninil = -n; |
| qep->setupcalled = 0; |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPAllocateSolution" |
| /* |
| QEPAllocateSolution - Allocate memory storage for common variables such |
| as eigenvalues and eigenvectors. All vectors in V (and W) share a |
| contiguous chunk of memory. |
| */ |
| PetscErrorCode QEPAllocateSolution(QEP qep) |
| { |
| PetscErrorCode ierr; |
| PetscFunctionBegin; |
| if (qep->allocated_ncv != qep->ncv) { |
| ierr = QEPFreeSolution(qep);CHKERRQ(ierr); |
| ierr = PetscMalloc(qep->ncv*sizeof(PetscScalar),&qep->eigr);CHKERRQ(ierr); |
| ierr = PetscMalloc(qep->ncv*sizeof(PetscScalar),&qep->eigi);CHKERRQ(ierr); |
| ierr = PetscMalloc(qep->ncv*sizeof(PetscReal),&qep->errest);CHKERRQ(ierr); |
| ierr = PetscMalloc(qep->ncv*sizeof(PetscInt),&qep->perm);CHKERRQ(ierr); |
| ierr = VecDuplicateVecs(qep->t,qep->ncv,&qep->V);CHKERRQ(ierr); |
| qep->allocated_ncv = qep->ncv; |
| } |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPFreeSolution" |
| /* |
| QEPFreeSolution - Free memory storage. This routine is related to |
| QEPAllocateSolution(). |
| */ |
| PetscErrorCode QEPFreeSolution(QEP qep) |
| { |
| PetscErrorCode ierr; |
| PetscFunctionBegin; |
| if (qep->allocated_ncv > 0) { |
| ierr = PetscFree(qep->eigr);CHKERRQ(ierr); |
| ierr = PetscFree(qep->eigi);CHKERRQ(ierr); |
| ierr = PetscFree(qep->errest);CHKERRQ(ierr); |
| ierr = PetscFree(qep->perm);CHKERRQ(ierr); |
| ierr = VecDestroyVecs(qep->allocated_ncv,&qep->V);CHKERRQ(ierr); |
| qep->allocated_ncv = 0; |
| } |
| PetscFunctionReturn(0); |
| } |
| /* |
| The basic QEP routines, Create, View, etc. are here. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| SLEPc - Scalable Library for Eigenvalue Problem Computations |
| Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| This file is part of SLEPc. |
| SLEPc is free software: you can redistribute it and/or modify it under the |
| terms of version 3 of the GNU Lesser General Public License as published by |
| the Free Software Foundation. |
| SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| more details. |
| You should have received a copy of the GNU Lesser General Public License |
| along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| */ |
| #include <private/qepimpl.h> /*I "slepcqep.h" I*/ |
| PetscFList QEPList = 0; |
| PetscBool QEPRegisterAllCalled = PETSC_FALSE; |
| PetscClassId QEP_CLASSID = 0; |
| PetscLogEvent QEP_SetUp = 0,QEP_Solve = 0,QEP_Dense = 0; |
| static PetscBool QEPPackageInitialized = PETSC_FALSE; |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPFinalizePackage" |
| /*@C |
| QEPFinalizePackage - This function destroys everything in the Slepc interface |
| to the QEP package. It is called from SlepcFinalize(). |
| Level: developer |
| .seealso: SlepcFinalize() |
| @*/ |
| PetscErrorCode QEPFinalizePackage(void) |
| { |
| PetscFunctionBegin; |
| QEPPackageInitialized = PETSC_FALSE; |
| QEPList = 0; |
| QEPRegisterAllCalled = PETSC_FALSE; |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPInitializePackage" |
| /*@C |
| QEPInitializePackage - This function initializes everything in the QEP package. It is called |
| from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to QEPCreate() |
| when using static libraries. |
| Input Parameter: |
| . path - The dynamic library path, or PETSC_NULL |
| Level: developer |
| .seealso: SlepcInitialize() |
| @*/ |
| PetscErrorCode QEPInitializePackage(const char *path) |
| { |
| char logList[256]; |
| char *className; |
| PetscBool opt; |
| PetscErrorCode ierr; |
| PetscFunctionBegin; |
| if (QEPPackageInitialized) PetscFunctionReturn(0); |
| QEPPackageInitialized = PETSC_TRUE; |
| /* Register Classes */ |
| ierr = PetscClassIdRegister("Quadratic Eigenproblem Solver",&QEP_CLASSID);CHKERRQ(ierr); |
| /* Register Constructors */ |
| ierr = QEPRegisterAll(path);CHKERRQ(ierr); |
| /* Register Events */ |
| ierr = PetscLogEventRegister("QEPSetUp",QEP_CLASSID,&QEP_SetUp);CHKERRQ(ierr); |
| ierr = PetscLogEventRegister("QEPSolve",QEP_CLASSID,&QEP_Solve);CHKERRQ(ierr); |
| ierr = PetscLogEventRegister("QEPDense",QEP_CLASSID,&QEP_Dense);CHKERRQ(ierr); |
| /* Process info exclusions */ |
| ierr = PetscOptionsGetString(PETSC_NULL,"-info_exclude",logList,256,&opt);CHKERRQ(ierr); |
| if (opt) { |
| ierr = PetscStrstr(logList,"qep",&className);CHKERRQ(ierr); |
| if (className) { |
| ierr = PetscInfoDeactivateClass(QEP_CLASSID);CHKERRQ(ierr); |
| } |
| } |
| /* Process summary exclusions */ |
| ierr = PetscOptionsGetString(PETSC_NULL,"-log_summary_exclude",logList,256,&opt);CHKERRQ(ierr); |
| if (opt) { |
| ierr = PetscStrstr(logList,"qep",&className);CHKERRQ(ierr); |
| if (className) { |
| ierr = PetscLogEventDeactivateClass(QEP_CLASSID);CHKERRQ(ierr); |
| } |
| } |
| ierr = PetscRegisterFinalize(QEPFinalizePackage);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPView" |
| /*@C |
| QEPView - Prints the QEP data structure. |
| Collective on QEP |
| Input Parameters: |
| + qep - the quadratic eigenproblem solver context |
| - viewer - optional visualization context |
| Options Database Key: |
| . -qep_view - Calls QEPView() at end of QEPSolve() |
| Note: |
| The available visualization contexts include |
| + PETSC_VIEWER_STDOUT_SELF - standard output (default) |
| - PETSC_VIEWER_STDOUT_WORLD - synchronized standard |
| output where only the first processor opens |
| the file. All other processors send their |
| data to the first processor to print. |
| The user can open an alternative visualization context with |
| PetscViewerASCIIOpen() - output to a specified file. |
| Level: beginner |
| .seealso: PetscViewerASCIIOpen() |
| @*/ |
| PetscErrorCode QEPView(QEP qep,PetscViewer viewer) |
| { |
| PetscErrorCode ierr; |
| const char *type; |
| PetscBool isascii; |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| if (!viewer) viewer = PETSC_VIEWER_STDOUT_(((PetscObject)qep)->comm); |
| PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,2); |
| PetscCheckSameComm(qep,1,viewer,2); |
| #if defined(PETSC_USE_COMPLEX) |
| #define HERM "hermitian" |
| #else |
| #define HERM "symmetric" |
| #endif |
| ierr = PetscTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); |
| if (isascii) { |
| ierr = PetscObjectPrintClassNamePrefixType((PetscObject)qep,viewer,"QEP Object");CHKERRQ(ierr); |
| if (qep->ops->view) { |
| ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); |
| ierr = (*qep->ops->view)(qep,viewer);CHKERRQ(ierr); |
| ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); |
| } |
| if (qep->problem_type) { |
| switch (qep->problem_type) { |
| case QEP_GENERAL: type = "general quadratic eigenvalue problem"; break; |
| case QEP_HERMITIAN: type = HERM " quadratic eigenvalue problem"; break; |
| case QEP_GYROSCOPIC: type = "gyroscopic quadratic eigenvalue problem"; break; |
| default: SETERRQ(((PetscObject)qep)->comm,1,"Wrong value of qep->problem_type"); |
| } |
| } else type = "not yet set"; |
| ierr = PetscViewerASCIIPrintf(viewer," problem type: %s\n",type);CHKERRQ(ierr); |
| ierr = PetscViewerASCIIPrintf(viewer," selected portion of the spectrum: ");CHKERRQ(ierr); |
| if (!qep->which) { |
| ierr = PetscViewerASCIIPrintf(viewer,"not yet set\n");CHKERRQ(ierr); |
| } else switch (qep->which) { |
| case QEP_LARGEST_MAGNITUDE: |
| ierr = PetscViewerASCIIPrintf(viewer,"largest eigenvalues in magnitude\n");CHKERRQ(ierr); |
| break; |
| case QEP_SMALLEST_MAGNITUDE: |
| ierr = PetscViewerASCIIPrintf(viewer,"smallest eigenvalues in magnitude\n");CHKERRQ(ierr); |
| break; |
| case QEP_LARGEST_REAL: |
| ierr = PetscViewerASCIIPrintf(viewer,"largest real parts\n");CHKERRQ(ierr); |
| break; |
| case QEP_SMALLEST_REAL: |
| ierr = PetscViewerASCIIPrintf(viewer,"smallest real parts\n");CHKERRQ(ierr); |
| break; |
| case QEP_LARGEST_IMAGINARY: |
| ierr = PetscViewerASCIIPrintf(viewer,"largest imaginary parts\n");CHKERRQ(ierr); |
| break; |
| case QEP_SMALLEST_IMAGINARY: |
| ierr = PetscViewerASCIIPrintf(viewer,"smallest imaginary parts\n");CHKERRQ(ierr); |
| break; |
| default: SETERRQ(((PetscObject)qep)->comm,1,"Wrong value of qep->which"); |
| } |
| if (qep->leftvecs) { |
| ierr = PetscViewerASCIIPrintf(viewer," computing left eigenvectors also\n");CHKERRQ(ierr); |
| } |
| ierr = PetscViewerASCIIPrintf(viewer," number of eigenvalues (nev): %D\n",qep->nev);CHKERRQ(ierr); |
| ierr = PetscViewerASCIIPrintf(viewer," number of column vectors (ncv): %D\n",qep->ncv);CHKERRQ(ierr); |
| ierr = PetscViewerASCIIPrintf(viewer," maximum dimension of projected problem (mpd): %D\n",qep->mpd);CHKERRQ(ierr); |
| ierr = PetscViewerASCIIPrintf(viewer," maximum number of iterations: %D\n",qep->max_it); |
| ierr = PetscViewerASCIIPrintf(viewer," tolerance: %G\n",qep->tol);CHKERRQ(ierr); |
| ierr = PetscViewerASCIIPrintf(viewer," scaling factor: %G\n",qep->sfactor);CHKERRQ(ierr); |
| if (qep->nini!=0) { |
| ierr = PetscViewerASCIIPrintf(viewer," dimension of user-provided initial space: %D\n",PetscAbs(qep->nini));CHKERRQ(ierr); |
| } |
| if (qep->ninil!=0) { |
| ierr = PetscViewerASCIIPrintf(viewer," dimension of user-provided initial left space: %D\n",PetscAbs(qep->ninil));CHKERRQ(ierr); |
| } |
| } else { |
| if (qep->ops->view) { |
| ierr = (*qep->ops->view)(qep,viewer);CHKERRQ(ierr); |
| } |
| } |
| if (!qep->ip) { ierr = QEPGetIP(qep,&qep->ip);CHKERRQ(ierr); } |
| ierr = IPView(qep->ip,viewer);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPPrintSolution" |
| /*@ |
| QEPPrintSolution - Prints the computed eigenvalues. |
| Collective on QEP |
| Input Parameters: |
| + qep - the eigensolver context |
| - viewer - optional visualization context |
| Options Database: |
| . -qep_terse - print only minimal information |
| Note: |
| By default, this function prints a table with eigenvalues and associated |
| relative errors. With -qep_terse only the eigenvalues are printed. |
| Level: intermediate |
| .seealso: PetscViewerASCIIOpen() |
| @*/ |
| PetscErrorCode QEPPrintSolution(QEP qep,PetscViewer viewer) |
| { |
| PetscBool terse,errok,isascii; |
| PetscReal error,re,im; |
| PetscScalar kr,ki; |
| PetscInt i,j; |
| PetscErrorCode ierr; |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| if (!viewer) viewer = PETSC_VIEWER_STDOUT_(((PetscObject)qep)->comm); |
| PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,2); |
| PetscCheckSameComm(qep,1,viewer,2); |
| if (!qep->eigr || !qep->eigi || !qep->V) { |
| SETERRQ(((PetscObject)qep)->comm,PETSC_ERR_ARG_WRONGSTATE,"QEPSolve must be called first"); |
| } |
| ierr = PetscTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); |
| if (!isascii) PetscFunctionReturn(0); |
| ierr = PetscOptionsHasName(PETSC_NULL,"-qep_terse",&terse);CHKERRQ(ierr); |
| if (terse) { |
| if (qep->nconv<qep->nev) { |
| ierr = PetscViewerASCIIPrintf(viewer," Problem: less than %D eigenvalues converged\n\n",qep->nev);CHKERRQ(ierr); |
| } else { |
| errok = PETSC_TRUE; |
| for (i=0;i<qep->nev;i++) { |
| ierr = QEPComputeRelativeError(qep,i,&error);CHKERRQ(ierr); |
| errok = (errok && error<qep->tol)? PETSC_TRUE: PETSC_FALSE; |
| } |
| if (errok) { |
| ierr = PetscViewerASCIIPrintf(viewer," All requested eigenvalues computed up to the required tolerance:");CHKERRQ(ierr); |
| for (i=0;i<=(qep->nev-1)/8;i++) { |
| ierr = PetscViewerASCIIPrintf(viewer,"\n ");CHKERRQ(ierr); |
| for (j=0;j<PetscMin(8,qep->nev-8*i);j++) { |
| ierr = QEPGetEigenpair(qep,8*i+j,&kr,&ki,PETSC_NULL,PETSC_NULL);CHKERRQ(ierr); |
| #if defined(PETSC_USE_COMPLEX) |
| re = PetscRealPart(kr); |
| im = PetscImaginaryPart(kr); |
| #else |
| re = kr; |
| im = ki; |
| #endif |
| if (PetscAbs(re)/PetscAbs(im)<PETSC_SMALL) re = 0.0; |
| if (PetscAbs(im)/PetscAbs(re)<PETSC_SMALL) im = 0.0; |
| if (im!=0.0) { |
| ierr = PetscViewerASCIIPrintf(viewer,"%.5F%+.5Fi",re,im);CHKERRQ(ierr); |
| } else { |
| ierr = PetscViewerASCIIPrintf(viewer,"%.5F",re);CHKERRQ(ierr); |
| } |
| if (8*i+j+1<qep->nev) { ierr = PetscViewerASCIIPrintf(viewer,", ");CHKERRQ(ierr); } |
| } |
| } |
| ierr = PetscViewerASCIIPrintf(viewer,"\n\n");CHKERRQ(ierr); |
| } else { |
| ierr = PetscViewerASCIIPrintf(viewer," Problem: some of the first %D relative errors are higher than the tolerance\n\n",qep->nev);CHKERRQ(ierr); |
| } |
| } |
| } else { |
| ierr = PetscViewerASCIIPrintf(viewer," Number of converged approximate eigenpairs: %D\n\n",qep->nconv);CHKERRQ(ierr); |
| if (qep->nconv>0) { |
| ierr = PetscViewerASCIIPrintf(viewer, |
| " k ||(k^2M+Ck+K)x||/||kx||\n" |
| " ----------------- -------------------------\n");CHKERRQ(ierr); |
| for (i=0;i<qep->nconv;i++) { |
| ierr = QEPGetEigenpair(qep,i,&kr,&ki,PETSC_NULL,PETSC_NULL);CHKERRQ(ierr); |
| ierr = QEPComputeRelativeError(qep,i,&error);CHKERRQ(ierr); |
| #if defined(PETSC_USE_COMPLEX) |
| re = PetscRealPart(kr); |
| im = PetscImaginaryPart(kr); |
| #else |
| re = kr; |
| im = ki; |
| #endif |
| if (im!=0.0) { |
| ierr = PetscViewerASCIIPrintf(viewer," % 9F%+9F i %12G\n",re,im,error);CHKERRQ(ierr); |
| } else { |
| ierr = PetscViewerASCIIPrintf(viewer," % 12F %12G\n",re,error);CHKERRQ(ierr); |
| } |
| } |
| ierr = PetscViewerASCIIPrintf(viewer,"\n");CHKERRQ(ierr); |
| } |
| } |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPCreate" |
| /*@C |
| QEPCreate - Creates the default QEP context. |
| Collective on MPI_Comm |
| Input Parameter: |
| . comm - MPI communicator |
| Output Parameter: |
| . qep - location to put the QEP context |
| Note: |
| The default QEP type is QEPLINEAR |
| Level: beginner |
| .seealso: QEPSetUp(), QEPSolve(), QEPDestroy(), QEP |
| @*/ |
| PetscErrorCode QEPCreate(MPI_Comm comm,QEP *outqep) |
| { |
| PetscErrorCode ierr; |
| QEP qep; |
| PetscFunctionBegin; |
| PetscValidPointer(outqep,2); |
| *outqep = 0; |
| ierr = PetscHeaderCreate(qep,_p_QEP,struct _QEPOps,QEP_CLASSID,-1,"QEP","Quadratic Eigenvalue Problem","QEP",comm,QEPDestroy,QEPView);CHKERRQ(ierr); |
| qep->M = 0; |
| qep->C = 0; |
| qep->K = 0; |
| qep->max_it = 0; |
| qep->nev = 1; |
| qep->ncv = 0; |
| qep->mpd = 0; |
| qep->nini = 0; |
| qep->ninil = 0; |
| qep->allocated_ncv = 0; |
| qep->tol = PETSC_DEFAULT; |
| qep->sfactor = 0.0; |
| qep->conv_func = QEPDefaultConverged; |
| qep->conv_ctx = PETSC_NULL; |
| qep->which = (QEPWhich)0; |
| qep->which_func = PETSC_NULL; |
| qep->which_ctx = PETSC_NULL; |
| qep->leftvecs = PETSC_FALSE; |
| qep->problem_type = (QEPProblemType)0; |
| qep->V = PETSC_NULL; |
| qep->W = PETSC_NULL; |
| qep->IS = PETSC_NULL; |
| qep->ISL = PETSC_NULL; |
| qep->T = PETSC_NULL; |
| qep->eigr = PETSC_NULL; |
| qep->eigi = PETSC_NULL; |
| qep->errest = PETSC_NULL; |
| qep->data = PETSC_NULL; |
| qep->t = PETSC_NULL; |
| qep->nconv = 0; |
| qep->its = 0; |
| qep->perm = PETSC_NULL; |
| qep->matvecs = 0; |
| qep->linits = 0; |
| qep->nwork = 0; |
| qep->work = PETSC_NULL; |
| qep->setupcalled = 0; |
| qep->reason = QEP_CONVERGED_ITERATING; |
| qep->numbermonitors = 0; |
| qep->trackall = PETSC_FALSE; |
| qep->rand = 0; |
| ierr = PetscRandomCreate(comm,&qep->rand);CHKERRQ(ierr); |
| ierr = PetscRandomSetSeed(qep->rand,0x12345678);CHKERRQ(ierr); |
| ierr = PetscLogObjectParent(qep,qep->rand);CHKERRQ(ierr); |
| *outqep = qep; |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPSetType" |
| /*@C |
| QEPSetType - Selects the particular solver to be used in the QEP object. |
| Logically Collective on QEP |
| Input Parameters: |
| + qep - the quadratic eigensolver context |
| - type - a known method |
| Options Database Key: |
| . -qep_type <method> - Sets the method; use -help for a list |
| of available methods |
| Notes: |
| See "slepc/include/slepcqep.h" for available methods. The default |
| is QEPLINEAR. |
| Normally, it is best to use the QEPSetFromOptions() command and |
| then set the QEP type from the options database rather than by using |
| this routine. Using the options database provides the user with |
| maximum flexibility in evaluating the different available methods. |
| The QEPSetType() routine is provided for those situations where it |
| is necessary to set the iterative solver independently of the command |
| line or options database. |
| Level: intermediate |
| .seealso: QEPType |
| @*/ |
| PetscErrorCode QEPSetType(QEP qep,const QEPType type) |
| { |
| PetscErrorCode ierr,(*r)(QEP); |
| PetscBool match; |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| PetscValidCharPointer(type,2); |
| ierr = PetscTypeCompare((PetscObject)qep,type,&match);CHKERRQ(ierr); |
| if (match) PetscFunctionReturn(0); |
| ierr = PetscFListFind(QEPList,((PetscObject)qep)->comm,type,PETSC_TRUE,(void (**)(void))&r);CHKERRQ(ierr); |
| if (!r) SETERRQ1(((PetscObject)qep)->comm,PETSC_ERR_ARG_UNKNOWN_TYPE,"Unknown QEP type given: %s",type); |
| if (qep->ops->destroy) { ierr = (*qep->ops->destroy)(qep);CHKERRQ(ierr); } |
| ierr = PetscMemzero(qep->ops,sizeof(struct _QEPOps));CHKERRQ(ierr); |
| qep->setupcalled = 0; |
| ierr = PetscObjectChangeTypeName((PetscObject)qep,type);CHKERRQ(ierr); |
| ierr = (*r)(qep);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPGetType" |
| /*@C |
| QEPGetType - Gets the QEP type as a string from the QEP object. |
| Not Collective |
| Input Parameter: |
| . qep - the eigensolver context |
| Output Parameter: |
| . name - name of QEP method |
| Level: intermediate |
| .seealso: QEPSetType() |
| @*/ |
| PetscErrorCode QEPGetType(QEP qep,const QEPType *type) |
| { |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| PetscValidPointer(type,2); |
| *type = ((PetscObject)qep)->type_name; |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPRegister" |
| /*@C |
| QEPRegister - See QEPRegisterDynamic() |
| Level: advanced |
| @*/ |
| PetscErrorCode QEPRegister(const char *sname,const char *path,const char *name,PetscErrorCode (*function)(QEP)) |
| { |
| PetscErrorCode ierr; |
| char fullname[PETSC_MAX_PATH_LEN]; |
| PetscFunctionBegin; |
| ierr = PetscFListConcat(path,name,fullname);CHKERRQ(ierr); |
| ierr = PetscFListAdd(&QEPList,sname,fullname,(void (*)(void))function);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPRegisterDestroy" |
| /*@ |
| QEPRegisterDestroy - Frees the list of QEP methods that were |
| registered by QEPRegisterDynamic(). |
| Not Collective |
| Level: advanced |
| .seealso: QEPRegisterDynamic(), QEPRegisterAll() |
| @*/ |
| PetscErrorCode QEPRegisterDestroy(void) |
| { |
| PetscErrorCode ierr; |
| PetscFunctionBegin; |
| ierr = PetscFListDestroy(&QEPList);CHKERRQ(ierr); |
| QEPRegisterAllCalled = PETSC_FALSE; |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPReset" |
| /*@C |
| QEPReset - Resets the QEP context to the setupcalled=0 state and removes any |
| allocated objects. |
| Collective on QEP |
| Input Parameter: |
| . qep - eigensolver context obtained from QEPCreate() |
| Level: advanced |
| .seealso: QEPDestroy() |
| @*/ |
| PetscErrorCode QEPReset(QEP qep) |
| { |
| PetscErrorCode ierr; |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| if (qep->ops->reset) { ierr = (qep->ops->reset)(qep);CHKERRQ(ierr); } |
| if (qep->ip) { ierr = IPReset(qep->ip);CHKERRQ(ierr); } |
| ierr = MatDestroy(&qep->M);CHKERRQ(ierr); |
| ierr = MatDestroy(&qep->C);CHKERRQ(ierr); |
| ierr = MatDestroy(&qep->K);CHKERRQ(ierr); |
| ierr = VecDestroy(&qep->t);CHKERRQ(ierr); |
| ierr = QEPFreeSolution(qep);CHKERRQ(ierr); |
| qep->matvecs = 0; |
| qep->linits = 0; |
| qep->setupcalled = 0; |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPDestroy" |
| /*@C |
| QEPDestroy - Destroys the QEP context. |
| Collective on QEP |
| Input Parameter: |
| . qep - eigensolver context obtained from QEPCreate() |
| Level: beginner |
| .seealso: QEPCreate(), QEPSetUp(), QEPSolve() |
| @*/ |
| PetscErrorCode QEPDestroy(QEP *qep) |
| { |
| PetscErrorCode ierr; |
| PetscFunctionBegin; |
| if (!*qep) PetscFunctionReturn(0); |
| PetscValidHeaderSpecific(*qep,QEP_CLASSID,1); |
| if (--((PetscObject)(*qep))->refct > 0) { *qep = 0; PetscFunctionReturn(0); } |
| ierr = QEPReset(*qep);CHKERRQ(ierr); |
| ierr = PetscObjectDepublish(*qep);CHKERRQ(ierr); |
| if ((*qep)->ops->destroy) { ierr = (*(*qep)->ops->destroy)(*qep);CHKERRQ(ierr); } |
| ierr = IPDestroy(&(*qep)->ip);CHKERRQ(ierr); |
| ierr = PetscRandomDestroy(&(*qep)->rand);CHKERRQ(ierr); |
| ierr = QEPMonitorCancel(*qep);CHKERRQ(ierr); |
| ierr = PetscHeaderDestroy(qep);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPSetIP" |
| /*@ |
| QEPSetIP - Associates an inner product object to the quadratic eigensolver. |
| Collective on QEP |
| Input Parameters: |
| + qep - eigensolver context obtained from QEPCreate() |
| - ip - the inner product object |
| Note: |
| Use QEPGetIP() to retrieve the inner product context (for example, |
| to free it at the end of the computations). |
| Level: advanced |
| .seealso: QEPGetIP() |
| @*/ |
| PetscErrorCode QEPSetIP(QEP qep,IP ip) |
| { |
| PetscErrorCode ierr; |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| PetscValidHeaderSpecific(ip,IP_CLASSID,2); |
| PetscCheckSameComm(qep,1,ip,2); |
| ierr = PetscObjectReference((PetscObject)ip);CHKERRQ(ierr); |
| ierr = IPDestroy(&qep->ip);CHKERRQ(ierr); |
| qep->ip = ip; |
| ierr = PetscLogObjectParent(qep,qep->ip);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPGetIP" |
| /*@C |
| QEPGetIP - Obtain the inner product object associated |
| to the quadratic eigensolver object. |
| Not Collective |
| Input Parameters: |
| . qep - eigensolver context obtained from QEPCreate() |
| Output Parameter: |
| . ip - inner product context |
| Level: advanced |
| .seealso: QEPSetIP() |
| @*/ |
| PetscErrorCode QEPGetIP(QEP qep,IP *ip) |
| { |
| PetscErrorCode ierr; |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| PetscValidPointer(ip,2); |
| if (!qep->ip) { |
| ierr = IPCreate(((PetscObject)qep)->comm,&qep->ip);CHKERRQ(ierr); |
| ierr = PetscLogObjectParent(qep,qep->ip);CHKERRQ(ierr); |
| } |
| *ip = qep->ip; |
| PetscFunctionReturn(0); |
| } |
| /* |
| This file contains some simple default routines for common QEP operations. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| SLEPc - Scalable Library for Eigenvalue Problem Computations |
| Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| This file is part of SLEPc. |
| SLEPc is free software: you can redistribute it and/or modify it under the |
| terms of version 3 of the GNU Lesser General Public License as published by |
| the Free Software Foundation. |
| SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| more details. |
| You should have received a copy of the GNU Lesser General Public License |
| along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| */ |
| #include <private/qepimpl.h> /*I "slepcqep.h" I*/ |
| #include <slepcblaslapack.h> |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPDefaultGetWork" |
| /* |
| QEPDefaultGetWork - Gets a number of work vectors. |
| */ |
| PetscErrorCode QEPDefaultGetWork(QEP qep,PetscInt nw) |
| { |
| PetscErrorCode ierr; |
| PetscFunctionBegin; |
| if (qep->nwork != nw) { |
| ierr = VecDestroyVecs(qep->nwork,&qep->work);CHKERRQ(ierr); |
| qep->nwork = nw; |
| ierr = VecDuplicateVecs(qep->t,nw,&qep->work);CHKERRQ(ierr); |
| ierr = PetscLogObjectParents(qep,nw,qep->work); |
| } |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPDefaultFreeWork" |
| /* |
| QEPDefaultFreeWork - Free work vectors. |
| */ |
| PetscErrorCode QEPDefaultFreeWork(QEP qep) |
| { |
| PetscErrorCode ierr; |
| PetscFunctionBegin; |
| ierr = VecDestroyVecs(qep->nwork,&qep->work);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPDefaultConverged" |
| /* |
| QEPDefaultConverged - Checks convergence relative to the eigenvalue. |
| */ |
| PetscErrorCode QEPDefaultConverged(QEP qep,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx) |
| { |
| PetscReal w; |
| PetscFunctionBegin; |
| w = SlepcAbsEigenvalue(eigr,eigi); |
| *errest = res; |
| if (w > res) *errest = res / w; |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPAbsoluteConverged" |
| /* |
| QEPAbsoluteConverged - Checks convergence absolutely. |
| */ |
| PetscErrorCode QEPAbsoluteConverged(QEP qep,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx) |
| { |
| PetscFunctionBegin; |
| *errest = res; |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPComputeVectors_Schur" |
| PetscErrorCode QEPComputeVectors_Schur(QEP qep) |
| { |
| #if defined(SLEPC_MISSING_LAPACK_TREVC) |
| SETERRQ(((PetscObject)qep)->comm,PETSC_ERR_SUP,"TREVC - Lapack routine is unavailable."); |
| #else |
| PetscErrorCode ierr; |
| PetscInt i; |
| PetscBLASInt ncv,nconv,mout,info,one = 1; |
| PetscScalar *Z,*work,tmp; |
| #if defined(PETSC_USE_COMPLEX) |
| PetscReal *rwork; |
| #else |
| PetscReal normi; |
| #endif |
| PetscReal norm; |
| PetscFunctionBegin; |
| ncv = PetscBLASIntCast(qep->ncv); |
| nconv = PetscBLASIntCast(qep->nconv); |
| ierr = PetscMalloc(nconv*nconv*sizeof(PetscScalar),&Z);CHKERRQ(ierr); |
| ierr = PetscMalloc(3*nconv*sizeof(PetscScalar),&work);CHKERRQ(ierr); |
| #if defined(PETSC_USE_COMPLEX) |
| ierr = PetscMalloc(nconv*sizeof(PetscReal),&rwork);CHKERRQ(ierr); |
| #endif |
| /* right eigenvectors */ |
| #if !defined(PETSC_USE_COMPLEX) |
| LAPACKtrevc_("R","A",PETSC_NULL,&nconv,qep->T,&ncv,PETSC_NULL,&nconv,Z,&nconv,&nconv,&mout,work,&info); |
| #else |
| LAPACKtrevc_("R","A",PETSC_NULL,&nconv,qep->T,&ncv,PETSC_NULL,&nconv,Z,&nconv,&nconv,&mout,work,rwork,&info); |
| #endif |
| if (info) SETERRQ1(((PetscObject)qep)->comm,PETSC_ERR_LIB,"Error in Lapack xTREVC %d",info); |
| /* normalize eigenvectors */ |
| for (i=0;i<qep->nconv;i++) { |
| #if !defined(PETSC_USE_COMPLEX) |
| if (qep->eigi[i] != 0.0) { |
| norm = BLASnrm2_(&nconv,Z+i*nconv,&one); |
| normi = BLASnrm2_(&nconv,Z+(i+1)*nconv,&one); |
| tmp = 1.0 / SlepcAbsEigenvalue(norm,normi); |
| BLASscal_(&nconv,&tmp,Z+i*nconv,&one); |
| BLASscal_(&nconv,&tmp,Z+(i+1)*nconv,&one); |
| i++; |
| } else |
| #endif |
| { |
| norm = BLASnrm2_(&nconv,Z+i*nconv,&one); |
| tmp = 1.0 / norm; |
| BLASscal_(&nconv,&tmp,Z+i*nconv,&one); |
| } |
| } |
| /* AV = V * Z */ |
| ierr = SlepcUpdateVectors(qep->nconv,qep->V,0,qep->nconv,Z,qep->nconv,PETSC_FALSE);CHKERRQ(ierr); |
| ierr = PetscFree(Z);CHKERRQ(ierr); |
| ierr = PetscFree(work);CHKERRQ(ierr); |
| #if defined(PETSC_USE_COMPLEX) |
| ierr = PetscFree(rwork);CHKERRQ(ierr); |
| #endif |
| PetscFunctionReturn(0); |
| #endif |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPKrylovConvergence" |
| /* |
| QEPKrylovConvergence - This is the analogue to EPSKrylovConvergence, but |
| for quadratic Krylov methods. |
| Differences: |
| - Always non-symmetric |
| - Does not check for STSHIFT |
| - No correction factor |
| - No support for true residual |
| */ |
| PetscErrorCode QEPKrylovConvergence(QEP qep,PetscInt kini,PetscInt nits,PetscScalar *S,PetscInt lds,PetscScalar *Q,PetscInt nv,PetscReal beta,PetscInt *kout,PetscScalar *work) |
| { |
| PetscErrorCode ierr; |
| PetscInt k,marker; |
| PetscScalar re,im,*Z,*work2; |
| PetscReal resnorm; |
| PetscBool iscomplex; |
| PetscFunctionBegin; |
| Z = work; work2 = work+2*nv; |
| marker = -1; |
| for (k=kini;k<kini+nits;k++) { |
| /* eigenvalue */ |
| re = qep->eigr[k]; |
| im = qep->eigi[k]; |
| iscomplex = PETSC_FALSE; |
| if (k<nv-1 && S[k+1+k*lds] != 0.0) iscomplex = PETSC_TRUE; |
| /* residual norm */ |
| ierr = DenseSelectedEvec(S,lds,Q,Z,k,iscomplex,nv,work2);CHKERRQ(ierr); |
| if (iscomplex) resnorm = beta*SlepcAbsEigenvalue(Z[nv-1],Z[2*nv-1]); |
| else resnorm = beta*PetscAbsScalar(Z[nv-1]); |
| /* error estimate */ |
| ierr = (*qep->conv_func)(qep,re,im,resnorm,&qep->errest[k],qep->conv_ctx);CHKERRQ(ierr); |
| if (marker==-1 && qep->errest[k] >= qep->tol) marker = k; |
| if (iscomplex) { qep->errest[k+1] = qep->errest[k]; k++; } |
| if (marker!=-1 && !qep->trackall) break; |
| } |
| if (marker!=-1) k = marker; |
| *kout = k; |
| PetscFunctionReturn(0); |
| } |
| /* |
| QEP routines related to options that can be set via the command-line |
| or procedurally. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| SLEPc - Scalable Library for Eigenvalue Problem Computations |
| Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| This file is part of SLEPc. |
| SLEPc is free software: you can redistribute it and/or modify it under the |
| terms of version 3 of the GNU Lesser General Public License as published by |
| the Free Software Foundation. |
| SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| more details. |
| You should have received a copy of the GNU Lesser General Public License |
| along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| */ |
| #include <private/qepimpl.h> /*I "slepcqep.h" I*/ |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPSetFromOptions" |
| /*@ |
| QEPSetFromOptions - Sets QEP options from the options database. |
| This routine must be called before QEPSetUp() if the user is to be |
| allowed to set the solver type. |
| Collective on QEP |
| Input Parameters: |
| . qep - the quadratic eigensolver context |
| Notes: |
| To see all options, run your program with the -help option. |
| Level: beginner |
| @*/ |
| PetscErrorCode QEPSetFromOptions(QEP qep) |
| { |
| PetscErrorCode ierr; |
| char type[256],monfilename[PETSC_MAX_PATH_LEN]; |
| PetscBool flg,val; |
| PetscReal r; |
| PetscInt i,j,k; |
| PetscViewer monviewer; |
| SlepcConvMonitor ctx; |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| if (!QEPRegisterAllCalled) { ierr = QEPRegisterAll(PETSC_NULL);CHKERRQ(ierr); } |
| if (!qep->ip) { ierr = QEPGetIP(qep,&qep->ip);CHKERRQ(ierr); } |
| ierr = PetscOptionsBegin(((PetscObject)qep)->comm,((PetscObject)qep)->prefix,"Quadratic Eigenvalue Problem (QEP) Solver Options","QEP");CHKERRQ(ierr); |
| ierr = PetscOptionsList("-qep_type","Quadratic Eigenvalue Problem method","QEPSetType",QEPList,(char*)(((PetscObject)qep)->type_name?((PetscObject)qep)->type_name:QEPLINEAR),type,256,&flg);CHKERRQ(ierr); |
| if (flg) { |
| ierr = QEPSetType(qep,type);CHKERRQ(ierr); |
| } else if (!((PetscObject)qep)->type_name) { |
| ierr = QEPSetType(qep,QEPLINEAR);CHKERRQ(ierr); |
| } |
| ierr = PetscOptionsBoolGroupBegin("-qep_general","general quadratic eigenvalue problem","QEPSetProblemType",&flg);CHKERRQ(ierr); |
| if (flg) {ierr = QEPSetProblemType(qep,QEP_GENERAL);CHKERRQ(ierr);} |
| ierr = PetscOptionsBoolGroup("-qep_hermitian","hermitian quadratic eigenvalue problem","QEPSetProblemType",&flg);CHKERRQ(ierr); |
| if (flg) {ierr = QEPSetProblemType(qep,QEP_HERMITIAN);CHKERRQ(ierr);} |
| ierr = PetscOptionsBoolGroupEnd("-qep_gyroscopic","gyroscopic quadratic eigenvalue problem","QEPSetProblemType",&flg);CHKERRQ(ierr); |
| if (flg) {ierr = QEPSetProblemType(qep,QEP_GYROSCOPIC);CHKERRQ(ierr);} |
| r = PETSC_IGNORE; |
| ierr = PetscOptionsReal("-qep_scale","Scale factor","QEPSetScaleFactor",qep->sfactor,&r,PETSC_NULL);CHKERRQ(ierr); |
| ierr = QEPSetScaleFactor(qep,r);CHKERRQ(ierr); |
| r = i = PETSC_IGNORE; |
| ierr = PetscOptionsInt("-qep_max_it","Maximum number of iterations","QEPSetTolerances",qep->max_it,&i,PETSC_NULL);CHKERRQ(ierr); |
| ierr = PetscOptionsReal("-qep_tol","Tolerance","QEPSetTolerances",qep->tol==PETSC_DEFAULT?SLEPC_DEFAULT_TOL:qep->tol,&r,PETSC_NULL);CHKERRQ(ierr); |
| ierr = QEPSetTolerances(qep,r,i);CHKERRQ(ierr); |
| ierr = PetscOptionsBoolGroupBegin("-qep_convergence_default","Default (relative error) convergence test","QEPSetConvergenceTest",&flg);CHKERRQ(ierr); |
| if (flg) {ierr = QEPSetConvergenceTest(qep,QEPDefaultConverged,PETSC_NULL);CHKERRQ(ierr);} |
| ierr = PetscOptionsBoolGroupEnd("-qep_convergence_absolute","Absolute error convergence test","QEPSetConvergenceTest",&flg);CHKERRQ(ierr); |
| if (flg) {ierr = QEPSetConvergenceTest(qep,QEPAbsoluteConverged,PETSC_NULL);CHKERRQ(ierr);} |
| i = j = k = PETSC_IGNORE; |
| ierr = PetscOptionsInt("-qep_nev","Number of eigenvalues to compute","QEPSetDimensions",qep->nev,&i,PETSC_NULL);CHKERRQ(ierr); |
| ierr = PetscOptionsInt("-qep_ncv","Number of basis vectors","QEPSetDimensions",qep->ncv,&j,PETSC_NULL);CHKERRQ(ierr); |
| ierr = PetscOptionsInt("-qep_mpd","Maximum dimension of projected problem","QEPSetDimensions",qep->mpd,&k,PETSC_NULL);CHKERRQ(ierr); |
| ierr = QEPSetDimensions(qep,i,j,k);CHKERRQ(ierr); |
| /* -----------------------------------------------------------------------*/ |
| /* |
| Cancels all monitors hardwired into code before call to QEPSetFromOptions() |
| */ |
| flg = PETSC_FALSE; |
| ierr = PetscOptionsBool("-qep_monitor_cancel","Remove any hardwired monitor routines","QEPMonitorCancel",flg,&flg,PETSC_NULL);CHKERRQ(ierr); |
| if (flg) { |
| ierr = QEPMonitorCancel(qep);CHKERRQ(ierr); |
| } |
| /* |
| Prints approximate eigenvalues and error estimates at each iteration |
| */ |
| ierr = PetscOptionsString("-qep_monitor","Monitor first unconverged approximate eigenvalue and error estimate","QEPMonitorSet","stdout",monfilename,PETSC_MAX_PATH_LEN,&flg);CHKERRQ(ierr); |
| if (flg) { |
| ierr = PetscViewerASCIIOpen(((PetscObject)qep)->comm,monfilename,&monviewer);CHKERRQ(ierr); |
| ierr = QEPMonitorSet(qep,QEPMonitorFirst,monviewer,(PetscErrorCode (*)(void**))PetscViewerDestroy);CHKERRQ(ierr); |
| } |
| ierr = PetscOptionsString("-qep_monitor_conv","Monitor approximate eigenvalues and error estimates as they converge","QEPMonitorSet","stdout",monfilename,PETSC_MAX_PATH_LEN,&flg);CHKERRQ(ierr); |
| if (flg) { |
| ierr = PetscNew(struct _n_SlepcConvMonitor,&ctx);CHKERRQ(ierr); |
| ierr = PetscViewerASCIIOpen(((PetscObject)qep)->comm,monfilename,&ctx->viewer);CHKERRQ(ierr); |
| ierr = QEPMonitorSet(qep,QEPMonitorConverged,ctx,(PetscErrorCode (*)(void**))SlepcConvMonitorDestroy);CHKERRQ(ierr); |
| } |
| ierr = PetscOptionsString("-qep_monitor_all","Monitor approximate eigenvalues and error estimates","QEPMonitorSet","stdout",monfilename,PETSC_MAX_PATH_LEN,&flg);CHKERRQ(ierr); |
| if (flg) { |
| ierr = PetscViewerASCIIOpen(((PetscObject)qep)->comm,monfilename,&monviewer);CHKERRQ(ierr); |
| ierr = QEPMonitorSet(qep,QEPMonitorAll,monviewer,(PetscErrorCode (*)(void**))PetscViewerDestroy);CHKERRQ(ierr); |
| ierr = QEPSetTrackAll(qep,PETSC_TRUE);CHKERRQ(ierr); |
| } |
| flg = PETSC_FALSE; |
| ierr = PetscOptionsBool("-qep_monitor_draw","Monitor first unconverged approximate error estimate graphically","QEPMonitorSet",flg,&flg,PETSC_NULL);CHKERRQ(ierr); |
| if (flg) { |
| ierr = QEPMonitorSet(qep,QEPMonitorLG,PETSC_NULL,PETSC_NULL);CHKERRQ(ierr); |
| } |
| flg = PETSC_FALSE; |
| ierr = PetscOptionsBool("-qep_monitor_draw_all","Monitor error estimates graphically","QEPMonitorSet",flg,&flg,PETSC_NULL);CHKERRQ(ierr); |
| if (flg) { |
| ierr = QEPMonitorSet(qep,QEPMonitorLGAll,PETSC_NULL,PETSC_NULL);CHKERRQ(ierr); |
| ierr = QEPSetTrackAll(qep,PETSC_TRUE);CHKERRQ(ierr); |
| } |
| /* -----------------------------------------------------------------------*/ |
| ierr = PetscOptionsBoolGroupBegin("-qep_largest_magnitude","compute largest eigenvalues in magnitude","QEPSetWhichEigenpairs",&flg);CHKERRQ(ierr); |
| if (flg) {ierr = QEPSetWhichEigenpairs(qep,QEP_LARGEST_MAGNITUDE);CHKERRQ(ierr);} |
| ierr = PetscOptionsBoolGroup("-qep_smallest_magnitude","compute smallest eigenvalues in magnitude","QEPSetWhichEigenpairs",&flg);CHKERRQ(ierr); |
| if (flg) {ierr = QEPSetWhichEigenpairs(qep,QEP_SMALLEST_MAGNITUDE);CHKERRQ(ierr);} |
| ierr = PetscOptionsBoolGroup("-qep_largest_real","compute largest real parts","QEPSetWhichEigenpairs",&flg);CHKERRQ(ierr); |
| if (flg) {ierr = QEPSetWhichEigenpairs(qep,QEP_LARGEST_REAL);CHKERRQ(ierr);} |
| ierr = PetscOptionsBoolGroup("-qep_smallest_real","compute smallest real parts","QEPSetWhichEigenpairs",&flg);CHKERRQ(ierr); |
| if (flg) {ierr = QEPSetWhichEigenpairs(qep,QEP_SMALLEST_REAL);CHKERRQ(ierr);} |
| ierr = PetscOptionsBoolGroup("-qep_largest_imaginary","compute largest imaginary parts","QEPSetWhichEigenpairs",&flg);CHKERRQ(ierr); |
| if (flg) {ierr = QEPSetWhichEigenpairs(qep,QEP_LARGEST_IMAGINARY);CHKERRQ(ierr);} |
| ierr = PetscOptionsBoolGroupEnd("-qep_smallest_imaginary","compute smallest imaginary parts","QEPSetWhichEigenpairs",&flg);CHKERRQ(ierr); |
| if (flg) {ierr = QEPSetWhichEigenpairs(qep,QEP_SMALLEST_IMAGINARY);CHKERRQ(ierr);} |
| ierr = PetscOptionsBool("-qep_left_vectors","Compute left eigenvectors also","QEPSetLeftVectorsWanted",qep->leftvecs,&val,&flg);CHKERRQ(ierr); |
| if (flg) { |
| ierr = QEPSetLeftVectorsWanted(qep,val);CHKERRQ(ierr); |
| } |
| ierr = PetscOptionsName("-qep_view","Print detailed information on solver used","QEPView",0);CHKERRQ(ierr); |
| ierr = PetscOptionsName("-qep_view_binary","Save the matrices associated to the eigenproblem","QEPSetFromOptions",0);CHKERRQ(ierr); |
| ierr = PetscOptionsName("-qep_plot_eigs","Make a plot of the computed eigenvalues","QEPSolve",0);CHKERRQ(ierr); |
| if (qep->ops->setfromoptions) { |
| ierr = (*qep->ops->setfromoptions)(qep);CHKERRQ(ierr); |
| } |
| ierr = PetscObjectProcessOptionsHandlers((PetscObject)qep);CHKERRQ(ierr); |
| ierr = PetscOptionsEnd();CHKERRQ(ierr); |
| ierr = IPSetFromOptions(qep->ip);CHKERRQ(ierr); |
| ierr = PetscRandomSetFromOptions(qep->rand);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPGetTolerances" |
| /*@ |
| QEPGetTolerances - Gets the tolerance and maximum iteration count used |
| by the QEP convergence tests. |
| Not Collective |
| Input Parameter: |
| . qep - the quadratic eigensolver context |
| Output Parameters: |
| + tol - the convergence tolerance |
| - maxits - maximum number of iterations |
| Notes: |
| The user can specify PETSC_NULL for any parameter that is not needed. |
| Level: intermediate |
| .seealso: QEPSetTolerances() |
| @*/ |
| PetscErrorCode QEPGetTolerances(QEP qep,PetscReal *tol,PetscInt *maxits) |
| { |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| if (tol) *tol = qep->tol; |
| if (maxits) *maxits = qep->max_it; |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPSetTolerances" |
| /*@ |
| QEPSetTolerances - Sets the tolerance and maximum iteration count used |
| by the QEP convergence tests. |
| Logically Collective on QEP |
| Input Parameters: |
| + qep - the quadratic eigensolver context |
| . tol - the convergence tolerance |
| - maxits - maximum number of iterations to use |
| Options Database Keys: |
| + -qep_tol <tol> - Sets the convergence tolerance |
| - -qep_max_it <maxits> - Sets the maximum number of iterations allowed |
| Notes: |
| Use PETSC_IGNORE for an argument that need not be changed. |
| Use PETSC_DECIDE for maxits to assign a reasonably good value, which is |
| dependent on the solution method. |
| Level: intermediate |
| .seealso: QEPGetTolerances() |
| @*/ |
| PetscErrorCode QEPSetTolerances(QEP qep,PetscReal tol,PetscInt maxits) |
| { |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| PetscValidLogicalCollectiveReal(qep,tol,2); |
| PetscValidLogicalCollectiveInt(qep,maxits,3); |
| if (tol != PETSC_IGNORE) { |
| if (tol == PETSC_DEFAULT) { |
| qep->tol = PETSC_DEFAULT; |
| } else { |
| if (tol < 0.0) SETERRQ(((PetscObject)qep)->comm,PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of tol. Must be > 0"); |
| qep->tol = tol; |
| } |
| } |
| if (maxits != PETSC_IGNORE) { |
| if (maxits == PETSC_DEFAULT || maxits == PETSC_DECIDE) { |
| qep->max_it = 0; |
| qep->setupcalled = 0; |
| } else { |
| if (maxits < 0) SETERRQ(((PetscObject)qep)->comm,PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of maxits. Must be > 0"); |
| qep->max_it = maxits; |
| } |
| } |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPGetDimensions" |
| /*@ |
| QEPGetDimensions - Gets the number of eigenvalues to compute |
| and the dimension of the subspace. |
| Not Collective |
| Input Parameter: |
| . qep - the quadratic eigensolver context |
| Output Parameters: |
| + nev - number of eigenvalues to compute |
| . ncv - the maximum dimension of the subspace to be used by the solver |
| - mpd - the maximum dimension allowed for the projected problem |
| Notes: |
| The user can specify PETSC_NULL for any parameter that is not needed. |
| Level: intermediate |
| .seealso: QEPSetDimensions() |
| @*/ |
| PetscErrorCode QEPGetDimensions(QEP qep,PetscInt *nev,PetscInt *ncv,PetscInt *mpd) |
| { |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| if (nev) *nev = qep->nev; |
| if (ncv) *ncv = qep->ncv; |
| if (mpd) *mpd = qep->mpd; |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPSetDimensions" |
| /*@ |
| QEPSetDimensions - Sets the number of eigenvalues to compute |
| and the dimension of the subspace. |
| Logically Collective on QEP |
| Input Parameters: |
| + qep - the quadratic eigensolver context |
| . nev - number of eigenvalues to compute |
| . ncv - the maximum dimension of the subspace to be used by the solver |
| - mpd - the maximum dimension allowed for the projected problem |
| Options Database Keys: |
| + -qep_nev <nev> - Sets the number of eigenvalues |
| . -qep_ncv <ncv> - Sets the dimension of the subspace |
| - -qep_mpd <mpd> - Sets the maximum projected dimension |
| Notes: |
| Use PETSC_IGNORE to retain the previous value of any parameter. |
| Use PETSC_DECIDE for ncv and mpd to assign a reasonably good value, which is |
| dependent on the solution method. |
| The parameters ncv and mpd are intimately related, so that the user is advised |
| to set one of them at most. Normal usage is that |
| (a) in cases where nev is small, the user sets ncv (a reasonable default is 2*nev); and |
| (b) in cases where nev is large, the user sets mpd. |
| The value of ncv should always be between nev and (nev+mpd), typically |
| ncv=nev+mpd. If nev is not too large, mpd=nev is a reasonable choice, otherwise |
| a smaller value should be used. |
| Level: intermediate |
| .seealso: QEPGetDimensions() |
| @*/ |
| PetscErrorCode QEPSetDimensions(QEP qep,PetscInt nev,PetscInt ncv,PetscInt mpd) |
| { |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| PetscValidLogicalCollectiveInt(qep,nev,2); |
| PetscValidLogicalCollectiveInt(qep,ncv,3); |
| PetscValidLogicalCollectiveInt(qep,mpd,4); |
| if (nev != PETSC_IGNORE) { |
| if (nev<1) SETERRQ(((PetscObject)qep)->comm,PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of nev. Must be > 0"); |
| qep->nev = nev; |
| qep->setupcalled = 0; |
| } |
| if (ncv != PETSC_IGNORE) { |
| if (ncv == PETSC_DECIDE || ncv == PETSC_DEFAULT) { |
| qep->ncv = 0; |
| } else { |
| if (ncv<1) SETERRQ(((PetscObject)qep)->comm,PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of ncv. Must be > 0"); |
| qep->ncv = ncv; |
| } |
| qep->setupcalled = 0; |
| } |
| if (mpd != PETSC_IGNORE) { |
| if (mpd == PETSC_DECIDE || mpd == PETSC_DEFAULT) { |
| qep->mpd = 0; |
| } else { |
| if (mpd<1) SETERRQ(((PetscObject)qep)->comm,PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of mpd. Must be > 0"); |
| qep->mpd = mpd; |
| } |
| } |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPSetWhichEigenpairs" |
| /*@ |
| QEPSetWhichEigenpairs - Specifies which portion of the spectrum is |
| to be sought. |
| Logically Collective on QEP |
| Input Parameters: |
| + qep - eigensolver context obtained from QEPCreate() |
| - which - the portion of the spectrum to be sought |
| Possible values: |
| The parameter 'which' can have one of these values |
| + QEP_LARGEST_MAGNITUDE - largest eigenvalues in magnitude (default) |
| . QEP_SMALLEST_MAGNITUDE - smallest eigenvalues in magnitude |
| . QEP_LARGEST_REAL - largest real parts |
| . QEP_SMALLEST_REAL - smallest real parts |
| . QEP_LARGEST_IMAGINARY - largest imaginary parts |
| - QEP_SMALLEST_IMAGINARY - smallest imaginary parts |
| Options Database Keys: |
| + -qep_largest_magnitude - Sets largest eigenvalues in magnitude |
| . -qep_smallest_magnitude - Sets smallest eigenvalues in magnitude |
| . -qep_largest_real - Sets largest real parts |
| . -qep_smallest_real - Sets smallest real parts |
| . -qep_largest_imaginary - Sets largest imaginary parts |
| - -qep_smallest_imaginary - Sets smallest imaginary parts |
| Notes: |
| Not all eigensolvers implemented in QEP account for all the possible values |
| stated above. If SLEPc is compiled for real numbers QEP_LARGEST_IMAGINARY |
| and QEP_SMALLEST_IMAGINARY use the absolute value of the imaginary part |
| for eigenvalue selection. |
| Level: intermediate |
| .seealso: QEPGetWhichEigenpairs(), QEPWhich |
| @*/ |
| PetscErrorCode QEPSetWhichEigenpairs(QEP qep,QEPWhich which) |
| { |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| PetscValidLogicalCollectiveEnum(qep,which,2); |
| if (which!=PETSC_IGNORE) { |
| if (which==PETSC_DECIDE || which==PETSC_DEFAULT) qep->which = (QEPWhich)0; |
| else switch (which) { |
| case QEP_LARGEST_MAGNITUDE: |
| case QEP_SMALLEST_MAGNITUDE: |
| case QEP_LARGEST_REAL: |
| case QEP_SMALLEST_REAL: |
| case QEP_LARGEST_IMAGINARY: |
| case QEP_SMALLEST_IMAGINARY: |
| if (qep->which != which) { |
| qep->setupcalled = 0; |
| qep->which = which; |
| } |
| break; |
| default: |
| SETERRQ(((PetscObject)qep)->comm,PETSC_ERR_ARG_OUTOFRANGE,"Invalid 'which' value"); |
| } |
| } |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPGetWhichEigenpairs" |
| /*@C |
| QEPGetWhichEigenpairs - Returns which portion of the spectrum is to be |
| sought. |
| Not Collective |
| Input Parameter: |
| . qep - eigensolver context obtained from QEPCreate() |
| Output Parameter: |
| . which - the portion of the spectrum to be sought |
| Notes: |
| See QEPSetWhichEigenpairs() for possible values of 'which'. |
| Level: intermediate |
| .seealso: QEPSetWhichEigenpairs(), QEPWhich |
| @*/ |
| PetscErrorCode QEPGetWhichEigenpairs(QEP qep,QEPWhich *which) |
| { |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| PetscValidPointer(which,2); |
| *which = qep->which; |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPSetLeftVectorsWanted" |
| /*@ |
| QEPSetLeftVectorsWanted - Specifies which eigenvectors are required. |
| Logically Collective on QEP |
| Input Parameters: |
| + qep - the quadratic eigensolver context |
| - leftvecs - whether left eigenvectors are required or not |
| Options Database Keys: |
| . -qep_left_vectors <boolean> - Sets/resets the boolean flag 'leftvecs' |
| Notes: |
| If the user sets leftvecs=PETSC_TRUE then the solver uses a variant of |
| the algorithm that computes both right and left eigenvectors. This is |
| usually much more costly. This option is not available in all solvers. |
| Level: intermediate |
| .seealso: QEPGetLeftVectorsWanted() |
| @*/ |
| PetscErrorCode QEPSetLeftVectorsWanted(QEP qep,PetscBool leftvecs) |
| { |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| PetscValidLogicalCollectiveBool(qep,leftvecs,2); |
| if (qep->leftvecs != leftvecs) { |
| qep->leftvecs = leftvecs; |
| qep->setupcalled = 0; |
| } |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPGetLeftVectorsWanted" |
| /*@C |
| QEPGetLeftVectorsWanted - Returns the flag indicating whether left |
| eigenvectors are required or not. |
| Not Collective |
| Input Parameter: |
| . qep - the eigensolver context |
| Output Parameter: |
| . leftvecs - the returned flag |
| Level: intermediate |
| .seealso: QEPSetLeftVectorsWanted() |
| @*/ |
| PetscErrorCode QEPGetLeftVectorsWanted(QEP qep,PetscBool *leftvecs) |
| { |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| PetscValidPointer(leftvecs,2); |
| *leftvecs = qep->leftvecs; |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPGetScaleFactor" |
| /*@ |
| QEPGetScaleFactor - Gets the factor used for scaling the quadratic eigenproblem. |
| Not Collective |
| Input Parameter: |
| . qep - the quadratic eigensolver context |
| Output Parameters: |
| . alpha - the scaling factor |
| Notes: |
| If the user did not specify a scaling factor, then after QEPSolve() the |
| default value is returned. |
| Level: intermediate |
| .seealso: QEPSetScaleFactor(), QEPSolve() |
| @*/ |
| PetscErrorCode QEPGetScaleFactor(QEP qep,PetscReal *alpha) |
| { |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| PetscValidPointer(alpha,2); |
| *alpha = qep->sfactor; |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPSetScaleFactor" |
| /*@ |
| QEPSetScaleFactor - Sets the scaling factor to be used for scaling the |
| quadratic problem before attempting to solve. |
| Logically Collective on QEP |
| Input Parameters: |
| + qep - the quadratic eigensolver context |
| - alpha - the scaling factor |
| Options Database Keys: |
| . -qep_scale <alpha> - Sets the scaling factor |
| Notes: |
| For the problem (l^2*M + l*C + K)*x = 0, the effect of scaling is to work |
| with matrices (alpha^2*M, alpha*C, K), then scale the computed eigenvalue. |
| The default is to scale with alpha = norm(K)/norm(M). |
| Level: intermediate |
| .seealso: QEPGetScaleFactor() |
| @*/ |
| PetscErrorCode QEPSetScaleFactor(QEP qep,PetscReal alpha) |
| { |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| PetscValidLogicalCollectiveReal(qep,alpha,2); |
| if (alpha != PETSC_IGNORE) { |
| if (alpha == PETSC_DEFAULT || alpha == PETSC_DECIDE) { |
| qep->sfactor = 0.0; |
| } else { |
| if (alpha < 0.0) SETERRQ(((PetscObject)qep)->comm,PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of alpha. Must be > 0"); |
| qep->sfactor = alpha; |
| } |
| } |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPSetProblemType" |
| /*@ |
| QEPSetProblemType - Specifies the type of the quadratic eigenvalue problem. |
| Logically Collective on QEP |
| Input Parameters: |
| + qep - the quadratic eigensolver context |
| - type - a known type of quadratic eigenvalue problem |
| Options Database Keys: |
| + -qep_general - general problem with no particular structure |
| . -qep_hermitian - problem whose coefficient matrices are Hermitian |
| - -qep_gyroscopic - problem with Hamiltonian structure |
| Notes: |
| Allowed values for the problem type are: general (QEP_GENERAL), Hermitian |
| (QEP_HERMITIAN), and gyroscopic (QEP_GYROSCOPIC). |
| This function is used to instruct SLEPc to exploit certain structure in |
| the quadratic eigenproblem. By default, no particular structure is assumed. |
| If the problem matrices are Hermitian (symmetric in the real case) or |
| Hermitian/skew-Hermitian then the solver can exploit this fact to perform |
| less operations or provide better stability. |
| Level: intermediate |
| .seealso: QEPSetOperators(), QEPSetType(), QEPGetProblemType(), QEPProblemType |
| @*/ |
| PetscErrorCode QEPSetProblemType(QEP qep,QEPProblemType type) |
| { |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| PetscValidLogicalCollectiveEnum(qep,type,2); |
| if (type!=QEP_GENERAL && type!=QEP_HERMITIAN && type!=QEP_GYROSCOPIC) |
| SETERRQ(((PetscObject)qep)->comm,PETSC_ERR_ARG_WRONG,"Unknown eigenvalue problem type"); |
| qep->problem_type = type; |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPGetProblemType" |
| /*@C |
| QEPGetProblemType - Gets the problem type from the QEP object. |
| Not Collective |
| Input Parameter: |
| . qep - the quadratic eigensolver context |
| Output Parameter: |
| . type - name of QEP problem type |
| Level: intermediate |
| .seealso: QEPSetProblemType(), QEPProblemType |
| @*/ |
| PetscErrorCode QEPGetProblemType(QEP qep,QEPProblemType *type) |
| { |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| PetscValidPointer(type,2); |
| *type = qep->problem_type; |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPSetConvergenceTest" |
| /*@C |
| QEPSetConvergenceTest - Sets a function to compute the error estimate used in |
| the convergence test. |
| Logically Collective on QEP |
| Input Parameters: |
| + qep - eigensolver context obtained from QEPCreate() |
| . func - a pointer to the convergence test function |
| - ctx - a context pointer (the last parameter to the convergence test function) |
| Calling Sequence of func: |
| $ func(QEP qep,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal* errest,void *ctx) |
| + qep - eigensolver context obtained from QEPCreate() |
| . eigr - real part of the eigenvalue |
| . eigi - imaginary part of the eigenvalue |
| . res - residual norm associated to the eigenpair |
| . errest - (output) computed error estimate |
| - ctx - optional context, as set by QEPSetConvergenceTest() |
| Note: |
| If the error estimate returned by the convergence test function is less than |
| the tolerance, then the eigenvalue is accepted as converged. |
| Level: advanced |
| .seealso: QEPSetTolerances() |
| @*/ |
| extern PetscErrorCode QEPSetConvergenceTest(QEP qep,PetscErrorCode (*func)(QEP,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*),void* ctx) |
| { |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| qep->conv_func = func; |
| qep->conv_ctx = ctx; |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPSetTrackAll" |
| /*@ |
| QEPSetTrackAll - Specifies if the solver must compute the residual of all |
| approximate eigenpairs or not. |
| Logically Collective on QEP |
| Input Parameters: |
| + qep - the eigensolver context |
| - trackall - whether compute all residuals or not |
| Notes: |
| If the user sets trackall=PETSC_TRUE then the solver explicitly computes |
| the residual for each eigenpair approximation. Computing the residual is |
| usually an expensive operation and solvers commonly compute the associated |
| residual to the first unconverged eigenpair. |
| The options '-qep_monitor_all' and '-qep_monitor_draw_all' automatically |
| activates this option. |
| Level: intermediate |
| .seealso: QEPGetTrackAll() |
| @*/ |
| PetscErrorCode QEPSetTrackAll(QEP qep,PetscBool trackall) |
| { |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| PetscValidLogicalCollectiveBool(qep,trackall,2); |
| qep->trackall = trackall; |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPGetTrackAll" |
| /*@ |
| QEPGetTrackAll - Returns the flag indicating whether all residual norms must |
| be computed or not. |
| Not Collective |
| Input Parameter: |
| . qep - the eigensolver context |
| Output Parameter: |
| . trackall - the returned flag |
| Level: intermediate |
| .seealso: QEPSetTrackAll() |
| @*/ |
| PetscErrorCode QEPGetTrackAll(QEP qep,PetscBool *trackall) |
| { |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| PetscValidPointer(trackall,2); |
| *trackall = qep->trackall; |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPSetOptionsPrefix" |
| /*@C |
| QEPSetOptionsPrefix - Sets the prefix used for searching for all |
| QEP options in the database. |
| Logically Collective on QEP |
| Input Parameters: |
| + qep - the quadratic eigensolver context |
| - prefix - the prefix string to prepend to all QEP option requests |
| Notes: |
| A hyphen (-) must NOT be given at the beginning of the prefix name. |
| The first character of all runtime options is AUTOMATICALLY the |
| hyphen. |
| For example, to distinguish between the runtime options for two |
| different QEP contexts, one could call |
| .vb |
| QEPSetOptionsPrefix(qep1,"qeig1_") |
| QEPSetOptionsPrefix(qep2,"qeig2_") |
| .ve |
| Level: advanced |
| .seealso: QEPAppendOptionsPrefix(), QEPGetOptionsPrefix() |
| @*/ |
| PetscErrorCode QEPSetOptionsPrefix(QEP qep,const char *prefix) |
| { |
| PetscErrorCode ierr; |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| if (!qep->ip) { ierr = QEPGetIP(qep,&qep->ip);CHKERRQ(ierr); } |
| ierr = IPSetOptionsPrefix(qep->ip,prefix);CHKERRQ(ierr); |
| ierr = PetscObjectSetOptionsPrefix((PetscObject)qep,prefix);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPAppendOptionsPrefix" |
| /*@C |
| QEPAppendOptionsPrefix - Appends to the prefix used for searching for all |
| QEP options in the database. |
| Logically Collective on QEP |
| Input Parameters: |
| + qep - the quadratic eigensolver context |
| - prefix - the prefix string to prepend to all QEP option requests |
| Notes: |
| A hyphen (-) must NOT be given at the beginning of the prefix name. |
| The first character of all runtime options is AUTOMATICALLY the hyphen. |
| Level: advanced |
| .seealso: QEPSetOptionsPrefix(), QEPGetOptionsPrefix() |
| @*/ |
| PetscErrorCode QEPAppendOptionsPrefix(QEP qep,const char *prefix) |
| { |
| PetscErrorCode ierr; |
| PetscBool flg; |
| EPS eps; |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| if (!qep->ip) { ierr = QEPGetIP(qep,&qep->ip);CHKERRQ(ierr); } |
| ierr = IPSetOptionsPrefix(qep->ip,prefix);CHKERRQ(ierr); |
| ierr = PetscObjectAppendOptionsPrefix((PetscObject)qep,prefix);CHKERRQ(ierr); |
| ierr = PetscTypeCompare((PetscObject)qep,QEPLINEAR,&flg);CHKERRQ(ierr); |
| if (flg) { |
| ierr = QEPLinearGetEPS(qep,&eps);CHKERRQ(ierr); |
| ierr = EPSSetOptionsPrefix(eps,((PetscObject)qep)->prefix);CHKERRQ(ierr); |
| ierr = EPSAppendOptionsPrefix(eps,"qep_");CHKERRQ(ierr); |
| } |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPGetOptionsPrefix" |
| /*@C |
| QEPGetOptionsPrefix - Gets the prefix used for searching for all |
| QEP options in the database. |
| Not Collective |
| Input Parameters: |
| . qep - the quadratic eigensolver context |
| Output Parameters: |
| . prefix - pointer to the prefix string used is returned |
| Notes: On the fortran side, the user should pass in a string 'prefix' of |
| sufficient length to hold the prefix. |
| Level: advanced |
| .seealso: QEPSetOptionsPrefix(), QEPAppendOptionsPrefix() |
| @*/ |
| PetscErrorCode QEPGetOptionsPrefix(QEP qep,const char *prefix[]) |
| { |
| PetscErrorCode ierr; |
| PetscFunctionBegin; |
| PetscValidHeaderSpecific(qep,QEP_CLASSID,1); |
| PetscValidPointer(prefix,2); |
| ierr = PetscObjectGetOptionsPrefix((PetscObject)qep,prefix);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| # |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # SLEPc - Scalable Library for Eigenvalue Problem Computations |
| # Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| # |
| # This file is part of SLEPc. |
| # |
| # SLEPc is free software: you can redistribute it and/or modify it under the |
| # terms of version 3 of the GNU Lesser General Public License as published by |
| # the Free Software Foundation. |
| # |
| # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| # more details. |
| # |
| # You should have received a copy of the GNU Lesser General Public License |
| # along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # |
| ALL: lib |
| CFLAGS = |
| FFLAGS = |
| SOURCEC = qepmon.c qepbasic.c qepdefault.c qepregis.c qepopts.c qepsetup.c qepsolve.c qepdense.c |
| SOURCEF = |
| SOURCEH = |
| OBJSC = qepmon.o qepbasic.o qepdefault.o qepregis.o qepopts.o qepsetup.o qepsolve.o qepdense.o |
| LIBBASE = libslepc |
| DIRS = |
| MANSEC = QEP |
| LOCDIR = src/qep/interface/ |
| include ${SLEPC_DIR}/conf/slepc_common |
| /* |
| Q-Arnoldi method for quadratic eigenproblems. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| SLEPc - Scalable Library for Eigenvalue Problem Computations |
| Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| This file is part of SLEPc. |
| SLEPc is free software: you can redistribute it and/or modify it under the |
| terms of version 3 of the GNU Lesser General Public License as published by |
| the Free Software Foundation. |
| SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| more details. |
| You should have received a copy of the GNU Lesser General Public License |
| along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| */ |
| #include <private/qepimpl.h> /*I "slepcqep.h" I*/ |
| #include <petscblaslapack.h> |
| typedef struct { |
| KSP ksp; |
| } QEP_QARNOLDI; |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPSetUp_QArnoldi" |
| PetscErrorCode QEPSetUp_QArnoldi(QEP qep) |
| { |
| PetscErrorCode ierr; |
| QEP_QARNOLDI *ctx = (QEP_QARNOLDI*)qep->data; |
| PetscFunctionBegin; |
| if (qep->ncv) { /* ncv set */ |
| if (qep->ncv<qep->nev) SETERRQ(((PetscObject)qep)->comm,1,"The value of ncv must be at least nev"); |
| } |
| else if (qep->mpd) { /* mpd set */ |
| qep->ncv = PetscMin(qep->n,qep->nev+qep->mpd); |
| } |
| else { /* neither set: defaults depend on nev being small or large */ |
| if (qep->nev<500) qep->ncv = PetscMin(qep->n,PetscMax(2*qep->nev,qep->nev+15)); |
| else { qep->mpd = 500; qep->ncv = PetscMin(qep->n,qep->nev+qep->mpd); } |
| } |
| if (!qep->mpd) qep->mpd = qep->ncv; |
| if (qep->ncv>qep->nev+qep->mpd) SETERRQ(((PetscObject)qep)->comm,1,"The value of ncv must not be larger than nev+mpd"); |
| if (!qep->max_it) qep->max_it = PetscMax(100,2*qep->n/qep->ncv); |
| if (!qep->which) qep->which = QEP_LARGEST_MAGNITUDE; |
| if (qep->problem_type != QEP_GENERAL) |
| SETERRQ(((PetscObject)qep)->comm,1,"Wrong value of qep->problem_type"); |
| ierr = QEPAllocateSolution(qep);CHKERRQ(ierr); |
| ierr = PetscFree(qep->T);CHKERRQ(ierr); |
| ierr = PetscMalloc(qep->ncv*qep->ncv*sizeof(PetscScalar),&qep->T);CHKERRQ(ierr); |
| ierr = QEPDefaultGetWork(qep,4);CHKERRQ(ierr); |
| ierr = KSPSetOperators(ctx->ksp,qep->M,qep->M,DIFFERENT_NONZERO_PATTERN);CHKERRQ(ierr); |
| ierr = KSPSetUp(ctx->ksp);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPQArnoldiCGS" |
| /* |
| Compute a step of Classical Gram-Schmidt orthogonalization |
| */ |
| PetscErrorCode QEPQArnoldiCGS(QEP qep,PetscScalar *H,PetscBLASInt ldh,PetscScalar *h,PetscBLASInt j,Vec *V,Vec t,Vec v,Vec w,PetscReal *onorm,PetscReal *norm,PetscScalar *work) |
| { |
| PetscErrorCode ierr; |
| PetscBLASInt ione = 1,j_1 = j+1; |
| PetscReal x,y; |
| PetscScalar dot,one = 1.0,zero = 0.0; |
| PetscFunctionBegin; |
| /* compute norm of v and w */ |
| if (onorm) { |
| ierr = VecNorm(v,NORM_2,&x);CHKERRQ(ierr); |
| ierr = VecNorm(w,NORM_2,&y);CHKERRQ(ierr); |
| *onorm = PetscSqrtReal(x*x+y*y); |
| } |
| /* orthogonalize: compute h */ |
| ierr = VecMDot(v,j_1,V,h);CHKERRQ(ierr); |
| ierr = VecMDot(w,j_1,V,work);CHKERRQ(ierr); |
| if (j>0) |
| BLASgemv_("C",&j_1,&j,&one,H,&ldh,work,&ione,&one,h,&ione); |
| ierr = VecDot(t,w,&dot);CHKERRQ(ierr); |
| h[j] += dot; |
| /* orthogonalize: update v and w */ |
| ierr = SlepcVecMAXPBY(v,1.0,-1.0,j_1,h,V);CHKERRQ(ierr); |
| if (j>0) { |
| BLASgemv_("N",&j_1,&j,&one,H,&ldh,h,&ione,&zero,work,&ione); |
| ierr = SlepcVecMAXPBY(w,1.0,-1.0,j_1,work,V);CHKERRQ(ierr); |
| } |
| ierr = VecAXPY(w,-h[j],t);CHKERRQ(ierr); |
| /* compute norm of v and w */ |
| if (norm) { |
| ierr = VecNorm(v,NORM_2,&x);CHKERRQ(ierr); |
| ierr = VecNorm(w,NORM_2,&y);CHKERRQ(ierr); |
| *norm = PetscSqrtReal(x*x+y*y);CHKERRQ(ierr); |
| } |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPQArnoldi" |
| /* |
| Compute a run of Q-Arnoldi iterations |
| */ |
| PetscErrorCode QEPQArnoldi(QEP qep,PetscScalar *H,PetscInt ldh,Vec *V,PetscInt k,PetscInt *M,Vec v,Vec w,PetscReal *beta,PetscBool *breakdown,PetscScalar *work) |
| { |
| PetscErrorCode ierr; |
| PetscInt i,j,l,m = *M; |
| QEP_QARNOLDI *ctx = (QEP_QARNOLDI*)qep->data; |
| Vec t = qep->work[2],u = qep->work[3]; |
| IPOrthogRefineType refinement; |
| PetscReal norm,onorm,eta; |
| PetscScalar *c = work + m; |
| PetscFunctionBegin; |
| ierr = IPGetOrthogonalization(qep->ip,PETSC_NULL,&refinement,&eta);CHKERRQ(ierr); |
| ierr = VecCopy(v,qep->V[k]);CHKERRQ(ierr); |
| for (j=k;j<m;j++) { |
| /* apply operator */ |
| ierr = VecCopy(w,t);CHKERRQ(ierr); |
| ierr = MatMult(qep->K,v,u);CHKERRQ(ierr); |
| ierr = MatMult(qep->C,t,w);CHKERRQ(ierr); |
| ierr = VecAXPY(u,qep->sfactor,w);CHKERRQ(ierr); |
| ierr = KSPSolve(ctx->ksp,u,w);CHKERRQ(ierr); |
| ierr = VecScale(w,-1.0/(qep->sfactor*qep->sfactor));CHKERRQ(ierr); |
| ierr = VecCopy(t,v);CHKERRQ(ierr); |
| /* orthogonalize */ |
| switch (refinement) { |
| case IP_ORTHOG_REFINE_NEVER: |
| ierr = QEPQArnoldiCGS(qep,H,ldh,H+ldh*j,j,V,t,v,w,PETSC_NULL,&norm,work);CHKERRQ(ierr); |
| *breakdown = PETSC_FALSE; |
| break; |
| case IP_ORTHOG_REFINE_ALWAYS: |
| ierr = QEPQArnoldiCGS(qep,H,ldh,H+ldh*j,j,V,t,v,w,PETSC_NULL,PETSC_NULL,work);CHKERRQ(ierr); |
| ierr = QEPQArnoldiCGS(qep,H,ldh,c,j,V,t,v,w,&onorm,&norm,work);CHKERRQ(ierr); |
| for (i=0;i<j;i++) H[ldh*j+i] += c[i]; |
| if (norm < eta * onorm) *breakdown = PETSC_TRUE; |
| else *breakdown = PETSC_FALSE; |
| break; |
| case IP_ORTHOG_REFINE_IFNEEDED: |
| ierr = QEPQArnoldiCGS(qep,H,ldh,H+ldh*j,j,V,t,v,w,&onorm,&norm,work);CHKERRQ(ierr); |
| /* ||q|| < eta ||h|| */ |
| l = 1; |
| while (l<3 && norm < eta * onorm) { |
| l++; |
| onorm = norm; |
| ierr = QEPQArnoldiCGS(qep,H,ldh,c,j,V,t,v,w,PETSC_NULL,&norm,work);CHKERRQ(ierr); |
| for (i=0;i<j;i++) H[ldh*j+i] += c[i]; |
| } |
| if (norm < eta * onorm) *breakdown = PETSC_TRUE; |
| else *breakdown = PETSC_FALSE; |
| break; |
| default: SETERRQ(((PetscObject)qep)->comm,1,"Wrong value of ip->orth_ref"); |
| } |
| ierr = VecScale(v,1.0/norm);CHKERRQ(ierr); |
| ierr = VecScale(w,1.0/norm);CHKERRQ(ierr); |
| if (j<m-1) { |
| H[j+1+ldh*j] = norm; |
| ierr = VecCopy(v,V[j+1]);CHKERRQ(ierr); |
| } |
| } |
| *beta = norm; |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPProjectedKSNonsym" |
| /* |
| QEPProjectedKSNonsym - Solves the projected eigenproblem in the Krylov-Schur |
| method (non-symmetric case). |
| On input: |
| l is the number of vectors kept in previous restart (0 means first restart) |
| S is the projected matrix (leading dimension is lds) |
| On output: |
| S has (real) Schur form with diagonal blocks sorted appropriately |
| Q contains the corresponding Schur vectors (order n, leading dimension n) |
| */ |
| PetscErrorCode QEPProjectedKSNonsym(QEP qep,PetscInt l,PetscScalar *S,PetscInt lds,PetscScalar *Q,PetscInt n) |
| { |
| PetscErrorCode ierr; |
| PetscInt i; |
| PetscFunctionBegin; |
| if (l==0) { |
| ierr = PetscMemzero(Q,n*n*sizeof(PetscScalar));CHKERRQ(ierr); |
| for (i=0;i<n;i++) |
| Q[i*(n+1)] = 1.0; |
| } else { |
| /* Reduce S to Hessenberg form, S <- Q S Q' */ |
| ierr = EPSDenseHessenberg(n,qep->nconv,S,lds,Q);CHKERRQ(ierr); |
| } |
| /* Reduce S to (quasi-)triangular form, S <- Q S Q' */ |
| ierr = EPSDenseSchur(n,qep->nconv,S,lds,Q,qep->eigr,qep->eigi);CHKERRQ(ierr); |
| /* Sort the remaining columns of the Schur form */ |
| ierr = QEPSortDenseSchur(qep,n,qep->nconv,S,lds,Q,qep->eigr,qep->eigi);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPSolve_QArnoldi" |
| PetscErrorCode QEPSolve_QArnoldi(QEP qep) |
| { |
| PetscErrorCode ierr; |
| PetscInt i,j,k,l,lwork,nv; |
| Vec v=qep->work[0],w=qep->work[1]; |
| PetscScalar *S=qep->T,*Q,*work; |
| PetscReal beta,norm,x,y; |
| PetscBool breakdown; |
| PetscFunctionBegin; |
| ierr = PetscMemzero(S,qep->ncv*qep->ncv*sizeof(PetscScalar));CHKERRQ(ierr); |
| ierr = PetscMalloc(qep->ncv*qep->ncv*sizeof(PetscScalar),&Q);CHKERRQ(ierr); |
| lwork = 7*qep->ncv; |
| ierr = PetscMalloc(lwork*sizeof(PetscScalar),&work);CHKERRQ(ierr); |
| /* Get the starting Arnoldi vector */ |
| if (qep->nini>0) { |
| ierr = VecCopy(qep->V[0],v);CHKERRQ(ierr); |
| } else { |
| ierr = SlepcVecSetRandom(v,qep->rand);CHKERRQ(ierr); |
| } |
| /* w is always a random vector */ |
| ierr = SlepcVecSetRandom(w,qep->rand);CHKERRQ(ierr); |
| ierr = VecNorm(v,NORM_2,&x);CHKERRQ(ierr); |
| ierr = VecNorm(w,NORM_2,&y);CHKERRQ(ierr); |
| norm = PetscSqrtReal(x*x+y*y);CHKERRQ(ierr); |
| ierr = VecScale(v,1.0/norm);CHKERRQ(ierr); |
| ierr = VecScale(w,1.0/norm);CHKERRQ(ierr); |
| /* Restart loop */ |
| l = 0; |
| while (qep->reason == QEP_CONVERGED_ITERATING) { |
| qep->its++; |
| /* Compute an nv-step Arnoldi factorization */ |
| nv = PetscMin(qep->nconv+qep->mpd,qep->ncv); |
| ierr = QEPQArnoldi(qep,S,qep->ncv,qep->V,qep->nconv+l,&nv,v,w,&beta,&breakdown,work);CHKERRQ(ierr); |
| /* Solve projected problem */ |
| ierr = QEPProjectedKSNonsym(qep,l,S,qep->ncv,Q,nv);CHKERRQ(ierr); |
| /* Check convergence */ |
| ierr = QEPKrylovConvergence(qep,qep->nconv,nv-qep->nconv,S,qep->ncv,Q,nv,beta,&k,work);CHKERRQ(ierr); |
| if (qep->its >= qep->max_it) qep->reason = QEP_DIVERGED_ITS; |
| if (k >= qep->nev) qep->reason = QEP_CONVERGED_TOL; |
| /* Update l */ |
| if (qep->reason != QEP_CONVERGED_ITERATING || breakdown) l = 0; |
| else { |
| l = (nv-k)/2; |
| #if !defined(PETSC_USE_COMPLEX) |
| if (S[(k+l-1)*(qep->ncv+1)+1] != 0.0) { |
| if (k+l<nv-1) l = l+1; |
| else l = l-1; |
| } |
| #endif |
| } |
| if (qep->reason == QEP_CONVERGED_ITERATING) { |
| if (breakdown) { |
| /* Stop if breakdown */ |
| PetscInfo2(qep,"Breakdown Quadratic Arnoldi method (it=%D norm=%G)\n",qep->its,beta); |
| qep->reason = QEP_DIVERGED_BREAKDOWN; |
| } else { |
| /* Prepare the Rayleigh quotient for restart */ |
| for (i=k;i<k+l;i++) { |
| S[i*qep->ncv+k+l] = Q[(i+1)*nv-1]*beta; |
| } |
| } |
| } |
| /* Update the corresponding vectors V(:,idx) = V*Q(:,idx) */ |
| ierr = SlepcUpdateVectors(nv,qep->V,qep->nconv,k+l,Q,nv,PETSC_FALSE);CHKERRQ(ierr); |
| qep->nconv = k; |
| ierr = QEPMonitor(qep,qep->its,qep->nconv,qep->eigr,qep->eigi,qep->errest,nv);CHKERRQ(ierr); |
| } |
| for (j=0;j<qep->nconv;j++) { |
| qep->eigr[j] *= qep->sfactor; |
| qep->eigi[j] *= qep->sfactor; |
| } |
| /* Compute eigenvectors */ |
| if (qep->nconv > 0) { |
| ierr = QEPComputeVectors_Schur(qep); |
| } |
| ierr = PetscFree(Q);CHKERRQ(ierr); |
| ierr = PetscFree(work);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPSetFromOptions_QArnoldi" |
| PetscErrorCode QEPSetFromOptions_QArnoldi(QEP qep) |
| { |
| PetscErrorCode ierr; |
| QEP_QARNOLDI *ctx = (QEP_QARNOLDI*)qep->data; |
| PetscFunctionBegin; |
| ierr = KSPSetFromOptions(ctx->ksp);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPView_QArnoldi" |
| PetscErrorCode QEPView_QArnoldi(QEP qep,PetscViewer viewer) |
| { |
| PetscErrorCode ierr; |
| QEP_QARNOLDI *ctx = (QEP_QARNOLDI*)qep->data; |
| PetscFunctionBegin; |
| ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); |
| ierr = KSPView(ctx->ksp,viewer);CHKERRQ(ierr); |
| ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPReset_QArnoldi" |
| PetscErrorCode QEPReset_QArnoldi(QEP qep) |
| { |
| PetscErrorCode ierr; |
| QEP_QARNOLDI *ctx = (QEP_QARNOLDI*)qep->data; |
| PetscFunctionBegin; |
| ierr = PetscFree(qep->T);CHKERRQ(ierr); |
| ierr = KSPReset(ctx->ksp);CHKERRQ(ierr); |
| ierr = QEPDefaultFreeWork(qep);CHKERRQ(ierr); |
| ierr = QEPFreeSolution(qep);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPDestroy_QArnoldi" |
| PetscErrorCode QEPDestroy_QArnoldi(QEP qep) |
| { |
| PetscErrorCode ierr; |
| QEP_QARNOLDI *ctx = (QEP_QARNOLDI*)qep->data; |
| PetscFunctionBegin; |
| ierr = KSPDestroy(&ctx->ksp);CHKERRQ(ierr); |
| ierr = PetscFree(qep->data);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| EXTERN_C_BEGIN |
| #undef __FUNCT__ |
| #define __FUNCT__ "QEPCreate_QArnoldi" |
| PetscErrorCode QEPCreate_QArnoldi(QEP qep) |
| { |
| PetscErrorCode ierr; |
| QEP_QARNOLDI *ctx; |
| PetscFunctionBegin; |
| ierr = PetscNewLog(qep,QEP_QARNOLDI,&ctx);CHKERRQ(ierr); |
| qep->data = ctx; |
| qep->ops->solve = QEPSolve_QArnoldi; |
| qep->ops->setup = QEPSetUp_QArnoldi; |
| qep->ops->setfromoptions = QEPSetFromOptions_QArnoldi; |
| qep->ops->destroy = QEPDestroy_QArnoldi; |
| qep->ops->reset = QEPReset_QArnoldi; |
| qep->ops->view = QEPView_QArnoldi; |
| ierr = KSPCreate(((PetscObject)qep)->comm,&ctx->ksp);CHKERRQ(ierr); |
| ierr = KSPSetOptionsPrefix(ctx->ksp,((PetscObject)qep)->prefix);CHKERRQ(ierr); |
| ierr = KSPAppendOptionsPrefix(ctx->ksp,"qep_");CHKERRQ(ierr); |
| ierr = PetscObjectIncrementTabLevel((PetscObject)ctx->ksp,(PetscObject)qep,1);CHKERRQ(ierr); |
| ierr = PetscLogObjectParent(qep,ctx->ksp);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| EXTERN_C_END |
| # |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # SLEPc - Scalable Library for Eigenvalue Problem Computations |
| # Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| # |
| # This file is part of SLEPc. |
| # |
| # SLEPc is free software: you can redistribute it and/or modify it under the |
| # terms of version 3 of the GNU Lesser General Public License as published by |
| # the Free Software Foundation. |
| # |
| # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| # more details. |
| # |
| # You should have received a copy of the GNU Lesser General Public License |
| # along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| # |
| ALL: lib |
| CFLAGS = |
| FFLAGS = |
| SOURCEC = qarnoldi.c |
| SOURCEF = |
| SOURCEH = |
| OBJSC = qarnoldi.o |
| LIBBASE = libslepc |
| DIRS = |
| MANSEC = QEP |
| LOCDIR = src/qep/impls/qarnoldi/ |
| include ${SLEPC_DIR}/conf/slepc_common |
| /* |
| Private header for QEPLINEAR. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| SLEPc - Scalable Library for Eigenvalue Problem Computations |
| Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| This file is part of SLEPc. |
| SLEPc is free software: you can redistribute it and/or modify it under the |
| terms of version 3 of the GNU Lesser General Public License as published by |
| the Free Software Foundation. |
| SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| more details. |
| You should have received a copy of the GNU Lesser General Public License |
| along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| */ |
| typedef struct { |
| PetscBool explicitmatrix; |
| PetscInt cform; /* companion form */ |
| PetscReal sfactor; /* scaling factor */ |
| Mat A,B; /* matrices of generalized eigenproblem */ |
| EPS eps; /* linear eigensolver for Az=lBz */ |
| Mat M,C,K; /* copy of QEP coefficient matrices */ |
| Vec x1,x2,y1,y2; /* work vectors */ |
| PetscBool setfromoptionscalled; |
| } QEP_LINEAR; |
| /* N1 */ |
| extern PetscErrorCode MatMult_Linear_N1A(Mat,Vec,Vec); |
| extern PetscErrorCode MatMult_Linear_N1B(Mat,Vec,Vec); |
| extern PetscErrorCode MatGetDiagonal_Linear_N1A(Mat,Vec); |
| extern PetscErrorCode MatGetDiagonal_Linear_N1B(Mat,Vec); |
| extern PetscErrorCode MatCreateExplicit_Linear_N1A(MPI_Comm,QEP_LINEAR*,Mat*); |
| extern PetscErrorCode MatCreateExplicit_Linear_N1B(MPI_Comm,QEP_LINEAR*,Mat*); |
| /* N2 */ |
| extern PetscErrorCode MatMult_Linear_N2A(Mat,Vec,Vec); |
| extern PetscErrorCode MatMult_Linear_N2B(Mat,Vec,Vec); |
| extern PetscErrorCode MatGetDiagonal_Linear_N2A(Mat,Vec); |
| extern PetscErrorCode MatGetDiagonal_Linear_N2B(Mat,Vec); |
| extern PetscErrorCode MatCreateExplicit_Linear_N2A(MPI_Comm,QEP_LINEAR*,Mat*); |
| extern PetscErrorCode MatCreateExplicit_Linear_N2B(MPI_Comm,QEP_LINEAR*,Mat*); |
| /* S1 */ |
| extern PetscErrorCode MatMult_Linear_S1A(Mat,Vec,Vec); |
| extern PetscErrorCode MatMult_Linear_S1B(Mat,Vec,Vec); |
| extern PetscErrorCode MatGetDiagonal_Linear_S1A(Mat,Vec); |
| extern PetscErrorCode MatGetDiagonal_Linear_S1B(Mat,Vec); |
| extern PetscErrorCode MatCreateExplicit_Linear_S1A(MPI_Comm,QEP_LINEAR*,Mat*); |
| extern PetscErrorCode MatCreateExplicit_Linear_S1B(MPI_Comm,QEP_LINEAR*,Mat*); |
| /* S2 */ |
| extern PetscErrorCode MatMult_Linear_S2A(Mat,Vec,Vec); |
| extern PetscErrorCode MatMult_Linear_S2B(Mat,Vec,Vec); |
| extern PetscErrorCode MatGetDiagonal_Linear_S2A(Mat,Vec); |
| extern PetscErrorCode MatGetDiagonal_Linear_S2B(Mat,Vec); |
| extern PetscErrorCode MatCreateExplicit_Linear_S2A(MPI_Comm,QEP_LINEAR*,Mat*); |
| extern PetscErrorCode MatCreateExplicit_Linear_S2B(MPI_Comm,QEP_LINEAR*,Mat*); |
| /* H1 */ |
| extern PetscErrorCode MatMult_Linear_H1A(Mat,Vec,Vec); |
| extern PetscErrorCode MatMult_Linear_H1B(Mat,Vec,Vec); |
| extern PetscErrorCode MatGetDiagonal_Linear_H1A(Mat,Vec); |
| extern PetscErrorCode MatGetDiagonal_Linear_H1B(Mat,Vec); |
| extern PetscErrorCode MatCreateExplicit_Linear_H1A(MPI_Comm,QEP_LINEAR*,Mat*); |
| extern PetscErrorCode MatCreateExplicit_Linear_H1B(MPI_Comm,QEP_LINEAR*,Mat*); |
| /* H2 */ |
| extern PetscErrorCode MatMult_Linear_H2A(Mat,Vec,Vec); |
| extern PetscErrorCode MatMult_Linear_H2B(Mat,Vec,Vec); |
| extern PetscErrorCode MatGetDiagonal_Linear_H2A(Mat,Vec); |
| extern PetscErrorCode MatGetDiagonal_Linear_H2B(Mat,Vec); |
| extern PetscErrorCode MatCreateExplicit_Linear_H2A(MPI_Comm,QEP_LINEAR*,Mat*); |
| extern PetscErrorCode MatCreateExplicit_Linear_H2B(MPI_Comm,QEP_LINEAR*,Mat*); |
| /* |
| Linearization for gyroscopic QEP, companion form 1. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| SLEPc - Scalable Library for Eigenvalue Problem Computations |
| Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| This file is part of SLEPc. |
| SLEPc is free software: you can redistribute it and/or modify it under the |
| terms of version 3 of the GNU Lesser General Public License as published by |
| the Free Software Foundation. |
| SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| more details. |
| You should have received a copy of the GNU Lesser General Public License |
| along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| */ |
| #include <private/qepimpl.h> /*I "slepcqep.h" I*/ |
| #include "linearp.h" |
| /* |
| Given the quadratic problem (l^2*M + l*C + K)*x = 0 the following |
| linearization is employed: |
| A*z = l*B*z where A = [ K 0 ] B = [ 0 K ] z = [ x ] |
| [ C K ] [-M 0 ] [ l*x ] |
| */ |
| #undef __FUNCT__ |
| #define __FUNCT__ "MatMult_Linear_H1A" |
| PetscErrorCode MatMult_Linear_H1A(Mat A,Vec x,Vec y) |
| { |
| PetscErrorCode ierr; |
| QEP_LINEAR *ctx; |
| const PetscScalar *px; |
| PetscScalar *py; |
| PetscInt m; |
| PetscFunctionBegin; |
| ierr = MatShellGetContext(A,(void**)&ctx);CHKERRQ(ierr); |
| ierr = MatGetLocalSize(ctx->M,&m,PETSC_NULL);CHKERRQ(ierr); |
| ierr = VecGetArrayRead(x,&px);CHKERRQ(ierr); |
| ierr = VecGetArray(y,&py);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->x1,px);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->x2,px+m);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->y1,py);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->y2,py+m);CHKERRQ(ierr); |
| /* y2 = C*x1 + K*x2 */ |
| ierr = MatMult(ctx->C,ctx->x1,ctx->y1);CHKERRQ(ierr); |
| ierr = MatMult(ctx->K,ctx->x2,ctx->y2);CHKERRQ(ierr); |
| ierr = VecAXPY(ctx->y2,ctx->sfactor,ctx->y1);CHKERRQ(ierr); |
| /* y1 = K*x1 */ |
| ierr = MatMult(ctx->K,ctx->x1,ctx->y1);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->x1);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->x2);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->y1);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->y2);CHKERRQ(ierr); |
| ierr = VecRestoreArrayRead(x,&px);CHKERRQ(ierr); |
| ierr = VecRestoreArray(y,&py);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "MatMult_Linear_H1B" |
| PetscErrorCode MatMult_Linear_H1B(Mat B,Vec x,Vec y) |
| { |
| PetscErrorCode ierr; |
| QEP_LINEAR *ctx; |
| const PetscScalar *px; |
| PetscScalar *py; |
| PetscInt m; |
| PetscFunctionBegin; |
| ierr = MatShellGetContext(B,(void**)&ctx);CHKERRQ(ierr); |
| ierr = MatGetLocalSize(ctx->M,&m,PETSC_NULL);CHKERRQ(ierr); |
| ierr = VecGetArrayRead(x,&px);CHKERRQ(ierr); |
| ierr = VecGetArray(y,&py);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->x1,px);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->x2,px+m);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->y1,py);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->y2,py+m);CHKERRQ(ierr); |
| /* y1 = K*x2 */ |
| ierr = MatMult(ctx->K,ctx->x2,ctx->y1);CHKERRQ(ierr); |
| /* y2 = -M*x1 */ |
| ierr = MatMult(ctx->M,ctx->x1,ctx->y2);CHKERRQ(ierr); |
| ierr = VecScale(ctx->y2,-ctx->sfactor*ctx->sfactor);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->x1);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->x2);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->y1);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->y2);CHKERRQ(ierr); |
| ierr = VecRestoreArrayRead(x,&px);CHKERRQ(ierr); |
| ierr = VecRestoreArray(y,&py);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "MatGetDiagonal_Linear_H1A" |
| PetscErrorCode MatGetDiagonal_Linear_H1A(Mat A,Vec diag) |
| { |
| PetscErrorCode ierr; |
| QEP_LINEAR *ctx; |
| PetscScalar *pd; |
| PetscInt m; |
| PetscFunctionBegin; |
| ierr = MatShellGetContext(A,(void**)&ctx);CHKERRQ(ierr); |
| ierr = MatGetLocalSize(ctx->M,&m,PETSC_NULL);CHKERRQ(ierr); |
| ierr = VecGetArray(diag,&pd);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->x1,pd);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->x2,pd+m);CHKERRQ(ierr); |
| ierr = MatGetDiagonal(ctx->K,ctx->x1);CHKERRQ(ierr); |
| ierr = VecCopy(ctx->x1,ctx->x2);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->x1);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->x2);CHKERRQ(ierr); |
| ierr = VecRestoreArray(diag,&pd);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "MatGetDiagonal_Linear_H1B" |
| PetscErrorCode MatGetDiagonal_Linear_H1B(Mat B,Vec diag) |
| { |
| PetscErrorCode ierr; |
| PetscFunctionBegin; |
| ierr = VecSet(diag,0.0);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "MatCreateExplicit_Linear_H1A" |
| PetscErrorCode MatCreateExplicit_Linear_H1A(MPI_Comm comm,QEP_LINEAR *ctx,Mat *A) |
| { |
| PetscErrorCode ierr; |
| PetscFunctionBegin; |
| ierr = SlepcMatTile(1.0,ctx->K,0.0,ctx->K,ctx->sfactor,ctx->C,1.0,ctx->K,A);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "MatCreateExplicit_Linear_H1B" |
| PetscErrorCode MatCreateExplicit_Linear_H1B(MPI_Comm comm,QEP_LINEAR *ctx,Mat *B) |
| { |
| PetscErrorCode ierr; |
| PetscFunctionBegin; |
| ierr = SlepcMatTile(0.0,ctx->K,1.0,ctx->K,-ctx->sfactor*ctx->sfactor,ctx->M,0.0,ctx->K,B);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| /* |
| Linearization for gyroscopic QEP, companion form 2. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| SLEPc - Scalable Library for Eigenvalue Problem Computations |
| Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| This file is part of SLEPc. |
| SLEPc is free software: you can redistribute it and/or modify it under the |
| terms of version 3 of the GNU Lesser General Public License as published by |
| the Free Software Foundation. |
| SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| more details. |
| You should have received a copy of the GNU Lesser General Public License |
| along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| */ |
| #include <private/qepimpl.h> /*I "slepcqep.h" I*/ |
| #include "linearp.h" |
| /* |
| Given the quadratic problem (l^2*M + l*C + K)*x = 0 the following |
| linearization is employed: |
| A*z = l*B*z where A = [ 0 -K ] B = [ M C ] z = [ x ] |
| [ M 0 ] [ 0 M ] [ l*x ] |
| */ |
| #undef __FUNCT__ |
| #define __FUNCT__ "MatMult_Linear_H2A" |
| PetscErrorCode MatMult_Linear_H2A(Mat A,Vec x,Vec y) |
| { |
| PetscErrorCode ierr; |
| QEP_LINEAR *ctx; |
| const PetscScalar *px; |
| PetscScalar *py; |
| PetscInt m; |
| PetscFunctionBegin; |
| ierr = MatShellGetContext(A,(void**)&ctx);CHKERRQ(ierr); |
| ierr = MatGetLocalSize(ctx->M,&m,PETSC_NULL);CHKERRQ(ierr); |
| ierr = VecGetArrayRead(x,&px);CHKERRQ(ierr); |
| ierr = VecGetArray(y,&py);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->x1,px);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->x2,px+m);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->y1,py);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->y2,py+m);CHKERRQ(ierr); |
| /* y1 = -K*x2 */ |
| ierr = MatMult(ctx->K,ctx->x2,ctx->y1);CHKERRQ(ierr); |
| ierr = VecScale(ctx->y1,-1.0);CHKERRQ(ierr); |
| /* y2 = M*x1 */ |
| ierr = MatMult(ctx->M,ctx->x1,ctx->y2);CHKERRQ(ierr); |
| ierr = VecScale(ctx->y2,ctx->sfactor*ctx->sfactor);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->x1);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->x2);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->y1);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->y2);CHKERRQ(ierr); |
| ierr = VecRestoreArrayRead(x,&px);CHKERRQ(ierr); |
| ierr = VecRestoreArray(y,&py);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "MatMult_Linear_H2B" |
| PetscErrorCode MatMult_Linear_H2B(Mat B,Vec x,Vec y) |
| { |
| PetscErrorCode ierr; |
| QEP_LINEAR *ctx; |
| const PetscScalar *px; |
| PetscScalar *py; |
| PetscInt m; |
| PetscFunctionBegin; |
| ierr = MatShellGetContext(B,(void**)&ctx);CHKERRQ(ierr); |
| ierr = MatGetLocalSize(ctx->M,&m,PETSC_NULL);CHKERRQ(ierr); |
| ierr = VecGetArrayRead(x,&px);CHKERRQ(ierr); |
| ierr = VecGetArray(y,&py);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->x1,px);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->x2,px+m);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->y1,py);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->y2,py+m);CHKERRQ(ierr); |
| /* y1 = M*x1 + C*x2 */ |
| ierr = MatMult(ctx->M,ctx->x1,ctx->y1);CHKERRQ(ierr); |
| ierr = VecScale(ctx->y1,ctx->sfactor*ctx->sfactor);CHKERRQ(ierr); |
| ierr = MatMult(ctx->C,ctx->x2,ctx->y2);CHKERRQ(ierr); |
| ierr = VecAXPY(ctx->y1,ctx->sfactor,ctx->y2);CHKERRQ(ierr); |
| /* y2 = M*x2 */ |
| ierr = MatMult(ctx->M,ctx->x2,ctx->y2);CHKERRQ(ierr); |
| ierr = VecScale(ctx->y2,ctx->sfactor*ctx->sfactor);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->x1);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->x2);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->y1);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->y2);CHKERRQ(ierr); |
| ierr = VecRestoreArrayRead(x,&px);CHKERRQ(ierr); |
| ierr = VecRestoreArray(y,&py);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "MatGetDiagonal_Linear_H2A" |
| PetscErrorCode MatGetDiagonal_Linear_H2A(Mat A,Vec diag) |
| { |
| PetscErrorCode ierr; |
| PetscFunctionBegin; |
| ierr = VecSet(diag,0.0);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "MatGetDiagonal_Linear_H2B" |
| PetscErrorCode MatGetDiagonal_Linear_H2B(Mat B,Vec diag) |
| { |
| PetscErrorCode ierr; |
| QEP_LINEAR *ctx; |
| PetscScalar *pd; |
| PetscInt m; |
| PetscFunctionBegin; |
| ierr = MatShellGetContext(B,(void**)&ctx);CHKERRQ(ierr); |
| ierr = MatGetLocalSize(ctx->M,&m,PETSC_NULL);CHKERRQ(ierr); |
| ierr = VecGetArray(diag,&pd);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->x1,pd);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->x2,pd+m);CHKERRQ(ierr); |
| ierr = MatGetDiagonal(ctx->M,ctx->x1);CHKERRQ(ierr); |
| ierr = VecScale(ctx->x1,ctx->sfactor*ctx->sfactor);CHKERRQ(ierr); |
| ierr = VecCopy(ctx->x1,ctx->x2);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->x1);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->x2);CHKERRQ(ierr); |
| ierr = VecRestoreArray(diag,&pd);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "MatCreateExplicit_Linear_H2A" |
| PetscErrorCode MatCreateExplicit_Linear_H2A(MPI_Comm comm,QEP_LINEAR *ctx,Mat *A) |
| { |
| PetscErrorCode ierr; |
| PetscFunctionBegin; |
| ierr = SlepcMatTile(0.0,ctx->K,-1.0,ctx->K,ctx->sfactor*ctx->sfactor,ctx->M,0.0,ctx->K,A);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "MatCreateExplicit_Linear_H2B" |
| PetscErrorCode MatCreateExplicit_Linear_H2B(MPI_Comm comm,QEP_LINEAR *ctx,Mat *B) |
| { |
| PetscErrorCode ierr; |
| PetscFunctionBegin; |
| ierr = SlepcMatTile(ctx->sfactor*ctx->sfactor,ctx->M,ctx->sfactor,ctx->C,0.0,ctx->C,ctx->sfactor*ctx->sfactor,ctx->M,B);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| /* |
| Linearization for general QEP, companion form 1. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| SLEPc - Scalable Library for Eigenvalue Problem Computations |
| Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| This file is part of SLEPc. |
| SLEPc is free software: you can redistribute it and/or modify it under the |
| terms of version 3 of the GNU Lesser General Public License as published by |
| the Free Software Foundation. |
| SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| more details. |
| You should have received a copy of the GNU Lesser General Public License |
| along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| */ |
| #include <private/qepimpl.h> /*I "slepcqep.h" I*/ |
| #include "linearp.h" |
| /* |
| Given the quadratic problem (l^2*M + l*C + K)*x = 0 the following |
| linearization is employed: |
| A*z = l*B*z where A = [ 0 I ] B = [ I 0 ] z = [ x ] |
| [ -K -C ] [ 0 M ] [ l*x ] |
| */ |
| #undef __FUNCT__ |
| #define __FUNCT__ "MatMult_Linear_N1A" |
| PetscErrorCode MatMult_Linear_N1A(Mat A,Vec x,Vec y) |
| { |
| PetscErrorCode ierr; |
| QEP_LINEAR *ctx; |
| const PetscScalar *px; |
| PetscScalar *py; |
| PetscInt m; |
| PetscFunctionBegin; |
| ierr = MatShellGetContext(A,(void**)&ctx);CHKERRQ(ierr); |
| ierr = MatGetLocalSize(ctx->M,&m,PETSC_NULL);CHKERRQ(ierr); |
| ierr = VecGetArrayRead(x,&px);CHKERRQ(ierr); |
| ierr = VecGetArray(y,&py);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->x1,px);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->x2,px+m);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->y1,py);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->y2,py+m);CHKERRQ(ierr); |
| /* y2 = -(K*x1 + C*x2) */ |
| ierr = MatMult(ctx->K,ctx->x1,ctx->y2);CHKERRQ(ierr); |
| ierr = MatMult(ctx->C,ctx->x2,ctx->y1);CHKERRQ(ierr); |
| ierr = VecAXPY(ctx->y2,ctx->sfactor,ctx->y1);CHKERRQ(ierr); |
| ierr = VecScale(ctx->y2,-1.0);CHKERRQ(ierr); |
| /* y1 = x2 */ |
| ierr = VecCopy(ctx->x2,ctx->y1);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->x1);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->x2);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->y1);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->y2);CHKERRQ(ierr); |
| ierr = VecRestoreArrayRead(x,&px);CHKERRQ(ierr); |
| ierr = VecRestoreArray(y,&py);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "MatMult_Linear_N1B" |
| PetscErrorCode MatMult_Linear_N1B(Mat B,Vec x,Vec y) |
| { |
| PetscErrorCode ierr; |
| QEP_LINEAR *ctx; |
| const PetscScalar *px; |
| PetscScalar *py; |
| PetscInt m; |
| PetscFunctionBegin; |
| ierr = MatShellGetContext(B,(void**)&ctx);CHKERRQ(ierr); |
| ierr = MatGetLocalSize(ctx->M,&m,PETSC_NULL);CHKERRQ(ierr); |
| ierr = VecGetArrayRead(x,&px);CHKERRQ(ierr); |
| ierr = VecGetArray(y,&py);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->x1,px);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->x2,px+m);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->y1,py);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->y2,py+m);CHKERRQ(ierr); |
| /* y1 = x1 */ |
| ierr = VecCopy(ctx->x1,ctx->y1);CHKERRQ(ierr); |
| /* y2 = M*x2 */ |
| ierr = MatMult(ctx->M,ctx->x2,ctx->y2);CHKERRQ(ierr); |
| ierr = VecScale(ctx->y2,ctx->sfactor*ctx->sfactor);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->x1);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->x2);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->y1);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->y2);CHKERRQ(ierr); |
| ierr = VecRestoreArrayRead(x,&px);CHKERRQ(ierr); |
| ierr = VecRestoreArray(y,&py);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "MatGetDiagonal_Linear_N1A" |
| PetscErrorCode MatGetDiagonal_Linear_N1A(Mat A,Vec diag) |
| { |
| PetscErrorCode ierr; |
| QEP_LINEAR *ctx; |
| PetscScalar *pd; |
| PetscInt m; |
| PetscFunctionBegin; |
| ierr = MatShellGetContext(A,(void**)&ctx);CHKERRQ(ierr); |
| ierr = MatGetLocalSize(ctx->M,&m,PETSC_NULL);CHKERRQ(ierr); |
| ierr = VecGetArray(diag,&pd);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->x1,pd);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->x2,pd+m);CHKERRQ(ierr); |
| ierr = VecSet(ctx->x1,0.0);CHKERRQ(ierr); |
| ierr = MatGetDiagonal(ctx->C,ctx->x2);CHKERRQ(ierr); |
| ierr = VecScale(ctx->x2,-ctx->sfactor);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->x1);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->x2);CHKERRQ(ierr); |
| ierr = VecRestoreArray(diag,&pd);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "MatGetDiagonal_Linear_N1B" |
| PetscErrorCode MatGetDiagonal_Linear_N1B(Mat B,Vec diag) |
| { |
| PetscErrorCode ierr; |
| QEP_LINEAR *ctx; |
| PetscScalar *pd; |
| PetscInt m; |
| PetscFunctionBegin; |
| ierr = MatShellGetContext(B,(void**)&ctx);CHKERRQ(ierr); |
| ierr = MatGetLocalSize(ctx->M,&m,PETSC_NULL);CHKERRQ(ierr); |
| ierr = VecGetArray(diag,&pd);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->x1,pd);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->x2,pd+m);CHKERRQ(ierr); |
| ierr = VecSet(ctx->x1,1.0);CHKERRQ(ierr); |
| ierr = MatGetDiagonal(ctx->M,ctx->x2);CHKERRQ(ierr); |
| ierr = VecScale(ctx->x2,ctx->sfactor*ctx->sfactor);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->x1);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->x2);CHKERRQ(ierr); |
| ierr = VecRestoreArray(diag,&pd);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "MatCreateExplicit_Linear_N1A" |
| PetscErrorCode MatCreateExplicit_Linear_N1A(MPI_Comm comm,QEP_LINEAR *ctx,Mat *A) |
| { |
| PetscErrorCode ierr; |
| PetscInt M,N,m,n; |
| Mat Id; |
| PetscFunctionBegin; |
| ierr = MatGetSize(ctx->M,&M,&N);CHKERRQ(ierr); |
| ierr = MatGetLocalSize(ctx->M,&m,&n);CHKERRQ(ierr); |
| ierr = MatCreate(((PetscObject)ctx->M)->comm,&Id);CHKERRQ(ierr); |
| ierr = MatSetSizes(Id,m,n,M,N);CHKERRQ(ierr); |
| ierr = MatSetFromOptions(Id);CHKERRQ(ierr); |
| ierr = MatAssemblyBegin(Id,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); |
| ierr = MatAssemblyEnd(Id,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); |
| ierr = MatShift(Id,1.0);CHKERRQ(ierr); |
| ierr = SlepcMatTile(0.0,Id,1.0,Id,-1.0,ctx->K,-ctx->sfactor,ctx->C,A);CHKERRQ(ierr); |
| ierr = MatDestroy(&Id);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "MatCreateExplicit_Linear_N1B" |
| PetscErrorCode MatCreateExplicit_Linear_N1B(MPI_Comm comm,QEP_LINEAR *ctx,Mat *B) |
| { |
| PetscErrorCode ierr; |
| PetscInt M,N,m,n; |
| Mat Id; |
| PetscFunctionBegin; |
| ierr = MatGetSize(ctx->M,&M,&N);CHKERRQ(ierr); |
| ierr = MatGetLocalSize(ctx->M,&m,&n);CHKERRQ(ierr); |
| ierr = MatCreate(((PetscObject)ctx->M)->comm,&Id);CHKERRQ(ierr); |
| ierr = MatSetSizes(Id,m,n,M,N);CHKERRQ(ierr); |
| ierr = MatSetFromOptions(Id);CHKERRQ(ierr); |
| ierr = MatAssemblyBegin(Id,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); |
| ierr = MatAssemblyEnd(Id,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); |
| ierr = MatShift(Id,1.0);CHKERRQ(ierr); |
| ierr = SlepcMatTile(1.0,Id,0.0,Id,0.0,Id,ctx->sfactor*ctx->sfactor,ctx->M,B);CHKERRQ(ierr); |
| ierr = MatDestroy(&Id);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| /* |
| Linearization for general QEP, companion form 2. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| SLEPc - Scalable Library for Eigenvalue Problem Computations |
| Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain |
| This file is part of SLEPc. |
| SLEPc is free software: you can redistribute it and/or modify it under the |
| terms of version 3 of the GNU Lesser General Public License as published by |
| the Free Software Foundation. |
| SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY |
| WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| more details. |
| You should have received a copy of the GNU Lesser General Public License |
| along with SLEPc. If not, see <http://www.gnu.org/licenses/>. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| */ |
| #include <private/qepimpl.h> /*I "slepcqep.h" I*/ |
| #include "linearp.h" |
| /* |
| Given the quadratic problem (l^2*M + l*C + K)*x = 0 the following |
| linearization is employed: |
| A*z = l*B*z where A = [ -K 0 ] B = [ C M ] z = [ x ] |
| [ 0 I ] [ I 0 ] [ l*x ] |
| */ |
| #undef __FUNCT__ |
| #define __FUNCT__ "MatMult_Linear_N2A" |
| PetscErrorCode MatMult_Linear_N2A(Mat A,Vec x,Vec y) |
| { |
| PetscErrorCode ierr; |
| QEP_LINEAR *ctx; |
| const PetscScalar *px; |
| PetscScalar *py; |
| PetscInt m; |
| PetscFunctionBegin; |
| ierr = MatShellGetContext(A,(void**)&ctx);CHKERRQ(ierr); |
| ierr = MatGetLocalSize(ctx->M,&m,PETSC_NULL);CHKERRQ(ierr); |
| ierr = VecGetArrayRead(x,&px);CHKERRQ(ierr); |
| ierr = VecGetArray(y,&py);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->x1,px);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->x2,px+m);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->y1,py);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->y2,py+m);CHKERRQ(ierr); |
| /* y1 = -K*x1 */ |
| ierr = MatMult(ctx->K,ctx->x1,ctx->y1);CHKERRQ(ierr); |
| ierr = VecScale(ctx->y1,-1.0);CHKERRQ(ierr); |
| /* y2 = x2 */ |
| ierr = VecCopy(ctx->x2,ctx->y2);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->x1);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->x2);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->y1);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->y2);CHKERRQ(ierr); |
| ierr = VecRestoreArrayRead(x,&px);CHKERRQ(ierr); |
| ierr = VecRestoreArray(y,&py);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "MatMult_Linear_N2B" |
| PetscErrorCode MatMult_Linear_N2B(Mat B,Vec x,Vec y) |
| { |
| PetscErrorCode ierr; |
| QEP_LINEAR *ctx; |
| const PetscScalar *px; |
| PetscScalar *py; |
| PetscInt m; |
| PetscFunctionBegin; |
| ierr = MatShellGetContext(B,(void**)&ctx);CHKERRQ(ierr); |
| ierr = MatGetLocalSize(ctx->M,&m,PETSC_NULL);CHKERRQ(ierr); |
| ierr = VecGetArrayRead(x,&px);CHKERRQ(ierr); |
| ierr = VecGetArray(y,&py);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->x1,px);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->x2,px+m);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->y1,py);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->y2,py+m);CHKERRQ(ierr); |
| /* y1 = C*x1 + M*x2 */ |
| ierr = MatMult(ctx->C,ctx->x1,ctx->y1);CHKERRQ(ierr); |
| ierr = VecScale(ctx->y1,ctx->sfactor);CHKERRQ(ierr); |
| ierr = MatMult(ctx->M,ctx->x2,ctx->y2);CHKERRQ(ierr); |
| ierr = VecAXPY(ctx->y1,ctx->sfactor*ctx->sfactor,ctx->y2);CHKERRQ(ierr); |
| /* y2 = x1 */ |
| ierr = VecCopy(ctx->x1,ctx->y2);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->x1);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->x2);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->y1);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->y2);CHKERRQ(ierr); |
| ierr = VecRestoreArrayRead(x,&px);CHKERRQ(ierr); |
| ierr = VecRestoreArray(y,&py);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |
| #undef __FUNCT__ |
| #define __FUNCT__ "MatGetDiagonal_Linear_N2A" |
| PetscErrorCode MatGetDiagonal_Linear_N2A(Mat A,Vec diag) |
| { |
| PetscErrorCode ierr; |
| QEP_LINEAR *ctx; |
| PetscScalar *pd; |
| PetscInt m; |
| PetscFunctionBegin; |
| ierr = MatShellGetContext(A,(void**)&ctx);CHKERRQ(ierr); |
| ierr = MatGetLocalSize(ctx->M,&m,PETSC_NULL);CHKERRQ(ierr); |
| ierr = VecGetArray(diag,&pd);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->x1,pd);CHKERRQ(ierr); |
| ierr = VecPlaceArray(ctx->x2,pd+m);CHKERRQ(ierr); |
| ierr = MatGetDiagonal(ctx->K,ctx->x1);CHKERRQ(ierr); |
| ierr = VecScale(ctx->x1,-1.0);CHKERRQ(ierr); |
| ierr = VecSet(ctx->x2,1.0);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->x1);CHKERRQ(ierr); |
| ierr = VecResetArray(ctx->x2);CHKERRQ(ierr); |
| ierr = VecRestoreArray(diag,&pd);CHKERRQ(ierr); |
| PetscFunctionReturn(0); |
| } |