NumericalVector< T > Class Template Reference

#include <NumericalVector.h>

Public Member Functions

 NumericalVector ()
 
 NumericalVector (std::size_t m)
 
 NumericalVector (std::initializer_list< T > l)
 
 NumericalVector (const NumericalVector &other)
 
 NumericalVector (NumericalVector &&other)
 
 NumericalVector (const T array[], std::size_t size)
 
void resize (std::size_t size)
 
NumericalVector< T > & operator= (const NumericalVector< T > &right)
 
NumericalVector< T > & operator= (const std::initializer_list< T > l)
 
NumericalVector< T > operator+ (const NumericalVector< T > &right) const
 
NumericalVector< T > operator- (const NumericalVector< T > &right) const
 
NumericalVector< T > operator* (const T &right) const
 
operator* (const NumericalVector &right) const
 
NumericalVector< T > & operator/= (const T &right)
 
NumericalVector< T > operator/ (const T &right) const
 
NumericalVector< T > & operator+= (const NumericalVector< T > &right)
 
NumericalVector< T > & operator-= (const NumericalVector< T > &right)
 
NumericalVector< T > & operator*= (const T &right)
 
T & operator[] (std::size_t n)
 
const T & operator[] (std::size_t n) const
 
T & operator() (std::size_t n)
 
const T & operator() (std::size_t n) const
 
std::size_t size () const
 
const T * data () const
 
T * data ()
 

Private Attributes

std::vector< T > data_
 

Constructor & Destructor Documentation

◆ NumericalVector() [1/6]

template<typename T = Mdouble>
NumericalVector< T >::NumericalVector ( )
inline
68  : data_()
69  {
70  }
std::vector< T > data_
Definition: NumericalVector.h:232

◆ NumericalVector() [2/6]

template<typename T = Mdouble>
NumericalVector< T >::NumericalVector ( std::size_t  m)
inlineexplicit
73  : data_(m)
74  {
75  }

◆ NumericalVector() [3/6]

template<typename T = Mdouble>
NumericalVector< T >::NumericalVector ( std::initializer_list< T >  l)
inline
78  : data_(l)
79  {
80  }

◆ NumericalVector() [4/6]

template<typename T = Mdouble>
NumericalVector< T >::NumericalVector ( const NumericalVector< T > &  other)
inline
83  : data_(other.data_)
84  {
85  }

◆ NumericalVector() [5/6]

template<typename T = Mdouble>
NumericalVector< T >::NumericalVector ( NumericalVector< T > &&  other)
inline
88  : data_(std::move(other.data_))
89  {
90  }

◆ NumericalVector() [6/6]

template<typename T = Mdouble>
NumericalVector< T >::NumericalVector ( const T  array[],
std::size_t  size 
)
inline
93  : data_(array, array + size)
94  {
95  }
std::size_t size() const
Definition: NumericalVector.h:216

Member Function Documentation

◆ data() [1/2]

template<typename T = Mdouble>
T* NumericalVector< T >::data ( )
inline
227  {
228  return data_.data();
229  }

References NumericalVector< T >::data_.

◆ data() [2/2]

template<typename T = Mdouble>
const T* NumericalVector< T >::data ( ) const
inline
222  {
223  return data_.data();
224  }

References NumericalVector< T >::data_.

◆ operator()() [1/2]

template<typename T = Mdouble>
T& NumericalVector< T >::operator() ( std::size_t  n)
inline
205  {
206  logger.assert_debug(n < data_.size(), "Requested entry %, but there are only % entries", n, data_.size());
207  return data_[n];
208  }
const unsigned n
Definition: CG3DPackingUnitTest.cpp:32
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.

References NumericalVector< T >::data_, logger, and n.

◆ operator()() [2/2]

template<typename T = Mdouble>
const T& NumericalVector< T >::operator() ( std::size_t  n) const
inline
211  {
212  logger.assert_debug(n < data_.size(), "Requested entry %, but there are only % entries", n, data_.size());
213  return data_[n];
214  }

References NumericalVector< T >::data_, logger, and n.

◆ operator*() [1/2]

template<typename T = Mdouble>
T NumericalVector< T >::operator* ( const NumericalVector< T > &  right) const
inline
145  {
146  logger.assert_debug(data_.size() == right.data_.size(), "Vectors don't have equal length.");
147  T sum = 0;
148  for (std::size_t i = 0; i < data_.size(); i++)
149  sum += data_[i] * right.data_[i];
150  return sum;
151  }
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51

References NumericalVector< T >::data_, constants::i, and logger.

◆ operator*() [2/2]

