CppNoddy  0.92
Loading...
Searching...
No Matches
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...
 
 DenseVector (const DenseVector< double > &source)
 
 DenseVector (const DenseVector< std::complex< double > > &source)
 
void dump_file (std::string filename, int precision) const
 
void dump_file (std::string filename, int precision) const
 

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 34 of file DenseVector.h.

Member Typedef Documentation

◆ elt_citer

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

Definition at line 38 of file DenseVector.h.

◆ elt_criter

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

Definition at line 40 of file DenseVector.h.

◆ elt_iter

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

Definition at line 37 of file DenseVector.h.

◆ elt_riter

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

Definition at line 39 of file DenseVector.h.

Constructor & Destructor Documentation

◆ DenseVector() [1/6]

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

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

Definition at line 17 of file DenseVector.cpp.

18 {}

◆ DenseVector() [2/6]

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 28 of file DenseVector.cpp.

29 : m_vec(size, fill)
30 {}
std::size_t size() const
A pass-thru definition to get the size of the vector.
Definition: DenseVector.h:330

◆ DenseVector() [3/6]

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 21 of file DenseVector.cpp.

21 {
22 m_vec.reserve(size);
23 // assign the array contents to the vector
24 m_vec.assign(p, p + size);
25 }

References p.

◆ DenseVector() [4/6]

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 62 of file DenseVector.h.

62 {
63 // size the current vector
64 m_vec.resize(source.size());
65 elt_iter p_local(m_vec.begin());
67 p_from = source.begin();
68 p_from != source.end();
69 ++p_from, ++p_local) {
70 *p_local = *p_from;
71 }
72 }
std::vector< _Type >::const_iterator elt_citer
Definition: DenseVector.h:38
std::vector< _Type >::iterator elt_iter
Definition: DenseVector.h:37
double source(const double &x, const double &y, const double &t)
Definition: IBVPLinear.cpp:26

◆ ~DenseVector()

template<typename _Type >
CppNoddy::DenseVector< _Type >::~DenseVector
inline

Definition at line 268 of file DenseVector.h.

269 {}

◆ DenseVector() [5/6]

CppNoddy::DenseVector< double >::DenseVector ( const DenseVector< double > &  source)
inline

Definition at line 274 of file DenseVector.h.

274 {
275 m_vec = source.m_vec;
276 }

◆ DenseVector() [6/6]

CppNoddy::DenseVector< std::complex< double > >::DenseVector ( const DenseVector< std::complex< double > > &  source)
inline

Definition at line 280 of file DenseVector.h.

280 {
281 m_vec = source.m_vec;
282 }

Member Function Documentation

◆ add()

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 38 of file DenseVector.cpp.

39 {
40 operator+=(x);
41 }
DenseVector< _Type > & operator+=(const DenseVector< _Type > &x)
Overloading the += operator.
Definition: DenseVector.h:389

◆ assign()

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 190 of file DenseVector.h.

190 {
191 m_vec.assign(n, elem);
192 }

◆ begin() [1/2]

template<typename _Type >
elt_iter CppNoddy::DenseVector< _Type >::begin ( )
inline

Pass through to the storage container.

Definition at line 82 of file DenseVector.h.

82 {
83 return m_vec.begin();
84 }

Referenced by CppNoddy::Utility::dot(), main(), CppNoddy::DenseVector< _Type >::operator+=(), and CppNoddy::DenseVector< _Type >::operator-=().

◆ begin() [2/2]

template<typename _Type >
elt_citer CppNoddy::DenseVector< _Type >::begin ( ) const
inline

Pass through to the storage container.

Definition at line 92 of file DenseVector.h.

92 {
93 return m_vec.begin();
94 }

◆ clear()

template<typename _Type >
void CppNoddy::DenseVector< _Type >::clear
inline

A pass-thru definition of clear.

Definition at line 320 of file DenseVector.h.

320 {
321 m_vec.clear();
322 }

◆ dump()

template<typename _Type >
void CppNoddy::DenseVector< _Type >::dump

Dump to std::cout.

Definition at line 64 of file DenseVector.cpp.

64 {
65 std::cout << "size = " << size() << "\n";
66 for(std::size_t i = 0; i < size(); ++i) {
67 std::cout << m_vec[ i ] << ", ";
68 }
69 std::cout << "\n";
70 }

Referenced by main().

◆ dump_file() [1/3]

void CppNoddy::DenseVector< double >::dump_file ( std::string  filename,
int  precision 
) const

Definition at line 74 of file DenseVector.cpp.

