|
Teuchos - Trilinos Tools Package
Version of the Day
|
Go to the documentation of this file.
42 #ifndef _TEUCHOS_SERIALDENSEHELPERS_HPP_
43 #define _TEUCHOS_SERIALDENSEHELPERS_HPP_
52 #include "Teuchos_Assert.hpp"
58 #include "Teuchos_CommHelpers.hpp"
59 #include "Teuchos_DefaultComm.hpp"
74 template<
typename OrdinalType,
typename ScalarType>
80 OrdinalType A_nrowcols = A.
numRows();
81 OrdinalType B_nrowcols = (ETranspChar[transw]!=
'N') ? W.
numCols() : W.
numRows();
82 OrdinalType W_nrows = (ETranspChar[transw]!=
'N') ? W.
numRows() : W.
numCols();
83 OrdinalType W_ncols = (ETranspChar[transw]!=
'N') ? W.
numCols() : W.
numRows();
85 bool isBUpper = B.
upper();
89 "Teuchos::symMatTripleProduct<>() : "
90 "Num Rows/Cols B (" << B.
numRows() <<
") inconsistent with W ("<< B_nrowcols <<
")");
92 "Teuchos::symMatTripleProduct<>() : "
93 "Num Rows/Cols A (" << A_nrowcols <<
") inconsistent with W ("<< W_nrows <<
")");
111 if (ETranspChar[transw]!=
'N') {
120 for (OrdinalType j=0; j<B_nrowcols; ++j)
121 blas.
GEMV( transw, W_nrows, j+1, one, W.
values(), W.
stride(), AW[j], 1, zero, &B(0,j), 1 );
124 for (OrdinalType j=0; j<B_nrowcols; ++j)
125 blas.
GEMV( transw, W_nrows, B_nrowcols-j, one, W[j], W.
stride(), AW[j], 1, zero, &B(j,j), 1 );
137 for (OrdinalType j=0; j<B_nrowcols; ++j)
138 for (OrdinalType i=0; i<=j; ++i)
139 blas.
GEMV( transw, 1, A_nrowcols, one, &AW(i,0), AW.
stride(), &W(j,0), W.
stride(), zero, &B(i,j), 1 );
142 for (OrdinalType j=0; j<B_nrowcols; ++j)
143 for (OrdinalType i=j; i<B_nrowcols; ++i)
144 blas.
GEMV( transw, 1, A_nrowcols, one, &AW(i,0), AW.
stride(), &W(j,0), W.
stride(), zero, &B(i,j), 1 );
160 template<
typename OrdinalType,
typename ScalarType>
176 template<
typename OrdinalType,
typename ScalarType>
178 const OrdinalType col,
193 template <
typename OrdinalType,
typename ScalarType>
199 const OrdinalType procRank = rank(*comm);
226 template<
typename OrdinalType,
typename ScalarType>
229 const OrdinalType kl,
const OrdinalType ku,
230 const bool factorFormat)
232 OrdinalType m = A->numRows();
233 OrdinalType n = A->numCols();
237 "SerialBandDenseSolver<T>::generalToBanded: A is an empty SerialDenseMatrix<T>!");
239 "SerialBandDenseSolver<T>::generalToBanded: The lower bandwidth kl is invalid!");
241 "SerialBandDenseSolver<T>::generalToBanded: The upper bandwidth ku is invalid!");
243 OrdinalType extraBands = (factorFormat ? kl : 0);
247 for (OrdinalType j = 0; j < n; j++) {
248 for (OrdinalType i=TEUCHOS_MAX(0,j-ku); i<=TEUCHOS_MIN(m-1,j+kl); i++) {
249 (*AB)(i,j) = (*A)(i,j);
262 template<
typename OrdinalType,
typename ScalarType>
267 OrdinalType m = AB->numRows();
268 OrdinalType n = AB->numCols();
269 OrdinalType kl = AB->lowerBandwidth();
270 OrdinalType ku = AB->upperBandwidth();
274 "SerialBandDenseSolver<T>::bandedToGeneral: AB is an empty SerialBandDenseMatrix<T>!");
277 for (OrdinalType j = 0; j < n; j++) {
278 for (OrdinalType i=TEUCHOS_MAX(0,j-ku); i<=TEUCHOS_MIN(m-1,j+kl); i++) {
279 (*A)(i,j) = (*AB)(i,j);
Teuchos::DataAccess Mode enumerable type.
OrdinalType length() const
Returns the length of this vector.
This class creates and provides basic support for banded dense matrices of templated type.
static T zero()
Returns representation of zero for this scalar type.
OrdinalType numRows() const
Returns the row dimension of this matrix.
ScalarType * values() const
Data array access method.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
OrdinalType numRows() const
Returns the row dimension of this matrix.
int putScalar(const ScalarType value=Teuchos::ScalarTraits< ScalarType >::zero(), bool fullMatrix=false)
Set all values in the matrix to a constant value.
This class creates and provides basic support for symmetric, positive-definite dense matrices of temp...
int putScalar(const ScalarType value=Teuchos::ScalarTraits< ScalarType >::zero())
Set all values in the matrix to a constant value.
void randomSyncedMatrix(Teuchos::SerialDenseMatrix< OrdinalType, ScalarType > &A)
A templated, non-member, helper function for generating a random SerialDenseMatrix that is synchroniz...
OrdinalType stride() const
Returns the stride between the columns of this matrix in memory.
Templated serial dense matrix class.
Smart reference counting pointer class for automatic garbage collection.
void symMatTripleProduct(ETransp transw, const ScalarType alpha, const SerialSymDenseMatrix< OrdinalType, ScalarType > &A, const SerialDenseMatrix< OrdinalType, ScalarType > &W, SerialSymDenseMatrix< OrdinalType, ScalarType > &B)
A templated, non-member, helper function for computing the matrix triple-product: B = alpha*W^T*A*W o...
bool upper() const
Returns true if upper triangular part of this matrix has and will be used.
static T one()
Returns representation of one for this scalar type.
OrdinalType numCols() const
Returns the column dimension of this matrix.
This structure defines some basic traits for a scalar field type.
bool setCol(const SerialDenseVector< OrdinalType, ScalarType > &v, const OrdinalType col, SerialDenseMatrix< OrdinalType, ScalarType > &A)
A templated, non-member, helper function for setting a SerialDenseMatrix column using a SerialDenseVe...
Teuchos header file which uses auto-configuration information to include necessary C++ headers.
Templated serial dense matrix class.
static Teuchos::RCP< const Comm< OrdinalType > > getComm()
Return the default global communicator.
void GEMV(ETransp trans, const OrdinalType &m, const OrdinalType &n, const alpha_type alpha, const A_type *A, const OrdinalType &lda, const x_type *x, const OrdinalType &incx, const beta_type beta, ScalarType *y, const OrdinalType &incy) const
Performs the matrix-vector operation: y <- alpha*A*x+beta*y or y <- alpha*A'*x+beta*y where A is a ge...
SerialDenseMatrix< OrdinalType, ScalarType > & assign(const SerialDenseMatrix< OrdinalType, ScalarType > &Source)
Copies values from one matrix to another.
int shapeUninitialized(OrdinalType numRows, OrdinalType numCols)
Same as shape() except leaves uninitialized.
This class creates and provides basic support for dense vectors of templated type as a specialization...
Templated serial, dense, symmetric matrix class.
This class creates and provides basic support for dense rectangular matrix of templated type.
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.
Teuchos::RCP< SerialDenseMatrix< OrdinalType, ScalarType > > bandedToGeneral(const RCP< SerialBandDenseMatrix< OrdinalType, ScalarType > > &AB)
A templated, non-member, helper function for converting a SerialBandDenseMatrix to a SerialDenseMatri...
Defines basic traits for the scalar field type.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...
Templated serial dense vector class.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
Teuchos::RCP< SerialBandDenseMatrix< OrdinalType, ScalarType > > generalToBanded(const RCP< SerialDenseMatrix< OrdinalType, ScalarType > > &A, const OrdinalType kl, const OrdinalType ku, const bool factorFormat)
A templated, non-member, helper function for converting a SerialDenseMatrix to a SerialBandDenseMatri...
SerialDenseVector< OrdinalType, ScalarType > getCol(DataAccess CV, SerialDenseMatrix< OrdinalType, ScalarType > &A, const OrdinalType col)
A templated, non-member, helper function for viewing or copying a column of a SerialDenseMatrix as a ...
int random()
Set all values in the matrix to be random numbers.