CppNoddy  0.90
Public Types | Public Member Functions | Friends | List of all members
CppNoddy::DenseVector< _Type > Class Template Reference

An DenseVector class – a dense vector object. More...

#include <DenseVector.h>

Public Types

typedef std::vector< _Type >::iterator elt_iter
 
typedef std::vector< _Type >::const_iterator elt_citer
 
typedef std::vector< _Type >::reverse_iterator elt_riter
 
typedef std::vector< _Type >::const_reverse_iterator elt_criter
 

Public Member Functions

 DenseVector ()
 Constructor for a non-filled vector, to be filled by the user. More...
 
 DenseVector (const std::size_t &size, const _Type &fill)
 Constructor with specified fill-in initialization. More...
 
 DenseVector (const std::size_t &size, const _Type *p)
 Construct a Noddy vector from a contiguous set of real data. More...
 
template<typename _sourceType >
 DenseVector (const DenseVector< _sourceType > &source)
 A templated implicitly converting copy constructor. More...
 
DenseVectoroperator= (const DenseVector &source)
 Copy assignment. More...
 
 ~DenseVector ()
 
elt_iter begin ()
 Pass through to the storage container. More...
 
elt_riter rbegin ()
 Pass through to the storage container. More...
 
elt_citer begin () const
 Pass through to the storage container. More...
 
elt_criter rbegin () const
 Pass through to the storage container. More...
 
elt_iter end ()
 Pass through to the storage container. More...
 
elt_citer end () const
 Pass through to the storage container. More...
 
elt_riter rend ()
 Pass through to the storage container. More...
 
elt_criter rend () const
 Pass through to the storage container. More...
 
DenseVector< _Type > operator+ (const DenseVector< _Type > &x) const
 Operator overloading for addition. More...
 
DenseVector< _Type > operator+ () const
 Overloading for +. More...
 
DenseVector< _Type > operator- (const DenseVector< _Type > &x) const
 Operator overloading for subtraction. More...
 
DenseVector< _Type > operator- () const
 Overloading for -. More...
 
DenseVector< _Type > operator* (const _Type &m) const
 Operator overloading for scalar multiplication. More...
 
DenseVector< _Type > operator/ (const _Type &m) const
 Operaotr overloading for scalar division. More...
 
const _Type & operator[] (const std::size_t &i) const
 Overloading of the [] operator. More...
 
_Type & operator[] (const std::size_t &i)
 Overloading of the [] operator. More...
 
DenseVector< _Type > & operator*= (const _Type &m)
 Overloading *= for scalar multiplication. More...
 
DenseVector< _Type > & operator/= (const _Type &m)
 Overloading /= for scalar multiplication. More...
 
DenseVector< _Type > & operator-= (const DenseVector< _Type > &x)
 Overloading the -= operator. More...
 
DenseVector< _Type > & operator+= (const DenseVector< _Type > &x)
 Overloading the += operator. More...
 
void push_back (const _Type &fill)
 A pass-thru definition of push_back. More...
 
void resize (const std::size_t &length)
 A pass-thru definition of resize. More...
 
void assign (const std::size_t n, const _Type elem)
 A pass-thru definition of assign. More...
 
void clear ()
 A pass-thru definition of clear. More...
 
double one_norm () const
 l1-norm. More...
 
double two_norm () const
 l2-norm. More...
 
double inf_norm () const
 Infinity norm. More...
 
void scale (const _Type &scale)
 Scale each element of the vector, equivalent to *=. More...
 
void add (const DenseVector< _Type > &x)
 Add a vector, element wise, equivalent to +=. More...
 
void sub (const DenseVector< _Type > &x)
 Subtract a vector, element wise, equivalent to -=. More...
 
std::size_t size () const
 A pass-thru definition to get the size of the vector. More...
 
std::size_t nelts () const
 Get the number of elements in the vector Since the vector is dense, the number of elements is the size. More...
 
void reserve (const std::size_t &n)
 Reserve space for the vector. More...
 
void swap (const std::size_t &i, const std::size_t &j)
 Swap elements i and j. More...
 
void dump () const
 Dump to std::cout. More...
 