74 {
75 std::ofstream dump;
76 dump.open(filename.c_str());
77 dump.precision(precision);
78 dump.setf(std::ios::showpoint);
79 dump.setf(std::ios::showpos);
80 dump.setf(std::ios::scientific);
81 for(std::size_t i = 0; i < m_vec.size(); ++i) {
82 dump << i << " " << m_vec[ i ] << "\n";
83 }
84 }
void dump() const
Dump to std::cout.
Definition: DenseVector.cpp:64

◆ dump_file() [2/3]

void CppNoddy::DenseVector< std::complex< double > >::dump_file ( std::string  filename,
int  precision 
) const

Definition at line 87 of file DenseVector.cpp.

87 {
88 std::ofstream dump;
89 dump.open(filename.c_str());
90 dump.precision(precision);
91 dump.setf(std::ios::showpoint);
92 dump.setf(std::ios::showpos);
93 dump.setf(std::ios::scientific);
94 for(std::size_t i = 0; i < m_vec.size(); ++i) {
95 dump << i << " " << m_vec[ i ].real() << " " << m_vec[ i ].imag() << "\n";
96 }
97 }

◆ dump_file() [3/3]

template<typename _Type >
void CppNoddy::DenseVector< _Type >::dump_file ( std::string  filename,
int  precision = 10 
) const

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

◆ end() [1/2]

template<typename _Type >
elt_iter CppNoddy::DenseVector< _Type >::end ( )
inline

Pass through to the storage container.

Definition at line 102 of file DenseVector.h.

102 {
103 return m_vec.end();
104 }

Referenced by CppNoddy::Utility::dot(), and main().

◆ end() [2/2]

template<typename _Type >
elt_citer CppNoddy::DenseVector< _Type >::end ( ) const
inline

Pass through to the storage container.

Definition at line 107 of file DenseVector.h.

107 {
108 return m_vec.end();
109 }

◆ inf_norm()

template<typename _Type >
double CppNoddy::DenseVector< _Type >::inf_norm

Infinity norm.

Returns
The maximum (abs) element in the vector.

Definition at line 59 of file DenseVector.cpp.

59 {
60 return std::abs(*max_element(begin(), end(), abs_predicate<_Type>()));
61 }
elt_iter begin()
Pass through to the storage container.
Definition: DenseVector.h:82
elt_iter end()
Pass through to the storage container.
Definition: DenseVector.h:102

Referenced by CppNoddy::ODE_BVP< _Type, _Xtype >::adapt(), CppNoddy::ODE_BVP< _Type, _Xtype >::arclength_solve(), CppNoddy::Newton< _Type >::arclength_solve(), CppNoddy::reversed_BL< _Type >::bidirectional_step2(), CppNoddy::BandedMatrix< _Type >::inf_norm(), main(), CppNoddy::PDE_double_IBVP< _Type >::step2(), CppNoddy::PDE_IBVP< _Type >::step2(), and CppNoddy::reversed_BL< _Type >::step2().

◆ nelts()

template<typename _Type >
std::size_t CppNoddy::DenseVector< _Type >::nelts
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 335 of file DenseVector.h.

335 {
336 return m_vec.size();
337 }

Referenced by main().

◆ one_norm()

template<typename _Type >
double CppNoddy::DenseVector< _Type >::one_norm

l1-norm.

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

Definition at line 49 of file DenseVector.cpp.

49 {
50 return accumulate(begin(), end(), 0.0, absAdd_functor<_Type>());
51 }

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

◆ operator*()

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 345 of file DenseVector.h.

345 {
346 DenseVector<_Type> temp(*this);
347 temp *= m;
348 return temp;
349 }

References m.

◆ operator*=()

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 352 of file DenseVector.h.

352 {
353 // run thru m_vec from begin to end, transforming into
354 // m_vec container starting from begin using functor
355 std::transform(m_vec.begin(), m_vec.end(), m_vec.begin(), scale_functor<_Type, _Type>(m));
356 return *this;
357 }

References m.

◆ operator+() [1/2]

template<typename _Type >
DenseVector< _Type > CppNoddy::DenseVector< _Type >::operator+
inline

Overloading for +.

Returns
+this

Definition at line 325 of file DenseVector.h.

325 {
326 return * this;
327 }

◆ operator+() [2/2]

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 425 of file DenseVector.h.

425 {
426#ifdef PARANOID
427 if(x.size() != size()) {
428 std::string problem;
429 problem = " The DenseVector.operator+ method is trying to use \n";
430 problem += " two vectors of unequal length \n";
431 throw ExceptionGeom(problem, size(), x.size());
432 }
433#endif
434 DenseVector<_Type> temp(*this);
435 temp += x;
436 return temp;
437 }

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

