PandA-2024.02
Public Member Functions | Private Attributes
AugmentedVector< T > Class Template Reference

#include <augmented_vector.hpp>

Public Member Functions

 AugmentedVector ()=default
 Empty Constructor. More...
 
 AugmentedVector (const size_t _size, T element)
 Construct a vector composed by size element. More...
 
 AugmentedVector (const size_t _size)
 Construct a vector of size size. More...
 
 AugmentedVector (const std::vector< T > &vector)
 Constructor from std::vector. More...
 
T & operator[] (size_t position)
 Redefinition of [] operator. More...
 
const T & operator[] (size_t position) const
 Redefinition of [] operator. More...
 
operator* (const AugmentedVector< T > &other) const
 Redefinition of * operator as scalar multiplication. More...
 
AugmentedVector< T > operator- (const AugmentedVector< T > &other) const
 Redefinition of - operator as the difference of the single element. More...
 
size_t size () const
 Return the size of the vector. More...
 
Norm2 () const
 Return the 2-norm of the vector. More...
 
void get_min (size_t &min) const
 Return the index of mininum element of the vector. More...
 
void get_min_max (size_t &min, size_t &max) const
 Return the index of the minimum and maximum element of the vector. More...
 
get_sum () const
 Return the sum of a row. More...
 
get_mean () const
 Return the mean of the vector. More...
 
void remove (const size_t index)
 Remove an element. More...
 
void clear ()
 Erase all the elements. More...
 
void push_back (const T &elem)
 Inserts a new elment at the end. More...
 
void resize (size_t n, T t=T())
 Inserts or erases elements at the end such that the size becomes n. More...
 
void normalize ()
 Normalize the row. More...
 
void Clear ()
 Erase all elements. More...
 

Private Attributes

std::vector< T > internal_vector
 The class which it logical extended by this (inheritance from template is not allowed) More...
 

Detailed Description

template<class T>
class AugmentedVector< T >

Definition at line 54 of file augmented_vector.hpp.

Constructor & Destructor Documentation

◆ AugmentedVector() [1/4]

template<class T>
AugmentedVector< T >::AugmentedVector ( )
default

Empty Constructor.

◆ AugmentedVector() [2/4]

template<class T>
AugmentedVector< T >::AugmentedVector ( const size_t  _size,
element 
)
inline

Construct a vector composed by size element.

Parameters
sizeis the size of the vector
elementis the element with which the vector is filled

Definition at line 71 of file augmented_vector.hpp.

◆ AugmentedVector() [3/4]

template<class T>
AugmentedVector< T >::AugmentedVector ( const size_t  _size)
inlineexplicit

Construct a vector of size size.

Parameters
sizeis the size of the vector

Definition at line 79 of file augmented_vector.hpp.

◆ AugmentedVector() [4/4]

template<class T>
AugmentedVector< T >::AugmentedVector ( const std::vector< T > &  vector)
inlineexplicit

Constructor from std::vector.

Parameters
vectoris the starting vector

Definition at line 87 of file augmented_vector.hpp.

Member Function Documentation

◆ clear()

template<class T>
void AugmentedVector< T >::clear ( )
inline

Erase all the elements.

Definition at line 249 of file augmented_vector.hpp.

◆ Clear()

template<class T>
void AugmentedVector< T >::Clear ( )
inline

Erase all elements.

Definition at line 289 of file augmented_vector.hpp.

◆ get_mean()

template<class T>
T AugmentedVector< T >::get_mean ( ) const
inline

Return the mean of the vector.

Returns
the mean

Definition at line 229 of file augmented_vector.hpp.

References AugmentedVector< T >::get_sum(), and AugmentedVector< T >::size().

Here is the call graph for this function:

◆ get_min()

template<class T>
void AugmentedVector< T >::get_min ( size_t min) const
inline

Return the index of mininum element of the vector.

Parameters
minis where the index of the mimimum element will be stored

Definition at line 174 of file augmented_vector.hpp.

References index, and AugmentedVector< T >::size().

Here is the call graph for this function:

◆ get_min_max()

template<class T>
void AugmentedVector< T >::get_min_max ( size_t min,
size_t max 
) const
inline

Return the index of the minimum and maximum element of the vector.

Parameters
minis where the index of the minimum element will be stored
maxis where the index of the maximum element will be stored

