void diagonalShift(double lambda);
void zeroEntries();//sets the matrix coefficients to zero
- std::vector< double > getEigenvalues( int nev, EPSWhich which=EPS_SMALLEST_MAGNITUDE, double tol=1e-6) const;
- std::vector< Vector > getEigenvectors(int nev, EPSWhich which=EPS_SMALLEST_MAGNITUDE, double tol=1e-6) const;
- MEDCoupling::DataArrayDouble * getEigenvectorsDataArrayDouble(int nev, EPSWhich which=EPS_SMALLEST_MAGNITUDE, double tol=1e-6) const;
- std::vector< double > getSingularValues( int nsv, SVDWhich which=SVD_SMALLEST, double tol=1e-6) const;
- std::vector< Vector > getSingularVectors(int nsv, SVDWhich which=SVD_SMALLEST, double tol=1e-6) const;
+ std::vector< double > getEigenvalues( int nev, EPSWhich which=EPS_SMALLEST_MAGNITUDE, double tol=1e-6, EPSType type = EPSKRYLOVSCHUR) const;
+ std::vector< Vector > getEigenvectors(int nev, EPSWhich which=EPS_SMALLEST_MAGNITUDE, double tol=1e-6, EPSType type = EPSKRYLOVSCHUR) const;
+ MEDCoupling::DataArrayDouble * getEigenvectorsDataArrayDouble(int nev, EPSWhich which=EPS_SMALLEST_MAGNITUDE, double tol=1e-6, EPSType type = EPSKRYLOVSCHUR) const;
+ std::vector< double > getSingularValues( int nsv, SVDWhich which=SVD_SMALLEST, double tol=1e-6, SVDType type = SVDCYCLIC) const;
+ std::vector< Vector > getSingularVectors(int nsv, SVDWhich which=SVD_SMALLEST, double tol=1e-6, SVDType type = SVDCYCLIC) const;
double getConditionNumber(bool isSingular=false, double tol=1e-6) const;
bool isSymmetric(double tol=1.e-6) const ;
int _numberOfNonZeros ;//The maximum number of nonzeros coefficients per line (or an upper bound)
- int computeSpectrum(int nev, double ** valP, double ***vecP, EPSWhich which=EPS_SMALLEST_MAGNITUDE, double tol=1e-6) const;
- int computeSVD (int nsv, double ** valS, double ***vecS, SVDWhich which=SVD_SMALLEST , double tol=1e-6) const;
+ int computeSpectrum(int nev, double ** valP, double ***vecP, EPSWhich which=EPS_SMALLEST_MAGNITUDE, double tol=1e-6, EPSType type = EPSKRYLOVSCHUR) const;
+ int computeSVD (int nsv, double ** valS, double ***vecS, SVDWhich which=SVD_SMALLEST , double tol=1e-6, SVDType type = SVDCYCLIC) const;
Vector vecToVector(const Vec& vec) const ;
Vec vectorToVec( const Vector& myVector ) const ;
}
int
-SparseMatrixPetsc::computeSpectrum(int nev, double ** valP, double ***vecP, EPSWhich which, double tol) const
+SparseMatrixPetsc::computeSpectrum(int nev, double ** valP, double ***vecP, EPSWhich which, double tol, EPSType type) const
{
EPS eps; /* eigenproblem solver context */
- EPSType type;
PetscReal error;
PetscScalar kr,ki;
Vec xr,xi;
EPSSetWhichEigenpairs(eps,which);
EPSSetDimensions(eps,nev,PETSC_DEFAULT,PETSC_DEFAULT);
EPSSetTolerances(eps,tol,PETSC_DEFAULT);
-
+ EPSSetType(eps,type);
/*
Set solver parameters at runtime
*/
}
int
-SparseMatrixPetsc::computeSVD(int nsv, double ** valS, double ***vecS, SVDWhich which, double tol) const
+SparseMatrixPetsc::computeSVD(int nsv, double ** valS, double ***vecS, SVDWhich which, double tol, SVDType type) const
{
SVD svd; /* Singular value decomposition solver context */
- SVDType type;
PetscReal error;
PetscScalar sigma;
Vec u,v;
SVDSetWhichSingularTriplets(svd,which);
SVDSetDimensions(svd,nsv,PETSC_DEFAULT,PETSC_DEFAULT);
+ SVDSetType(svd, type);
SVDSetTolerances(svd,tol,PETSC_DEFAULT);
/*
}
std::vector< double >
-SparseMatrixPetsc::getEigenvalues(int nev, EPSWhich which, double tol) const
+SparseMatrixPetsc::getEigenvalues(int nev, EPSWhich which, double tol, EPSType type) const
{
int nconv;
double * valP;
double **vecP;
- nconv=computeSpectrum(nev, &valP, &vecP, which, tol);
+ nconv=computeSpectrum(nev, &valP, &vecP, which, tol,type);
std::vector< double > result(nconv);
}
std::vector< Vector >
-SparseMatrixPetsc::getEigenvectors(int nev, EPSWhich which, double tol) const
+SparseMatrixPetsc::getEigenvectors(int nev, EPSWhich which, double tol, EPSType type) const
{
int nconv;
double * valP;
double **vecP;
- nconv=computeSpectrum(nev, &valP, &vecP, which, tol);
+ nconv=computeSpectrum(nev, &valP, &vecP, which, tol,type);
std::vector< Vector > result(nconv);
}
MEDCoupling::DataArrayDouble *
-SparseMatrixPetsc::getEigenvectorsDataArrayDouble(int nev, EPSWhich which, double tol) const
+SparseMatrixPetsc::getEigenvectorsDataArrayDouble(int nev, EPSWhich which, double tol, EPSType type) const
{
int nconv;
double * valP;
else
nsv=1 ;
- nconv=computeSVD(nsv, &valS, &vecS, SVD_SMALLEST, tol);
+ nconv=computeSVD(nsv, &valS, &vecS, SVD_SMALLEST, tol,SVDCYCLIC);
if(nconv<nsv)
throw CdmathException("SparseMatrixPetsc::getConditionNumber could not find the smallest singular value");
sigma_min=valS[nsv-1];
/*** Largest singular value ***/
nsv=1;
- nconv=computeSVD(nsv, &valS, &vecS, SVD_LARGEST, tol);
+ nconv=computeSVD(nsv, &valS, &vecS, SVD_LARGEST, tol,SVDCYCLIC);
if(nconv<nsv)
throw CdmathException("SparseMatrixPetsc::getConditionNumber could not find the largest singular value");
sigma_max=valS[nsv-1];
}
std::vector< double >
-SparseMatrixPetsc::getSingularValues(int nsv, SVDWhich which, double tol) const
+SparseMatrixPetsc::getSingularValues(int nsv, SVDWhich which, double tol, SVDType type) const
{
int nconv;
double * valS;
double **vecS;
- nconv=computeSVD(nsv, &valS, &vecS, which, tol);
+ nconv=computeSVD(nsv, &valS, &vecS, which, tol, type);
std::vector< double > result(nconv);
}
std::vector< Vector >
-SparseMatrixPetsc::getSingularVectors(int nsv, SVDWhich which, double tol) const
+SparseMatrixPetsc::getSingularVectors(int nsv, SVDWhich which, double tol, SVDType type) const
{
int nconv;
double * valS;
double **vecS;
- nconv=computeSVD(nsv, &valS, &vecS, which, tol);
+ nconv=computeSVD(nsv, &valS, &vecS, which, tol, type);
std::vector< Vector > result(2*nconv);