Teuchos::SerialDenseMatrix< OrdinalType, ScalarType > Class Template Reference

This class creates and provides basic support for dense rectangular matrix of templated type. More...

#include <Teuchos_SerialDenseMatrix.hpp>

Inheritance diagram for Teuchos::SerialDenseMatrix< OrdinalType, ScalarType >:

[legend]
Collaboration diagram for Teuchos::SerialDenseMatrix< OrdinalType, ScalarType >:
[legend]
List of all members.

Public Member Functions

Constructor/Destructor methods.
 SerialDenseMatrix ()
 Default Constructor.
 SerialDenseMatrix (int numRows, int numCols)
 Shaped Constructor.
 SerialDenseMatrix (DataAccess CV, ScalarType *values, int stride, int numRows, int numCols)
 Shaped Constructor with Values.
 SerialDenseMatrix (const SerialDenseMatrix< OrdinalType, ScalarType > &Source)
 Copy Constructor.
 SerialDenseMatrix (DataAccess CV, const SerialDenseMatrix< OrdinalType, ScalarType > &Source, int numRows, int numCols, int startRow=0, int startCol=0)
 Submatrix Copy Constructor.
virtual ~SerialDenseMatrix ()
 Destructor.
Shaping methods.
int shape (int numRows, int numCols)
 Shape method for changing the size of a SerialDenseMatrix, initializing entries to zero.
int reshape (int numRows, int numCols)
 Reshaping method for changing the size of a SerialDenseMatrix, keeping the entries.
Set methods.
SerialDenseMatrixoperator= (const SerialDenseMatrix &Source)
 Copies values from one matrix to another.
int putScalar (const ScalarType value=Teuchos::ScalarTraits< ScalarType >::zero())
 Set all values in the matrix to a constant value.
int random ()
 Set all values in the matrix to be random numbers.
Accessor methods.
ScalarType & operator() (int rowIndex, int colIndex)
 Element access method (non-const).
const ScalarType & operator() (int rowIndex, int colIndex) const
 Element access method (const).
ScalarType * operator[] (int colIndex)
 Column access method (non-const).
const ScalarType * operator[] (int colIndex) const
 Column access method (const).
ScalarType * values () const
 Data array access method.
Mathematical methods.
SerialDenseMatrixoperator+= (const SerialDenseMatrix &Source)
 Add another matrix to this matrix.
int scale (const ScalarType alpha)
 Scale this matrix; A = alpha*A.
int multiply (ETransp transa, ETransp transb, ScalarType alpha, const SerialDenseMatrix< OrdinalType, ScalarType > &A, const SerialDenseMatrix< OrdinalType, ScalarType > &B, ScalarType beta)
 Multiply A * B and add them to this; this = beta * this + alpha*A*B.
Comparison methods.
bool operator== (const SerialDenseMatrix< OrdinalType, ScalarType > &Operand)
 Equality of two matrices.
bool operator!= (const SerialDenseMatrix< OrdinalType, ScalarType > &Operand)
 Inequality of two matrices.
Attribute methods.
int numRows () const
 Returns the row dimension of this matrix.
int numCols () const
 Returns the column dimension of this matrix.
int stride () const
 Returns the stride between the columns of this matrix in memory.
Norm methods.
ScalarTraits< ScalarType
>::magnitudeType 
normOne () const
 Returns the 1-norm of the matrix.
ScalarTraits< ScalarType
>::magnitudeType 
normInf () const
 Returns the Infinity-norm of the matrix.
ScalarTraits< ScalarType
>::magnitudeType 
normFrobenius () const
 Returns the Frobenius-norm of the matrix.
I/O methods.
virtual void print (ostream &os) const
 Print method. Defines the behavior of the ostream << operator inherited from the Object class.

Protected Member Functions

void copyMat (ScalarType *inputMatrix, int strideInput, int numRows, int numCols, ScalarType *outputMatrix, int strideOutput, int startRow, int startCol, bool add)
void deleteArrays ()
void checkIndex (int rowIndex, int colIndex=0) const

Protected Attributes

int numRows_
int numCols_
int stride_
bool valuesCopied_
ScalarType * values_

Detailed Description

template<typename OrdinalType, typename ScalarType>
class Teuchos::SerialDenseMatrix< OrdinalType, ScalarType >

