42 #ifndef _TEUCHOS_SERIALDENSEHELPERS_HPP_ 43 #define _TEUCHOS_SERIALDENSEHELPERS_HPP_ 71 template<
typename OrdinalType,
typename ScalarType>
77 OrdinalType A_nrowcols =
A.numRows();
82 bool isBUpper =
B.upper();
86 "Teuchos::symMatTripleProduct<>() : " 87 "Num Rows/Cols B (" <<
B.numRows() <<
") inconsistent with W ("<< B_nrowcols <<
")");
89 "Teuchos::symMatTripleProduct<>() : " 90 "Num Rows/Cols A (" << A_nrowcols <<
") inconsistent with W ("<< W_nrows <<
")");
117 for (
int j=0; j<B_nrowcols; ++j)
118 blas.
GEMV( transw, W_nrows, j+1, one, W.
values(), W.
stride(), AW[j], 1, zero, &
B(0,j), 1 );
121 for (
int j=0; j<B_nrowcols; ++j)
122 blas.
GEMV( transw, W_nrows, B_nrowcols-j, one, W[j], W.
stride(), AW[j], 1, zero, &
B(j,j), 1 );
134 for (
int j=0; j<B_nrowcols; ++j)
135 for (
int i=0; i<=j; ++i)
136 blas.
GEMV( transw, 1, A_nrowcols, one, &AW(i,0), AW.
stride(), &W(j,0), W.
stride(), zero, &
B(i,j), 1 );
139 for (
int j=0; j<B_nrowcols; ++j)
140 for (
int i=j; i<B_nrowcols; ++i)
141 blas.
GEMV( transw, 1, A_nrowcols, one, &AW(i,0), AW.
stride(), &W(j,0), W.
stride(), zero, &
B(i,j), 1 );
157 template<
typename OrdinalType,
typename ScalarType>
173 template<
typename OrdinalType,
typename ScalarType>
175 const OrdinalType col,
178 if (v.
length() !=
A.numRows())
return false;
195 template<
typename OrdinalType,
typename ScalarType>
198 const OrdinalType kl,
const OrdinalType ku,
199 const bool factorFormat)
201 OrdinalType m =
A->numRows();
202 OrdinalType
n =
A->numCols();
206 "SerialBandDenseSolver<T>::generalToBanded: A is an empty SerialDenseMatrix<T>!");
208 "SerialBandDenseSolver<T>::generalToBanded: The lower bandwidth kl is invalid!");
210 "SerialBandDenseSolver<T>::generalToBanded: The upper bandwidth ku is invalid!");
212 OrdinalType extraBands = (factorFormat ? kl : 0);
216 for (OrdinalType j = 0; j <
n; j++) {
218 (*AB)(i,j) = (*
A)(i,j);
231 template<
typename OrdinalType,
typename ScalarType>
236 OrdinalType m = AB->numRows();
237 OrdinalType
n = AB->numCols();
238 OrdinalType kl = AB->lowerBandwidth();
239 OrdinalType ku = AB->upperBandwidth();
243 "SerialBandDenseSolver<T>::bandedToGeneral: AB is an empty SerialBandDenseMatrix<T>!");
246 for (OrdinalType j = 0; j <
n; j++) {
248 (*A)(i,j) = (*AB)(i,j);
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...
Templated serial dense matrix class.
ScalarType * values() const
Data array access method.
int shapeUninitialized(OrdinalType numRows, OrdinalType numCols)
Same as shape() except leaves uninitialized.
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...
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.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
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 ...
Teuchos header file which uses auto-configuration information to include necessary C++ headers...
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...
This class creates and provides basic support for symmetric, positive-definite dense matrices of temp...
This class creates and provides basic support for dense vectors of templated type as a specialization...
This structure defines some basic traits for a scalar field type.
Templated serial dense matrix class.
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...
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
OrdinalType numRows() const
Returns the row dimension of this matrix.
This class creates and provides basic support for banded dense matrices of templated type...
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...
#define TEUCHOS_MAX(x, y)
Templated serial, dense, symmetric matrix class.
Templated serial dense vector class.
Defines basic traits for the scalar field type.
static T zero()
Returns representation of zero for this scalar type.
TEUCHOSNUMERICS_LIB_DLL_EXPORT const char ETranspChar[]
OrdinalType stride() const
Returns the stride between the columns of this matrix in memory.
Smart reference counting pointer class for automatic garbage collection.
OrdinalType numCols() const
Returns the column dimension of this matrix.
#define TEUCHOS_MIN(x, y)
OrdinalType length() const
Returns the length of this vector.
static T one()
Returns representation of one for this scalar type.
Teuchos::DataAccess Mode enumerable type.
This class creates and provides basic support for dense rectangular matrix of templated type...