MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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_
 

Detailed Description

template<typename T = Mdouble>
class NumericalVector< T >

Definition at line 63 of file NumericalVector.h.

Constructor & Destructor Documentation

template<typename T = Mdouble>
NumericalVector< T >::NumericalVector ( )
inline

Definition at line 67 of file NumericalVector.h.

68  : data_()
69  {
70  }
std::vector< T > data_
template<typename T = Mdouble>
NumericalVector< T >::NumericalVector ( std::size_t  m)
inlineexplicit

Definition at line 72 of file NumericalVector.h.

73  : data_(m)
74  {
75  }
std::vector< T > data_
template<typename T = Mdouble>
NumericalVector< T >::NumericalVector ( std::initializer_list< T >  l)
inline

Definition at line 77 of file NumericalVector.h.

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

Definition at line 82 of file NumericalVector.h.

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

Definition at line 87 of file NumericalVector.h.

88  : data_(std::move(other.data_))
89  {
90  }
std::vector< T > data_
template<typename T = Mdouble>
NumericalVector< T >::NumericalVector ( const T  array[],
std::size_t  size 
)
inline

Definition at line 92 of file NumericalVector.h.

93  : data_(array, array + size)
94  {
95  }
std::vector< T > data_
std::size_t size() const

Member Function Documentation

template<typename T = Mdouble>
const T* NumericalVector< T >::data ( ) const
inline

Definition at line 221 of file NumericalVector.h.

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

Definition at line 226 of file NumericalVector.h.

227  {
228  return data_.data();
229  }
std::vector< T > data_
template<typename T = Mdouble>
T& NumericalVector< T >::operator() ( std::size_t  n)
inline

Definition at line 204 of file NumericalVector.h.

205  {
206  logger.assert(n < data_.size(), "Requested entry %, but there are only % entries", n, data_.size());
207  return data_[n];
208  }
std::vector< T > data_
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
template<typename T = Mdouble>
const T& NumericalVector< T >::operator() ( std::size_t  n) const
inline

Definition at line 210 of file NumericalVector.h.

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

Definition at line 135 of file NumericalVector.h.

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.
template<typename T = Mdouble>
T NumericalVector< T >::operator* ( const NumericalVector< T > &  right) const
inline

Definition at line 144 of file NumericalVector.h.

145  {
146  logger.assert(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  }
std::vector< T > data_
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
template<typename T = Mdouble>
NumericalVector<T>& NumericalVector< T >::operator*= ( const T &  right)
inline

Definition at line 185 of file NumericalVector.h.

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

Definition at line 117 of file NumericalVector.h.

118  {
119  NumericalVector<T> result(*this);
120  logger.assert(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  }
std::vector< T > data_
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
This is a vector of doubles.
template<typename T = Mdouble>
NumericalVector<T>& NumericalVector< T >::operator+= ( const NumericalVector< T > &  right)
inline

Definition at line 168 of file NumericalVector.h.

169  {
170  logger.assert(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  }
std::vector< T > data_
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
template<typename T = Mdouble>
NumericalVector<T> NumericalVector< T >::operator- ( const NumericalVector< T > &  right) const
inline

Definition at line 126 of file NumericalVector.h.

127  {
128  NumericalVector<T> result(*this);
129  logger.assert(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  }
std::vector< T > data_
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
This is a vector of doubles.
template<typename T = Mdouble>
NumericalVector<T>& NumericalVector< T >::operator-= ( const NumericalVector< T > &  right)
inline

Definition at line 177 of file NumericalVector.h.

178  {
179  logger.assert(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  }
std::vector< T > data_
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
template<typename T = Mdouble>
NumericalVector<T> NumericalVector< T >::operator/ ( const T &  right) const
inline

Definition at line 161 of file NumericalVector.h.

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

Definition at line 153 of file NumericalVector.h.

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

Definition at line 105 of file NumericalVector.h.

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

Definition at line 111 of file NumericalVector.h.

112  {
113  data_ = l;
114  return *this;
115  }
std::vector< T > data_
template<typename T = Mdouble>
T& NumericalVector< T >::operator[] ( std::size_t  n)
inline

Definition at line 192 of file NumericalVector.h.

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

Definition at line 198 of file NumericalVector.h.

199  {
200  logger.assert(n < data_.size(), "Requested entry %, but there are only % entries", n, data_.size());
201  return data_[n];
202  }
std::vector< T > data_
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
template<typename T = Mdouble>
void NumericalVector< T >::resize ( std::size_t  size)
inline

Definition at line 97 of file NumericalVector.h.

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

Member Data Documentation


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