Teuchos - Trilinos Tools Package Version of the Day
Loading...
Searching...
No Matches
Teuchos_SerialDenseVector.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Teuchos: Common Tools Package
4//
5// Copyright 2004 NTESS and the Teuchos contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef _TEUCHOS_SERIALDENSEVECTOR_HPP_
11#define _TEUCHOS_SERIALDENSEVECTOR_HPP_
12
18#include "Teuchos_Object.hpp"
20
24namespace Teuchos {
25
26 template<typename OrdinalType, typename ScalarType>
27 class SerialDenseVector : public SerialDenseMatrix<OrdinalType,ScalarType> {
28
29 public:
31
32
34
37
39
47
49
55
58
60
63
65 virtual ~SerialDenseVector ();
67
69
70
72
81
85
87
96
98
99
101
104 SerialDenseVector<OrdinalType, ScalarType>& operator= (const ScalarType value) { this->putScalar(value); return(*this); }
106
108
109
113
115
119
121
122
124
132
134
135
141
143
147 const ScalarType& operator () (OrdinalType index) const;
148
150
155
157
161 const ScalarType& operator [] (OrdinalType index) const;
162
164
166
167
170
172
173
174 OrdinalType length() const {return(this->numRows_);}
176
178
179
180 std::ostream& print(std::ostream& os) const;
182};
183
184 template<typename OrdinalType, typename ScalarType>
186
187 template<typename OrdinalType, typename ScalarType>
189
190 template<typename OrdinalType, typename ScalarType>
193
194 template<typename OrdinalType, typename ScalarType>
197
198 template<typename OrdinalType, typename ScalarType>
201
202 template<typename OrdinalType, typename ScalarType>
204
205 template<typename OrdinalType, typename ScalarType>
211
212 template<typename OrdinalType, typename ScalarType>
214 {
215 bool result = 1;
216 if(this->numRows_ != Operand.numRows_)
217 {
218 result = 0;
219 }
220 else
221 {
223 for(i = 0; i < this->numRows_; i++) {
224 if((*this)(i) != Operand(i))
225 {
226 return 0;
227 }
228 }
229 }
230 return result;
231 }
232
233 template<typename OrdinalType, typename ScalarType>
238
239 template<typename OrdinalType, typename ScalarType>
241 {
242 TEUCHOS_TEST_FOR_EXCEPTION(this->numRows_!= x.numRows_, std::invalid_argument,
243 "SerialDenseVector<T>::dot : " <<
244 "Number of rows " << this->numRows_ << " not equal to x.numRows_ "<< x.numRows() );
245
246 // Compute the dot product and return the result.
247 return BLAS<OrdinalType, ScalarType>::DOT(this->numRows_, this->values(), 1, x.values(), 1);
248 }
249
250 template<typename OrdinalType, typename ScalarType>
251 std::ostream& SerialDenseVector<OrdinalType, ScalarType>::print(std::ostream& os) const
252 {
253 os << std::endl;
254 if(this->valuesCopied_)
255 os << "Values_copied : yes" << std::endl;
256 else
257 os << "Values_copied : no" << std::endl;
258 os << "Length : " << this->numRows_ << std::endl;
259 if(this->numRows_ == 0) {
260 os << "(std::vector is empty, no values to display)" << std::endl;
261 } else {
262 for(OrdinalType i = 0; i < this->numRows_; i++) {
263 os << (*this)(i) << " ";
264 }
265 os << std::endl;
266 }
267 return os;
268 }
269
270 //----------------------------------------------------------------------------------------------------
271 // Accessor methods
272 //----------------------------------------------------------------------------------------------------
273
274 template<typename OrdinalType, typename ScalarType>
276 {
277#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
278 this->checkIndex( index );
279#endif
280 return(this->values_[index]);
281 }
282
283 template<typename OrdinalType, typename ScalarType>
285 {
286#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
287 this->checkIndex( index );
288#endif
289 return(this->values_[index]);
290 }
291
292 template<typename OrdinalType, typename ScalarType>
294 {
295#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
296 this->checkIndex( index );
297#endif
298 return(this->values_[index]);
299 }
300
301 template<typename OrdinalType, typename ScalarType>
303 {
304#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
305 this->checkIndex( index );
306#endif
307 return(this->values_[index]);
308 }
309
311template<typename OrdinalType, typename ScalarType>
319
321template<typename OrdinalType, typename ScalarType>
322std::ostream&
323operator<<(std::ostream &out,
325{
326 printer.obj.print(out);
327 return out;
328}
329
331template<typename OrdinalType, typename ScalarType>
332SerialDenseVectorPrinter<OrdinalType,ScalarType>
337
338
339} // namespace Teuchos
340
341#endif /* _TEUCHOS_SERIALDENSEVECTOR_HPP_ */
Teuchos header file which uses auto-configuration information to include necessary C++ headers.
The base Teuchos object.
Templated serial dense matrix class.
ScalarType DOT(const OrdinalType &n, const x_type *x, const OrdinalType &incx, const y_type *y, const OrdinalType &incy) const
Form the dot product of the vectors x and y.
Smart reference counting pointer class for automatic garbage collection.
This class creates and provides basic support for dense rectangular matrix of templated type.
int putScalar(const ScalarType value=Teuchos::ScalarTraits< ScalarType >::zero())
Set all values in the matrix to a constant value.
SerialDenseMatrix< OrdinalType, ScalarType > & operator=(const SerialDenseMatrix< OrdinalType, ScalarType > &Source)
Copies values from one matrix to another.
ScalarType * values() const
Data array access method.
This class creates and provides basic support for dense vectors of templated type as a specialization...
bool operator==(const SerialDenseVector< OrdinalType, ScalarType > &Operand) const
Equality of two matrices.
OrdinalType length() const
Returns the length of this vector.
bool operator!=(const SerialDenseVector< OrdinalType, ScalarType > &Operand) const
Inequality of two matrices.
ScalarType & operator[](OrdinalType index)
Element access method (non-const).
int resize(OrdinalType length_in)
Resizing method for changing the size of a SerialDenseVector, keeping the entries.
ScalarType dot(const SerialDenseVector< OrdinalType, ScalarType > &x) const
Compute the dot product of this vector and x.
int size(OrdinalType length_in)
Size method for changing the size of a SerialDenseVector, initializing entries to zero.
int sizeUninitialized(OrdinalType length_in)
Same as size() except leaves values uninitialized.
ScalarType & operator()(OrdinalType index)
Element access method (non-const).
std::ostream & print(std::ostream &os) const
Print method. Define the behavior of the std::ostream << operator inherited from the Object class.
SerialDenseVector< OrdinalType, ScalarType > & operator=(const ScalarType value)
Set all values in the matrix to a constant value.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...
SerialBandDenseMatrixPrinter< OrdinalType, ScalarType > printMat(const SerialBandDenseMatrix< OrdinalType, ScalarType > &obj)
Return SerialBandDenseMatrix ostream manipulator Use as:
Ostream manipulator for SerialDenseVector.