This class creates and provides basic support for dense rectangular matrix of templated type.
Examples:

DenseMatrix/cxx_main.cpp, and LAPACK/cxx_main.cpp.

Definition at line 72 of file Teuchos_SerialDenseMatrix.hpp.


Constructor & Destructor Documentation

template<typename OrdinalType, typename ScalarType>
Teuchos::SerialDenseMatrix< OrdinalType, ScalarType >::SerialDenseMatrix  ) 
 

Default Constructor.

Creates a empty matrix of no dimension. The Shaping methods should be used to size this matrix. Values of this matrix should be set using the [] or the () operators.

Definition at line 322 of file Teuchos_SerialDenseMatrix.hpp.

template<typename OrdinalType, typename ScalarType>
Teuchos::SerialDenseMatrix< OrdinalType, ScalarType >::SerialDenseMatrix int  numRows,
int  numCols
 

Shaped Constructor.

Parameters:
numRows - Number of rows in matrix.
numCols - Number of columns in matrix.
Creates a shaped matrix with numRows rows and numCols cols. All values are initialized to 0. Values of this matrix should be set using the [] or the () operators.

Definition at line 325 of file Teuchos_SerialDenseMatrix.hpp.

template<typename OrdinalType, typename ScalarType>
Teuchos::SerialDenseMatrix< OrdinalType, ScalarType >::SerialDenseMatrix DataAccess  CV,
ScalarType *  values,
int  stride,
int  numRows,
int  numCols
 

Shaped Constructor with Values.

Parameters:
CV - Enumerated type set to Teuchos::Copy or Teuchos::View.
values - Pointer to an array of ScalarType. The first column starts at values, the second at values+stride, etc.
stride - The stride between the columns of the matrix in memory.
numRows - Number of rows in matrix.
numCols - Number of columns in matrix.

Definition at line 333 of file Teuchos_SerialDenseMatrix.hpp.

template<typename OrdinalType, typename ScalarType>
Teuchos::SerialDenseMatrix< OrdinalType, ScalarType >::SerialDenseMatrix const SerialDenseMatrix< OrdinalType, ScalarType > &  Source  ) 
 

Copy Constructor.

Definition at line 345 of file Teuchos_SerialDenseMatrix.hpp.

template<typename OrdinalType, typename ScalarType>
Teuchos::SerialDenseMatrix< OrdinalType, ScalarType >::SerialDenseMatrix DataAccess  CV,
const SerialDenseMatrix< OrdinalType, ScalarType > &  Source,
int  numRows,
int  numCols,
int  startRow = 0,
int  startCol = 0
 

Submatrix Copy Constructor.

Parameters:
CV - Enumerated type set to Teuchos::Copy or Teuchos::View.
Source - Reference to another dense matrix from which values are to be copied.
numRows - The number of rows in this matrix.
numCols - The number of columns in this matrix.
startRow - The row of Source from which the submatrix copy should start.
startCol - The column of Source from which the submatrix copy should start.
Creates a shaped matrix with numRows rows and numCols columns, which is a submatrix of Source. If startRow and startCol are not given, then the submatrix is the leading submatrix of Source. Otherwise, the (1,1) entry in the copied matrix is the (startRow, startCol) entry of Source.

Definition at line 353 of file Teuchos_SerialDenseMatrix.hpp.

template<typename OrdinalType, typename ScalarType>
Teuchos::SerialDenseMatrix< OrdinalType, ScalarType >::~SerialDenseMatrix  )  [virtual]
 

Destructor.

Definition at line 369 of file Teuchos_SerialDenseMatrix.hpp.


Member Function Documentation

template<typename OrdinalType, typename ScalarType>
int Teuchos::SerialDenseMatrix< OrdinalType, ScalarType >::shape int  numRows,
int  numCols
 

Shape method for changing the size of a SerialDenseMatrix, initializing entries to zero.

Parameters:
numRows - The number of rows in this matrix.
numCols - The number of columns in this matrix.
This method allows the user to define the dimensions of a SerialDenseMatrix at any point. This method can be called at any point after construction. Any values previously in this object will be destroyed and the resized matrix starts of with all zero values.

Returns:
Integer error code, set to 0 if successful.