template<typename T = Mdouble>
NumericalVector<T> NumericalVector< T >::operator* ( const T &  right) const
inline
136  {
137  NumericalVector<T> result(*this);
138  for (T& d : result.data_)
139  d *= right;
140  return result;
141  }
This is a vector of doubles.

◆ operator*=()

template<typename T = Mdouble>
NumericalVector<T>& NumericalVector< T >::operator*= ( const T &  right)
inline
186  {
187  for (T& d : data_)
188  d *= right;
189  return *this;
190  }

References NumericalVector< T >::data_.

◆ operator+()

template<typename T = Mdouble>
NumericalVector<T> NumericalVector< T >::operator+ ( const NumericalVector< T > &  right) const
inline
118  {
119  NumericalVector<T> result(*this);
120  logger.assert_debug(data_.size() == right.data_.size(), "Vectors don't have the same size");
121  for (std::size_t i = 0; i < data_.size(); i++)
122  result.data_[i] += right.data_[i];
123  return result;
124  }

References NumericalVector< T >::data_, constants::i, and logger.

◆ operator+=()

template<typename T = Mdouble>
NumericalVector<T>& NumericalVector< T >::operator+= ( const NumericalVector< T > &  right)
inline
169  {
170  logger.assert_debug(data_.size() == right.data_.size(), "Vectors don't have the same size");
171  for (std::size_t i = 0; i < data_.size(); i++)
172  data_[i] += right.data_[i];
173  return *this;
174  }

References NumericalVector< T >::data_, constants::i, and logger.

◆ operator-()

template<typename T = Mdouble>
NumericalVector<T> NumericalVector< T >::operator- ( const NumericalVector< T > &  right) const
inline
127  {
128  NumericalVector<T> result(*this);
129  logger.assert_debug(data_.size() == right.data_.size(), "Vectors don't have the same size");
130  for (std::size_t i = 0; i < data_.size(); i++)
131  result.data_[i] -= right.data_[i];
132  return result;
133  }

References NumericalVector< T >::data_, constants::i, and logger.

◆ operator-=()

template<typename T = Mdouble>
NumericalVector<T>& NumericalVector< T >::operator-= ( const NumericalVector< T > &  right)
inline
178  {
179  logger.assert_debug(data_.size() == right.data_.size(), "Vectors don't have the same size");
180  for (std::size_t i = 0; i < data_.size(); i++)
181  data_[i] -= right.data_[i];
182  return *this;
183  }

References NumericalVector< T >::data_, constants::i, and logger.

◆ operator/()

template<typename T = Mdouble>
NumericalVector<T> NumericalVector< T >::operator/ ( const T &  right) const
inline
162  {
163  NumericalVector<T> result(*this);
164  return (result /= right);
165 
166  }

◆ operator/=()

template<typename T = Mdouble>
NumericalVector<T>& NumericalVector< T >::operator/= ( const T &  right)
inline
154  {
155  for (T& d : data_)
156  d /= right;
157 
158  return *this;
159  }

References NumericalVector< T >::data_.

◆ operator=() [1/2]

template<typename T = Mdouble>
NumericalVector<T>& NumericalVector< T >::operator= ( const NumericalVector< T > &  right)
inline
106  {
107  data_ = right.data_;
108  return *this;
109  }

References NumericalVector< T >::data_.

◆ operator=() [2/2]

template<typename T = Mdouble>
NumericalVector<T>& NumericalVector< T >::operator= ( const std::initializer_list< T >  l)
inline
112  {
113  data_ = l;
114  return *this;
115  }

References NumericalVector< T >::data_.

◆ operator[]() [1/2]

template<typename T = Mdouble>
T& NumericalVector< T >::operator[] ( std::size_t  n)
inline
193  {
194  logger.assert_debug(n < data_.size(), "Requested entry %, but there are only % entries", n, data_.size());
195  return data_[n];
196  }

References NumericalVector< T >::data_, logger, and n.

◆ operator[]() [2/2]

template<typename T = Mdouble>
const T& NumericalVector< T >::operator[] ( std::size_t  n) const
inline
199  {
200  logger.assert_debug(n < data_.size(), "Requested entry %, but there are only % entries", n, data_.size());
201  return data_[n];
202  }

References NumericalVector< T >::data_, logger, and n.

◆ resize()

template<typename T = Mdouble>
void NumericalVector< T >::resize ( std::size_t  size)
inline
98  {
99  if (size != data_.size())
100  {
101  data_.resize(size);
102  }
103  }

References NumericalVector< T >::data_, and NumericalVector< T >::size().

◆ size()

template<typename T = Mdouble>
std::size_t NumericalVector< T >::size ( ) const
inline
217  {
218  return data_.size();
219  }

References NumericalVector< T >::data_.

Referenced by NumericalVector< T >::resize().

Member Data Documentation

◆ data_


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