45 #ifndef AUGMENTED_VECTOR_HPP 46 #define AUGMENTED_VECTOR_HPP 97 return internal_vector[position];
106 return internal_vector[position];
119 "Different size in operands: " + std::to_string(internal_vector.size()) +
" vs " +
120 std::to_string(other.
size()));
121 for(
size_t i = 0; i < internal_vector.size(); i++)
123 return_value += internal_vector[i] * other[i];
137 "Different size in operands: " + std::to_string(internal_vector.size()) +
" vs " +
138 std::to_string(other.
size()));
139 for(
size_t i = 0; i < internal_vector.size(); i++)
152 return internal_vector.size();
163 for(
size_t i = 0; i < internal_vector.size(); i++)
165 return_value += internal_vector[i] * internal_vector[i];
167 return sqrtl(return_value);
177 const size_t _size = this->
size();
180 if(this->internal_vector[
index] < this->internal_vector[min])
196 const size_t _size = this->
size();
199 if(this->internal_vector[
index] > this->internal_vector[max])
203 if(this->internal_vector[
index] < this->internal_vector[min])
217 const size_t _size = this->
size();
220 return_value += this->internal_vector[
index];
240 typename std::vector<T>::iterator it = internal_vector.begin();
242 it +=
static_cast<ptrdiff_t
>(
index);
243 internal_vector.erase(it);
251 this->internal_vector.clear();
260 this->internal_vector.push_back(elem);
270 this->internal_vector.resize(n, t);
279 const size_t _size = this->
size();
282 this->internal_vector[
index] /=
sum;
291 this->internal_vector.clear();
void normalize()
Normalize the row.
T & operator[](size_t position)
Redefinition of [] operator.
void get_min(size_t &min) const
Return the index of mininum element of the vector.
AugmentedVector< T > operator-(const AugmentedVector< T > &other) const
Redefinition of - operator as the difference of the single element.
void push_back(const T &elem)
Inserts a new elment at the end.
T get_mean() const
Return the mean of the vector.
exceptions managed by PandA
const T & operator[](size_t position) const
Redefinition of [] operator.
size_t size() const
Return the size of the vector.
T get_sum() const
Return the sum of a row.
void get_min_max(size_t &min, size_t &max) const
Return the index of the minimum and maximum element of the vector.
void Clear()
Erase all elements.
T operator*(const AugmentedVector< T > &other) const
Redefinition of * operator as scalar multiplication.
T Norm2() const
Return the 2-norm of the vector.
void clear()
Erase all the elements.
std::vector< T > internal_vector
The class which it logical extended by this (inheritance from template is not allowed) ...
void resize(size_t n, T t=T())
Inserts or erases elements at the end such that the size becomes n.
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...