void dump_file (std::string filename, int precision=10) const
 Dump the contents to a file, each element on a separate line. More...
 
template<>
 DenseVector (const DenseVector< double > &source)
 
template<>
 DenseVector (const DenseVector< std::complex< double > > &source)
 

Friends

class BandedMatrix< _Type >
 

Detailed Description

template<typename _Type>
class CppNoddy::DenseVector< _Type >

An DenseVector class – a dense vector object.

This is templated but intended ONLY for double or std::complex<double>. We just encapsulate the STL vector container and pass through a few simple iterators whilst adding appropriate operator overloading and norms.

Definition at line 35 of file DenseVector.h.

Member Typedef Documentation

template<typename _Type>
typedef std::vector<_Type>::const_iterator CppNoddy::DenseVector< _Type >::elt_citer

Definition at line 40 of file DenseVector.h.

template<typename _Type>
typedef std::vector<_Type>::const_reverse_iterator CppNoddy::DenseVector< _Type >::elt_criter

Definition at line 42 of file DenseVector.h.

template<typename _Type>
typedef std::vector<_Type>::iterator CppNoddy::DenseVector< _Type >::elt_iter

Definition at line 39 of file DenseVector.h.

template<typename _Type>
typedef std::vector<_Type>::reverse_iterator CppNoddy::DenseVector< _Type >::elt_riter

Definition at line 41 of file DenseVector.h.

Constructor & Destructor Documentation

template<typename _Type >
CppNoddy::DenseVector< _Type >::DenseVector ( )

Constructor for a non-filled vector, to be filled by the user.

Definition at line 18 of file DenseVector.cpp.

19  {}
template<typename _Type>
CppNoddy::DenseVector< _Type >::DenseVector ( const std::size_t &  size,
const _Type &  fill 
)

Constructor with specified fill-in initialization.

Parameters
fillData to be initialised to each entry
sizeThe size of the vector to be instantiated

Definition at line 30 of file DenseVector.cpp.

31  : VEC( size, fill )
32  {}
std::size_t size() const
A pass-thru definition to get the size of the vector.
Definition: DenseVector.h:365
void fill(BandedMatrix< _Type > &A, const _Type &value)
Set all elements of a specified BANDED matrix.
Definition: Utility.h:89
template<typename _Type>
CppNoddy::DenseVector< _Type >::DenseVector ( const std::size_t &  size,
const _Type *  p 
)

Construct a Noddy vector from a contiguous set of real data.

This will be nasty if you pass the wrong pointer, but is useful in interfacing with external libraries

Parameters
sizeThe number of elements in the vector.
pA pointer to the start of the data.

Definition at line 22 of file DenseVector.cpp.

23  {
24  VEC.reserve( size );
25  // assign the array contents to the vector
26  VEC.assign( p, p + size );
27  }
std::size_t size() const
A pass-thru definition to get the size of the vector.
Definition: DenseVector.h:365
template<typename _Type>
template<typename _sourceType >
CppNoddy::DenseVector< _Type >::DenseVector ( const DenseVector< _sourceType > &  source)
inline

A templated implicitly converting copy constructor.

Note this is specialised for double to double and std::complex<double> to std::complex<double> copy construction.

Parameters
sourceThe DenseVector to be used in the initialising.

Definition at line 64 of file DenseVector.h.

65  {
66  // size the current vector
67  VEC.resize( source.size() );
68  elt_iter p_local( VEC.begin() );
70  p_from = source.begin();
71  p_from != source.end();
72  ++p_from, ++p_local )
73  {
74  *p_local = *p_from;
75  }
76  }
double source(const double &x, const double &y, const double &t)
Definition: IBVP_linear.cpp:25
std::vector< _Type >::const_iterator elt_citer
Definition: DenseVector.h:40
std::vector< _Type >::iterator elt_iter
Definition: DenseVector.h:39
template<typename _Type >
CppNoddy::DenseVector< _Type >::~DenseVector ( )
inline

Definition at line 293 of file DenseVector.h.

Referenced by CppNoddy::DenseVector< D_complex >::DenseVector().

294  {}
template<>
CppNoddy::DenseVector< double >::DenseVector ( const DenseVector< double > &  source)
inline