Definition at line 379 of file Teuchos_SerialDenseMatrix.hpp.

template<typename OrdinalType, typename ScalarType>
int Teuchos::SerialDenseMatrix< OrdinalType, ScalarType >::reshape int  numRows,
int  numCols
 

Reshaping method for changing the size of a SerialDenseMatrix, keeping the entries.

Parameters:
numRows - The number of rows in this matrix.
numCols - The number of columns in this matrix.
This method allows the user to redefine the dimensions of a SerialDenseMatrix at any point. This method can be called at any point after construction. Any values previously in this object will be copied into the reshaped matrix.

Returns:
Integer error code, set 0 if successful.

Definition at line 392 of file Teuchos_SerialDenseMatrix.hpp.

template<typename OrdinalType, typename ScalarType>
SerialDenseMatrix< OrdinalType, ScalarType > & Teuchos::SerialDenseMatrix< OrdinalType, ScalarType >::operator= const SerialDenseMatrix< OrdinalType, ScalarType > &  Source  ) 
 

Copies values from one matrix to another.

The operator= copies the values from one existing SerialDenseMatrix to another. If Source is a view (i.e. CV = Teuchos::View), then this method will return a view. Otherwise, it will return a copy of Source. this object will be resized if it is not large enough to copy Source into.

Definition at line 449 of file Teuchos_SerialDenseMatrix.hpp.

template<typename OrdinalType, typename ScalarType>
int Teuchos::SerialDenseMatrix< OrdinalType, ScalarType >::putScalar const ScalarType  value = Teuchos::ScalarTraits< ScalarType >::zero()  ) 
 

Set all values in the matrix to a constant value.

Parameters:
value - Value to use; zero if none specified.
Returns:
Integer error code, set to 0 if successful.

Definition at line 421 of file Teuchos_SerialDenseMatrix.hpp.

template<typename OrdinalType, typename ScalarType>
int Teuchos::SerialDenseMatrix< OrdinalType, ScalarType >::random  ) 
 

Set all values in the matrix to be random numbers.

Definition at line 435 of file Teuchos_SerialDenseMatrix.hpp.

template<typename OrdinalType, typename ScalarType>
ScalarType & Teuchos::SerialDenseMatrix< OrdinalType, ScalarType >::operator() int  rowIndex,
int  colIndex
[inline]
 

Element access method (non-const).

Returns the element in the ith row and jth column if A(i,j) is specified, the expression A[j][i] will return the same element.

Returns:
Element from the specified rowIndex row and colIndex column.
Warning:
The validity of rowIndex and colIndex will only be checked if Teuchos is configured with --enable-teuchos-abc.

Definition at line 521 of file Teuchos_SerialDenseMatrix.hpp.

template<typename OrdinalType, typename ScalarType>
const ScalarType & Teuchos::SerialDenseMatrix< OrdinalType, ScalarType >::operator() int  rowIndex,
int  colIndex
const [inline]
 

Element access method (const).

Returns the element in the ith row and jth column if A(i,j) is specified, the expression A[j][i] will return the same element.

Returns:
Element from the specified rowIndex row and colIndex column.
Warning:
The validity of rowIndex and colIndex will only be checked if Teuchos is configured with --enable-teuchos-abc.

Definition at line 530 of file Teuchos_SerialDenseMatrix.hpp.

template<typename OrdinalType, typename ScalarType>
ScalarType * Teuchos::SerialDenseMatrix< OrdinalType, ScalarType >::operator[] int  colIndex  )  [inline]
 

Column access method (non-const).

Returns the pointer to the ScalarType array at the jth column if A[j] is specified, the expression A[j][i] will return the same element as A(i,j).

Returns:
Pointer to the ScalarType array at the colIndex column ( values_+colIndex*stride_ ).
Warning:
The validity of colIndex will only be checked if Teuchos is configured with --enable-teuchos-abc.

Reimplemented in Teuchos::SerialDenseVector< OrdinalType, ScalarType >.

Definition at line 548 of file Teuchos_SerialDenseMatrix.hpp.

template<typename OrdinalType, typename ScalarType>
const ScalarType * Teuchos::SerialDenseMatrix< OrdinalType, ScalarType >::operator[] int  colIndex  )  const [inline]
 

Column access method (const).

