BioDynaMo  v1.05.0-137fdb15
Public Member Functions | Private Member Functions | Private Attributes | List of all members
bdm::MathArray< T, N > Class Template Reference

#include <math_array.h>

Public Member Functions

 MathArray ()
 Default constructor. More...
 
constexpr MathArray (std::initializer_list< T > l)
 
const T * data () const
 
const size_t size () const
 
const bool empty () const
 
T & operator[] (size_t idx)
 
const T & operator[] (size_t idx) const
 
T & at (size_t idx) noexcept(false)
 
const T * begin () const
 
const T * end () const
 
T * begin ()
 
T * end ()
 
T & front ()
 
T & back ()
 
MathArrayoperator= (const MathArray &other)
 
bool operator== (const MathArray &other) const
 
bool operator!= (const MathArray &other) const
 
MathArrayoperator++ ()
 
MathArray operator++ (int)
 
MathArrayoperator-- ()
 
MathArray operator-- (int)
 
MathArrayoperator+= (const MathArray &rhs)
 
MathArray operator+ (const MathArray &rhs)
 
const MathArray operator+ (const MathArray &rhs) const
 
MathArrayoperator+= (const T &rhs)
 
MathArray operator+ (const T &rhs)
 
MathArrayoperator-= (const MathArray &rhs)
 
MathArray operator- (const MathArray &rhs)
 
const MathArray operator- (const MathArray &rhs) const
 
MathArrayoperator-= (const T &rhs)
 
MathArray operator- (const T &rhs)
 
T & operator*= (const MathArray &rhs)=delete
 
operator* (const MathArray &rhs)
 
const T operator* (const MathArray &rhs) const
 
MathArrayoperator*= (const T &k)
 
MathArray operator* (const T &k)
 
const MathArray operator* (const T &k) const
 
MathArrayoperator/= (const T &k)
 
MathArray operator/ (const T &k)
 
MathArrayfill (const T &k)
 
Sum () const
 
bool IsZero () const
 Checks if vector is a zero vector, e.g. if all entries are zero. More...
 
Norm () const
 
void Normalize ()
 Normalize the array in-place. More...
 
void Normalize (T norm)
 
MathArray GetNormalizedArray () const
 Get a nomalized copy of the MathArray. More...
 
MathArray EntryWiseProduct (const MathArray &rhs) const
 

Private Member Functions

 BDM_CLASS_DEF_NV (MathArray, 1)
 

Private Attributes

data_ [N]
 

Detailed Description

template<class T, std::size_t N>
class bdm::MathArray< T, N >

Array with a fixed number of elements. It implements the same behaviour of the standard std::array<T, N> container. However, it provides also several custom mathematical operations (e.g. Sum(), Norm() etc.).

Definition at line 36 of file math_array.h.

Constructor & Destructor Documentation

◆ MathArray() [1/2]

template<class T , std::size_t N>
bdm::MathArray< T, N >::MathArray ( )
inline

Default constructor.

Definition at line 39 of file math_array.h.

◆ MathArray() [2/2]

template<class T , std::size_t N>
constexpr bdm::MathArray< T, N >::MathArray ( std::initializer_list< T >  l)
inlineconstexpr

Constructor which accepts an std::initializer_list to set the array's content.

Parameters
lan initializer list

Definition at line 49 of file math_array.h.

Member Function Documentation

◆ at()

template<class T , std::size_t N>
T& bdm::MathArray< T, N >::at ( size_t  idx)
inlinenoexcept

Returns the element at the given position. It will throw an std::out_of_range exception if the given index is out of the array's boundaries.

Parameters
idxthe index of the element.
Returns
the requested element.

Definition at line 88 of file math_array.h.

◆ back()

template<class T , std::size_t N>
T& bdm::MathArray< T, N >::back ( )
inline

Return the element at the end of the array.

Returns
last element.

Definition at line 109 of file math_array.h.

◆ BDM_CLASS_DEF_NV()

template<class T , std::size_t N>
bdm::MathArray< T, N >::BDM_CLASS_DEF_NV ( MathArray< T, N >  ,
 
)
private

◆ begin() [1/2]

template<class T , std::size_t N>
T* bdm::MathArray< T, N >::begin ( )
inline

Definition at line 99 of file math_array.h.

◆ begin() [2/2]

template<class T , std::size_t N>
const T* bdm::MathArray< T, N >::begin ( ) const
inline

Definition at line 95 of file math_array.h.

◆ data()

template<class T , std::size_t N>
const T* bdm::MathArray< T, N >::data ( ) const
inline

Return a pointer to the underlying data.