Definition at line 299 of file DenseVector.h.

300  {
301  VEC = source.VEC;
302  }
template<>
CppNoddy::DenseVector< std::complex< double > >::DenseVector ( const DenseVector< std::complex< double > > &  source)
inline

Definition at line 306 of file DenseVector.h.

References CppNoddy::Example::source().

307  {
308  VEC = source.VEC;
309  }

Member Function Documentation

template<typename _Type>
void CppNoddy::DenseVector< _Type >::add ( const DenseVector< _Type > &  x)

Add a vector, element wise, equivalent to +=.

Parameters
xThe vector to be added to this object.

Definition at line 42 of file DenseVector.cpp.

References CppNoddy::DenseVector< _Type >::operator+=().

Referenced by CppNoddy::DenseVector< D_complex >::assign(), and CppNoddy::DenseVector< _Type >::scale().

43  {
44  operator+=( x );
45  }
DenseVector< _Type > & operator+=(const DenseVector< _Type > &x)
Overloading the += operator.
Definition: DenseVector.h:433
template<typename _Type>
void CppNoddy::DenseVector< _Type >::assign ( const std::size_t  n,
const _Type  elem 
)
inline

A pass-thru definition of assign.

Parameters
nThe number of elements to assign
elemThe element copy to be used in the assign

Definition at line 202 of file DenseVector.h.

203  {
204  VEC.assign( n, elem );
205  }
template<typename _Type>
elt_iter CppNoddy::DenseVector< _Type >::begin ( )
inline
template<typename _Type>
elt_citer CppNoddy::DenseVector< _Type >::begin ( ) const
inline

Pass through to the storage container.

Definition at line 98 of file DenseVector.h.

99  {
100  return VEC.begin();
101  }
template<typename _Type >
void CppNoddy::DenseVector< _Type >::clear ( )
inline

A pass-thru definition of clear.

Definition at line 353 of file DenseVector.h.

Referenced by CppNoddy::DenseVector< D_complex >::assign().

354  {
355  VEC.clear();
356  }
template<typename _Type >
void CppNoddy::DenseVector< _Type >::dump ( ) const

Dump to std::cout.

Definition at line 72 of file DenseVector.cpp.

References CppNoddy::DenseVector< _Type >::size().

Referenced by CppNoddy::DenseVector< D_complex >::assign(), CppNoddy::DenseVector< D_complex >::dump_file(), and main().

73  {
74  std::cout << "size = " << size() << "\n";
75  for ( std::size_t i = 0; i < size(); ++i )
76  {
77  std::cout << VEC[ i ] << ", ";
78  }
79  std::cout << "\n";
80  }
std::size_t size() const
A pass-thru definition to get the size of the vector.
Definition: DenseVector.h:365
template<typename _Type>
void CppNoddy::DenseVector< _Type >::dump_file ( std::string  filename,
int  precision = 10 
) const
inline

Dump the contents to a file, each element on a separate line.

Parameters
filenameThe name of the file to write to
precisionPrecision of the output strings

Definition at line 262 of file DenseVector.h.

263  {
264  std::ofstream dump;
265  dump.open( filename.c_str() );
266  dump.precision( precision );
267  dump.setf( std::ios::showpoint );
268  dump.setf( std::ios::showpos );
269  dump.setf( std::ios::scientific );
270  for ( std::size_t i = 0; i < VEC.size(); ++i )
271  {
272  dump << VEC[ i ] << "\n";
273  }
274  }
void dump() const
Dump to std::cout.
Definition: DenseVector.cpp:72
template<typename _Type>
elt_iter CppNoddy::DenseVector< _Type >::end ( )
inline
template<typename _Type>
elt_citer CppNoddy::DenseVector< _Type >::end ( ) const
inline

Pass through to the storage container.

Definition at line 116 of file DenseVector.h.

117  {
118  return VEC.end();
119  }
template<typename _Type >
double CppNoddy::DenseVector< _Type >::inf_norm ( ) const
template<typename _Type >
std::size_t CppNoddy::DenseVector< _Type >::nelts ( ) const
inline

Get the number of elements in the vector Since the vector is dense, the number of elements is the size.

