26#ifndef ASLVECTORSDYNAMICLENGTHOPERATIONS_H
27#define ASLVECTORSDYNAMICLENGTHOPERATIONS_H
30#include "../aslUtilities.h"
38 template <
typename T1,
typename T2>
132 template <
typename T>
140 template <
typename T1,
typename T2>
147 template <
typename T>
inline const T
l2(
const AVec<T> &
a)
160 errorMessage(
"(AVec; operator+) Vector sizes are incompatible");
162 for (
unsigned int i(0); i <
a.getSize(); ++i)
170 errorMessage(
"(AVec; operator-) Vector sizes are incompatible");
172 for (
unsigned int i(0); i <
a.getSize(); ++i)
180 for (
unsigned int i(0); i <
a.getSize(); ++i)
187 errorMessage(
"(AVec; operator*) Vector sizes are incompatible");
189 for (
unsigned int i(0); i <
a.getSize(); ++i)
196 for (
unsigned int i(0); i <
a.getSize(); ++i)
207 for (
unsigned int i(0); i <
a.getSize(); ++i)
215 for (
unsigned int i(0); i <
a.getSize(); ++i)
223 for (
unsigned int i(0); i <
a.size; ++i)
229 for (
unsigned int i(0); i <
a.getSize(); ++i)
240 for (
unsigned int i(0); i <
a.getSize(); ++i)
241 c = c && (
a[i] == b[i]);
252 template <
typename T>
256 errorMessage(
"(AVec; crossProduct) Vector sizes are incompatible");
258 errorMessage(
"(AVec; crossProduct) number of components is more than 3");
260 errorMessage(
"(AVec; crossProduct) number of components is less than 2");
265 res[0] =
a[0]*b[1]-
a[1]*b[0];
270 res[0] =
a[1]*b[2]-
a[2]*b[1];
271 res[1] =
a[2]*b[0]-
a[0]*b[2];
272 res[2] =
a[0]*b[1]-
a[1]*b[0];
280 for (
unsigned int i(1); i <
a.getSize(); ++i)
281 ma = std::min(
ma,
a[i]);
289 for (
unsigned int i(1); i <
a.getSize(); ++i)
290 ma=std::max(
ma,
a[i]);
295 unsigned int start,
unsigned int end)
297 if (source.getSize() <=
end )
298 errorMessage(
"subAVec: attempt to copy besides the vector range");
301 for (
unsigned int i(start); i <=
end; ++i)
302 destination[i - start] = source[i];
309 for (
unsigned int i(0); i <
a.getSize(); ++i)
317 for (
unsigned int i(0); i <
a.getSize(); ++i)
326 errorMessage(
"(AVec; productOfElements) Vector sizes are incompatible");
328 for (
unsigned int i(0); i <
a.getSize(); ++i)
336 errorMessage(
"(AVec; divisionOfElements) Vector sizes are incompatible");
339 for (
unsigned int i(0); i <
a.getSize(); ++i)
350 for (
unsigned int i(1); i <
a.getSize(); ++i)
360 for (
unsigned int i(1); i <
a.getSize(); ++i)
369 AVec<int> res(
a.getSize());
370 for (
unsigned int i(0); i <
a.getSize(); ++i)
371 res[i] = std::floor(
a[i]);
379 AVec<int> res(
a.getSize());
380 for (
unsigned int i(0); i <
a.getSize(); ++i)
381 res[i] = std::round(
a[i]);
388 if (coefs.getSize() < 1)
389 errorMessage(
"Error: (asl::computePolynom) size of \"coefs\" less than 1");
392 for (
unsigned int i(1); i < coefs.getSize(); ++i)
403 std::swap(res[0],res[2]);
const AVec swapXZ(const AVec<> &a)
returns true in case when all components of a more then 0
const unsigned int & getSize() const
SPDataWrapperACLData generateDataContainerACL_SP(const Block &b, unsigned int n=1)
generates pointer to ACL Data field with n components
void errorMessage(cl_int status, const char *errorMessage)
Prints errorMessage and exits depending on the status.
SPDistanceFunction normalize(SPDistanceFunction a, double dx)
SPDistanceFunction operator-(SPDistanceFunction a)
SPPositionFunction operator*(SPPositionFunction a, SPPositionFunction b)
Advanced Simulation Library.
const T minComponent(const AVec< T > &a)
double computePolynom(double x, AVec<> &coefs)
const AVec< T > divisionOfElements(const AVec< T > &a, const AVec< T > &b)
T productOfElements(const AVec< T > &a)
std::ostream & operator<<(std::ostream &output, const std::vector< T > &vector)
Prints elements of the vector separated by space.
const AVec< T > & operator*=(AVec< T > &a, const T &b)
const AVec< int > round(const AVec<> &a)
AVec< T > subAVec(const AVec< T > &source, unsigned int start, unsigned int end)
const AMatr< T > operator+(const AMatr< T > &a, const AMatr< T > &b)
bool operator==(const std::vector< T > &vector1, const std::vector< T > &vector2)
Compares two vectors.
T sumOfElements(const AVec< T > &a)
const AVec< T > & operator-=(AVec< T > &a, const AVec< T > &b)
const T maxComponent(const AVec< T > &a)
const AMatr< T > & operator+=(AMatr< T > &a, const AMatr< T > &b)
const T l2(const AVec< T > &a)
const AVec< T > crossProduct(const AVec< T > &a, const AVec< T > &b)
const bool positive(const AVec< T > &a)
bool compatibleSizes(AVec< T1 > a, AVec< T2 > b)
const AVec< int > floor(const AVec<> &a)
const AMatr< T > operator/(const AMatr< T > &b, const T &a)
const bool operator!=(const AVec< T > &a, const AVec< T > &b)
const bool nonNegative(const AVec< T > &a)