Returns the pointer to the ScalarType array at the jth column if A[j] is specified, the expression A[j][i] will return the same element as A(i,j).

Returns:
Pointer to the ScalarType array at the colIndex column ( values_+colIndex*stride_ ).
Warning:
The validity of colIndex will only be checked if Teuchos is configured with --enable-teuchos-abc.

Reimplemented in Teuchos::SerialDenseVector< OrdinalType, ScalarType >.

Definition at line 539 of file Teuchos_SerialDenseMatrix.hpp.

template<typename OrdinalType, typename ScalarType>
ScalarType* Teuchos::SerialDenseMatrix< OrdinalType, ScalarType >::values  )  const [inline]
 

Data array access method.

Returns:
Pointer to the ScalarType data array contained in the object.

Definition at line 223 of file Teuchos_SerialDenseMatrix.hpp.

template<typename OrdinalType, typename ScalarType>
SerialDenseMatrix< OrdinalType, ScalarType > & Teuchos::SerialDenseMatrix< OrdinalType, ScalarType >::operator+= const SerialDenseMatrix< OrdinalType, ScalarType > &  Source  ) 
 

Add another matrix to this matrix.

Add Source to this if the dimension of both matrices are the same. If not, this matrix will be returned unchanged.

Definition at line 505 of file Teuchos_SerialDenseMatrix.hpp.

template<typename OrdinalType, typename ScalarType>
int Teuchos::SerialDenseMatrix< OrdinalType, ScalarType >::scale const ScalarType  alpha  ) 
 

Scale this matrix; A = alpha*A.

Parameters:
alpha Scalar to multiply this by.
Returns:
Integer error code, set to 0 if successful.

Definition at line 657 of file Teuchos_SerialDenseMatrix.hpp.

template<typename OrdinalType, typename ScalarType>
int Teuchos::SerialDenseMatrix< OrdinalType, ScalarType >::multiply ETransp  transa,
ETransp  transb,
ScalarType  alpha,
const SerialDenseMatrix< OrdinalType, ScalarType > &  A,
const SerialDenseMatrix< OrdinalType, ScalarType > &  B,
ScalarType  beta
 

Multiply A * B and add them to this; this = beta * this + alpha*A*B.

Parameters:
transa - Use the transpose of A if transa = Teuchos::TRANS, else don't use the transpose if transa = Teuchos::NOTRANS.
transb - Use the transpose of B if transb = Teuchos::TRANS, else don't use the transpose if transb = Teuchos::NOTRANS.
alpha - The scaling factor for A * B.
A - SerialDenseMatrix
B - SerialDenseMatrix
beta - The scaling factor for this.
If the matrices A and B are not of the right dimension, consistent with this, then this matrix will not be altered and -1 will be returned.
Returns:
Integer error code, set to 0 if successful.

Definition at line 672 of file Teuchos_SerialDenseMatrix.hpp.

template<typename OrdinalType, typename ScalarType>
bool Teuchos::SerialDenseMatrix< OrdinalType, ScalarType >::operator== const SerialDenseMatrix< OrdinalType, ScalarType > &  Operand  ) 
 

Equality of two matrices.

Returns:
True if this matrix and Operand are of the same shape (rows and columns) and have the same entries, else False will be returned.

Definition at line 622 of file Teuchos_SerialDenseMatrix.hpp.

template<typename OrdinalType, typename ScalarType>
bool Teuchos::SerialDenseMatrix< OrdinalType, ScalarType >::operator!= const SerialDenseMatrix< OrdinalType, ScalarType > &  Operand  ) 
 

Inequality of two matrices.

Returns:
True if this matrix and Operand of not of the same shape (rows and columns) or don't have the same entries, else False will be returned.

Definition at line 647 of file Teuchos_SerialDenseMatrix.hpp.

template<typename OrdinalType, typename ScalarType>
int Teuchos::SerialDenseMatrix< OrdinalType, ScalarType >::numRows  )  const [inline]
 

Returns the row dimension of this matrix.

Definition at line 279 of file Teuchos_SerialDenseMatrix.hpp.

template<typename OrdinalType, typename ScalarType>
int Teuchos::SerialDenseMatrix< OrdinalType, ScalarType >::numCols  )  const [inline]
 

Returns the column dimension of this matrix.