Returns
The number of elements in the vector.

Definition at line 371 of file DenseVector.h.

Referenced by CppNoddy::DenseVector< D_complex >::assign().

372  {
373  return VEC.size();
374  }
template<typename _Type >
double CppNoddy::DenseVector< _Type >::one_norm ( ) const

l1-norm.

Returns
The square-root of the sum of the squares.

Definition at line 54 of file DenseVector.cpp.

References CppNoddy::DenseVector< _Type >::begin(), and CppNoddy::DenseVector< _Type >::end().

Referenced by CppNoddy::DenseVector< D_complex >::assign(), main(), and CppNoddy::BandedMatrix< _Type >::one_norm().

55  {
56  return accumulate( begin(), end(), 0.0, absAdd_functor<_Type>() );
57  }
elt_iter end()
Pass through to the storage container.
Definition: DenseVector.h:110
elt_iter begin()
Pass through to the storage container.
Definition: DenseVector.h:86
template<typename _Type>
DenseVector< _Type > CppNoddy::DenseVector< _Type >::operator* ( const _Type &  m) const
inline

Operator overloading for scalar multiplication.

Parameters
mThe scalar multiplier
Returns
The 'this' vector scaled by the constant 'm'

Definition at line 383 of file DenseVector.h.

References m.

Referenced by CppNoddy::DenseVector< D_complex >::rend().

384  {
385  DenseVector<_Type> temp( *this );
386  temp *= m;
387  return temp;
388  }
template<typename _Type>
DenseVector< _Type > & CppNoddy::DenseVector< _Type >::operator*= ( const _Type &  m)
inline

Overloading *= for scalar multiplication.

Parameters
mThe scalar multiplier
Returns
A reference to the 'this' vector multiplied by the scalar

Definition at line 391 of file DenseVector.h.

References m.

Referenced by CppNoddy::DenseVector< D_complex >::rend(), and CppNoddy::DenseVector< _Type >::scale().

392  {
393  // run thru VEC from begin to end, transforming into
394  // VEC container starting from begin using functor
395  std::transform( VEC.begin(), VEC.end(), VEC.begin(), scale_functor<_Type, _Type>( m ) );
396  return *this;
397  }
template<typename _Type>
DenseVector< _Type > CppNoddy::DenseVector< _Type >::operator+ ( const DenseVector< _Type > &  x) const
inline

Operator overloading for addition.

Parameters
xThe dense vector to be added
Returns
The sum of 'this' and x

Definition at line 474 of file DenseVector.h.

References CppNoddy::DenseVector< _Type >::size().

475  {
476 #ifdef PARANOID
477  if ( x.size() != size() )
478  {
479  std::string problem;
480  problem = " The DenseVector.operator+ method is trying to use \n";
481  problem += " two vectors of unequal length \n";
482  throw ExceptionGeom( problem, size(), x.size() );
483  }
484 #endif
485  DenseVector<_Type> temp( *this );
486  temp += x;
487  return temp;
488  }
std::size_t size() const
A pass-thru definition to get the size of the vector.
Definition: DenseVector.h:365
template<typename _Type>
DenseVector< _Type > CppNoddy::DenseVector< _Type >::operator+ ( ) const
inline

Overloading for +.

Returns
+this

Definition at line 359 of file DenseVector.h.

Referenced by CppNoddy::DenseVector< D_complex >::rend().

360  {
361  return * this;
362  }
template<typename _Type>
DenseVector< _Type > & CppNoddy::DenseVector< _Type >::operator+= ( const DenseVector< _Type > &  x)
inline

Overloading the += operator.

Parameters
xA dense vector that will be added to 'this'
Returns
A reference to the 'this' vector after addition by x

Definition at line 433 of file DenseVector.h.

References CppNoddy::DenseVector< _Type >::begin(), and CppNoddy::DenseVector< _Type >::size().

Referenced by CppNoddy::DenseVector< _Type >::add(), and CppNoddy::DenseVector< D_complex >::rend().