Returns
cont T pointer to the first entry of the array.

Definition at line 62 of file math_array.h.

◆ empty()

template<class T , std::size_t N>
const bool bdm::MathArray< T, N >::empty ( ) const
inline

Check if the array is empty.

Returns
true if size() == 0, false otherwise.

Definition at line 70 of file math_array.h.

◆ end() [1/2]

template<class T , std::size_t N>
T* bdm::MathArray< T, N >::end ( )
inline

Definition at line 101 of file math_array.h.

◆ end() [2/2]

template<class T , std::size_t N>
const T* bdm::MathArray< T, N >::end ( ) const
inline

Definition at line 97 of file math_array.h.

◆ EntryWiseProduct()

template<class T , std::size_t N>
MathArray bdm::MathArray< T, N >::EntryWiseProduct ( const MathArray< T, N > &  rhs) const
inline

Compute the entry wise product given another array of the same size.

Parameters
rhsthe other array
Returns
a new array with the result

Definition at line 396 of file math_array.h.

◆ fill()

template<class T , std::size_t N>
MathArray& bdm::MathArray< T, N >::fill ( const T &  k)
inline

Fill the MathArray with a constant value.

Parameters
kthe constant value
Returns
the array

Definition at line 331 of file math_array.h.

◆ front()

template<class T , std::size_t N>
T& bdm::MathArray< T, N >::front ( )
inline

Returns the element at the beginning of the array.

Returns
first element.

Definition at line 105 of file math_array.h.

◆ GetNormalizedArray()

template<class T , std::size_t N>
MathArray bdm::MathArray< T, N >::GetNormalizedArray ( ) const
inline

Get a nomalized copy of the MathArray.

Definition at line 386 of file math_array.h.

◆ IsZero()

template<class T , std::size_t N>
bool bdm::MathArray< T, N >::IsZero ( ) const
inline

Checks if vector is a zero vector, e.g. if all entries are zero.

Definition at line 341 of file math_array.h.

◆ Norm()

template<class T , std::size_t N>
T bdm::MathArray< T, N >::Norm ( ) const
inline

Compute the norm of the array's content.

Returns
array's norm.

Definition at line 352 of file math_array.h.

◆ Normalize() [1/2]

template<class T , std::size_t N>
void bdm::MathArray< T, N >::Normalize ( )
inline

Normalize the array in-place.

Definition at line 364 of file math_array.h.

◆ Normalize() [2/2]

template<class T , std::size_t N>
void bdm::MathArray< T, N >::Normalize ( norm)
inline

Normalize the array in-place.
If the calling code has already calculated the norm, this function signature ensures that the norm calculation is not duplicated.

Definition at line 373 of file math_array.h.

◆ operator!=()

template<class T , std::size_t N>
bool bdm::MathArray< T, N >::operator!= ( const MathArray< T, N > &  other) const
inline

Definition at line 141 of file math_array.h.

◆ operator*() [1/4]

template<class T , std::size_t N>
T bdm::MathArray< T, N >::operator* ( const MathArray< T, N > &  rhs)
inline

Definition at line 265 of file math_array.h.

◆ operator*() [2/4]

template<class T , std::size_t N>
const T bdm::MathArray< T, N >::operator* ( const MathArray< T, N > &  rhs) const
inline

Definition at line 275 of file math_array.h.

◆ operator*() [3/4]

template<class T , std::size_t N>
MathArray bdm::MathArray< T, N >::operator* ( const T &  k)
inline

Definition at line 293 of file math_array.h.

◆ operator*() [4/4]

template<class T , std::size_t N>
const MathArray bdm::MathArray< T, N >::operator* ( const T &  k) const
inline

Definition at line 302 of file math_array.h.

◆ operator*=() [1/2]

template<class T , std::size_t N>
T& bdm::MathArray< T, N >::operator*= ( const MathArray< T, N > &  rhs)
delete

◆ operator*=() [2/2]

template<class T , std::size_t N>
MathArray& bdm::MathArray< T, N >::operator*= ( const T &  k)
inline

Definition at line 285 of file math_array.h.

◆ operator+() [1/3]

template<class T , std::size_t N>
MathArray bdm::MathArray< T, N >::operator+ ( const MathArray< T, N > &  rhs)
inline

Definition at line 180 of file math_array.h.

◆ operator+() [2/3]

template<class T , std::size_t N>
const MathArray bdm::MathArray< T, N >::operator+ ( const MathArray< T, N > &  rhs) const
inline

Definition at line 190 of file math_array.h.

◆ operator+() [3/3]

