43#ifndef _TEUCHOS_SERIALTRIDIMATRIX_HPP_
44#define _TEUCHOS_SERIALTRIDIMATRIX_HPP_
66template<
typename OrdinalType,
typename ScalarType>
371 virtual void print(std::ostream&
os)
const;
395template<
typename OrdinalType,
typename ScalarType>
400 valuesCopied_(
false),
408template<
typename OrdinalType,
typename ScalarType>
424template<
typename OrdinalType,
typename ScalarType>
449template<
typename OrdinalType,
typename ScalarType>
475 if(min > Source.numRowsCols_) min = Source.numRowsCols_;
494 if(min > Source.numRowsCols_) min = Source.numRowsCols_;
496 D_[
i] = Source.D_[
i];
498 DL_[
i] = Source.DL_[
i];
499 DU_[
i] = Source.DU_[
i];
508template<
typename OrdinalType,
typename ScalarType>
513 valuesCopied_(
false), values_(Source.values_) {
528template<
typename OrdinalType,
typename ScalarType>
538template<
typename OrdinalType,
typename ScalarType>
547 valuesCopied_ =
true;
551template<
typename OrdinalType,
typename ScalarType>
558 valuesCopied_ =
true;
562template<
typename OrdinalType,
typename ScalarType>
600 valuesCopied_ =
true;
608template<
typename OrdinalType,
typename ScalarType>
634template<
typename OrdinalType,
typename ScalarType>
640 if((!valuesCopied_) && (!Source.valuesCopied_) && (values_ == Source.values_))
644 if (!Source.valuesCopied_) {
649 numRowsCols_ = Source.numRowsCols_;
650 values_ = Source.values_;
655 numRowsCols_ = Source.numRowsCols_;
656 const OrdinalType numvals = ( Source.numRowsCols_ == 1) ? 1 : 4*(Source.numRowsCols_ - 1);
659 valuesCopied_ =
true;
669 numRowsCols_ = Source.numRowsCols_;
670 const OrdinalType numvals = ( Source.numRowsCols_ == 1) ? 1 : 4*(Source.numRowsCols_ - 1);
673 valuesCopied_ =
true;
678 D_ = DL_ + (numRowsCols_-1);
679 DU_ = D_ + numRowsCols_;
680 DU2_ = DU_ + (numRowsCols_-1);
684 D_[
i] = Source.D()[
i];
687 DL_[
i] = Source.DL()[
i];
688 DU_[
i] = Source.DU()[
i];
691 DU2_[
i] = Source.DU2()[
i];
702template<
typename OrdinalType,
typename ScalarType>
706 if ((numRowsCols_ != Source.numRowsCols_) )
714template<
typename OrdinalType,
typename ScalarType>
718 if ((numRowsCols_ != Source.numRowsCols_) )
726template<
typename OrdinalType,
typename ScalarType>
731 if((!valuesCopied_) && (!Source.valuesCopied_) && (values_ == Source.values_))
735 if ((numRowsCols_ != Source.numRowsCols_) )
739 copyMat(Source, 0, 0);
747template<
typename OrdinalType,
typename ScalarType>
753 checkIndex( rowIndex, colIndex );
757 return DL_[colIndex];
761 return DU_[rowIndex];
763 return DU2_[rowIndex];
766 "SerialTriDiMatrix<T>::operator (row,col) "
767 "Index (" << rowIndex <<
","<<colIndex<<
") out of range ");
771template<
typename OrdinalType,
typename ScalarType>
776 checkIndex( rowIndex, colIndex );
780 return DL_[colIndex];
784 return DU_[rowIndex];
786 return DU2_[rowIndex];
789 "SerialTriDiMatrix<T>::operator (row,col) "
790 "Index (" << rowIndex <<
","<<colIndex<<
") out of range ");
798template<
typename OrdinalType,
typename ScalarType>
807 for(
j = 0;
j < numRowsCols_;
j++)
819 updateFlops(numRowsCols_ * numRowsCols_);
823template<
typename OrdinalType,
typename ScalarType>
829 for (
i = 0;
i < numRowsCols_;
i++) {
831 for (
j=
i-1;
j<=
i+1;
j++) {
836 updateFlops(numRowsCols_ * numRowsCols_);
840template<
typename OrdinalType,
typename ScalarType>
846 for (
j = 0;
j < numRowsCols_;
j++) {
847 for (
i =
j-1;
i <=
j+1;
i++) {
852 updateFlops( (numRowsCols_ == 1) ? 1 : 4*(numRowsCols_-1) );
860template<
typename OrdinalType,
typename ScalarType>
865 if((numRowsCols_ !=
Operand.numRowsCols_) )
879template<
typename OrdinalType,
typename ScalarType>
888template<
typename OrdinalType,
typename ScalarType>
891 this->scale(
alpha );
895template<
typename OrdinalType,
typename ScalarType>
906template<
typename OrdinalType,
typename ScalarType>
912 if ((numRowsCols_ !=
A.numRowsCols_) )
918 values_[
j] =
A.values_ * values_[
j];
924template<
typename OrdinalType,
typename ScalarType>
929 os <<
"A_Copied: yes" << std::endl;
931 os <<
"A_Copied: no" << std::endl;
932 os <<
"Rows and Columns: " << numRowsCols_ << std::endl;
933 if(numRowsCols_ == 0) {
934 os <<
"(matrix is empty, no values to display)" << std::endl;
939 os <<
"DL: "<<std::endl;
940 for(
int i=0;
i<numRowsCols_-1;++
i)
943 os <<
"D: "<<std::endl;
944 for(
int i=0;
i<numRowsCols_;++
i)
947 os <<
"DU: "<<std::endl;
948 for(
int i=0;
i<numRowsCols_-1;++
i)
951 os <<
"DU2: "<<std::endl;
952 for(
int i=0;
i<numRowsCols_-2;++
i)
957 os <<
" square format:"<<std::endl;
958 for(
int i=0 ;
i < numRowsCols_ ; ++
i ) {
959 for(
int j=0;
j<numRowsCols_;++
j) {
960 if (
j >=
i-1 &&
j <=
i+1) {
961 os << (*this)(
i,
j)<<
" ";
975template<
typename OrdinalType,
typename ScalarType>
980 "SerialTriDiMatrix<T>::checkIndex: "
981 "Row index " << rowIndex <<
" out of range [0, "<< numRowsCols_ <<
"]");
984 "SerialTriDiMatrix<T>::checkIndex: "
985 "Col index " << colIndex <<
" out of range [0, "<< numRowsCols_ <<
"]");
987 "SerialTriDiMatrix<T>::checkIndex: "
988 "index difference " <<
diff <<
" out of range [-1, 2]");
991template<
typename OrdinalType,
typename ScalarType>
998 valuesCopied_ =
false;
1002template<
typename OrdinalType,
typename ScalarType>
1009 if(max > numRowsCols_ ) max = numRowsCols_;
Templated interface class to BLAS routines.
Object for storing data and providing functionality that is common to all computational classes.
Teuchos header file which uses auto-configuration information to include necessary C++ headers.
#define TEUCHOS_CHK_REF(a)
#define TEUCHOS_MIN(x, y)
#define TEUCHOS_MAX(x, y)
#define TEUCHOS_CHK_ERR(a)
Teuchos::DataAccess Mode enumerable type.
Defines basic traits for the scalar field type.
Functionality and data that is common to all computational classes.
Concrete serial communicator subclass.
This class creates and provides basic support for TriDi matrix of templated type.
void checkIndex(OrdinalType rowIndex, OrdinalType colIndex=0) const
int reshape(OrdinalType numRowsCols)
Reshaping method for changing the size of a SerialTriDiMatrix, keeping the entries.
virtual void print(std::ostream &os) const
Print method. Defines the behavior of the std::ostream << operator inherited from the Object class.
ScalarType scalarType
Typedef for scalar type.
bool operator==(const SerialTriDiMatrix< OrdinalType, ScalarType > &Operand) const
Equality of two matrices.
void copyMat(SerialTriDiMatrix< OrdinalType, ScalarType > matrix, OrdinalType startCol, ScalarType alpha=ScalarTraits< ScalarType >::zero())
SerialTriDiMatrix< OrdinalType, ScalarType > & assign(const SerialTriDiMatrix< OrdinalType, ScalarType > &Source)
Copies values from one matrix to another.
ScalarTraits< ScalarType >::magnitudeType normOne() const
Returns the 1-norm of the matrix.
int shape(OrdinalType numRows)
Shape method for changing the size of a SerialTriDiMatrix, initializing entries to zero.
int scale(const ScalarType alpha)
Scale this matrix by alpha; *this = alpha**this.
SerialTriDiMatrix()
Default Constructor.
SerialTriDiMatrix< OrdinalType, ScalarType > & operator+=(const SerialTriDiMatrix< OrdinalType, ScalarType > &Source)
Add another matrix to this matrix.
SerialTriDiMatrix< OrdinalType, ScalarType > & operator-=(const SerialTriDiMatrix< OrdinalType, ScalarType > &Source)
Subtract another matrix from this matrix.
bool empty() const
Returns the column dimension of this matrix.
OrdinalType numRowsCols() const
Returns the row dimension of this matrix.
ScalarTraits< ScalarType >::magnitudeType normInf() const
Returns the Infinity-norm of the matrix.
int shapeUninitialized(OrdinalType numRows)
Same as shape() except leaves uninitialized.
virtual ~SerialTriDiMatrix()
Destructor.
int putScalar(const ScalarType value=Teuchos::ScalarTraits< ScalarType >::zero())
Set all values in the matrix to a constant value.
SerialTriDiMatrix< OrdinalType, ScalarType > & operator*=(const ScalarType alpha)
Scale this matrix by alpha; *this = alpha**this.
SerialTriDiMatrix< OrdinalType, ScalarType > & operator=(const SerialTriDiMatrix< OrdinalType, ScalarType > &Source)
Copies values from one matrix to another.
ScalarType & operator()(OrdinalType rowIndex, OrdinalType colIndex)
Element access method (non-const).
OrdinalType ordinalType
Typedef for ordinal type.
ScalarTraits< ScalarType >::magnitudeType normFrobenius() const
Returns the Frobenius-norm of the matrix.
bool operator!=(const SerialTriDiMatrix< OrdinalType, ScalarType > &Operand) const
Inequality of two matrices.
ScalarType * values() const
Column access method (non-const).
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
This structure defines some basic traits for a scalar field type.
static magnitudeType magnitude(T a)
Returns the magnitudeType of the scalar type a.
T magnitudeType
Mandatory typedef for result of magnitude.
static T zero()
Returns representation of zero for this scalar type.
static T conjugate(T a)
Returns the conjugate of the scalar type a.