434  {
435 #ifdef PARANOID
436  if ( x.size() != size() )
437  {
438  std::string problem;
439  problem = " The DenseVector.operator+= method is trying to use \n";
440  problem += " two vectors of unequal length \n";
441  throw ExceptionGeom( problem, size(), x.size() );
442  }
443 #endif
444  std::transform( VEC.begin(), VEC.end(), x.begin(), VEC.begin(), std::plus<_Type>() );
445  return *this;
446  }
std::size_t size() const
A pass-thru definition to get the size of the vector.
Definition: DenseVector.h:365
template<typename _Type>
DenseVector< _Type > CppNoddy::DenseVector< _Type >::operator- ( const DenseVector< _Type > &  x) const
inline

Operator overloading for subtraction.

Parameters
xThe dense vector to be subtracted from 'this'
Returns
The subtraction of x from 'this'

Definition at line 449 of file DenseVector.h.

References CppNoddy::DenseVector< _Type >::size().

450  {
451 #ifdef PARANOID
452  if ( x.size() != size() )
453  {
454  std::string problem;
455  problem = " The DenseVector.operator- method is trying to use \n";
456  problem += " two vectors of unequal length \n";
457  throw ExceptionGeom( problem, size(), x.size() );
458  }
459 #endif
460  DenseVector<_Type> temp( *this );
461  temp -= x;
462  return temp;
463  }
std::size_t size() const
A pass-thru definition to get the size of the vector.
Definition: DenseVector.h:365
template<typename _Type>
DenseVector< _Type > CppNoddy::DenseVector< _Type >::operator- ( ) const
inline

Overloading for -.

Returns
-this

Definition at line 466 of file DenseVector.h.

Referenced by CppNoddy::DenseVector< D_complex >::rend().

467  {
468  DenseVector<_Type> temp( *this );
469  temp *= -1;
470  return temp;
471  }
template<typename _Type>
DenseVector< _Type > & CppNoddy::DenseVector< _Type >::operator-= ( const DenseVector< _Type > &  x)
inline

Overloading the -= operator.

Parameters
xA dense vector that will be subtracted from 'this'
Returns
A reference to the 'this' vector after subtraction by x

Definition at line 417 of file DenseVector.h.

References CppNoddy::DenseVector< _Type >::begin(), and CppNoddy::DenseVector< _Type >::size().

Referenced by CppNoddy::DenseVector< D_complex >::rend(), and CppNoddy::DenseVector< _Type >::sub().

418  {
419 #ifdef PARANOID
420  if ( x.size() != size() )
421  {
422  std::string problem;
423  problem = " The DenseVector.operator-= method is trying to use \n";
424  problem += " two vectors of unequal length \n";
425  throw ExceptionGeom( problem, size(), x.size() );
426  }
427 #endif
428  std::transform( VEC.begin(), VEC.end(), x.begin(), VEC.begin(), std::minus<_Type>() );
429  return *this;
430  }
std::size_t size() const
A pass-thru definition to get the size of the vector.
Definition: DenseVector.h:365
template<typename _Type>
DenseVector< _Type > CppNoddy::DenseVector< _Type >::operator/ ( const _Type &  m) const
inline

Operaotr overloading for scalar division.

Parameters
mThe scalar divisor
Returns
The 'this' vector divided by the constant 'm'

Definition at line 400 of file DenseVector.h.

References m.

Referenced by CppNoddy::DenseVector< D_complex >::rend().

401  {
402  DenseVector<_Type> temp( *this );
403  temp *= ( 1. / m );
404  return temp;
405  }
template<typename _Type>
DenseVector< _Type > & CppNoddy::DenseVector< _Type >::operator/= ( const _Type &  m)
inline

Overloading /= for scalar multiplication.

Parameters
mThe scalar divisor
Returns
A reference to the 'this' vector divided by the scalar

Definition at line 408 of file DenseVector.h.

References m.

Referenced by CppNoddy::DenseVector< D_complex >::rend().

409  {
410  // run thru VECfrom begin to end, transforming into
411  // VEC container starting from begin using functor
412  std::transform( VEC.begin(), VEC.end(), VEC.begin(), scale_functor<_Type, _Type>( 1.0 / m ) );
413  return *this;
414  }
template<typename _Type >
DenseVector< _Type > & CppNoddy::DenseVector< _Type >::operator= ( const DenseVector< _Type > &  source)
inline