template<class T , std::size_t N>
MathArray bdm::MathArray< T, N >::operator+ ( const T &  rhs)
inline

Definition at line 208 of file math_array.h.

◆ operator++() [1/2]

template<class T , std::size_t N>
MathArray& bdm::MathArray< T, N >::operator++ ( )
inline

Definition at line 143 of file math_array.h.

◆ operator++() [2/2]

template<class T , std::size_t N>
MathArray bdm::MathArray< T, N >::operator++ ( int  )
inline

Definition at line 151 of file math_array.h.

◆ operator+=() [1/2]

template<class T , std::size_t N>
MathArray& bdm::MathArray< T, N >::operator+= ( const MathArray< T, N > &  rhs)
inline

Definition at line 171 of file math_array.h.

◆ operator+=() [2/2]

template<class T , std::size_t N>
MathArray& bdm::MathArray< T, N >::operator+= ( const T &  rhs)
inline

Definition at line 200 of file math_array.h.

◆ operator-() [1/3]

template<class T , std::size_t N>
MathArray bdm::MathArray< T, N >::operator- ( const MathArray< T, N > &  rhs)
inline

Definition at line 226 of file math_array.h.

◆ operator-() [2/3]

template<class T , std::size_t N>
const MathArray bdm::MathArray< T, N >::operator- ( const MathArray< T, N > &  rhs) const
inline

Definition at line 236 of file math_array.h.

◆ operator-() [3/3]

template<class T , std::size_t N>
MathArray bdm::MathArray< T, N >::operator- ( const T &  rhs)
inline

Definition at line 254 of file math_array.h.

◆ operator--() [1/2]

template<class T , std::size_t N>
MathArray& bdm::MathArray< T, N >::operator-- ( )
inline

Definition at line 157 of file math_array.h.

◆ operator--() [2/2]

template<class T , std::size_t N>
MathArray bdm::MathArray< T, N >::operator-- ( int  )
inline

Definition at line 165 of file math_array.h.

◆ operator-=() [1/2]

template<class T , std::size_t N>
MathArray& bdm::MathArray< T, N >::operator-= ( const MathArray< T, N > &  rhs)
inline

Definition at line 217 of file math_array.h.

◆ operator-=() [2/2]

template<class T , std::size_t N>
MathArray& bdm::MathArray< T, N >::operator-= ( const T &  rhs)
inline

Definition at line 246 of file math_array.h.

◆ operator/()

template<class T , std::size_t N>
MathArray bdm::MathArray< T, N >::operator/ ( const T &  k)
inline

Definition at line 319 of file math_array.h.

◆ operator/=()

template<class T , std::size_t N>
MathArray& bdm::MathArray< T, N >::operator/= ( const T &  k)
inline

Definition at line 311 of file math_array.h.

◆ operator=()

template<class T , std::size_t N>
MathArray& bdm::MathArray< T, N >::operator= ( const MathArray< T, N > &  other)
inline

Assignment operator.

Parameters
otherthe other MathArray instance.
Returns
the current MathArray.

Definition at line 118 of file math_array.h.

◆ operator==()

template<class T , std::size_t N>
bool bdm::MathArray< T, N >::operator== ( const MathArray< T, N > &  other) const
inline

Equality operator.

Parameters
othera MathArray instance.
Returns
true if they have the same content, false otherwise.

Definition at line 129 of file math_array.h.

◆ operator[]() [1/2]

template<class T , std::size_t N>
T& bdm::MathArray< T, N >::operator[] ( size_t  idx)
inline

Overloaded array subscript operator. It does not perform any boundary checks.

Parameters
idxelement's index.
Returns
the requested element.

Definition at line 76 of file math_array.h.

◆ operator[]() [2/2]

template<class T , std::size_t N>
const T& bdm::MathArray< T, N >::operator[] ( size_t  idx) const
inline

Const overloaded array subscript operator.

Parameters
idxelement's index.
Returns
the requested element.

Definition at line 81 of file math_array.h.

◆ size()

template<class T , std::size_t N>
const size_t bdm::MathArray< T, N >::size ( ) const
inline

Return the size of the array.

Returns
integer denoting the array's size.

Definition at line 66 of file math_array.h.

◆ Sum()

template<class T , std::size_t N>
T bdm::MathArray< T, N >::Sum ( ) const
inline

Return the sum of all the array's elements.

Returns
sum of the array's content.

Definition at line 338 of file math_array.h.

Member Data Documentation

◆ data_

template<class T , std::size_t N>
T bdm::MathArray< T, N >::data_[N]
private

Definition at line 407 of file math_array.h.


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