11 #ifndef _TEUCHOS_SERIALSYMDENSEMATRIX_HPP_ 
   12 #define _TEUCHOS_SERIALSYMDENSEMATRIX_HPP_ 
   90 template<
typename OrdinalType, 
typename ScalarType>
 
  172   int shape(OrdinalType numRowsCols);
 
  197   int reshape(OrdinalType numRowsCols);
 
  268   ScalarType& 
operator () (OrdinalType rowIndex, OrdinalType colIndex);
 
  278   const ScalarType& 
operator () (OrdinalType rowIndex, OrdinalType colIndex) 
const;
 
  294   char UPLO()
 const {
return(UPLO_);};
 
  372   virtual std::ostream& 
print(std::ostream& os) 
const;
 
  380   void scale( 
const ScalarType alpha );
 
  383   void copyMat(
bool inputUpper, ScalarType* inputMatrix, OrdinalType inputStride,
 
  384                OrdinalType numRowCols, 
bool outputUpper, ScalarType* outputMatrix,
 
  385                OrdinalType outputStride, OrdinalType startRowCol,
 
  389   void copyUPLOMat(
bool inputUpper, ScalarType* inputMatrix,
 
  390                    OrdinalType inputStride, OrdinalType inputRows);
 
  393   void checkIndex( OrdinalType rowIndex, OrdinalType colIndex = 0 ) 
const;
 
  399     const size_t size = size_t(numRows) * size_t(numCols);
 
  400     return new ScalarType[size];
 
  415 template<
typename OrdinalType, 
typename ScalarType>
 
  417   : numRowCols_(numRowCols_in), stride_(numRowCols_in), valuesCopied_(false), upper_(false), UPLO_(
'L')
 
  427 template<
typename OrdinalType, 
typename ScalarType>
 
  429   DataAccess CV, 
bool upper_in, ScalarType* values_in, OrdinalType stride_in, OrdinalType numRowCols_in
 
  431   : numRowCols_(numRowCols_in), stride_(stride_in), valuesCopied_(false),
 
  432     values_(values_in), upper_(upper_in)
 
  448 template<
typename OrdinalType, 
typename ScalarType>
 
  450   : numRowCols_(Source.numRowCols_), stride_(0), valuesCopied_(true),
 
  451     values_(0), upper_(Source.upper_), UPLO_(Source.UPLO_)
 
  474 template<
typename OrdinalType, 
typename ScalarType>
 
  477                                                                     ScalarType> &Source, OrdinalType numRowCols_in, OrdinalType startRowCol )
 
  479     numRowCols_(numRowCols_in), stride_(Source.stride_), valuesCopied_(false), upper_(Source.upper_), UPLO_(Source.UPLO_)
 
  494 template<
typename OrdinalType, 
typename ScalarType>
 
  504 template<
typename OrdinalType, 
typename ScalarType>
 
  508   numRowCols_ = numRowCols_in;
 
  509   stride_ = numRowCols_;
 
  510   values_ = allocateValues(stride_, numRowCols_);
 
  512   valuesCopied_ = 
true;
 
  516 template<
typename OrdinalType, 
typename ScalarType>
 
  520   numRowCols_ = numRowCols_in;
 
  521   stride_ = numRowCols_;
 
  522   values_ = allocateValues(stride_, numRowCols_);
 
  523   valuesCopied_ = 
true;
 
  527 template<
typename OrdinalType, 
typename ScalarType>
 
  531   ScalarType* values_tmp = allocateValues(numRowCols_in, numRowCols_in);
 
  533   for(OrdinalType k = 0; k < numRowCols_in * numRowCols_in; k++)
 
  535     values_tmp[k] = zero;
 
  537   OrdinalType numRowCols_tmp = 
TEUCHOS_MIN(numRowCols_, numRowCols_in);
 
  540     copyMat(upper_, values_, stride_, numRowCols_tmp, upper_, values_tmp, numRowCols_in, 0); 
 
  543   numRowCols_ = numRowCols_in;
 
  544   stride_ = numRowCols_;
 
  545   values_ = values_tmp; 
 
  546   valuesCopied_ = 