Copy assignment.

Parameters
sourceObject to copy
Returns
The new object

Definition at line 491 of file DenseVector.h.

Referenced by CppNoddy::DenseVector< D_complex >::DenseVector().

492  {
493  if ( this == &source )
494  return *this;
495  VEC = source.VEC;
496  return *this;
497  }
double source(const double &x, const double &y, const double &t)
Definition: IBVP_linear.cpp:25
template<typename _Type >
const _Type & CppNoddy::DenseVector< _Type >::operator[] ( const std::size_t &  i) const
inline

Overloading of the [] operator.

Parameters
iThe index of the element to be accessed
Returns
The element stored at index i (read only)

Definition at line 326 of file DenseVector.h.

References CppNoddy::DenseVector< _Type >::size().

Referenced by CppNoddy::DenseVector< D_complex >::rend().

327  {
328 #ifdef PARANOID
329  if ( ( i < 0 ) || ( i >= size() ) )
330  {
331  std::string problem;
332  problem = " The DenseVector.operator[] method has a range error. \n";
333  throw ExceptionRange( problem, size(), i );
334  }
335 #endif
336  return VEC[ i ];
337  }
std::size_t size() const
A pass-thru definition to get the size of the vector.
Definition: DenseVector.h:365
template<typename _Type >
_Type & CppNoddy::DenseVector< _Type >::operator[] ( const std::size_t &  i)
inline

Overloading of the [] operator.

Parameters
iThe index of the element to be accessed
Returns
The element stored at index i (read/write)

Definition at line 312 of file DenseVector.h.

References CppNoddy::DenseVector< _Type >::size().

313  {
314 #ifdef PARANOID
315  if ( ( i < 0 ) || ( i >= size() ) )
316  {
317  std::string problem;
318  problem = " The DenseVector.operator[] method has a range error. \n";
319  throw ExceptionRange( problem, size(), i );
320  }
321 #endif
322  return VEC[ i ];
323  }
std::size_t size() const
A pass-thru definition to get the size of the vector.
Definition: DenseVector.h:365
template<typename _Type>
void CppNoddy::DenseVector< _Type >::push_back ( const _Type &  fill)
inline
template<typename _Type>
elt_riter CppNoddy::DenseVector< _Type >::rbegin ( )
inline

Pass through to the storage container.

Definition at line 92 of file DenseVector.h.

93  {
94  return VEC.rbegin();
95  }
template<typename _Type>
elt_criter CppNoddy::DenseVector< _Type >::rbegin ( ) const
inline

Pass through to the storage container.

Definition at line 104 of file DenseVector.h.

105  {
106  return VEC.rbegin();
107  }
template<typename _Type>
elt_riter CppNoddy::DenseVector< _Type >::rend ( )
inline

Pass through to the storage container.

Definition at line 122 of file DenseVector.h.

123  {
124  return VEC.rend();
125  }
template<typename _Type>
elt_criter CppNoddy::DenseVector< _Type >::rend ( ) const
inline

Pass through to the storage container.

Definition at line 128 of file DenseVector.h.

129  {
130  return VEC.rend();
131  }
template<typename _Type >
void CppNoddy::DenseVector< _Type >::reserve ( const std::size_t &  n)
inline

Reserve space for the vector.

Parameters
nThe number of elements to reserve space for

Definition at line 377 of file DenseVector.h.

Referenced by CppNoddy::DenseVector< D_complex >::assign(), CppNoddy::DenseMatrix< _Type >::matrix_to_vector(), CppNoddy::DenseMatrix< _Type >::multiply(), and CppNoddy::Utility::uniform_node_vector().

378  {
379  VEC.reserve( n );
380  }
template<typename _Type >
void CppNoddy::DenseVector< _Type >::resize ( const std::size_t &  length)
inline

A pass-thru definition of resize.

Parameters
lengthThe target length after resizing

Definition at line 347 of file DenseVector.h.

Referenced by CppNoddy::DenseVector< D_complex >::rend().

