CppNoddy
0.92
|
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... | |
DenseVector & | operator= (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 > |
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.
typedef std::vector<_Type>::const_iterator CppNoddy::DenseVector< _Type >::elt_citer |
Definition at line 38 of file DenseVector.h.
typedef std::vector<_Type>::const_reverse_iterator CppNoddy::DenseVector< _Type >::elt_criter |
Definition at line 40 of file DenseVector.h.
typedef std::vector<_Type>::iterator CppNoddy::DenseVector< _Type >::elt_iter |
Definition at line 37 of file DenseVector.h.
typedef std::vector<_Type>::reverse_iterator CppNoddy::DenseVector< _Type >::elt_riter |
Definition at line 39 of file DenseVector.h.
CppNoddy::DenseVector< _Type >::DenseVector |
Constructor for a non-filled vector, to be filled by the user.
Definition at line 17 of file DenseVector.cpp.
CppNoddy::DenseVector< _Type >::DenseVector | ( | const std::size_t & | size, |
const _Type & | fill | ||
) |
Constructor with specified fill-in initialization.
fill | Data to be initialised to each entry |
size | The size of the vector to be instantiated |
Definition at line 28 of file DenseVector.cpp.
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
size | The number of elements in the vector. |
p | A pointer to the start of the data. |
Definition at line 21 of file DenseVector.cpp.
References p.
|
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.
source | The DenseVector to be used in the initialising. |
Definition at line 62 of file DenseVector.h.
|
inline |
Definition at line 268 of file DenseVector.h.
|
inline |
Definition at line 274 of file DenseVector.h.
|
inline |
Definition at line 280 of file DenseVector.h.
void CppNoddy::DenseVector< _Type >::add | ( | const DenseVector< _Type > & | x | ) |
Add a vector, element wise, equivalent to +=.
x | The vector to be added to this object. |
Definition at line 38 of file DenseVector.cpp.
|
inline |
A pass-thru definition of assign.
n | The number of elements to assign |
elem | The element copy to be used in the assign |
Definition at line 190 of file DenseVector.h.
|
inline |
Pass through to the storage container.
Definition at line 82 of file DenseVector.h.
Referenced by CppNoddy::Utility::dot(), main(), CppNoddy::DenseVector< _Type >::operator+=(), and CppNoddy::DenseVector< _Type >::operator-=().
|
inline |
Pass through to the storage container.
Definition at line 92 of file DenseVector.h.
|
inline |
A pass-thru definition of clear.
Definition at line 320 of file DenseVector.h.
void CppNoddy::DenseVector< _Type >::dump |
Dump to std::cout.
Definition at line 64 of file DenseVector.cpp.
Referenced by main().
void CppNoddy::DenseVector< double >::dump_file | ( | std::string | filename, |
int | precision | ||
) | const |
Definition at line 74 of file DenseVector.cpp.
void CppNoddy::DenseVector< std::complex< double > >::dump_file | ( | std::string | filename, |
int | precision | ||
) | const |
Definition at line 87 of file DenseVector.cpp.
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.
filename | The name of the file to write to |
precision | Precision of the output strings |
|
inline |
Pass through to the storage container.
Definition at line 102 of file DenseVector.h.
Referenced by CppNoddy::Utility::dot(), and main().
|
inline |
Pass through to the storage container.
Definition at line 107 of file DenseVector.h.
double CppNoddy::DenseVector< _Type >::inf_norm |
Infinity norm.
Definition at line 59 of file DenseVector.cpp.
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().
|
inline |
Get the number of elements in the vector Since the vector is dense, the number of elements is the size.
Definition at line 335 of file DenseVector.h.
Referenced by main().
double CppNoddy::DenseVector< _Type >::one_norm |
l1-norm.
Definition at line 49 of file DenseVector.cpp.
Referenced by main(), and CppNoddy::BandedMatrix< _Type >::one_norm().
|
inline |
Operator overloading for scalar multiplication.
m | The scalar multiplier |
Definition at line 345 of file DenseVector.h.
References m.
|
inline |
Overloading *= for scalar multiplication.
m | The scalar multiplier |
Definition at line 352 of file DenseVector.h.
References m.
|
inline |
Overloading for +.
Definition at line 325 of file DenseVector.h.
|
inline |
Operator overloading for addition.
x | The dense vector to be added |
Definition at line 425 of file DenseVector.h.
References CppNoddy::DenseVector< _Type >::size().
|
inline |
Overloading the += operator.
x | A dense vector that will be added to 'this' |
Definition at line 389 of file DenseVector.h.
References CppNoddy::DenseVector< _Type >::begin(), and CppNoddy::DenseVector< _Type >::size().
|
inline |
Overloading for -.
Definition at line 418 of file DenseVector.h.
|
inline |
Operator overloading for subtraction.
x | The dense vector to be subtracted from 'this' |
Definition at line 403 of file DenseVector.h.
References CppNoddy::DenseVector< _Type >::size().
|
inline |
Overloading the -= operator.
x | A dense vector that will be subtracted from 'this' |
Definition at line 375 of file DenseVector.h.
References CppNoddy::DenseVector< _Type >::begin(), and CppNoddy::DenseVector< _Type >::size().
|
inline |
Operaotr overloading for scalar division.
m | The scalar divisor |
Definition at line 360 of file DenseVector.h.
References m.
|
inline |
Overloading /= for scalar multiplication.
m | The scalar divisor |
Definition at line 367 of file DenseVector.h.
References m.
|
inline |
Copy assignment.
source | Object to copy |
Definition at line 440 of file DenseVector.h.
|
inline |
Overloading of the [] operator.
i | The index of the element to be accessed |
Definition at line 285 of file DenseVector.h.
|
inline |
Overloading of the [] operator.
i | The index of the element to be accessed |
Definition at line 297 of file DenseVector.h.
|
inline |
A pass-thru definition of push_back.
fill | The data element to be pushed into the vector |
Definition at line 310 of file DenseVector.h.
Referenced by CppNoddy::ODE_BVP< _Type, _Xtype >::adapt(), CppNoddy::OneD_Node_Mesh< _Type, _Xtype >::find_roots1(), CppNoddy::FnQuadrature::Gauss(), CppNoddy::OneD_TVDLF_Mesh::get_face_pos_vector(), CppNoddy::OneD_TVDLF_Mesh::get_mid_node_vector(), CppNoddy::OneD_Node_Mesh< _Type, _Xtype >::get_nodes_vars(), CppNoddy::DenseLinearEigenSystem< _Type >::get_tagged_eigenvalues(), CppNoddy::LinearEigenSystem_base::get_tagged_eigenvalues(), main(), CppNoddy::TwoD_TVDLF_Mesh::maxmod(), CppNoddy::TwoD_TVDLF_Mesh::minmod(), CppNoddy::ODE_IVP< _Type >::shoot45(), CppNoddy::ODE_IVP< double >::store_every(), CppNoddy::Utility::three_uniform_node_vector(), CppNoddy::Utility::two_uniform_node_vector(), and CppNoddy::TwoD_Node_Mesh< _Type >::TwoD_Node_Mesh().
|
inline |
Pass through to the storage container.
Definition at line 87 of file DenseVector.h.
|
inline |
Pass through to the storage container.
Definition at line 97 of file DenseVector.h.
|
inline |
Pass through to the storage container.
Definition at line 112 of file DenseVector.h.
|
inline |
Pass through to the storage container.
Definition at line 117 of file DenseVector.h.
|
inline |
Reserve space for the vector.
n | The number of elements to reserve space for |
Definition at line 340 of file DenseVector.h.
Referenced by CppNoddy::TwoD_Node_Mesh< _Type >::TwoD_Node_Mesh().
|
inline |
A pass-thru definition of resize.
length | The target length after resizing |
Definition at line 315 of file DenseVector.h.
void CppNoddy::DenseVector< _Type >::scale | ( | const _Type & | scale | ) |
Scale each element of the vector, equivalent to *=.
scale | The value to scale each element by. |
Definition at line 33 of file DenseVector.cpp.
References m.
Referenced by CppNoddy::FnQuadrature::Gauss().
|
inline |
A pass-thru definition to get the size of the vector.
Since the vector is dense, the number of elements is the size.
Definition at line 330 of file DenseVector.h.
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().
void CppNoddy::DenseVector< _Type >::sub | ( | const DenseVector< _Type > & | x | ) |
Subtract a vector, element wise, equivalent to -=.
x | The vector to be subtracted from this object. |
Definition at line 44 of file DenseVector.cpp.
Referenced by main().
void CppNoddy::DenseVector< _Type >::swap | ( | const std::size_t & | i, |
const std::size_t & | j | ||
) |
Swap elements i and j.
i | The index of the element to swap. |
j | The index of the other element to swap. |
Definition at line 100 of file DenseVector.cpp.
double CppNoddy::DenseVector< _Type >::two_norm |
l2-norm.
No attention paid to possible overflow for large vectors.
Definition at line 54 of file DenseVector.cpp.
Referenced by CppNoddy::BandedMatrix< _Type >::frob_norm(), main(), and CppNoddy::BandedMatrix< _Type >::two_norm().
|
friend |
Definition at line 249 of file DenseVector.h.
© 2012
R.E. Hewitt