Epetra_SerialDenseMatrix: A class for constructing and using real double precision general dense matrices. More...
#include <Epetra_SerialDenseMatrix.h>
Public Member Functions | |
Constructor/Destructor Methods | |
Epetra_SerialDenseMatrix (bool set_object_label=true) | |
Default constructor; defines a zero size object. More... | |
Epetra_SerialDenseMatrix (int NumRows, int NumCols, bool set_object_label=true) | |
Shaped constructor; defines a variable-sized object. More... | |
Epetra_SerialDenseMatrix (Epetra_DataAccess CV, double *A_in, int LDA_in, int NumRows, int NumCols, bool set_object_label=true) | |
Set object values from two-dimensional array. More... | |
Epetra_SerialDenseMatrix (const Epetra_SerialDenseMatrix &Source) | |
Epetra_SerialDenseMatrix copy constructor. | |
virtual | ~Epetra_SerialDenseMatrix () |
Epetra_SerialDenseMatrix destructor. | |
Shaping/sizing Methods | |
int | Shape (int NumRows, int NumCols) |
Set dimensions of a Epetra_SerialDenseMatrix object; init values to zero. More... | |
int | Reshape (int NumRows, int NumCols) |
Reshape a Epetra_SerialDenseMatrix object. More... | |
Mathematical methods | |
int | Multiply (char TransA, char TransB, double ScalarAB, const Epetra_SerialDenseMatrix &A, const Epetra_SerialDenseMatrix &B, double ScalarThis) |
Matrix-Matrix multiplication, this = ScalarThis*this + ScalarAB*A*B. More... | |
int | Multiply (bool transA, const Epetra_SerialDenseMatrix &x, Epetra_SerialDenseMatrix &y) |
Matrix-Vector multiplication, y = A*x, where 'this' == A. | |
int | Multiply (char SideA, double ScalarAB, const Epetra_SerialSymDenseMatrix &A, const Epetra_SerialDenseMatrix &B, double ScalarThis) |
Matrix-Matrix multiplication with a symmetric matrix A. More... | |
int | Scale (double ScalarA) |
Inplace scalar-matrix product A = a A. More... | |
virtual double | NormOne () const |
Computes the 1-Norm of the this matrix. More... | |
virtual double | NormInf () const |
Computes the Infinity-Norm of the this matrix. | |
Data Accessor methods | |
Epetra_SerialDenseMatrix & | operator= (const Epetra_SerialDenseMatrix &Source) |
Value copy from one matrix to another. More... | |
bool | operator== (const Epetra_SerialDenseMatrix &rhs) const |
Comparison operator. More... | |
bool | operator!= (const Epetra_SerialDenseMatrix &rhs) const |
Inequality operator. More... | |
Epetra_SerialDenseMatrix & | operator+= (const Epetra_SerialDenseMatrix &Source) |
Add one matrix to another. More... | |
double & | operator() (int RowIndex, int ColIndex) |
Element access function. More... | |
const double & | operator() (int RowIndex, int ColIndex) const |
Element access function. More... | |
double * | operator[] (int ColIndex) |
Column access function. More... | |
const double * | operator[] (int ColIndex) const |
Column access function. More... | |
int | Random () |
Set matrix values to random numbers. More... | |
int | M () const |
Returns row dimension of system. | |
int | N () const |
Returns column dimension of system. | |
double * | A () const |
Returns pointer to the this matrix. | |
double * | A () |
Returns pointer to the this matrix. | |
int | LDA () const |
Returns the leading dimension of the this matrix. | |
Epetra_DataAccess | CV () const |
Returns the data access mode of the this matrix. | |
I/O methods | |
virtual void | Print (std::ostream &os) const |
Print service methods; defines behavior of ostream << operator. | |
Deprecated methods (will be removed in later versions of this class) | |
virtual double | OneNorm () const |
Computes the 1-Norm of the this matrix (identical to NormOne() method). More... | |
virtual double | InfNorm () const |
Computes the Infinity-Norm of the this matrix (identical to NormInf() method). | |
Additional methods to support Epetra_SerialDenseOperator interface | |
virtual int | SetUseTranspose (bool UseTranspose_in) |
If set true, transpose of this operator will be applied. More... | |
virtual int | Apply (const Epetra_SerialDenseMatrix &X, Epetra_SerialDenseMatrix &Y) |
Returns the result of a Epetra_SerialDenseOperator applied to a Epetra_SerialDenseMatrix X in Y. More... | |
virtual int | ApplyInverse (const Epetra_SerialDenseMatrix &X, Epetra_SerialDenseMatrix &Y) |
Returns the result of a Epetra_SerialDenseOperator inverse applied to an Epetra_SerialDenseMatrix X in Y. More... | |
virtual const char * | Label () const |
Returns a character string describing the operator. | |
virtual bool | UseTranspose () const |
Returns the current UseTranspose setting. | |
virtual bool | HasNormInf () const |
Returns true if the this object can provide an approximate Inf-norm, false otherwise. | |
virtual int | RowDim () const |
Returns the row dimension of operator. | |
virtual int | ColDim () const |
Returns the column dimension of operator. | |
Public Member Functions inherited from Epetra_CompObject | |
Epetra_CompObject & | operator= (const Epetra_CompObject &src) |
Epetra_CompObject () | |
Basic Epetra_CompObject constuctor. | |
Epetra_CompObject (const Epetra_CompObject &Source) | |
Epetra_CompObject copy constructor. | |
virtual | ~Epetra_CompObject () |
Epetra_CompObject destructor. | |
void | SetFlopCounter (const Epetra_Flops &FlopCounter_in) |
Set the internal Epetra_Flops() pointer. | |
void | SetFlopCounter (const Epetra_CompObject &CompObject) |
Set the internal Epetra_Flops() pointer to the flop counter of another Epetra_CompObject. | |
void | UnsetFlopCounter () |
Set the internal Epetra_Flops() pointer to 0 (no flops counted). | |
Epetra_Flops * | GetFlopCounter () const |
Get the pointer to the Epetra_Flops() object associated with this object, returns 0 if none. | |
void | ResetFlops () const |
Resets the number of floating point operations to zero for this multi-vector. | |
double | Flops () const |
Returns the number of floating point operations with this multi-vector. | |
void | UpdateFlops (int Flops_in) const |
Increment Flop count for this object. | |
void | UpdateFlops (long int Flops_in) const |
Increment Flop count for this object. | |
void | UpdateFlops (long long Flops_in) const |
Increment Flop count for this object. | |
void | UpdateFlops (double Flops_in) const |
Increment Flop count for this object. | |
void | UpdateFlops (float Flops_in) const |
Increment Flop count for this object. | |
Public Member Functions inherited from Epetra_Object | |
Epetra_Object (int TracebackModeIn=-1, bool set_label=true) | |
Epetra_Object Constructor. More... | |
Epetra_Object (const char *const Label, int TracebackModeIn=-1) | |
Epetra_Object Constructor. More... | |
Epetra_Object (const Epetra_Object &Object) | |
Epetra_Object Copy Constructor. More... | |
virtual | ~Epetra_Object () |
Epetra_Object Destructor. More... | |
virtual int | ReportError (const std::string Message, int ErrorCode) const |
Error reporting method. | |
virtual void | SetLabel (const char *const Label) |
Epetra_Object Label definition using char *. More... | |
Public Member Functions inherited from Epetra_SerialDenseOperator | |
virtual | ~Epetra_SerialDenseOperator () |
Destructor. | |
Public Member Functions inherited from Epetra_BLAS | |
Epetra_BLAS (void) | |
Epetra_BLAS Constructor. More... | |
Epetra_BLAS (const Epetra_BLAS &BLAS) | |
Epetra_BLAS Copy Constructor. More... | |
virtual | ~Epetra_BLAS (void) |
Epetra_BLAS Destructor. | |
float | ASUM (const int N, const float *X, const int INCX=1) const |
Epetra_BLAS one norm function (SASUM). | |
double | ASUM (const int N, const double *X, const int INCX=1) const |
Epetra_BLAS one norm function (DASUM). | |
float | DOT (const int N, const float *X, const float *Y, const int INCX=1, const int INCY=1) const |
Epetra_BLAS dot product function (SDOT). | |
double | DOT (const int N, const double *X, const double *Y, const int INCX=1, const int INCY=1) const |
Epetra_BLAS dot product function (DDOT). | |
float | NRM2 (const int N, const float *X, const int INCX=1) const |
Epetra_BLAS norm function (SNRM2). | |
double | NRM2 (const int N, const double *X, const int INCX=1) const |
Epetra_BLAS norm function (DNRM2). | |
void | SCAL (const int N, const float ALPHA, float *X, const int INCX=1) const |
Epetra_BLAS vector scale function (SSCAL) | |
void | SCAL (const int N, const double ALPHA, double *X, const int INCX=1) const |
Epetra_BLAS vector scale function (DSCAL) | |
void | COPY (const int N, const float *X, float *Y, const int INCX=1, const int INCY=1) const |
Epetra_BLAS vector copy function (SCOPY) | |
void | COPY (const int N, const double *X, double *Y, const int INCX=1, const int INCY=1) const |
Epetra_BLAS vector scale function (DCOPY) | |
int | IAMAX (const int N, const float *X, const int INCX=1) const |
Epetra_BLAS arg maximum of absolute value function (ISAMAX) | |
int | IAMAX (const int N, const double *X, const int INCX=1) const |
Epetra_BLAS arg maximum of absolute value function (IDAMAX) | |
void | AXPY (const int N, const float ALPHA, const float *X, float *Y, const int INCX=1, const int INCY=1) const |
Epetra_BLAS vector update function (SAXPY) | |
void | AXPY (const int N, const double ALPHA, const double *X, double *Y, const int INCX=1, const int INCY=1) const |
Epetra_BLAS vector update function (DAXPY) | |
void | GEMV (const char TRANS, const int M, const int N, const float ALPHA, const float *A, const int LDA, const float *X, const float BETA, float *Y, const int INCX=1, const int INCY=1) const |
Epetra_BLAS matrix-vector multiply function (SGEMV) | |
void | GEMV (const char TRANS, const int M, const int N, const double ALPHA, const double *A, const int LDA, const double *X, const double BETA, double *Y, const int INCX=1, const int INCY=1) const |
Epetra_BLAS matrix-vector multiply function (DGEMV) | |
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) | |
void | GEMM (const char TRANSA, const char TRANSB, const int M, const int N, const int K, const double ALPHA, const double *A, const int LDA, const double *B, const int LDB, const double BETA, double *C, const int LDC) const |
Epetra_BLAS matrix-matrix multiply function (DGEMM) | |
void | SYMM (const char SIDE, const char UPLO, const int M, const int N, 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 symmetric matrix-matrix multiply function (SSYMM) | |
void | SYMM (const char SIDE, const char UPLO, const int M, const int N, const double ALPHA, const double *A, const int LDA, const double *B, const int LDB, const double BETA, double *C, const int LDC) const |
Epetra_BLAS matrix-matrix multiply function (DSYMM) | |
void | TRMM (const char SIDE, const char UPLO, const char TRANSA, const char DIAG, const int M, const int N, const float ALPHA, const float *A, const int LDA, float *B, const int LDB) const |
Epetra_BLAS triangular matrix-matrix multiply function (STRMM) | |
void | TRMM (const char SIDE, const char UPLO, const char TRANSA, const char DIAG, const int M, const int N, const double ALPHA, const double *A, const int LDA, double *B, const int LDB) const |
Epetra_BLAS triangular matrix-matrix multiply function (DTRMM) | |
void | SYRK (const char UPLO, const char TRANS, const int N, const int K, const float ALPHA, const float *A, const int LDA, const float BETA, float *C, const int LDC) const |
Eperta_BLAS symetric rank k funtion (ssyrk) | |
void | SYRK (const char UPLO, const char TRANS, const int N, const int K, const double ALPHA, const double *A, const int LDA, const double BETA, double *C, const int LDC) const |
Eperta_BLAS symetric rank k funtion (dsyrk) | |
Protected Member Functions | |
void | CopyMat (const double *Source, int Source_LDA, int NumRows, int NumCols, double *Target, int Target_LDA, bool add=false) |
void | CleanupData () |
Protected Member Functions inherited from Epetra_Object | |
std::string | toString (const int &x) const |
std::string | toString (const long long &x) const |
std::string | toString (const double &x) const |
Protected Attributes | |
int | M_ |
int | N_ |
bool | A_Copied_ |
Epetra_DataAccess | CV_ |
int | LDA_ |
double * | A_ |
bool | UseTranspose_ |
Protected Attributes inherited from Epetra_CompObject | |
Epetra_Flops * | FlopCounter_ |
Friends | |
class | Epetra_VbrMatrix |
Additional Inherited Members | |
Static Public Member Functions inherited from Epetra_Object | |
static void | SetTracebackMode (int TracebackModeValue) |
Set the value of the Epetra_Object error traceback report mode. More... | |
static int | GetTracebackMode () |
Get the value of the Epetra_Object error report mode. | |
static std::ostream & | GetTracebackStream () |
Get the output stream for error reporting. | |
Static Public Attributes inherited from Epetra_Object | |
static int | TracebackMode |
Epetra_SerialDenseMatrix: A class for constructing and using real double precision general dense matrices.
The Epetra_SerialDenseMatrix class enables the construction and use of real-valued, general, double-precision dense matrices. It is built on the BLAS, and derives from the Epetra_BLAS.
The Epetra_SerialDenseMatrix class is intended to provide very basic support for dense rectangular matrices.
Constructing Epetra_SerialDenseMatrix Objects
There are four Epetra_SerialDenseMatrix constructors. The first constructs a zero-sized object which should be made to appropriate length using the Shape() or Reshape() functions and then filled with the [] or () operators. The second constructs an object sized to the dimensions specified, which should be filled with the [] or () operators. The third is a constructor that accepts user data as a 2D array, and the fourth is a copy constructor. The third constructor has two data access modes (specified by the Epetra_DataAccess argument):
Extracting Data from Epetra_SerialDenseMatrix Objects
Once a Epetra_SerialDenseMatrix is constructed, it is possible to view the data via access functions.
Vector and Utility Functions
Once a Epetra_SerialDenseMatrix is constructed, several mathematical functions can be applied to the object. Specifically:
Counting floating point operations The Epetra_SerialDenseMatrix class has Epetra_CompObject as a base class. Thus, floating point operations are counted and accumulated in the Epetra_Flop object (if any) that was set using the SetFlopCounter() method in the Epetra_CompObject base class.
Epetra_SerialDenseMatrix::Epetra_SerialDenseMatrix | ( | bool | set_object_label = true | ) |
Default constructor; defines a zero size object.
Epetra_SerialDenseMatrix objects defined by the default constructor should be sized with the Shape() or Reshape functions. Values should be defined by using the [] or () operators.
Epetra_SerialDenseMatrix::Epetra_SerialDenseMatrix | ( | int | NumRows, |
int | NumCols, | ||
bool | set_object_label = true |
||
) |
Shaped constructor; defines a variable-sized object.
In | NumRows - Number of rows in object. |
In | NumCols - Number of columns in object. |
Epetra_SerialDenseMatrix objects defined by the shaped constructor are already shaped to the dimensions given as a parameters. All values are initialized to 0. Calling this constructor is equivalent to using the default constructor, and then calling the Shape function on it. Values should be defined by using the [] or () operators.
Epetra_SerialDenseMatrix::Epetra_SerialDenseMatrix | ( | Epetra_DataAccess | CV, |
double * | A_in, | ||
int | LDA_in, | ||
int | NumRows, | ||
int | NumCols, | ||
bool | set_object_label = true |
||
) |
Set object values from two-dimensional array.
In | Epetra_DataAccess - Enumerated type set to Copy or View. |
In | A - Pointer to an array of double precision numbers. The first vector starts at A. The second vector starts at A+LDA, the third at A+2*LDA, and so on. |
In | LDA - The "Leading Dimension", or stride between vectors in memory. |
In | NumRows - Number of rows in object. |
In | NumCols - Number of columns in object. |
See Detailed Description section for further discussion.
|
virtual |
Returns the result of a Epetra_SerialDenseOperator applied to a Epetra_SerialDenseMatrix X in Y.
In | X - A Epetra_SerialDenseMatrix to multiply with operator. |
Out | Y -A Epetra_SerialDenseMatrix containing result. |
Implements Epetra_SerialDenseOperator.
|
inlinevirtual |
Returns the result of a Epetra_SerialDenseOperator inverse applied to an Epetra_SerialDenseMatrix X in Y.
In | X - A Epetra_SerialDenseMatrix to solve for. |
Out | Y -A Epetra_SerialDenseMatrix containing result. |
Implements Epetra_SerialDenseOperator.
int Epetra_SerialDenseMatrix::Multiply | ( | char | TransA, |
char | TransB, | ||
double | ScalarAB, | ||
const Epetra_SerialDenseMatrix & | A, | ||
const Epetra_SerialDenseMatrix & | B, | ||
double | ScalarThis | ||
) |
Matrix-Matrix multiplication, this = ScalarThis*this + ScalarAB*A*B.
This function performs a variety of matrix-matrix multiply operations.
In | TransA - Operate with the transpose of A if = 'T', else no transpose if = 'N'. |
In | TransB - Operate with the transpose of B if = 'T', else no transpose if = 'N'. |
In | ScalarAB - Scalar to multiply with A*B. |
In | A - Dense Matrix. |
In | B - Dense Matrix. |
In | ScalarThis - Scalar to multiply with this. |
Referenced by Epetra_SerialDenseSVD::Apply().
int Epetra_SerialDenseMatrix::Multiply | ( | char | SideA, |
double | ScalarAB, | ||
const Epetra_SerialSymDenseMatrix & | A, | ||
const Epetra_SerialDenseMatrix & | B, | ||
double | ScalarThis | ||
) |
Matrix-Matrix multiplication with a symmetric matrix A.
If SideA = 'L', compute \e this = ScalarThis*\e this + ScalarAB*A*B. If SideA = 'R', compute \e this = ScalarThis*\e this + ScalarAB*B*A.
This function performs a variety of matrix-matrix multiply operations.
In | SideA - Specifies order of A relative to B. |
In | ScalarAB - Scalar to multiply with A*B. |
In | A - Symmetric Dense Matrix, either upper or lower triangle will be used depending on value of A.Upper(). |
In | B - Dense Matrix. |
In | ScalarThis - Scalar to multiply with this. |
|
virtual |
Computes the 1-Norm of the this matrix.
Reimplemented in Epetra_SerialSymDenseMatrix.
|
inlinevirtual |
Computes the 1-Norm of the this matrix (identical to NormOne() method).
Reimplemented in Epetra_SerialSymDenseMatrix.
|
inline |
Inequality operator.
operator!= simply returns the negation of operator==.
|
inline |
Element access function.
The parentheses operator returns the element in the ith row and jth column if A(i,j) is specified, the expression A[j][i] (note that i and j are reversed) will return the same element. Thus, A(i,j) = A[j][i] for all valid i and j.
\warning No bounds checking is done unless Epetra is compiled with HAVE_EPETRA_ARRAY_BOUNDS_CHECK.
References Epetra_Object::ReportError().
|
inline |
Element access function.
The parentheses operator returns the element in the ith row and jth column if A(i,j) is specified, the expression A[j][i] (note that i and j are reversed) will return the same element. Thus, A(i,j) = A[j][i] for all valid i and j.
\warning No bounds checking is done unless Epetra is compiled with HAVE_EPETRA_ARRAY_BOUNDS_CHECK.
References Epetra_Object::ReportError().
Epetra_SerialDenseMatrix& Epetra_SerialDenseMatrix::operator+= | ( | const Epetra_SerialDenseMatrix & | Source | ) |
Add one matrix to another.
The operator+= allows one to add the values from one existin SerialDenseMatrix to another, as long as there is enough room in the target to hold the source.
Epetra_SerialDenseMatrix& Epetra_SerialDenseMatrix::operator= | ( | const Epetra_SerialDenseMatrix & | Source | ) |
Value copy from one matrix to another.
The operator= allows one to copy the values from one existing SerialDenseMatrix to another, as long as there is enough room in the target to hold the source.
bool Epetra_SerialDenseMatrix::operator== | ( | const Epetra_SerialDenseMatrix & | rhs | ) | const |
Comparison operator.
operator== compares two Epetra_SerialDenseMatrix objects, returns false if sizes are different, or if any coefficients differ by an amount greater than Epetra_MinDouble.
|
inline |
Column access function.
The parentheses operator returns the element in the ith row and jth column if A(i,j) is specified, the expression A[j][i] (note that i and j are reversed) will return the same element. Thus, A(i,j) = A[j][i] for all valid i and j.
References Epetra_Object::ReportError().
|
inline |
Column access function.
The parentheses operator returns the element in the ith row and jth column if A(i,j) is specified, the expression A[j][i] (note that i and j are reversed) will return the same element. Thus, A(i,j) = A[j][i] for all valid i and j.
References Epetra_Object::ReportError().
int Epetra_SerialDenseMatrix::Random | ( | ) |
Set matrix values to random numbers.
SerialDenseMatrix uses the random number generator provided by Epetra_Util. The matrix values will be set to random values on the interval (-1.0, 1.0).
int Epetra_SerialDenseMatrix::Reshape | ( | int | NumRows, |
int | NumCols | ||
) |
Reshape a Epetra_SerialDenseMatrix object.
In | NumRows - Number of rows in object. |
In | NumCols - Number of columns in object. |
Allows user to define the dimensions of a Epetra_SerialDenseMatrix at any point. This function can be called at any point after construction. Any values that were previously in this object are copied into the new shape. If the new shape is smaller than the original, the upper left portion of the original matrix (the principal submatrix) is copied to the new matrix.
Referenced by Epetra_SerialSymDenseMatrix::Reshape(), and Epetra_SerialDenseVector::Resize().
int Epetra_SerialDenseMatrix::Scale | ( | double | ScalarA | ) |
Inplace scalar-matrix product A = a A.
Scale a matrix, entry-by-entry using the value ScalarA.
ScalarA | (In) Scalar to multiply with A. |
|
inlinevirtual |
If set true, transpose of this operator will be applied.
This flag allows the transpose of the given operator to be used implicitly. Setting this flag affects only the Apply() and ApplyInverse() methods. If the implementation of this interface does not support transpose use, this method should return a value of -1.
In | UseTranspose -If true, multiply by the transpose of operator, otherwise just use operator. |
Implements Epetra_SerialDenseOperator.
int Epetra_SerialDenseMatrix::Shape | ( | int | NumRows, |
int | NumCols | ||
) |
Set dimensions of a Epetra_SerialDenseMatrix object; init values to zero.
In | NumRows - Number of rows in object. |
In | NumCols - Number of columns in object. |
Allows user to define the dimensions of a Epetra_SerialDenseMatrix at any point. This function can be called at any point after construction. Any values that were previously in this object are destroyed and the resized matrix starts off with all zero values.
Referenced by Epetra_SerialSymDenseMatrix::Shape(), and Epetra_SerialDenseVector::Size().