348  {
349  VEC.resize( length );
350  }
template<typename _Type>
void CppNoddy::DenseVector< _Type >::scale ( const _Type &  scale)

Scale each element of the vector, equivalent to *=.

Parameters
scaleThe value to scale each element by.

Definition at line 35 of file DenseVector.cpp.

References CppNoddy::DenseVector< _Type >::add(), and CppNoddy::DenseVector< _Type >::operator*=().

Referenced by CppNoddy::DenseVector< D_complex >::assign(), and CppNoddy::FnQuadrature::Gauss().

36  {
37  operator*=( m );
38  }
DenseVector< _Type > & operator*=(const _Type &m)
Overloading *= for scalar multiplication.
Definition: DenseVector.h:391
template<typename _Type >
std::size_t CppNoddy::DenseVector< _Type >::size ( ) const
inline

A pass-thru definition to get the size of the vector.

Since the vector is dense, the number of elements is the size.

Returns
The number of elements in the vector.

Definition at line 365 of file DenseVector.h.

Referenced by CppNoddy::ODE_EVP< _Type >::add_tagged_to_mesh(), CppNoddy::ArcLength_base< _Type >::arclength_residual(), CppNoddy::DenseVector< D_complex >::assign(), CppNoddy::DenseVector< D_complex >::DenseVector(), CppNoddy::Utility::dot(), CppNoddy::DenseVector< _Type >::dump(), CppNoddy::Example::NlinAdv::edge_values(), CppNoddy::Example::Acoustic_1d_ref::edge_values(), CppNoddy::Example::Euler_1d::edge_values(), CppNoddy::Example::Shallow_1d_ref::edge_values(), CppNoddy::Example::Euler_2d::edge_values(), CppNoddy::Example::RayTay::edge_values(), CppNoddy::Example::Shallow_2d_source::edge_values(), CppNoddy::ODE_EVP< _Type >::eigensolve(), CppNoddy::Utility::fill(), CppNoddy::Utility::fill_random(), CppNoddy::FnQuadrature::Gauss(), CppNoddy::OneD_TVDLF_Mesh::get_slope(), CppNoddy::OneD_TVDLF_Mesh::get_soln(), CppNoddy::DenseLinearEigenSystem< _Type >::get_tagged_eigenvectors(), CppNoddy::HST::Rayleigh< _Type >::global_evp(), CppNoddy::Utility::imag(), CppNoddy::Newton< _Type >::iterate(), CppNoddy::ArcLength_base< D_complex >::Jac_arclength_residual(), main(), CppNoddy::OneD_Node_Mesh< D_complex >::max(), CppNoddy::TwoD_Node_Mesh< _Type >::max(), CppNoddy::TwoD_Node_Mesh< _Type >::max_real_part(), CppNoddy::TwoD_TVDLF_Mesh::maxmod(), CppNoddy::TwoD_TVDLF_Mesh::minmod(), CppNoddy::DenseMatrix< _Type >::multiply(), CppNoddy::ODE_EVP< _Type >::ODE_EVP(), CppNoddy::OneD_Node_Mesh< D_complex >::OneD_Node_Mesh(), CppNoddy::OneD_TVDLF_Mesh::OneD_TVDLF_Mesh(), CppNoddy::DenseVector< _Type >::operator+(), CppNoddy::DenseVector< _Type >::operator+=(), CppNoddy::DenseVector< _Type >::operator-(), CppNoddy::DenseVector< _Type >::operator-=(), CppNoddy::DenseVector< _Type >::operator[](), CppNoddy::Utility::real(), CppNoddy::OneD_Node_Mesh< _Type, _Xtype >::remesh1(), CppNoddy::TwoD_Node_Mesh< _Type >::remesh1(), CppNoddy::TwoD_Node_Mesh< _Type >::set_nodes_vars(), CppNoddy::OneD_Node_Mesh< _Type, _Xtype >::set_nodes_vars(), CppNoddy::OneD_Node_Mesh< _Type, _Xtype >::set_vars_from_vector(), CppNoddy::ODE_IVP< _Type >::shoot4(), CppNoddy::ODE_IVP< _Type >::shoot45(), CppNoddy::SparseLinearSystem< _Type >::solve_using_factorisation(), CppNoddy::FnQuadrature::sub_Gauss(), CppNoddy::DenseVector< _Type >::swap(), CppNoddy::LinearEigenSystem_base::tag_eigenvalues_all(), CppNoddy::DenseLinearEigenSystem< _Type >::tag_eigenvalues_disc(), CppNoddy::LinearEigenSystem_base::tag_eigenvalues_disc(), CppNoddy::DenseLinearEigenSystem< _Type >::tag_eigenvalues_left(), CppNoddy::LinearEigenSystem_base::tag_eigenvalues_left(), CppNoddy::DenseLinearEigenSystem< _Type >::tag_eigenvalues_lower(), CppNoddy::LinearEigenSystem_base::tag_eigenvalues_lower(), CppNoddy::DenseLinearEigenSystem< _Type >::tag_eigenvalues_right(), CppNoddy::LinearEigenSystem_base::tag_eigenvalues_right(), CppNoddy::DenseLinearEigenSystem< _Type >::tag_eigenvalues_upper(), CppNoddy::LinearEigenSystem_base::tag_eigenvalues_upper(), CppNoddy::FnQuadrature::trapezium(), CppNoddy::TwoD_TVDLF_Mesh::TwoD_TVDLF_Mesh(), and CppNoddy::ArcLength_base< _Type >::update_theta().

