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)
289 for (
unsigned int i(1); i < a.
getSize(); ++i)
295 unsigned int start,
unsigned int end)
298 errorMessage(
"subAVec: attempt to copy besides the vector range");
300 AVec<T> destination(1 + end - start);
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)
370 for (
unsigned int i(0); i < a.
getSize(); ++i)
380 for (
unsigned int i(0); i < a.
getSize(); ++i)
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 bool nonNegative(const AVec< T > &a)
returns true in case when all components of a more or equal 0
const AVec< T > operator-(const AVec< T > &a, const AVec< T > &b)
const AVec< T > divisionOfElements(const AVec< T > &a, const AVec< T > &b)
returns vector which elements are division of corresponding elements of a and b
const bool operator!=(const AVec< T > &a, const AVec< T > &b)
const bool positive(const AVec< T > &a)
returns true in case when all components of a more or then 0
const AVec< T > operator*(const T &a, const AVec< T > &b)
const bool operator==(const AVec< T > &a, const AVec< T > &b)
const AVec swapXZ(const AVec<> &a)
returns true in case when all components of a more then 0
T sumOfElements(const AVec< T > &a)
returns summ of all components
const AVec< T > & operator-=(AVec< T > &a, const AVec< T > &b)
const T minComponent(const AVec< T > &a)
returns minimal component
const AVec< T > operator-(const AVec< T > &a)
T productOfElements(const AVec< T > &a)
returns product of all components
const T l2(const AVec< T > &a)
const AVec< T > operator+(const AVec< T > &a, const AVec< T > &b)
bool compatibleSizes(AVec< T1 > a, AVec< T2 > b)
The function checks whether the sizes are equal.
const AVec< T > operator/(const AVec< T > &a, const T &b)
const T operator*(const AVec< T > &a, const AVec< T > &b)
double computePolynom(double x, AVec<> &coefs)
computes polynom for x with coefs
const T maxComponent(const AVec< T > &a)
returns maximal component
const AVec< T > operator*(const AVec< T > &a, const T &b)
const AVec< int > floor(const AVec<> &a)
returns true in case when all components of a more then 0
const AVec< T > crossProduct(const AVec< T > &a, const AVec< T > &b)
const AVec< T > productOfElements(const AVec< T > &a, const AVec< T > &b)
returns vector which elements are product of corresponding elements of a and b
const unsigned int & getSize() const
const AVec< T > & operator+=(AVec< T > &a, const AVec< T > &b)
const AVec normalize(const AVec< T > &a)
const AVec< T > & operator*=(AVec< T > &a, const T &b)
void resize(unsigned int newSize)
const AVec< int > round(const AVec<> &a)
returns true in case when all components of a more then 0
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)
Element max(Element a, Element b)
Element min(Element a, Element b)
SPPositionFunction operator*(SPPositionFunction a, SPPositionFunction b)
Advanced Simulation Library.
const AMatr< T > operator+(const AMatr< T > &a, const AMatr< T > &b)
const AVec< int > round(const AVec<> &a)
const AMatr< T > operator/(const AMatr< T > &b, const T &a)
const T minComponent(const AVec< T > &a)
double computePolynom(double x, AVec<> &coefs)
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< T > & operator-=(AVec< T > &a, const AVec< T > &b)
bool operator==(const std::vector< T > &vector1, const std::vector< T > &vector2)
Compares two vectors.
const AVec< int > floor(const AVec<> &a)
T sumOfElements(const AVec< T > &a)
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)
AVec< T > subAVec(const AVec< T > &source, unsigned int start, unsigned int end)
const AVec< T > divisionOfElements(const AVec< T > &a, const AVec< T > &b)
const bool operator!=(const AVec< T > &a, const AVec< T > &b)
const bool nonNegative(const AVec< T > &a)