50 #ifndef MERCURYDPM_SMALLVECTOR_H
51 #define MERCURYDPM_SMALLVECTOR_H
60 template<
unsigned int numberOfRows>
84 std::copy(array, array + numberOfRows,
data_.begin());
90 logger.assert_debug(
data.size() == numberOfRows,
"provided array has size %, but should have size %",
91 data.size(), numberOfRows);
103 std::copy(l.begin(), l.end(),
data_.begin());
110 std::transform(
data_.begin(),
data_.end(), right.
data_.begin(), result.
data_.begin(), std::plus<Mdouble>());
117 std::transform(
data_.begin(),
data_.end(), right.
data_.begin(), result.
data_.begin(), std::minus<Mdouble>());
124 std::transform(
data_.begin(),
data_.end(), result.
data_.begin(), std::bind(std::multiplies<Mdouble>(),
125 std::placeholders::_1, right));
132 return std::inner_product(right.
data_.begin(), right.
data_.end(),
data_.begin(), 0.0);
137 std::transform(
data_.begin(),
data_.end(),
data_.begin(), std::bind(std::divides<Mdouble>(),
138 std::placeholders::_1, right));
145 std::transform(
data_.begin(),
data_.end(), result.
data_.begin(), std::bind(std::divides<Mdouble>(),
146 std::placeholders::_1, right));
152 for (
unsigned int i = 0;
i < numberOfRows; ++
i)
162 for (
unsigned int i = 0;
i < numberOfRows; ++
i)
176 for (
unsigned int i = 0;
i < numberOfRows; ++
i)
192 std::transform(
data_.begin(),
data_.end(), right.
data_.begin(),
data_.begin(), std::plus<Mdouble>());
198 std::transform(
data_.begin(),
data_.end(), right.
data_.begin(),
data_.begin(), std::minus<Mdouble>());
204 std::transform(
data_.begin(),
data_.end(),
data_.begin(), std::bind(std::multiplies<Mdouble>(),
205 std::placeholders::_1, right));
211 logger.assert_debug(
n < numberOfRows,
"Requested entry %, but there are only % entries",
n, numberOfRows);
217 logger.assert_debug(
n < numberOfRows,
"Requested entry %, but there are only % entries",
n, numberOfRows);
223 logger.assert_debug(
n < numberOfRows,
"Requested entry %, but there are only % entries",
n, numberOfRows);
229 logger.assert_debug(
n < numberOfRows,
"Requested entry %, but there are only % entries",
n, numberOfRows);
261 return std::sqrt(sum);
266 return (*
this) /
length();
270 std::array<Mdouble, numberOfRows>
data_;
274 template<
unsigned int numberOfRows>
280 template<
unsigned int numberOfRows>
284 for (std::size_t
i = 0;
i < numberOfRows; ++
i)
const unsigned n
Definition: CG3DPackingUnitTest.cpp:32
double Mdouble
Definition: GeneralDefine.h:34
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
std::ostream & operator<<(std::ostream &os, const SmallVector< numberOfRows > &A)
Definition: SmallVector.h:281
SmallVector< numberOfRows > operator*(const Mdouble &left, const SmallVector< numberOfRows > &right)
Definition: SmallVector.h:275
@ A
Definition: StatisticsVector.h:42
Definition: SmallVector.h:62
Mdouble operator*(const SmallVector &right) const
Computes inner product between two vectors.
Definition: SmallVector.h:130
SmallVector< numberOfRows > getNormalised() const
Definition: SmallVector.h:264
Mdouble length() const
Definition: SmallVector.h:253
const Mdouble & operator()(unsigned int n) const
Definition: SmallVector.h:227
bool operator<(const SmallVector &right) const
Definition: SmallVector.h:174
SmallVector & operator*=(const double &right)
Definition: SmallVector.h:202
unsigned int size() const
Definition: SmallVector.h:233
SmallVector(const Mdouble array[])
Definition: SmallVector.h:81
SmallVector operator*(const Mdouble &right) const
Definition: SmallVector.h:121
SmallVector operator/(const Mdouble &right) const
Definition: SmallVector.h:142
SmallVector & operator=(const std::array< Mdouble, numberOfRows > l)
Definition: SmallVector.h:101
Mdouble * data()
Definition: SmallVector.h:243
Mdouble & operator[](unsigned int n)
Definition: SmallVector.h:209
SmallVector(const SmallVector &other)
Definition: SmallVector.h:71
const Mdouble & operator[](unsigned int n) const
Definition: SmallVector.h:215
SmallVector(std::initializer_list< Mdouble > data)
Definition: SmallVector.h:87
SmallVector & operator=(const SmallVector &right)
Definition: SmallVector.h:95
std::array< Mdouble, numberOfRows > data_
Definition: SmallVector.h:270
SmallVector operator-() const
Definition: SmallVector.h:248
void axpy(Mdouble a, const SmallVector &x)
Definition: SmallVector.h:150
SmallVector(SmallVector &&other)
Definition: SmallVector.h:76
SmallVector & operator+=(const SmallVector &right)
Definition: SmallVector.h:190
Mdouble & operator()(unsigned int n)
Definition: SmallVector.h:221
SmallVector operator-(const SmallVector &right) const
Definition: SmallVector.h:114
const Mdouble * data() const
Definition: SmallVector.h:238
SmallVector & operator-=(const SmallVector &right)
Definition: SmallVector.h:196
SmallVector()
Definition: SmallVector.h:66
bool operator==(const SmallVector &right) const
Definition: SmallVector.h:160
SmallVector operator+(const SmallVector &right) const
Definition: SmallVector.h:107
SmallVector & operator/=(const Mdouble &right)
Definition: SmallVector.h:135
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51