Definition at line 192 of file augmented_vector.hpp.

References index, and AugmentedVector< T >::size().

Here is the call graph for this function:

◆ get_sum()

template<class T>
T AugmentedVector< T >::get_sum ( ) const
inline

Return the sum of a row.

Returns
the sum of the row

Definition at line 214 of file augmented_vector.hpp.

References index, and AugmentedVector< T >::size().

Referenced by AugmentedVector< T >::get_mean(), and AugmentedVector< T >::normalize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Norm2()

template<class T>
T AugmentedVector< T >::Norm2 ( ) const
inline

Return the 2-norm of the vector.

Returns
the 2-norm of the vector

Fixme this works only if exists conversion from 0 to T

Definition at line 159 of file augmented_vector.hpp.

◆ normalize()

template<class T>
void AugmentedVector< T >::normalize ( )
inline

Normalize the row.

Definition at line 276 of file augmented_vector.hpp.

References AugmentedVector< T >::get_sum(), index, AugmentedVector< T >::size(), and sum.

Here is the call graph for this function:

◆ operator*()

template<class T>
T AugmentedVector< T >::operator* ( const AugmentedVector< T > &  other) const
inline

Redefinition of * operator as scalar multiplication.

Parameters
otheris the second operand
Returns
the scalar multiplication

Fixme this works only if exists conversion from 0 to T

Definition at line 114 of file augmented_vector.hpp.

References AugmentedVector< T >::size(), and THROW_ASSERT.

Here is the call graph for this function:

◆ operator-()

template<class T>
AugmentedVector<T> AugmentedVector< T >::operator- ( const AugmentedVector< T > &  other) const
inline

Redefinition of - operator as the difference of the single element.

Parameters
otheris the second operand
Returns
a vector storing the difference of the corresponding elements

Definition at line 133 of file augmented_vector.hpp.

References AugmentedVector< T >::internal_vector, AugmentedVector< T >::size(), and THROW_ASSERT.

Here is the call graph for this function:

◆ operator[]() [1/2]

template<class T>
T& AugmentedVector< T >::operator[] ( size_t  position)
inline

Redefinition of [] operator.

Parameters
positionis the position of the element to get

Definition at line 95 of file augmented_vector.hpp.

◆ operator[]() [2/2]

template<class T>
const T& AugmentedVector< T >::operator[] ( size_t  position) const
inline

Redefinition of [] operator.

Parameters
positionis the position of the element to get

Definition at line 104 of file augmented_vector.hpp.

◆ push_back()

template<class T>
void AugmentedVector< T >::push_back ( const T &  elem)
inline

Inserts a new elment at the end.

Parameters
elemis the element to be inserted

Definition at line 258 of file augmented_vector.hpp.

◆ remove()

template<class T>
void AugmentedVector< T >::remove ( const size_t  index)
inline

Remove an element.

Parameters
indexis the index of the element to be removed

To avoid the cast, we should use a for with ++

Definition at line 238 of file augmented_vector.hpp.

References index.

◆ resize()

template<class T>
void AugmentedVector< T >::resize ( size_t  n,
t = T() 
)
inline

Inserts or erases elements at the end such that the size becomes n.

Parameters
nis the new size of the vector
tis the element to be inserted

Definition at line 268 of file augmented_vector.hpp.

◆ size()

template<class T>
size_t AugmentedVector< T >::size ( ) const
inline

Return the size of the vector.

Returns
the size of the vector

Definition at line 150 of file augmented_vector.hpp.

Referenced by AugmentedVector< T >::get_mean(), AugmentedVector< T >::get_min(), AugmentedVector< T >::get_min_max(), AugmentedVector< T >::get_sum(), AugmentedVector< T >::normalize(), AugmentedVector< T >::operator*(), and AugmentedVector< T >::operator-().

Here is the caller graph for this function:

Field Documentation

◆ internal_vector

template<class T>
std::vector<T> AugmentedVector< T >::internal_vector
private

The class which it logical extended by this (inheritance from template is not allowed)

Definition at line 58 of file augmented_vector.hpp.

Referenced by AugmentedVector< T >::operator-().


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

Generated on Mon Feb 12 2024 13:03:44 for PandA-2024.02 by doxygen 1.8.13