true;
 
  554 template<
typename OrdinalType, 
typename ScalarType>
 
  558   if (upper_ != 
false) {
 
  559     copyUPLOMat( 
true, values_, stride_, numRowCols_ );
 
  565 template<
typename OrdinalType, 
typename ScalarType>
 
  569   if (upper_ == 
false) {
 
  570     copyUPLOMat( 
false, values_, stride_, numRowCols_ );
 
  576 template<
typename OrdinalType, 
typename ScalarType>
 
  580   if (fullMatrix == 
true) {
 
  581     for(OrdinalType j = 0; j < numRowCols_; j++)
 
  583         for(OrdinalType i = 0; i < numRowCols_; i++)
 
  585             values_[i + j*stride_] = value_in;
 
  592       for(OrdinalType j = 0; j < numRowCols_; j++) {
 
  593         for(OrdinalType i = 0; i <= j; i++) {
 
  594           values_[i + j*stride_] = value_in;
 
  599       for(OrdinalType j = 0; j < numRowCols_; j++) {
 
  600         for(OrdinalType i = j; i < numRowCols_; i++) {
 
  601           values_[i + j*stride_] = value_in;
 
  609 template<
typename OrdinalType, 
typename ScalarType> 
void 
  613   std::swap(values_ ,      B.
values_);
 
  617   std::swap(upper_,        B.
upper_);
 
  618   std::swap(UPLO_,         B.UPLO_);
 
  621 template<
typename OrdinalType, 
typename ScalarType>
 
  629     for(OrdinalType j = 0; j < numRowCols_; j++) {
 
  630       for(OrdinalType i = 0; i < j; i++) {
 
  638     for(OrdinalType j = 0; j < numRowCols_; j++) {
 
  639       for(OrdinalType i = j+1; i < numRowCols_; i++) {
 
  648   for(OrdinalType i = 0; i < numRowCols_; i++) {
 
  649     values_[i + i*stride_] = diagSum[i] + bias;
 
  654 template<
typename OrdinalType, 
typename ScalarType>
 
  675     UPLO_ = Source.UPLO_;
 
  683       UPLO_ = Source.UPLO_;
 
  684       if(stride_ > 0 && numRowCols_ > 0) {
 
  685         values_ = allocateValues(stride_, numRowCols_);
 
  686         valuesCopied_ = 
true;
 
  697         UPLO_ = Source.UPLO_;
 
  704         UPLO_ = Source.UPLO_;
 
  705         if(stride_ > 0 && numRowCols_ > 0) {
 
  706           values_ = allocateValues(stride_, numRowCols_);
 
  707           valuesCopied_ = 
true;
 
  716 template<
typename OrdinalType, 
typename ScalarType>
 
  723 template<
typename OrdinalType, 
typename ScalarType>
 
  735 template<
typename OrdinalType, 
typename ScalarType>
 
  747 template<
typename OrdinalType, 
typename ScalarType>
 
  761   copyMat(Source.
upper_, Source.
values_, Source.
stride_, numRowCols_, upper_, values_, stride_, 0 );
 
  769 template<
typename OrdinalType, 
typename ScalarType>
 
  772 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK 
  773   checkIndex( rowIndex, colIndex );
 
  775   if ( rowIndex <= colIndex ) {
 
  778       return(values_[colIndex * stride_ + rowIndex]);
 
  780       return(values_[rowIndex * stride_ + colIndex]);
 
  785       return(values_[rowIndex * stride_ + colIndex]);
 
  787       return(values_[colIndex * stride_ + rowIndex]);
 
  791 template<
typename OrdinalType, 
typename ScalarType>
 
  794 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK 
  795   checkIndex( rowIndex, colIndex );
 
  797   if ( rowIndex <= colIndex ) {
 
  800       return(values_[colIndex * stride_ + rowIndex]);
 
  802       return(values_[rowIndex * stride_ + colIndex]);
 
  807       return(values_[rowIndex * stride_ + colIndex]);
 
  809       return(values_[colIndex * stride_ + rowIndex]);
 
  817 template<
typename OrdinalType, 
typename ScalarType>
 
  823 template<
typename OrdinalType, 
typename ScalarType>
 
  834     for (j=0; j<numRowCols_; j++) {
 
  836       ptr = values_ + j*stride_;
 
  837       for (i=0; i<j; i++) {
 
  840       ptr = values_ + j + j*stride_;
 
  841       for (i=j; i<numRowCols_; i++) {
 
  849     for (j=0; j<numRowCols_; j++) {
 
  851       ptr = values_ + j + j*stride_;
 
  852       for (i=j; i<numRowCols_; i++) {
 
  856       for (i=0; i<j; i++) {
 
  866 template<
typename OrdinalType, 
typename ScalarType>
 
  876     for (j = 0; j < numRowCols_; j++) {
 
  877       for (i = 0; i < j; i++) {
 
  884     for (j = 0; j < numRowCols_; j++) {
 
  886       for (i = j+1; i < numRowCols_; i++) {
 
  899 template<
typename OrdinalType, 
typename ScalarType>
 
  908     for(i = 0; i < numRowCols_; i++) {
 
  909       for(j = 0; j < numRowCols_; j++) {
 
  910         if((*
this)(i, j) != Operand(i, j)) {
 
  919 template<
typename OrdinalType, 
typename ScalarType>
 
  922   return !((*this) == Operand);
 
  929 template<
typename OrdinalType, 
typename ScalarType>
 
  936     for (j=0; j<numRowCols_; j++) {
 
  937       ptr = values_ + j*stride_;
 
  938       for (i=0; i<= j; i++) { *ptr = alpha * (*ptr); ptr++; }
 
  942     for (j=0; j<numRowCols_; j++) {
 
  943       ptr = values_ + j*stride_ + j;
 
  944       for (i=j; i<numRowCols_; i++) { *ptr = alpha * (*ptr); ptr++; }
 
  978 template<
typename OrdinalType, 
typename ScalarType>
 
  983     os << 
"Values_copied : yes" << std::endl;
 
  985     os << 
"Values_copied : no" << std::endl;
 
  986   os << 
"Rows / Columns : " << numRowCols_ << std::endl;
 
  987   os << 
"LDA : " << stride_ << std::endl;
 
  989     os << 
"Storage: Upper" << std::endl;
 
  991     os << 
"Storage: Lower" << std::endl;
 
  992   if(numRowCols_ == 0) {
 
  993     os << 
"(matrix is empty, no values to display)" << std::endl;
 
  995     for(OrdinalType i = 0; i < numRowCols_; i++) {
 
  996       for(OrdinalType j = 0; j < numRowCols_; j++){
 
  997         os << (*this)(i,j) << 
" ";
 
 1009 template<
typename OrdinalType, 
typename ScalarType>
 
 1012     "SerialSymDenseMatrix<T>::checkIndex: " 
 1013     "Row index " << rowIndex << 
" out of range [0, "<< numRowCols_ << 
")");
 
 1015     "SerialSymDenseMatrix<T>::checkIndex: " 
 1016     "Col index " << colIndex << 
" out of range [0, "<< numRowCols_ << 
")");
 
 1019 template<
typename OrdinalType, 
typename ScalarType>
 
 1026     valuesCopied_ = 
false;
 
 1030 template<
typename OrdinalType, 
typename ScalarType>
 
 1032                                                             bool inputUpper, ScalarType* inputMatrix,
 
 1033                                                             OrdinalType inputStride, OrdinalType numRowCols_in,
 
 1034                                                             bool outputUpper, ScalarType* outputMatrix,
 
 1035                                                             OrdinalType outputStride, OrdinalType startRowCol,
 
 1040   ScalarType* ptr1 = 0;
 
 1041   ScalarType* ptr2 = 0;
 
 1043   for (j = 0; j < numRowCols_in; j++) {
 
 1044     if (inputUpper == 
true) {
 
 1046       ptr2 = inputMatrix + (j + startRowCol) * inputStride + startRowCol;
 
 1047       if (outputUpper == 
true) {
 
 1049         ptr1 = outputMatrix + j*outputStride;
 
 1051           for(i = 0; i <= j; i++) {
 
 1052             *ptr1++ += alpha*(*ptr2++);
 
 1055           for(i = 0; i <= j; i++) {
 
 1063         ptr1 = outputMatrix + j;
 
 1065           for(i = 0; i <= j; i++) {
 
 1066             *ptr1 += alpha*(*ptr2++);
 
 1067             ptr1 += outputStride;
 
 1070           for(i = 0; i <= j; i++) {
 
 1072             ptr1 += outputStride;
 
 1079       ptr2 = inputMatrix + (startRowCol+j) * inputStride + startRowCol + j;
 
 1080       if (outputUpper == 
true) {
 
 1083         ptr1 = outputMatrix + j*outputStride + j;
 
 1085           for(i = j; i < numRowCols_in; i++) {
 
 1086             *ptr1 += alpha*(*ptr2++);
 
 1087             ptr1 += outputStride;
 
 1090           for(i = j; i < numRowCols_in; i++) {
 
 1092             ptr1 += outputStride;
 
 1098         ptr1 = outputMatrix + j*outputStride + j;
 
 1100           for(i = j; i < numRowCols_in; i++) {
 
 1101             *ptr1++ += alpha*(*ptr2++);
 
 1104           for(i = j; i < numRowCols_in; i++) {
 
 1113 template<
typename OrdinalType, 
typename ScalarType>
 
 1115                                                                 bool inputUpper, ScalarType* inputMatrix,
 
 1116                                                                 OrdinalType inputStride, OrdinalType inputRows
 
 1120   ScalarType * ptr1 = 0;
 
 1121   ScalarType * ptr2 = 0;
 
 1124     for (j=1; j<inputRows; j++) {
 
 1125       ptr1 = inputMatrix + j;
 
 1126       ptr2 = inputMatrix + j*inputStride;
 
 1127       for (i=0; i<j; i++) {
 
 1134     for (i=1; i<inputRows; i++) {
 
 1135       ptr1 = inputMatrix + i;
 
 1136       ptr2 = inputMatrix + i*inputStride;
 
 1137       for (j=0; j<i; j++) {
 
 1146 template<
typename OrdinalType, 
typename ScalarType>
 
 1156 template<
typename OrdinalType, 
typename ScalarType>
 
 1161   printer.
obj.print(out);
 
 1166 template<
typename OrdinalType, 
typename ScalarType>
 
 1167 SerialSymDenseMatrixPrinter<OrdinalType,ScalarType>
 
bool upper() const 
Returns true if upper triangular part of this matrix has and will be used. 
void copyUPLOMat(bool inputUpper, ScalarType *inputMatrix, OrdinalType inputStride, OrdinalType inputRows)
Ostream manipulator for SerialSymDenseMatrix. 
SerialSymDenseMatrix()=default
Default constructor; defines a zero size object. 
static ScalarType * allocateValues(const OrdinalType numRows, const OrdinalType numCols)
Templated interface class to BLAS routines. 
SerialSymDenseMatrixPrinter(const SerialSymDenseMatrix< OrdinalType, ScalarType > &obj_in)
virtual std::ostream & print(std::ostream &os) const 
Print method. Defines the behavior of the std::ostream << operator. 
SerialBandDenseMatrixPrinter< OrdinalType, ScalarType > printMat(const SerialBandDenseMatrix< OrdinalType, ScalarType > &obj)
Return SerialBandDenseMatrix ostream manipulator Use as: 
ScalarType * values() const 
Returns the pointer to the ScalarType data array contained in the object. 
const SerialSymDenseMatrix< OrdinalType, ScalarType > & obj
ScalarType & operator()(OrdinalType rowIndex, OrdinalType colIndex)
Element access method (non-const). 
void swap(SerialSymDenseMatrix< OrdinalType, ScalarType > &B)
Swap values between this matrix and incoming matrix. 
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging. 
int shape(OrdinalType numRowsCols)
Set dimensions of a Teuchos::SerialSymDenseMatrix object; init values to zero. 
Teuchos header file which uses auto-configuration information to include necessary C++ headers...
This class creates and provides basic support for symmetric, positive-definite dense matrices of temp...
OrdinalType numRows() const 
Returns the row dimension of this matrix. 
ScalarTraits< ScalarType >::magnitudeType normInf() const 
Returns the Infinity-norm of the matrix. 
Object for storing data and providing functionality that is common to all computational classes...
int reshape(OrdinalType numRowsCols)
Reshape a Teuchos::SerialSymDenseMatrix object. 
This structure defines some basic traits for a scalar field type. 
void setLower()
Specify that the lower triangle of the this matrix should be used. 
void setUpper()
Specify that the upper triangle of the this matrix should be used. 
Functionality and data that is common to all computational classes. 
void checkIndex(OrdinalType rowIndex, OrdinalType colIndex=0) const 
std::ostream & operator<<(std::ostream &os, BigUInt< n > a)
SerialSymDenseMatrix< OrdinalType, ScalarType > & operator*=(const ScalarType alpha)
Inplace scalar-matrix product A = alpha*A. 
bool operator==(const SerialSymDenseMatrix< OrdinalType, ScalarType > &Operand) const 
Equality of two matrices. 
int putScalar(const ScalarType value=Teuchos::ScalarTraits< ScalarType >::zero(), bool fullMatrix=false)
Set all values in the matrix to a constant value. 
SerialSymDenseMatrix< OrdinalType, ScalarType > & operator+=(const SerialSymDenseMatrix< OrdinalType, ScalarType > &Source)
Add another matrix to this matrix. 
ScalarTraits< ScalarType >::magnitudeType normOne() const 
Returns the 1-norm of the matrix. 
#define TEUCHOS_MAX(x, y)
int random(const ScalarType bias=0.1 *Teuchos::ScalarTraits< ScalarType >::one())
Set all values in the active area (upper/lower triangle) of this matrix to be random numbers...
char UPLO() const 
Returns character value of UPLO used by LAPACK routines. 
virtual ~SerialSymDenseMatrix()
Teuchos::SerialSymDenseMatrix destructor. 
void scale(const ScalarType alpha)
static magnitudeType magnitude(T a)
Returns the magnitudeType of the scalar type a. 
SerialSymDenseMatrix< OrdinalType, ScalarType > & operator-=(const SerialSymDenseMatrix< OrdinalType, ScalarType > &Source)
Subtract another matrix from this matrix. 
OrdinalType ordinalType
Typedef for ordinal type. 
SerialSymDenseMatrix< OrdinalType, ScalarType > & operator=(const SerialSymDenseMatrix< OrdinalType, ScalarType > &Source)
Copies values from one matrix to another. 
int shapeUninitialized(OrdinalType numRowsCols)
Set dimensions of a Teuchos::SerialSymDenseMatrix object; don't initialize values. 
Defines basic traits for the scalar field type. 
static T zero()
Returns representation of zero for this scalar type. 
static T random()
Returns a random number (between -one() and +one()) of this scalar type. 
OrdinalType stride() const 
Returns the stride between the columns of this matrix in memory. 
OrdinalType numCols() const 
Returns the column dimension of this matrix. 
ScalarTraits< ScalarType >::magnitudeType normFrobenius() const 
Returns the Frobenius-norm of the matrix. 
#define TEUCHOS_CHK_REF(a)
SerialSymDenseMatrix< OrdinalType, ScalarType > & assign(const SerialSymDenseMatrix< OrdinalType, ScalarType > &Source)
Copies values from one matrix to another. 
bool operator!=(const SerialSymDenseMatrix< OrdinalType, ScalarType > &Operand) const 
Inequality of two matrices. 
#define TEUCHOS_MIN(x, y)
Teuchos::DataAccess Mode enumerable type. 
bool empty() const 
Returns whether this matrix is empty. 
void copyMat(bool inputUpper, ScalarType *inputMatrix, OrdinalType inputStride, OrdinalType numRowCols, bool outputUpper, ScalarType *outputMatrix, OrdinalType outputStride, OrdinalType startRowCol, ScalarType alpha=ScalarTraits< ScalarType >::zero())
ScalarType scalarType
Typedef for scalar type.