26 #ifndef ASLVECTORSDYNAMICLENGTHOPERATIONS_H 27 #define ASLVECTORSDYNAMICLENGTHOPERATIONS_H 30 #include "../aslUtilities.h" 38 template <
typename T1,
typename T2>
43 inline const T
l2(
const AVec<T> & a);
51 inline const AVec<T>
operator+(
const AVec<T> & a,
const AVec<T> & b);
54 inline const AVec<T>
operator-(
const AVec<T> & a,
const AVec<T> & b);
57 inline const AVec<T>
operator-(
const AVec<T> & a);
60 inline const T
operator*(
const AVec<T> & a,
const AVec<T> & b);
63 inline const AVec<T>
operator*(
const T & a,
const AVec<T> & b);
66 inline const AVec<T>
operator*(
const AVec<T> & a,
const T & b);
69 inline const AVec<T>
operator/(
const AVec<T> & a,
const T & b);
72 template <
typename T>
inline const AVec<T> &
operator+=(AVec<T> & a,
75 template <
typename T>
inline const AVec<T> &
operator-=(AVec<T> & a,
78 template <
typename T>
inline const AVec<T> &
operator*=(AVec<T> & a,
82 template <
typename T>
inline const bool operator==(
const AVec<T> & a,
87 template <
typename T>
inline const bool operator!=(
const AVec<T> & a,
93 inline const AVec<T>
crossProduct(
const AVec<T> & a,
const AVec<T> & b);
96 template <
typename T>
inline const T
minComponent(
const AVec<T> & a);
98 template <
typename T>
inline const T
maxComponent(
const AVec<T> & a);
101 template <
typename T>
inline T
sumOfElements(
const AVec<T> & a);
113 template <
typename T>
inline const bool positive(
const AVec<T> & a);
116 template <
typename T>
inline const bool nonNegative(
const AVec<T> & a);
132 template <
typename T>
133 inline std::ostream &
operator<<(std::ostream & output,
const AVec<T> & a);
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]);
409 #endif //ASLVECTORSDYNAMICLENGTH_H bool compatibleSizes(AVec< T1 > a, AVec< T2 > b)
double computePolynom(double x, AVec<> &coefs)
const AVec< T > divisionOfElements(const AVec< T > &a, const AVec< T > &b)
Advanced Simulation Library.
const AVec< T > & operator*=(AVec< T > &a, const T &b)
SPDistanceFunction normalize(SPDistanceFunction a, double dx)
void errorMessage(cl_int status, const char *errorMessage)
Prints errorMessage and exits depending on the status.
const AMatr< T > & operator+=(AMatr< T > &a, const AMatr< T > &b)
const AVec< T > crossProduct(const AVec< T > &a, const AVec< T > &b)
Element max(Element a, Element b)
const T l2(const AVec< T > &a)
Element min(Element a, Element b)
bool operator==(const std::vector< T > &vector1, const std::vector< T > &vector2)
Compares two vectors.
AVec< T > subAVec(const AVec< T > &source, unsigned int start, unsigned int end)
T productOfElements(const AVec< T > &a)
const T maxComponent(const AVec< T > &a)
const bool nonNegative(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< int > floor(const AVec<> &a)
T sumOfElements(const AVec< T > &a)
const AMatr< T > operator/(const AMatr< T > &b, const T &a)
const AVec< T > & operator-=(AVec< T > &a, const AVec< T > &b)
SPPositionFunction operator*(SPPositionFunction a, SPPositionFunction b)
const AMatr< T > operator+(const AMatr< T > &a, const AMatr< T > &b)
const T minComponent(const AVec< T > &a)
SPDistanceFunction operator-(SPDistanceFunction a)
const unsigned int & getSize() const
const bool positive(const AVec< T > &a)
const AVec swapXZ(const AVec<> &a)
returns true in case when all components of a more then 0
void resize(unsigned int newSize)
const AVec< int > round(const AVec<> &a)
const bool operator!=(const AVec< T > &a, const AVec< T > &b)