116 if (
U_ !=0) {
delete[]
U_;
U_ = 0;}
117 if (
S_ !=0) {
delete[]
S_;
S_ = 0;}
159 if(
U_ ) {
delete []
U_;
U_ = 0; }
160 if(
S_ ) {
delete []
S_;
S_ = 0; }
229 for(
int i = 0; i <
M_; ++i )
S_[i]=0.0;
230 for(
int i = 0; i <
M_*
N_; ++i )
243 double *work =
new double[lwork];
248 GESVD( job, job,
M_,
N_, tempMat.
A(),
LDA_,
S_,
U_,
N_,
Vt_,
M_, work, &lwork, &
INFO_ );
292 double DNRHS =
NRHS_;
297 GEMM(
TRANS_,
'N',
N_,
NRHS_,
N_, 1.0,
AI_,
LDAI_,
B_,
LDB_, 0.0,
X_,
LDX_);
485 double thresh =
S_[0]*rthresh + athresh;
486 int num_replaced = 0;
487 for(
int i = 0; i <
M_; ++i )
498 for(
int i = 0; i <
N_; ++i )
501 if(
S_[i] ) scale = 1./
S_[i];
502 for(
int j = 0; j <
M_; ++j ) *p++ *= scale;
522 GEMM(
'T',
'T',
M_,
M_,
M_, 1.0,
Vt_,
M_,
U_,
M_, 0.0,
AI_,
M_ );
530 return(num_replaced);
564 if (
S_!=0)
for(
int i = 0; i <
M_; ++i ) std::cout <<
"(" << i <<
"," <<
S_[i] <<
")\n";
#define EPETRA_CHK_ERR(a)
Epetra_BLAS: The Epetra BLAS Wrapper Class.
void GEMM(const char TRANSA, const char TRANSB, const int M, const int N, const int K, const float ALPHA, const float *A, const int LDA, const float *B, const int LDB, const float BETA, float *C, const int LDC) const
Epetra_BLAS matrix-matrix multiply function (SGEMM)
Epetra_CompObject: Functionality and data that is common to all computational classes.
void UpdateFlops(int Flops_in) const
Increment Flop count for this object.
Epetra_LAPACK: The Epetra LAPACK Wrapper Class.
void GESVD(const char JOBU, const char JOBVT, const int M, const int N, float *A, const int LDA, float *S, float *U, const int LDU, float *VT, const int LDVT, float *WORK, const int *LWORK, int *INFO) const
Epetra_LAPACK wrapper for computing the singular value decomposition (SGESVD)
Epetra_Object: The base Epetra class.
Epetra_SerialDenseMatrix: A class for constructing and using real double precision general dense matr...
double * A() const
Returns pointer to the this matrix.
int LDA() const
Returns the leading dimension of the this matrix.
virtual double OneNorm() const
Computes the 1-Norm of the this matrix (identical to NormOne() method).
int Shape(int NumRows, int NumCols)
Set dimensions of a Epetra_SerialDenseMatrix object; init values to zero.
int M() const
Returns row dimension of system.
int N() const
Returns column dimension of system.
Epetra_SerialDenseMatrix * RHS_
Epetra_SerialDenseMatrix * Inverse_
Epetra_SerialDenseMatrix * Matrix_
virtual int Solve(void)
Computes the solution X to AX = B for the this matrix and the B provided to SetVectors()....
int SetVectors(Epetra_SerialDenseMatrix &X, Epetra_SerialDenseMatrix &B)
Sets the pointers for left and right hand side vector(s).
virtual int Invert(double rthresh=0.0, double athresh=0.0)
Inverts the this matrix.
virtual ~Epetra_SerialDenseSVD()
Epetra_SerialDenseSVD destructor.
Epetra_SerialDenseMatrix * LHS_
int SetMatrix(Epetra_SerialDenseMatrix &A)
Sets the pointers for coefficient matrix.
bool Inverted()
Returns true if matrix inverse has been computed (inverse available via AF() and LDAF()).
Epetra_SerialDenseSVD()
Default constructor; matrix should be set using SetMatrix(), LHS and RHS set with SetVectors().
virtual void Print(std::ostream &os) const
Print service methods; defines behavior of ostream << operator.
bool Factored()
Returns true if matrix is factored (factor available via AF() and LDAF()).