◆ operator+=()

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 389 of file DenseVector.h.

389 {
390#ifdef PARANOID
391 if(x.size() != size()) {
392 std::string problem;
393 problem = " The DenseVector.operator+= method is trying to use \n";
394 problem += " two vectors of unequal length \n";
395 throw ExceptionGeom(problem, size(), x.size());
396 }
397#endif
398 std::transform(m_vec.begin(), m_vec.end(), x.begin(), m_vec.begin(), std::plus<_Type>());
399 return *this;
400 }

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

◆ operator-() [1/2]

template<typename _Type >
DenseVector< _Type > CppNoddy::DenseVector< _Type >::operator-
inline

Overloading for -.

Returns
-this

Definition at line 418 of file DenseVector.h.

418 {
419 DenseVector<_Type> temp(*this);
420 temp *= -1;
421 return temp;
422 }

◆ operator-() [2/2]

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 403 of file DenseVector.h.

403 {
404#ifdef PARANOID
405 if(x.size() != size()) {
406 std::string problem;
407 problem = " The DenseVector.operator- method is trying to use \n";
408 problem += " two vectors of unequal length \n";
409 throw ExceptionGeom(problem, size(), x.size());
410 }
411#endif
412 DenseVector<_Type> temp(*this);
413 temp -= x;
414 return temp;
415 }

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

◆ operator-=()

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 375 of file DenseVector.h.

375 {
376#ifdef PARANOID
377 if(x.size() != size()) {
378 std::string problem;
379 problem = " The DenseVector.operator-= method is trying to use \n";
380 problem += " two vectors of unequal length \n";
381 throw ExceptionGeom(problem, size(), x.size());
382 }
383#endif
384 std::transform(m_vec.begin(), m_vec.end(), x.begin(), m_vec.begin(), std::minus<_Type>());
385 return *this;
386 }

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

◆ operator/()

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 360 of file DenseVector.h.

360 {
361 DenseVector<_Type> temp(*this);
362 temp *= (1. / m);
363 return temp;
364 }

References m.

◆ operator/=()

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 367 of file DenseVector.h.

367 {
368 // run thru m_vecfrom begin to end, transforming into
369 // m_vec container starting from begin using functor
370 std::transform(m_vec.begin(), m_vec.end(), m_vec.begin(), scale_functor<_Type, _Type>(1.0 / m));
371 return *this;
372 }

References m.

◆ operator=()

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 440 of file DenseVector.h.

440 {
441 if(this == &source)
442 return *this;
443 m_vec = source.m_vec;
444 return *this;
445 }

◆ operator[]() [1/2]

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 285 of file DenseVector.h.

285 {
286#ifdef PARANOID
287 if((i < 0) || (i >= size())) {
288 std::string problem;
289 problem = " The DenseVector.operator[] method has a range error. \n";
290 throw ExceptionRange(problem, size(), i);
291 }
292#endif
293 return m_vec[ i ];
294 }

◆ operator[]() [2/2]

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 297 of file DenseVector.h.

297 {
298#ifdef PARANOID
299 if((i < 0) || (i >= size())) {
300 std::string problem;
301 problem = " The DenseVector.operator[] method has a range error. \n";
302 throw ExceptionRange(problem, size(), i);
303 }
304#endif
305 return m_vec[ i ];
306 }

◆ push_back()

template<typename _Type >
void CppNoddy::DenseVector< _Type >::push_back ( const _Type &  fill)
inline

◆ rbegin() [1/2]

template<typename _Type >
elt_riter CppNoddy::DenseVector< _Type >::rbegin ( )
inline

Pass through to the storage container.

Definition at line 87 of file DenseVector.h.

87 {
88 return m_vec.rbegin();
89 }

◆ rbegin() [2/2]

template<typename _Type >
elt_criter CppNoddy::DenseVector< _Type >::rbegin ( ) const
inline

Pass through to the storage container.

Definition at line 97 of file DenseVector.h.

97 {
98 return m_vec.rbegin();
99 }

◆ rend() [1/2]

template<typename _Type >
elt_riter CppNoddy::DenseVector< _Type >::rend ( )
inline

Pass through to the storage container.

Definition at line 112 of file DenseVector.h.

112 {
113 return m_vec.rend();
114 }

◆ rend() [2/2]

template<typename _Type >
elt_criter CppNoddy::DenseVector< _Type >::rend ( ) const
inline

Pass through to the storage container.

Definition at line 117 of file DenseVector.h.

117 {
118 return m_vec.rend();
119 }