Definition at line 282 of file Teuchos_SerialDenseMatrix.hpp.

template<typename OrdinalType, typename ScalarType>
int Teuchos::SerialDenseMatrix< OrdinalType, ScalarType >::stride  )  const [inline]
 

Returns the stride between the columns of this matrix in memory.

Definition at line 285 of file Teuchos_SerialDenseMatrix.hpp.

template<typename OrdinalType, typename ScalarType>
ScalarTraits< ScalarType >::magnitudeType Teuchos::SerialDenseMatrix< OrdinalType, ScalarType >::normOne  )  const
 

Returns the 1-norm of the matrix.

Definition at line 561 of file Teuchos_SerialDenseMatrix.hpp.

template<typename OrdinalType, typename ScalarType>
ScalarTraits< ScalarType >::magnitudeType Teuchos::SerialDenseMatrix< OrdinalType, ScalarType >::normInf  )  const
 

Returns the Infinity-norm of the matrix.

Definition at line 586 of file Teuchos_SerialDenseMatrix.hpp.

template<typename OrdinalType, typename ScalarType>
ScalarTraits< ScalarType >::magnitudeType Teuchos::SerialDenseMatrix< OrdinalType, ScalarType >::normFrobenius  )  const
 

Returns the Frobenius-norm of the matrix.

Definition at line 603 of file Teuchos_SerialDenseMatrix.hpp.

template<typename OrdinalType, typename ScalarType>
void Teuchos::SerialDenseMatrix< OrdinalType, ScalarType >::print ostream &  os  )  const [virtual]
 

Print method. Defines the behavior of the ostream << operator inherited from the Object class.

Reimplemented from Teuchos::Object.

Reimplemented in Teuchos::SerialDenseVector< OrdinalType, ScalarType >.

Definition at line 694 of file Teuchos_SerialDenseMatrix.hpp.

template<typename OrdinalType, typename ScalarType>
void Teuchos::SerialDenseMatrix< OrdinalType, ScalarType >::copyMat ScalarType *  inputMatrix,
int  strideInput,
int  numRows,
int  numCols,
ScalarType *  outputMatrix,
int  strideOutput,
int  startRow,
int  startCol,
bool  add
[protected]
 

Definition at line 742 of file Teuchos_SerialDenseMatrix.hpp.

template<typename OrdinalType, typename ScalarType>
void Teuchos::SerialDenseMatrix< OrdinalType, ScalarType >::deleteArrays  )  [protected]
 

Definition at line 731 of file Teuchos_SerialDenseMatrix.hpp.

template<typename OrdinalType, typename ScalarType>
void Teuchos::SerialDenseMatrix< OrdinalType, ScalarType >::checkIndex int  rowIndex,
int  colIndex = 0
const [inline, protected]
 

Definition at line 721 of file Teuchos_SerialDenseMatrix.hpp.


Member Data Documentation

template<typename OrdinalType, typename ScalarType>
int Teuchos::SerialDenseMatrix< OrdinalType, ScalarType >::numRows_ [protected]
 

Definition at line 309 of file Teuchos_SerialDenseMatrix.hpp.

template<typename OrdinalType, typename ScalarType>
int Teuchos::SerialDenseMatrix< OrdinalType, ScalarType >::numCols_ [protected]
 

Definition at line 310 of file Teuchos_SerialDenseMatrix.hpp.

template<typename OrdinalType, typename ScalarType>
int Teuchos::SerialDenseMatrix< OrdinalType, ScalarType >::stride_ [protected]
 

Definition at line 311 of file Teuchos_SerialDenseMatrix.hpp.

template<typename OrdinalType, typename ScalarType>
bool Teuchos::SerialDenseMatrix< OrdinalType, ScalarType >::valuesCopied_ [protected]
 

Definition at line 312 of file Teuchos_SerialDenseMatrix.hpp.

template<typename OrdinalType, typename ScalarType>
ScalarType* Teuchos::SerialDenseMatrix< OrdinalType, ScalarType >::values_ [protected]
 

Definition at line 313 of file Teuchos_SerialDenseMatrix.hpp.


The documentation for this class was generated from the following file:
Generated on Thu Sep 18 12:42:53 2008 for Teuchos - Trilinos Tools Package by doxygen 1.3.9.1