16 template <
typename _Type>
20 template <
typename _Type>
24 m_vec.assign(
p,
p + size);
27 template <
typename _Type>
29 const _Type& fill) : m_vec(size, fill)
32 template <
typename _Type>
37 template <
typename _Type>
43 template <
typename _Type>
48 template <
typename _Type>
53 template <
typename _Type>
58 template <
typename _Type>
63 template <
typename _Type>
65 std::cout <<
"size = " << size() <<
"\n";
66 for(std::size_t i = 0; i < size(); ++i) {
67 std::cout << m_vec[ i ] <<
", ";
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";
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";
99 template <
typename _Type>
101 const std::size_t& j) {
103 if((i >= size()) || (j >= size())) {
105 problem =
" The DenseVector.swap method is trying to access \n";
106 problem +=
" outside the max/min number of elements. \n";
113 std::swap<_Type>(m_vec[ i ], m_vec[ j ]);
Specification for a templated DenseVector class – a dense, dynamic, vector object.
The collection of CppNoddy exceptions.
Some Function Objects that CppNoddy makes use of in algorithms applied to STL containers.
An DenseVector class – a dense vector object.
double one_norm() const
l1-norm.
void dump_file(std::string filename, int precision=10) const
Dump the contents to a file, each element on a separate line.
double inf_norm() const
Infinity norm.
void sub(const DenseVector< _Type > &x)
Subtract a vector, element wise, equivalent to -=.
void dump() const
Dump to std::cout.
void add(const DenseVector< _Type > &x)
Add a vector, element wise, equivalent to +=.
void swap(const std::size_t &i, const std::size_t &j)
Swap elements i and j.
void scale(const _Type &scale)
Scale each element of the vector, equivalent to *=.
DenseVector()
Constructor for a non-filled vector, to be filled by the user.
double two_norm() const
l2-norm.
An exception to indicate that a CppNoddy container has been accessed with index/indices outside the m...
A function object used to accumulate the absolute value of a container.
A function object used to accumulate the square of the absolute value of a container.
A function object predicate that compares the absolute value of two elements and returns a true of el...
A collection of OO numerical routines aimed at simple (typical) applied problems in continuum mechani...