366  {
367  return VEC.size();
368  }
template<typename _Type>
void CppNoddy::DenseVector< _Type >::sub ( const DenseVector< _Type > &  x)

Subtract a vector, element wise, equivalent to -=.

Parameters
xThe vector to be subtracted from this object.

Definition at line 48 of file DenseVector.cpp.

References CppNoddy::DenseVector< _Type >::operator-=().

Referenced by CppNoddy::DenseVector< D_complex >::assign(), and main().

49  {
50  operator-=( x );
51  }
DenseVector< _Type > & operator-=(const DenseVector< _Type > &x)
Overloading the -= operator.
Definition: DenseVector.h:417
template<typename _Type >
void CppNoddy::DenseVector< _Type >::swap ( const std::size_t &  i,
const std::size_t &  j 
)

Swap elements i and j.

Parameters
iThe index of the element to swap.
jThe index of the other element to swap.

Definition at line 83 of file DenseVector.cpp.

References CppNoddy::DenseVector< _Type >::size().

Referenced by CppNoddy::DenseVector< D_complex >::assign().

85  {
86 #ifdef PARANOID
87  if ( ( i >= size() ) || ( j >= size() ) )
88  {
89  std::string problem;
90  problem = " The DenseVector.swap method is trying to access \n";
91  problem += " outside the max/min number of elements. \n";
92  if ( i > size() )
93  throw ExceptionRange( problem, size(), i );
94  if ( j > size() )
95  throw ExceptionRange( problem, size(), j );
96  }
97 #endif
98  std::swap<_Type>( VEC[ i ], VEC[ j ] );
99  }
std::size_t size() const
A pass-thru definition to get the size of the vector.
Definition: DenseVector.h:365
template<typename _Type >
double CppNoddy::DenseVector< _Type >::two_norm ( ) const

l2-norm.

No attention paid to possible overflow for large vectors.

Returns
The square-root of the sum of the squares.

Definition at line 60 of file DenseVector.cpp.

References CppNoddy::DenseVector< _Type >::begin(), and CppNoddy::DenseVector< _Type >::end().

Referenced by CppNoddy::DenseVector< D_complex >::assign(), CppNoddy::BandedMatrix< _Type >::frob_norm(), main(), and CppNoddy::BandedMatrix< _Type >::two_norm().

61  {
62  return std::sqrt( accumulate( begin(), end(), 0.0, absSquareAdd_functor<_Type>() ) );
63  }
elt_iter end()
Pass through to the storage container.
Definition: DenseVector.h:110
elt_iter begin()
Pass through to the storage container.
Definition: DenseVector.h:86

Friends And Related Function Documentation

template<typename _Type>
friend class BandedMatrix< _Type >
friend

Definition at line 279 of file DenseVector.h.


The documentation for this class was generated from the following files:

© 2012

R.E. Hewitt