00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef _TEUCHOS_SERIALDENSEVECTOR_HPP_
00031 #define _TEUCHOS_SERIALDENSEVECTOR_HPP_
00032
00037 #include "Teuchos_ConfigDefs.hpp"
00038 #include "Teuchos_Object.hpp"
00039 #include "Teuchos_SerialDenseMatrix.hpp"
00040
00044 namespace Teuchos {
00045
00046 template<typename OrdinalType, typename ScalarType>
00047 class SerialDenseVector : public SerialDenseMatrix<OrdinalType,ScalarType> {
00048
00049 public:
00051
00052
00054
00056 SerialDenseVector();
00057
00059
00064 SerialDenseVector(int length);
00065
00067
00072 SerialDenseVector(DataAccess CV, ScalarType* values, int length);
00073
00075 SerialDenseVector(const SerialDenseVector<OrdinalType,ScalarType>& Source);
00076
00078 virtual ~SerialDenseVector ();
00080
00082
00083
00085
00092 int size(int length) {return(SerialDenseMatrix<OrdinalType, ScalarType>::shape(length, 1));};
00093
00095
00101 int resize(int length) {return(SerialDenseMatrix<OrdinalType,ScalarType>::reshape(length, 1));};
00103
00105
00106
00107
00109 bool operator == (const SerialDenseVector<OrdinalType, ScalarType> &Operand);
00110
00112
00114 bool operator != (const SerialDenseVector<OrdinalType, ScalarType> &Operand);
00116
00118
00119
00121
00127 SerialDenseVector<OrdinalType,ScalarType>& operator = (const SerialDenseVector<OrdinalType,ScalarType>& Source);
00129
00131
00132
00133
00137 ScalarType& operator () (int index);
00138
00140
00144 const ScalarType& operator () (int index) const;
00145
00147
00151 ScalarType& operator [] (int index);
00152
00154
00158 const ScalarType& operator [] (int index) const;
00159
00161
00163
00164
00165 int length() const {return(this->numRows_);};
00167
00169
00170
00171 virtual void print(ostream& os) const;
00173 };
00174
00175 template<typename OrdinalType, typename ScalarType>
00176 SerialDenseVector<OrdinalType, ScalarType>::SerialDenseVector() : SerialDenseMatrix<OrdinalType,ScalarType>() {}
00177
00178 template<typename OrdinalType, typename ScalarType>
00179 SerialDenseVector<OrdinalType, ScalarType>::SerialDenseVector( int length ) : SerialDenseMatrix<OrdinalType,ScalarType>( length, 1 ) {}
00180
00181 template<typename OrdinalType, typename ScalarType>
00182 SerialDenseVector<OrdinalType, ScalarType>::SerialDenseVector(DataAccess CV, ScalarType* values, int length) :
00183 SerialDenseMatrix<OrdinalType,ScalarType>( CV, values, length, length, 1 ) {}
00184
00185 template<typename OrdinalType, typename ScalarType>
00186 SerialDenseVector<OrdinalType, ScalarType>::SerialDenseVector(const SerialDenseVector<OrdinalType, ScalarType> &Source) :
00187 SerialDenseMatrix<OrdinalType,ScalarType>( Source ) {}
00188
00189 template<typename OrdinalType, typename ScalarType>
00190 SerialDenseVector<OrdinalType, ScalarType>::~SerialDenseVector() {}
00191
00192 template<typename OrdinalType, typename ScalarType>
00193 SerialDenseVector<OrdinalType, ScalarType>& SerialDenseVector<OrdinalType,ScalarType>::operator = (const SerialDenseVector<OrdinalType, ScalarType>& Source)
00194 {
00195 SerialDenseMatrix<OrdinalType,ScalarType>::operator=(Source);
00196 return(*this);
00197 }
00198
00199 template<typename OrdinalType, typename ScalarType>
00200 bool SerialDenseVector<OrdinalType, ScalarType>::operator == (const SerialDenseVector<OrdinalType, ScalarType> &Operand)
00201 {
00202 bool result = 1;
00203 if(this->numRows_ != Operand.numRows_)
00204 {
00205 result = 0;
00206 }
00207 else
00208 {
00209 int i;
00210 for(i = 0; i < this->numRows_; i++) {
00211 if((*this)(i) != Operand(i))
00212 {
00213 return 0;
00214 }
00215 }
00216 }
00217 return result;
00218 }
00219
00220 template<typename OrdinalType, typename ScalarType>
00221 bool SerialDenseVector<OrdinalType, ScalarType>::operator != (const SerialDenseVector<OrdinalType, ScalarType> &Operand)
00222 {
00223 return !((*this)==Operand);
00224 }
00225
00226 template<typename OrdinalType, typename ScalarType>
00227 void SerialDenseVector<OrdinalType, ScalarType>::print(ostream& os) const
00228 {
00229 os << endl;
00230 if(this->valuesCopied_)
00231 os << "Values_copied : yes" << endl;
00232 else
00233 os << "Values_copied : no" << endl;
00234 os << "Length : " << this->numRows_ << endl;
00235 if(this->numRows_ == 0) {
00236 os << "(vector is empty, no values to display)" << endl;
00237 } else {
00238 for(int i = 0; i < this->numRows_; i++) {
00239 os << (*this)(i) << " ";
00240 }
00241 os << endl;
00242 }
00243 }
00244
00245
00246
00247
00248
00249 template<typename OrdinalType, typename ScalarType>
00250 inline ScalarType& SerialDenseVector<OrdinalType, ScalarType>::operator () (int index)
00251 {
00252 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
00253 this->checkIndex( index );
00254 #endif
00255 return(this->values_[index]);
00256 }
00257
00258 template<typename OrdinalType, typename ScalarType>
00259 inline const ScalarType& SerialDenseVector<OrdinalType, ScalarType>::operator () (int index) const
00260 {
00261 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
00262 this->checkIndex( index );
00263 #endif
00264 return(this->values_[index]);
00265 }
00266
00267 template<typename OrdinalType, typename ScalarType>
00268 inline const ScalarType& SerialDenseVector<OrdinalType, ScalarType>::operator [] (int index) const
00269 {
00270 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
00271 this->checkIndex( index );
00272 #endif
00273 return(this->values_[index]);
00274 }
00275
00276 template<typename OrdinalType, typename ScalarType>
00277 inline ScalarType& SerialDenseVector<OrdinalType, ScalarType>::operator [] (int index)
00278 {
00279 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
00280 this->checkIndex( index );
00281 #endif
00282 return(this->values_[index]);
00283 }
00284
00285 }
00286
00287 #endif