◆ reserve()

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 340 of file DenseVector.h.

340 {
341 m_vec.reserve(n);
342 }

Referenced by CppNoddy::TwoD_Node_Mesh< _Type >::TwoD_Node_Mesh().

◆ resize()

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 315 of file DenseVector.h.

315 {
316 m_vec.resize(length);
317 }

◆ scale()

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 33 of file DenseVector.cpp.

33 {
35 }
DenseVector< _Type > & operator*=(const _Type &m)
Overloading *= for scalar multiplication.
Definition: DenseVector.h:352

References m.

Referenced by CppNoddy::FnQuadrature::Gauss().

◆ size()

template<typename _Type >
std::size_t CppNoddy::DenseVector< _Type >::size
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 330 of file DenseVector.h.

330 {
331 return m_vec.size();
332 }

Referenced by CppNoddy::ODE_EVP< _Type >::add_tagged_to_mesh(), CppNoddy::ArcLength_base< _Type >::arclength_residual(), CppNoddy::Utility::dot(), CppNoddy::Example::Shallow_2d_source::edge_values(), CppNoddy::Example::Acoustic_1d_ref::edge_values(), CppNoddy::Example::NlinAdv::edge_values(), Utils_Fill::fill(), CppNoddy::FnQuadrature::Gauss(), CppNoddy::OneD_TVDLF_Mesh::get_slope(), CppNoddy::OneD_TVDLF_Mesh::get_soln(), CppNoddy::Utility::imag(), CppNoddy::Newton< _Type >::iterate(), CppNoddy::ArcLength_base< _Type >::Jac_arclength_residual(), main(), CppNoddy::TwoD_Node_Mesh< _Type >::max_abs(), CppNoddy::ODE_EVP< _Type >::ODE_EVP(), CppNoddy::OneD_TVDLF_Mesh::OneD_TVDLF_Mesh(), CppNoddy::DenseVector< _Type >::operator+(), CppNoddy::DenseVector< _Type >::operator+=(), CppNoddy::DenseVector< _Type >::operator-(), CppNoddy::DenseVector< _Type >::operator-=(), CppNoddy::Utility::real(), CppNoddy::TwoD_Node_Mesh< _Type >::remesh1(), CppNoddy::OneD_Node_Mesh< _Type, _Xtype >::set_vars_from_vector(), CppNoddy::ODE_IVP< _Type >::shoot45(), CppNoddy::OneD_Node_Mesh< double >::squared_integral2(), CppNoddy::FnQuadrature::sub_Gauss(), CppNoddy::LinearEigenSystem_base::tag_eigenvalues_all(), CppNoddy::LinearEigenSystem_base::tag_eigenvalues_disc(), CppNoddy::LinearEigenSystem_base::tag_eigenvalues_left(), CppNoddy::LinearEigenSystem_base::tag_eigenvalues_lower(), CppNoddy::LinearEigenSystem_base::tag_eigenvalues_right(), CppNoddy::LinearEigenSystem_base::tag_eigenvalues_upper(), CppNoddy::FnQuadrature::trapezium(), CppNoddy::TwoD_TVDLF_Mesh::TwoD_TVDLF_Mesh(), and CppNoddy::ArcLength_base< _Type >::update_theta().

◆ sub()

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 44 of file DenseVector.cpp.

44 {
45 operator-=(x);
46 }
DenseVector< _Type > & operator-=(const DenseVector< _Type > &x)
Overloading the -= operator.
Definition: DenseVector.h:375

Referenced by main().

◆ swap()

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 100 of file DenseVector.cpp.

101 {
102#ifdef PARANOID
103 if((i >= size()) || (j >= size())) {
104 std::string problem;
105 problem = " The DenseVector.swap method is trying to access \n";
106 problem += " outside the max/min number of elements. \n";
107 if(i > size())
108 throw ExceptionRange(problem, size(), i);
109 if(j > size())
110 throw ExceptionRange(problem, size(), j);
111 }
112#endif
113 std::swap<_Type>(m_vec[ i ], m_vec[ j ]);
114 }

◆ two_norm()

template<typename _Type >
double CppNoddy::DenseVector< _Type >::two_norm

l2-norm.

No attention paid to possible overflow for large vectors.

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

Definition at line 54 of file DenseVector.cpp.

54 {
55 return std::sqrt(accumulate(begin(), end(), 0.0, absSquareAdd_functor<_Type>()));
56 }

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

Friends And Related Function Documentation

◆ BandedMatrix< _Type >

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

Definition at line 249 of file DenseVector.h.


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

© 2012

R.E. Hewitt