documentation correction and tests in PIMathVector.h
This commit is contained in:
@@ -175,14 +175,14 @@ public:
|
|||||||
_CVector projection(const _CVector & v) {Type tv = v.length(); return (tv == Type(0) ? _CVector() : v * (((*this) ^ v) / tv));}
|
_CVector projection(const _CVector & v) {Type tv = v.length(); return (tv == Type(0) ? _CVector() : v * (((*this) ^ v) / tv));}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Method that returns this normalized vector
|
* @brief Method that returns this normalized vector (each element of a vector is divided by the absolute value of this vector)
|
||||||
*
|
*
|
||||||
* @return reference to this
|
* @return reference to this
|
||||||
*/
|
*/
|
||||||
_CVector & normalize() {Type tv = length(); if (tv == Type(1)) return *this; if (piAbs<Type>(tv) <= Type(1E-100)) {fill(Type(0)); return *this;} PIMV_FOR(i, 0) c[i] /= tv; return *this;}
|
_CVector & normalize() {Type tv = length(); if (tv == Type(1)) return *this; if (piAbs<Type>(tv) <= Type(1E-100)) {fill(Type(0)); return *this;} PIMV_FOR(i, 0) c[i] /= tv; return *this;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Method that returns a normalized vector
|
* @brief Method that returns a normalized vector (each element of a vector is divided by the absolute value of this vector)
|
||||||
*
|
*
|
||||||
* @return normalized vector of type PIMathVectorT
|
* @return normalized vector of type PIMathVectorT
|
||||||
*/
|
*/
|
||||||
@@ -244,15 +244,16 @@ public:
|
|||||||
const Type & operator [](uint index) const {return c[index];}
|
const Type & operator [](uint index) const {return c[index];}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Vector assignment to vector "v" of type PIMathVectorT
|
* @brief Assignment all elements of this vector with all elements of vector "v"
|
||||||
|
* If the vectors have different dimensions, it returns this without changing anything
|
||||||
*
|
*
|
||||||
* @param v vector for the assigment
|
* @param v vector for the assigment
|
||||||
* @return vector equal to vector "v"
|
* @return reference to this
|
||||||
*/
|
*/
|
||||||
_CVector & operator =(const _CVector & v) {memcpy(c, v.c, sizeof(Type) * Size); return *this;}
|
_CVector & operator =(const _CVector & v) {memcpy(c, v.c, sizeof(Type) * Size); return *this;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Assignment operation. All vector values become equal to "v"
|
* @brief Assignment all elements of this vector with all elements of value "v"
|
||||||
*
|
*
|
||||||
* @param v value for the assigment
|
* @param v value for the assigment
|
||||||
* @return reference to this
|
* @return reference to this
|
||||||
@@ -260,7 +261,7 @@ public:
|
|||||||
_CVector & operator =(const Type & v) {PIMV_FOR(i, 0) c[i] = v; return *this;}
|
_CVector & operator =(const Type & v) {PIMV_FOR(i, 0) c[i] = v; return *this;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Compare with vector "v"
|
* @brief Compare all elements of this vector with all elements of vector "v"
|
||||||
*
|
*
|
||||||
* @param v vector for the compare
|
* @param v vector for the compare
|
||||||
* @return if vectors are equal true, else false
|
* @return if vectors are equal true, else false
|
||||||
@@ -268,7 +269,7 @@ public:
|
|||||||
bool operator ==(const _CVector & v) const {PIMV_FOR(i, 0) if (c[i] != v[i]) return false; return true;}
|
bool operator ==(const _CVector & v) const {PIMV_FOR(i, 0) if (c[i] != v[i]) return false; return true;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Compare with vector "v"
|
* @brief Compare all elements of this vector with all elements of vector "v"
|
||||||
*
|
*
|
||||||
* @param v vector for the compare
|
* @param v vector for the compare
|
||||||
* @return if vectors are not equal true, else false
|
* @return if vectors are not equal true, else false
|
||||||
@@ -276,42 +277,42 @@ public:
|
|||||||
bool operator !=(const _CVector & v) const {return !(*this == v);}
|
bool operator !=(const _CVector & v) const {return !(*this == v);}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Vector addition this vector with vector "v"
|
* @brief Addition all elements of this vector with all elements vector "v"
|
||||||
*
|
*
|
||||||
* @param v vector for the addition assigment
|
* @param v vector for the addition assigment
|
||||||
*/
|
*/
|
||||||
void operator +=(const _CVector & v) {PIMV_FOR(i, 0) c[i] += v[i];}
|
void operator +=(const _CVector & v) {PIMV_FOR(i, 0) c[i] += v[i];}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Subtraction assignmentthis vector with vector "v"
|
* @brief Subtraction all elements of this vector with all elements vector "v"
|
||||||
*
|
*
|
||||||
* @param v vector for the subtraction assigment
|
* @param v vector for the subtraction assigment
|
||||||
*/
|
*/
|
||||||
void operator -=(const _CVector & v) {PIMV_FOR(i, 0) c[i] -= v[i];}
|
void operator -=(const _CVector & v) {PIMV_FOR(i, 0) c[i] -= v[i];}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Multiplication assignment this vector with value "v"
|
* @brief Multiplication all elements of this vector with value "v"
|
||||||
*
|
*
|
||||||
* @param v value for the multiplication assigment
|
* @param v value for the multiplication assigment
|
||||||
*/
|
*/
|
||||||
void operator *=(const Type & v) {PIMV_FOR(i, 0) c[i] *= v;}
|
void operator *=(const Type & v) {PIMV_FOR(i, 0) c[i] *= v;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Multiplication assignment this vector with vector "v"
|
* @brief Multiplication all elements of this vector with all elements vector "v"
|
||||||
*
|
*
|
||||||
* @param v vector for the multiplication assigment
|
* @param v vector for the multiplication assigment
|
||||||
*/
|
*/
|
||||||
void operator *=(const _CVector & v) {PIMV_FOR(i, 0) c[i] *= v[i];}
|
void operator *=(const _CVector & v) {PIMV_FOR(i, 0) c[i] *= v[i];}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Division assignment with this vector value "v"
|
* @brief Division all elements of this vector with value "v"
|
||||||
*
|
*
|
||||||
* @param v value for the division assigment
|
* @param v value for the division assigment
|
||||||
*/
|
*/
|
||||||
void operator /=(const Type & v) {PIMV_FOR(i, 0) c[i] /= v;}
|
void operator /=(const Type & v) {PIMV_FOR(i, 0) c[i] /= v;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Division assignment this vector with vector "v"
|
* @brief Division all elements of this vector with all elements vector "v"
|
||||||
*
|
*
|
||||||
* @param v vector for the division assigment
|
* @param v vector for the division assigment
|
||||||
*/
|
*/
|
||||||
@@ -325,7 +326,7 @@ public:
|
|||||||
_CVector operator -() const {_CVector tv; PIMV_FOR(i, 0) tv[i] = -c[i]; return tv;}
|
_CVector operator -() const {_CVector tv; PIMV_FOR(i, 0) tv[i] = -c[i]; return tv;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Vector addition this vector with vector "v"
|
* @brief Addition all elements of this vector with all elements of vector "v"
|
||||||
*
|
*
|
||||||
* @param v is vector term
|
* @param v is vector term
|
||||||
* @return the result of vector addition
|
* @return the result of vector addition
|
||||||
@@ -333,7 +334,7 @@ public:
|
|||||||
_CVector operator +(const _CVector & v) const {_CVector tv = _CVector(*this); PIMV_FOR(i, 0) tv[i] += v[i]; return tv;}
|
_CVector operator +(const _CVector & v) const {_CVector tv = _CVector(*this); PIMV_FOR(i, 0) tv[i] += v[i]; return tv;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Vector substraction this vector with vector "v"
|
* @brief Substraction all elements of this vector with all elements of vector "v"
|
||||||
*
|
*
|
||||||
* @param v is vector term
|
* @param v is vector term
|
||||||
* @return the result of vector substraction
|
* @return the result of vector substraction
|
||||||
@@ -341,7 +342,7 @@ public:
|
|||||||
_CVector operator -(const _CVector & v) const {_CVector tv = _CVector(*this); PIMV_FOR(i, 0) tv[i] -= v[i]; return tv;}
|
_CVector operator -(const _CVector & v) const {_CVector tv = _CVector(*this); PIMV_FOR(i, 0) tv[i] -= v[i]; return tv;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Vector multiplication this vector with value "v"
|
* @brief Multiplication all elements of this vector with value "v"
|
||||||
*
|
*
|
||||||
* @param v is value factor
|
* @param v is value factor
|
||||||
* @return the result of vector multiplication
|
* @return the result of vector multiplication
|
||||||
@@ -349,7 +350,7 @@ public:
|
|||||||
_CVector operator *(const Type & v) const {_CVector tv = _CVector(*this); PIMV_FOR(i, 0) tv[i] *= v; return tv;}
|
_CVector operator *(const Type & v) const {_CVector tv = _CVector(*this); PIMV_FOR(i, 0) tv[i] *= v; return tv;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Vector division this vector with value "v"
|
* @brief Division all elements of this vector with value "v"
|
||||||
*
|
*
|
||||||
* @param v is value divider
|
* @param v is value divider
|
||||||
* @return the result of vector division
|
* @return the result of vector division
|
||||||
@@ -357,7 +358,7 @@ public:
|
|||||||
_CVector operator /(const Type & v) const {_CVector tv = _CVector(*this); PIMV_FOR(i, 0) tv[i] /= v; return tv;}
|
_CVector operator /(const Type & v) const {_CVector tv = _CVector(*this); PIMV_FOR(i, 0) tv[i] /= v; return tv;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Vector division this vector with vector "v"
|
* @brief Division all elements of this vector with all elements of vector "v"
|
||||||
*
|
*
|
||||||
* @param v is vector divider
|
* @param v is vector divider
|
||||||
* @return the result of vector division
|
* @return the result of vector division
|
||||||
@@ -418,7 +419,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Inline operator which returns vector multiplication with value "x"
|
* @brief Multiplication all vector elements with value "x"
|
||||||
*
|
*
|
||||||
* @param x value for the multiplication
|
* @param x value for the multiplication
|
||||||
* @param v vector for the multiplication
|
* @param v vector for the multiplication
|
||||||
@@ -430,7 +431,7 @@ inline PIMathVectorT<Size, Type> operator *(const Type & x, const PIMathVectorT<
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Inline operator for outputting the vector to the console
|
* @brief Outputting the vector to the console
|
||||||
*
|
*
|
||||||
* @param s PICout type
|
* @param s PICout type
|
||||||
* @param the vector type PIMathVectorT that we print to the console
|
* @param the vector type PIMathVectorT that we print to the console
|
||||||
@@ -440,7 +441,7 @@ template<uint Size, typename Type>
|
|||||||
inline PICout operator <<(PICout s, const PIMathVectorT<Size, Type> & v) {s << "{"; PIMV_FOR(i, 0) {s << v[i]; if (i < Size - 1) s << ", ";} s << "}"; return s;}
|
inline PICout operator <<(PICout s, const PIMathVectorT<Size, Type> & v) {s << "{"; PIMV_FOR(i, 0) {s << v[i]; if (i < Size - 1) s << ", ";} s << "}"; return s;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Inline operator checking if the cross product is zero. Works only with vector containing three elements, otherwise returns current vector
|
* @brief Checking if the cross product of two vectors is zero. Works only with vector containing three elements, otherwise returns current vector
|
||||||
*
|
*
|
||||||
* @param f vector of the first operand
|
* @param f vector of the first operand
|
||||||
* @param s vector of the second operand
|
* @param s vector of the second operand
|
||||||
@@ -450,7 +451,7 @@ template<uint Size, typename Type>
|
|||||||
inline bool operator ||(const PIMathVectorT<Size, Type> & f, const PIMathVectorT<Size, Type> & s) {return (f * s).isNull();}
|
inline bool operator ||(const PIMathVectorT<Size, Type> & f, const PIMathVectorT<Size, Type> & s) {return (f * s).isNull();}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Inline function which takes the square root of each element in the vector
|
* @brief The square root of every element in the vector
|
||||||
*
|
*
|
||||||
* @param v vector of whose elements the square root is taken
|
* @param v vector of whose elements the square root is taken
|
||||||
* @return resulting vector
|
* @return resulting vector
|
||||||
@@ -459,7 +460,7 @@ template<uint Size, typename Type>
|
|||||||
inline PIMathVectorT<Size, Type> sqrt(const PIMathVectorT<Size, Type> & v) {PIMathVectorT<Size, Type> ret; PIMV_FOR(i, 0) {ret[i] = sqrt(v[i]);} return ret;}
|
inline PIMathVectorT<Size, Type> sqrt(const PIMathVectorT<Size, Type> & v) {PIMathVectorT<Size, Type> ret; PIMV_FOR(i, 0) {ret[i] = sqrt(v[i]);} return ret;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Inline function which squares each element of the vector
|
* @brief Squares every element of the vector
|
||||||
*
|
*
|
||||||
* @param v vector whose elements are squared
|
* @param v vector whose elements are squared
|
||||||
* @return resulting vector
|
* @return resulting vector
|
||||||
@@ -468,7 +469,7 @@ template<uint Size, typename Type>
|
|||||||
inline PIMathVectorT<Size, Type> sqr(const PIMathVectorT<Size, Type> & v) {PIMathVectorT<Size, Type> ret; PIMV_FOR(i, 0) {ret[i] = sqr(v[i]);} return ret;}
|
inline PIMathVectorT<Size, Type> sqr(const PIMathVectorT<Size, Type> & v) {PIMathVectorT<Size, Type> ret; PIMV_FOR(i, 0) {ret[i] = sqr(v[i]);} return ret;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Inline operator for serializing a vector into a PIByteArray
|
* @brief Serializing a vector into a PIByteArray
|
||||||
*
|
*
|
||||||
* @param s PIByteArray type
|
* @param s PIByteArray type
|
||||||
* @param v PIMathVectorT type
|
* @param v PIMathVectorT type
|
||||||
@@ -478,7 +479,7 @@ template<uint Size, typename Type>
|
|||||||
inline PIByteArray & operator <<(PIByteArray & s, const PIMathVectorT<Size, Type> & v) {for (uint i = 0; i < Size; ++i) s << v[i]; return s;}
|
inline PIByteArray & operator <<(PIByteArray & s, const PIMathVectorT<Size, Type> & v) {for (uint i = 0; i < Size; ++i) s << v[i]; return s;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Inline operator to deserialize vector from PIByteArray
|
* @brief Deserializing vector from PIByteArray
|
||||||
*
|
*
|
||||||
* @param s PIByteArray type
|
* @param s PIByteArray type
|
||||||
* @param v PIMathVector type
|
* @param v PIMathVector type
|
||||||
@@ -488,7 +489,7 @@ template<uint Size, typename Type>
|
|||||||
inline PIByteArray & operator >>(PIByteArray & s, PIMathVectorT<Size, Type> & v) {for (uint i = 0; i < Size; ++i) s >> v[i]; return s;}
|
inline PIByteArray & operator >>(PIByteArray & s, PIMathVectorT<Size, Type> & v) {for (uint i = 0; i < Size; ++i) s >> v[i]; return s;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Inline function which returns vector size 2 and type of T
|
* @brief Function which returns vector size 2 and type of T
|
||||||
*
|
*
|
||||||
* @param x first element of vector
|
* @param x first element of vector
|
||||||
* @param y second element of vector
|
* @param y second element of vector
|
||||||
@@ -498,7 +499,7 @@ template<typename T>
|
|||||||
inline PIMathVectorT<2u, T> createVectorT2(T x, T y) {return PIMathVectorT<2u, T>(PIVector<T>() << x << y);}
|
inline PIMathVectorT<2u, T> createVectorT2(T x, T y) {return PIMathVectorT<2u, T>(PIVector<T>() << x << y);}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Inline function which returns vector size 3 and type of T
|
* @brief Function which returns vector size 3 and type of T
|
||||||
*
|
*
|
||||||
* @param x first element of vector
|
* @param x first element of vector
|
||||||
* @param y second element of vector
|
* @param y second element of vector
|
||||||
@@ -509,7 +510,7 @@ template<typename T>
|
|||||||
inline PIMathVectorT<3u, T> createVectorT3(T x, T y, T z) {return PIMathVectorT<3u, T>(PIVector<T>() << x << y << z);}
|
inline PIMathVectorT<3u, T> createVectorT3(T x, T y, T z) {return PIMathVectorT<3u, T>(PIVector<T>() << x << y << z);}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Inline function which returns vector size 4 and type of T
|
* @brief Function which returns vector size 4 and type of T
|
||||||
*
|
*
|
||||||
* @param x first element of vector
|
* @param x first element of vector
|
||||||
* @param y second element of vector
|
* @param y second element of vector
|
||||||
@@ -699,14 +700,14 @@ public:
|
|||||||
_CVector projection(const _CVector & v) {if(v.size() != c.size()) return *this; Type tv = v.length(); return (tv == Type(0) ? _CVector() : v * (((*this) ^ v) / tv));}
|
_CVector projection(const _CVector & v) {if(v.size() != c.size()) return *this; Type tv = v.length(); return (tv == Type(0) ? _CVector() : v * (((*this) ^ v) / tv));}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Method that returns a normalized vector
|
* @brief Method that returns a normalized vector (each element of a vector is divided by the absolute value of this vector)
|
||||||
*
|
*
|
||||||
* @return copy of normalized vector of type PIMathVector
|
* @return copy of normalized vector of type PIMathVector
|
||||||
*/
|
*/
|
||||||
_CVector & normalize() {Type tv = length(); if (tv == Type(1)) return *this; if (piAbs<Type>(tv) <= Type(1E-100)) {fill(Type(0)); return *this;} PIMV_FOR(i, 0) c[i] /= tv; return *this;}
|
_CVector & normalize() {Type tv = length(); if (tv == Type(1)) return *this; if (piAbs<Type>(tv) <= Type(1E-100)) {fill(Type(0)); return *this;} PIMV_FOR(i, 0) c[i] /= tv; return *this;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Method that returns a normalized vector
|
* @brief Method that returns a normalized vector (each element of a vector is divided by the absolute value of this vector)
|
||||||
*
|
*
|
||||||
* @return normalized vector of type PIMathVector
|
* @return normalized vector of type PIMathVector
|
||||||
*/
|
*/
|
||||||
@@ -720,7 +721,7 @@ public:
|
|||||||
bool isNull() const {PIMV_FOR(i, 0) if (c[i] != Type(0)) return false; return true;}
|
bool isNull() const {PIMV_FOR(i, 0) if (c[i] != Type(0)) return false; return true;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Method which checks if vector is valid
|
* @brief Method which checks if vector is empty
|
||||||
*
|
*
|
||||||
* @return true if vector is valid, else false
|
* @return true if vector is valid, else false
|
||||||
*/
|
*/
|
||||||
@@ -761,7 +762,7 @@ public:
|
|||||||
const Type & operator [](uint index) const {return c[index];}
|
const Type & operator [](uint index) const {return c[index];}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Vector assignment to vector "v" of type PIMathVector
|
* @brief Assignment all elements of this vector with all elements of vector "v"
|
||||||
* If the vectors have different dimensions, it returns this without changing anything
|
* If the vectors have different dimensions, it returns this without changing anything
|
||||||
*
|
*
|
||||||
* @param v vector for the assigment
|
* @param v vector for the assigment
|
||||||
@@ -770,7 +771,7 @@ public:
|
|||||||
_CVector & operator =(const _CVector & v) {if(v.size() != c.size()) return *this; c = v.c; return *this;}
|
_CVector & operator =(const _CVector & v) {if(v.size() != c.size()) return *this; c = v.c; return *this;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Vector assignment to value "v"
|
* @brief Assignment all elements of this vector with all elements of value "v"
|
||||||
*
|
*
|
||||||
* @param v value for the assigment
|
* @param v value for the assigment
|
||||||
* @return reference to this
|
* @return reference to this
|
||||||
@@ -778,7 +779,7 @@ public:
|
|||||||
_CVector & operator =(const Type & v) {PIMV_FOR(i, 0) c[i] = v; return *this;}
|
_CVector & operator =(const Type & v) {PIMV_FOR(i, 0) c[i] = v; return *this;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Compare with vector "v"
|
* @brief Compare all elements of this vector with all elements of vector "v"
|
||||||
*
|
*
|
||||||
* @param v vector for the compare
|
* @param v vector for the compare
|
||||||
* @return if vectors are equal true, else false
|
* @return if vectors are equal true, else false
|
||||||
@@ -786,7 +787,7 @@ public:
|
|||||||
bool operator ==(const _CVector & v) const {PIMV_FOR(i, 0) if ((c[i] != v[i]) || (v.size() != c.size())) return false; return true;}
|
bool operator ==(const _CVector & v) const {PIMV_FOR(i, 0) if ((c[i] != v[i]) || (v.size() != c.size())) return false; return true;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Compare with vector "v"
|
* @brief Compare all elements of this vector with all elements of vector "v"
|
||||||
*
|
*
|
||||||
* @param v vector for the compare
|
* @param v vector for the compare
|
||||||
* @return if vectors are not equal true, else false
|
* @return if vectors are not equal true, else false
|
||||||
@@ -794,42 +795,42 @@ public:
|
|||||||
bool operator !=(const _CVector & v) const {return !(*this == v);}
|
bool operator !=(const _CVector & v) const {return !(*this == v);}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Addition assignment this vector with vector "v". If the vectors have different dimensions, it returns void()
|
* @brief Addition all elements of this vector with all elements vector "v". If the vectors have different dimensions, it returns void()
|
||||||
*
|
*
|
||||||
* @param v vector for the addition assigment
|
* @param v vector for the addition assigment
|
||||||
*/
|
*/
|
||||||
void operator +=(const _CVector & v) {if(v.size() != c.size()) return void(); PIMV_FOR(i, 0) c[i] += v[i];}
|
void operator +=(const _CVector & v) {if(v.size() != c.size()) return void(); PIMV_FOR(i, 0) c[i] += v[i];}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Subtraction assignment this vector with vector "v". If the vectors have different dimensions, it returns void()
|
* @brief Subtraction all elements of this vector with all elements vector "v". If the vectors have different dimensions, it returns void()
|
||||||
*
|
*
|
||||||
* @param v vector for the subtraction assigment
|
* @param v vector for the subtraction assigment
|
||||||
*/
|
*/
|
||||||
void operator -=(const _CVector & v) {if(v.size() != c.size()) return void(); PIMV_FOR(i, 0) c[i] -= v[i];}
|
void operator -=(const _CVector & v) {if(v.size() != c.size()) return void(); PIMV_FOR(i, 0) c[i] -= v[i];}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Multiplication assignment this vector with value "v"
|
* @brief Multiplication all elements of this vector with value "v"
|
||||||
*
|
*
|
||||||
* @param v value for the multiplication assigment
|
* @param v value for the multiplication assigment
|
||||||
*/
|
*/
|
||||||
void operator *=(const Type & v) {PIMV_FOR(i, 0) c[i] *= v;}
|
void operator *=(const Type & v) {PIMV_FOR(i, 0) c[i] *= v;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Multiplication assignment this vector with vector "v". If the vectors have different dimensions, it returns void()
|
* @brief Multiplication all elements of this vector with all elements vector "v". If the vectors have different dimensions, it returns void()
|
||||||
*
|
*
|
||||||
* @param v vector for the multiplication assigment
|
* @param v vector for the multiplication assigment
|
||||||
*/
|
*/
|
||||||
void operator *=(const _CVector & v) {if(v.size() != c.size()) return void(); PIMV_FOR(i, 0) c[i] *= v[i];}
|
void operator *=(const _CVector & v) {if(v.size() != c.size()) return void(); PIMV_FOR(i, 0) c[i] *= v[i];}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Division assignment this vector with value "v"
|
* @brief Division all elements of this vector with value "v"
|
||||||
*
|
*
|
||||||
* @param v value for the division assigment
|
* @param v value for the division assigment
|
||||||
*/
|
*/
|
||||||
void operator /=(const Type & v) {PIMV_FOR(i, 0) c[i] /= v;}
|
void operator /=(const Type & v) {PIMV_FOR(i, 0) c[i] /= v;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Division assignment this vector with vector "v". If the vectors have different dimensions, it returns void()
|
* @brief Division all elements of this vector with all elements vector "v". If the vectors have different dimensions, it returns void()
|
||||||
*
|
*
|
||||||
* @param v vector for the division assigment
|
* @param v vector for the division assigment
|
||||||
*/
|
*/
|
||||||
@@ -843,15 +844,15 @@ public:
|
|||||||
_CVector operator -() const {_CVector tv; PIMV_FOR(i, 0) tv[i] = -c[i]; return tv;}
|
_CVector operator -() const {_CVector tv; PIMV_FOR(i, 0) tv[i] = -c[i]; return tv;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Vector addition this vector with vector "v". If the vectors have different dimensions, it returns this without changing anything
|
* @brief Addition all elements of this vector with all elements of vector "v". If the vectors have different dimensions, it returns this without changing anything
|
||||||
*
|
*
|
||||||
* @param v is vector term
|
* @param v is vector term
|
||||||
* @return the result of matrix addition
|
* @return the result of vector addition
|
||||||
*/
|
*/
|
||||||
_CVector operator +(const _CVector & v) const {if(v.size() != c.size()) return _CVector(*this); _CVector tv = _CVector(*this); PIMV_FOR(i, 0) tv[i] += v[i]; return tv;}
|
_CVector operator +(const _CVector & v) const {if(v.size() != c.size()) return _CVector(*this); _CVector tv = _CVector(*this); PIMV_FOR(i, 0) tv[i] += v[i]; return tv;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Vector substraction this vector with vector "v". If the vectors have different dimensions, it returns this without changing anything
|
* @brief Substraction all elements of this vector with all elements of vector "v". If the vectors have different dimensions, it returns this without changing anything
|
||||||
*
|
*
|
||||||
* @param v is vector term
|
* @param v is vector term
|
||||||
* @return the result of vector substraction
|
* @return the result of vector substraction
|
||||||
@@ -859,7 +860,7 @@ public:
|
|||||||
_CVector operator -(const _CVector & v) const {if(v.size() != c.size()) return _CVector(*this); _CVector tv = _CVector(*this); PIMV_FOR(i, 0) tv[i] -= v[i]; return tv;}
|
_CVector operator -(const _CVector & v) const {if(v.size() != c.size()) return _CVector(*this); _CVector tv = _CVector(*this); PIMV_FOR(i, 0) tv[i] -= v[i]; return tv;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Vector multiplicationthis vector with value "v"
|
* @brief Multiplication all elements of this vector with value "v"
|
||||||
*
|
*
|
||||||
* @param v is value factor
|
* @param v is value factor
|
||||||
* @return the result of vector multiplication
|
* @return the result of vector multiplication
|
||||||
@@ -867,7 +868,7 @@ public:
|
|||||||
_CVector operator *(const Type & v) const {_CVector tv = _CVector(*this); PIMV_FOR(i, 0) tv[i] *= v; return tv;}
|
_CVector operator *(const Type & v) const {_CVector tv = _CVector(*this); PIMV_FOR(i, 0) tv[i] *= v; return tv;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Vector division this vector with value "v"
|
* @brief Division all elements of this vector with value "v"
|
||||||
*
|
*
|
||||||
* @param v is value divider
|
* @param v is value divider
|
||||||
* @return the result of vector division
|
* @return the result of vector division
|
||||||
@@ -932,7 +933,7 @@ inline std::ostream & operator <<(std::ostream & s, const PIMathVector<Type> & v
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Inline operator for outputting the vector to the console
|
* @brief Outputting the vector to the console
|
||||||
*
|
*
|
||||||
* @param s PICout type
|
* @param s PICout type
|
||||||
* @param the vector type PIMathVector that we print to the console
|
* @param the vector type PIMathVector that we print to the console
|
||||||
@@ -942,7 +943,7 @@ template<typename Type>
|
|||||||
inline PICout operator <<(PICout s, const PIMathVector<Type> & v) {s << "Vector{"; for (uint i = 0; i < v.size(); ++i) {s << v[i]; if (i < v.size() - 1) s << ", ";} s << "}"; return s;}
|
inline PICout operator <<(PICout s, const PIMathVector<Type> & v) {s << "Vector{"; for (uint i = 0; i < v.size(); ++i) {s << v[i]; if (i < v.size() - 1) s << ", ";} s << "}"; return s;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Inline operator for serializing a vector into a PIByteArray
|
* @brief Serializing a vector into a PIByteArray
|
||||||
*
|
*
|
||||||
* @param s PIByteArray type
|
* @param s PIByteArray type
|
||||||
* @param v PIMathVector type
|
* @param v PIMathVector type
|
||||||
@@ -952,7 +953,7 @@ template<typename Type>
|
|||||||
inline PIByteArray & operator <<(PIByteArray & s, const PIMathVector<Type> & v) {s << v.c; return s;}
|
inline PIByteArray & operator <<(PIByteArray & s, const PIMathVector<Type> & v) {s << v.c; return s;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Inline operator to deserialize vector from PIByteArray
|
* @brief Deserializing vector from PIByteArray
|
||||||
*
|
*
|
||||||
* @param s PIByteArray type
|
* @param s PIByteArray type
|
||||||
* @param v PIMathVector type
|
* @param v PIMathVector type
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ bool cmpSquareMatrixWithValue(PIMathMatrixT<rows, cols, double> matrix, double v
|
|||||||
bool b = true;
|
bool b = true;
|
||||||
for(int i = 0; i < num; i++) {
|
for(int i = 0; i < num; i++) {
|
||||||
for(int j = 0; j < num; j++) {
|
for(int j = 0; j < num; j++) {
|
||||||
if(matrix.at(i, j) - val >= double(1E-200)) {
|
if(matrix[i][j] - val >= double(1E-200)) {
|
||||||
b = false;
|
b = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -63,15 +63,15 @@ TEST(PIMathMatrixT_Test, col) {
|
|||||||
PIMathMatrixT<rows, cols, double> matr;
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
PIMathVectorT<rows, double> vect;
|
PIMathVectorT<rows, double> vect;
|
||||||
uint g = 2;
|
uint g = 2;
|
||||||
matr.at(0,0) = 3;
|
matr[0][0] = 3;
|
||||||
matr.at(0,1) = 6;
|
matr[0][1] = 6;
|
||||||
matr.at(0,2) = 8;
|
matr[0][2] = 8;
|
||||||
matr.at(1,0) = 2;
|
matr[1][0] = 2;
|
||||||
matr.at(1,1) = 1;
|
matr[1][1] = 1;
|
||||||
matr.at(1,2) = 4;
|
matr[1][2] = 4;
|
||||||
matr.at(2,0) = 6;
|
matr[2][0] = 6;
|
||||||
matr.at(2,1) = 2;
|
matr[2][1] = 2;
|
||||||
matr.at(2,2) = 5;
|
matr[2][2] = 5;
|
||||||
vect = matr.col(g);
|
vect = matr.col(g);
|
||||||
for(uint i = 0; i < matr.cols(); i++) {
|
for(uint i = 0; i < matr.cols(); i++) {
|
||||||
if(matr.at(i, g) != vect.at(i)) {
|
if(matr.at(i, g) != vect.at(i)) {
|
||||||
@@ -85,15 +85,15 @@ TEST(PIMathMatrixT_Test, row) {
|
|||||||
PIMathMatrixT<rows, cols, double> matr;
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
PIMathVectorT<rows, double> vect;
|
PIMathVectorT<rows, double> vect;
|
||||||
uint g = 2;
|
uint g = 2;
|
||||||
matr.at(0,0) = 3;
|
matr[0][0] = 3;
|
||||||
matr.at(0,1) = 6;
|
matr[0][1] = 6;
|
||||||
matr.at(0,2) = 8;
|
matr[0][2] = 8;
|
||||||
matr.at(1,0) = 2;
|
matr[1][0] = 2;
|
||||||
matr.at(1,1) = 1;
|
matr[1][1] = 1;
|
||||||
matr.at(1,2) = 4;
|
matr[1][2] = 4;
|
||||||
matr.at(2,0) = 6;
|
matr[2][0] = 6;
|
||||||
matr.at(2,1) = 2;
|
matr[2][1] = 2;
|
||||||
matr.at(2,2) = 5;
|
matr[2][2] = 5;
|
||||||
vect = matr.row(g);
|
vect = matr.row(g);
|
||||||
for(uint i = 0; i < matr.rows(); i++) {
|
for(uint i = 0; i < matr.rows(); i++) {
|
||||||
if(matr.at(g, i) != vect.at(i)) {
|
if(matr.at(g, i) != vect.at(i)) {
|
||||||
@@ -138,15 +138,15 @@ TEST(PIMathMatrixT_Test, setRow) {
|
|||||||
TEST(PIMathMatrixT_Test, swapCols) {
|
TEST(PIMathMatrixT_Test, swapCols) {
|
||||||
PIMathMatrixT<rows, cols, double> matr;
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
int g1 = 1, g2 = 2;
|
int g1 = 1, g2 = 2;
|
||||||
matr.at(0,0) = 3;
|
matr[0][0] = 3;
|
||||||
matr.at(0,1) = 6;
|
matr[0][1] = 6;
|
||||||
matr.at(0,2) = 8;
|
matr[0][2] = 8;
|
||||||
matr.at(1,0) = 2;
|
matr[1][0] = 2;
|
||||||
matr.at(1,1) = 1;
|
matr[1][1] = 1;
|
||||||
matr.at(1,2) = 4;
|
matr[1][2] = 4;
|
||||||
matr.at(2,0) = 6;
|
matr[2][0] = 6;
|
||||||
matr.at(2,1) = 2;
|
matr[2][1] = 2;
|
||||||
matr.at(2,2) = 5;
|
matr[2][2] = 5;
|
||||||
const PIMathVectorT<rows, double> before_Vect1 = matr.col(g1);
|
const PIMathVectorT<rows, double> before_Vect1 = matr.col(g1);
|
||||||
const PIMathVectorT<rows, double> before_Vect2 = matr.col(g2);
|
const PIMathVectorT<rows, double> before_Vect2 = matr.col(g2);
|
||||||
matr.swapCols(g1, g2);
|
matr.swapCols(g1, g2);
|
||||||
@@ -163,15 +163,15 @@ TEST(PIMathMatrixT_Test, swapCols) {
|
|||||||
TEST(PIMathMatrixT_Test, swapRows) {
|
TEST(PIMathMatrixT_Test, swapRows) {
|
||||||
PIMathMatrixT<rows, cols, double> matr;
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
int g1 = 1, g2 = 2;
|
int g1 = 1, g2 = 2;
|
||||||
matr.at(0,0) = 3;
|
matr[0][0] = 3;
|
||||||
matr.at(0,1) = 6;
|
matr[0][1] = 6;
|
||||||
matr.at(0,2) = 8;
|
matr[0][2] = 8;
|
||||||
matr.at(1,0) = 2;
|
matr[1][0] = 2;
|
||||||
matr.at(1,1) = 1;
|
matr[1][1] = 1;
|
||||||
matr.at(1,2) = 4;
|
matr[1][2] = 4;
|
||||||
matr.at(2,0) = 6;
|
matr[2][0] = 6;
|
||||||
matr.at(2,1) = 2;
|
matr[2][1] = 2;
|
||||||
matr.at(2,2) = 5;
|
matr[2][2] = 5;
|
||||||
const PIMathVectorT<rows, double> before_Vect1 = matr.row(g1);
|
const PIMathVectorT<rows, double> before_Vect1 = matr.row(g1);
|
||||||
const PIMathVectorT<rows, double> before_Vect2 = matr.row(g2);
|
const PIMathVectorT<rows, double> before_Vect2 = matr.row(g2);
|
||||||
matr.swapRows(g1, g2);
|
matr.swapRows(g1, g2);
|
||||||
@@ -192,7 +192,7 @@ TEST(PIMathMatrixT_Test, fill) {
|
|||||||
matr.fill(g);
|
matr.fill(g);
|
||||||
for(uint i = 0; i < cols; i++) {
|
for(uint i = 0; i < cols; i++) {
|
||||||
for(uint j = 0; j < rows; j++) {
|
for(uint j = 0; j < rows; j++) {
|
||||||
matrix1.at(j,i) = g;
|
matrix1[j][i] = g;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ASSERT_TRUE(matr == matrix1);
|
ASSERT_TRUE(matr == matrix1);
|
||||||
@@ -239,56 +239,56 @@ TEST(PIMathMatrixT_Test, operator_Assignment) {
|
|||||||
TEST(PIMathMatrixT_Test, operator_EqualTrue) {
|
TEST(PIMathMatrixT_Test, operator_EqualTrue) {
|
||||||
PIMathMatrixT<rows, cols, double> matrix1;
|
PIMathMatrixT<rows, cols, double> matrix1;
|
||||||
PIMathMatrixT<rows, cols, double> matrix2;
|
PIMathMatrixT<rows, cols, double> matrix2;
|
||||||
matrix1.at(0, 0) = 5.1;
|
matrix1[0][0] = 5.1;
|
||||||
matrix1.at(0, 1) = 1.21;
|
matrix1[0][1] = 1.21;
|
||||||
matrix1.at(1, 1) = 0.671;
|
matrix1[1][1] = 0.671;
|
||||||
matrix1.at(1, 0) = 2.623;
|
matrix1[1][0] = 2.623;
|
||||||
matrix2.at(0, 0) = 5.1;
|
matrix2[0][0] = 5.1;
|
||||||
matrix2.at(0, 1) = 1.21;
|
matrix2[0][1] = 1.21;
|
||||||
matrix2.at(1, 1) = 0.671;
|
matrix2[1][1] = 0.671;
|
||||||
matrix2.at(1, 0) = 2.623;
|
matrix2[1][0] = 2.623;
|
||||||
ASSERT_TRUE(matrix1 == matrix2);
|
ASSERT_TRUE(matrix1 == matrix2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, operator_EqualFalse) {
|
TEST(PIMathMatrixT_Test, operator_EqualFalse) {
|
||||||
PIMathMatrixT<rows, cols, double> matrix1;
|
PIMathMatrixT<rows, cols, double> matrix1;
|
||||||
PIMathMatrixT<rows, cols, double> matrix2;
|
PIMathMatrixT<rows, cols, double> matrix2;
|
||||||
matrix1.at(0, 0) = 5.1;
|
matrix1[0][0] = 5.1;
|
||||||
matrix1.at(0, 1) = 1.21;
|
matrix1[0][1] = 1.21;
|
||||||
matrix1.at(1, 1) = 0.671;
|
matrix1[1][1] = 0.671;
|
||||||
matrix1.at(1, 0) = 2.623;
|
matrix1[1][0] = 2.623;
|
||||||
matrix2.at(0, 0) = 5.1;
|
matrix2[0][0] = 5.1;
|
||||||
matrix2.at(0, 1) = 1.21;
|
matrix2[0][1] = 1.21;
|
||||||
matrix2.at(1, 1) = 665.671;
|
matrix2[1][1] = 665.671;
|
||||||
matrix2.at(1, 0) = 2.623;
|
matrix2[1][0] = 2.623;
|
||||||
ASSERT_FALSE(matrix1 == matrix2);
|
ASSERT_FALSE(matrix1 == matrix2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, operator_Not_EqualTrue) {
|
TEST(PIMathMatrixT_Test, operator_Not_EqualTrue) {
|
||||||
PIMathMatrixT<rows, cols, double> matrix1;
|
PIMathMatrixT<rows, cols, double> matrix1;
|
||||||
PIMathMatrixT<rows, cols, double> matrix2;
|
PIMathMatrixT<rows, cols, double> matrix2;
|
||||||
matrix1.at(0, 0) = 5.1;
|
matrix1[0][0] = 5.1;
|
||||||
matrix1.at(0, 1) = 1.21;
|
matrix1[0][1] = 1.21;
|
||||||
matrix1.at(1, 1) = 0.671;
|
matrix1[1][1] = 0.671;
|
||||||
matrix1.at(1, 0) = 2.623;
|
matrix1[1][0] = 2.623;
|
||||||
matrix2.at(0, 0) = 5.1;
|
matrix2[0][0] = 5.1;
|
||||||
matrix2.at(0, 1) = 1.21;
|
matrix2[0][1] = 1.21;
|
||||||
matrix2.at(1, 1) = 665.671;
|
matrix2[1][1] = 665.671;
|
||||||
matrix2.at(1, 0) = 2.623;
|
matrix2[1][0] = 2.623;
|
||||||
ASSERT_TRUE(matrix1 != matrix2);
|
ASSERT_TRUE(matrix1 != matrix2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, operator_Not_EqualFalse) {
|
TEST(PIMathMatrixT_Test, operator_Not_EqualFalse) {
|
||||||
PIMathMatrixT<rows, cols, double> matrix1;
|
PIMathMatrixT<rows, cols, double> matrix1;
|
||||||
PIMathMatrixT<rows, cols, double> matrix2;
|
PIMathMatrixT<rows, cols, double> matrix2;
|
||||||
matrix1.at(0, 0) = 5.1;
|
matrix1[0][0] = 5.1;
|
||||||
matrix1.at(0, 1) = 1.21;
|
matrix1[0][1] = 1.21;
|
||||||
matrix1.at(1, 1) = 0.671;
|
matrix1[1][1] = 0.671;
|
||||||
matrix1.at(1, 0) = 2.623;
|
matrix1[1][0] = 2.623;
|
||||||
matrix2.at(0, 0) = 5.1;
|
matrix2[0][0] = 5.1;
|
||||||
matrix2.at(0, 1) = 1.21;
|
matrix2[0][1] = 1.21;
|
||||||
matrix2.at(1, 1) = 0.671;
|
matrix2[1][1] = 0.671;
|
||||||
matrix2.at(1, 0) = 2.623;
|
matrix2[1][0] = 2.623;
|
||||||
ASSERT_FALSE(matrix1 != matrix2);
|
ASSERT_FALSE(matrix1 != matrix2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -343,30 +343,30 @@ TEST(PIMathMatrixT_Test, determinantIfSquare) {
|
|||||||
double d;
|
double d;
|
||||||
double i = 59.0;
|
double i = 59.0;
|
||||||
PIMathMatrixT<rows, cols, double> matr;
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
matr.at(0,0) = 3;
|
matr[0][0] = 3;
|
||||||
matr.at(0,1) = 6;
|
matr[0][1] = 6;
|
||||||
matr.at(0,2) = 8;
|
matr[0][2] = 8;
|
||||||
matr.at(1,0) = 2;
|
matr[1][0] = 2;
|
||||||
matr.at(1,1) = 1;
|
matr[1][1] = 1;
|
||||||
matr.at(1,2) = 4;
|
matr[1][2] = 4;
|
||||||
matr.at(2,0) = 6;
|
matr[2][0] = 6;
|
||||||
matr.at(2,1) = 2;
|
matr[2][1] = 2;
|
||||||
matr.at(2,2) = 5;
|
matr[2][2] = 5;
|
||||||
d = matr.determinant();
|
d = matr.determinant();
|
||||||
ASSERT_DOUBLE_EQ(i, d);
|
ASSERT_DOUBLE_EQ(i, d);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, determinantIfNotSquare) {
|
TEST(PIMathMatrixT_Test, determinantIfNotSquare) {
|
||||||
PIMathMatrixT<rows, 5u, double> matr;
|
PIMathMatrixT<rows, 5u, double> matr;
|
||||||
matr.at(0,0) = 3;
|
matr[0][0] = 3;
|
||||||
matr.at(0,1) = 6;
|
matr[0][1] = 6;
|
||||||
matr.at(0,2) = 8;
|
matr[0][2] = 8;
|
||||||
matr.at(1,0) = 2;
|
matr[1][0] = 2;
|
||||||
matr.at(1,1) = 1;
|
matr[1][1] = 1;
|
||||||
matr.at(1,2) = 4;
|
matr[1][2] = 4;
|
||||||
matr.at(2,0) = 6;
|
matr[2][0] = 6;
|
||||||
matr.at(2,1) = 2;
|
matr[2][1] = 2;
|
||||||
matr.at(2,2) = 5;
|
matr[2][2] = 5;
|
||||||
ASSERT_FALSE(matr.determinant());
|
ASSERT_FALSE(matr.determinant());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -376,15 +376,15 @@ TEST(PIMathMatrixT_Test, invert) {
|
|||||||
PIMathMatrixT<rows, cols, double> matrix3;
|
PIMathMatrixT<rows, cols, double> matrix3;
|
||||||
PIMathMatrixT<rows, cols, double> matr;
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
double d1, d2;
|
double d1, d2;
|
||||||
matr.at(0,0) = 3;
|
matr[0][0] = 3;
|
||||||
matr.at(0,1) = 6;
|
matr[0][1] = 6;
|
||||||
matr.at(0,2) = 8;
|
matr[0][2] = 8;
|
||||||
matr.at(1,0) = 2;
|
matr[1][0] = 2;
|
||||||
matr.at(1,1) = 1;
|
matr[1][1] = 1;
|
||||||
matr.at(1,2) = 4;
|
matr[1][2] = 4;
|
||||||
matr.at(2,0) = 6;
|
matr[2][0] = 6;
|
||||||
matr.at(2,1) = 2;
|
matr[2][1] = 2;
|
||||||
matr.at(2,2) = 5;
|
matr[2][2] = 5;
|
||||||
matrix2 = matr;
|
matrix2 = matr;
|
||||||
matr.invert();
|
matr.invert();
|
||||||
d1 = matr.determinant();
|
d1 = matr.determinant();
|
||||||
@@ -401,15 +401,15 @@ TEST(PIMathMatrixT_Test, inverted) {
|
|||||||
PIMathMatrixT<rows, cols, double> matr;
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
double d1, d2;
|
double d1, d2;
|
||||||
matrix1 = matr.identity();
|
matrix1 = matr.identity();
|
||||||
matr.at(0,0) = 3;
|
matr[0][0] = 3;
|
||||||
matr.at(0,1) = 6;
|
matr[0][1] = 6;
|
||||||
matr.at(0,2) = 8;
|
matr[0][2] = 8;
|
||||||
matr.at(1,0) = 2;
|
matr[1][0] = 2;
|
||||||
matr.at(1,1) = 1;
|
matr[1][1] = 1;
|
||||||
matr.at(1,2) = 4;
|
matr[1][2] = 4;
|
||||||
matr.at(2,0) = 6;
|
matr[2][0] = 6;
|
||||||
matr.at(2,1) = 2;
|
matr[2][1] = 2;
|
||||||
matr.at(2,2) = 5;
|
matr[2][2] = 5;
|
||||||
matrix2 = matr.inverted();
|
matrix2 = matr.inverted();
|
||||||
d1 = matr.determinant();
|
d1 = matr.determinant();
|
||||||
d2 = matrix2.determinant();
|
d2 = matrix2.determinant();
|
||||||
@@ -421,15 +421,15 @@ TEST(PIMathMatrixT_Test, toUpperTriangular) {
|
|||||||
PIMathMatrixT<rows, cols, double> matrix;
|
PIMathMatrixT<rows, cols, double> matrix;
|
||||||
double d1, d2 = 1;
|
double d1, d2 = 1;
|
||||||
PIMathMatrixT<rows, cols, double> matr;
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
matr.at(0,0) = 3;
|
matr[0][0] = 3;
|
||||||
matr.at(0,1) = 6;
|
matr[0][1] = 6;
|
||||||
matr.at(0,2) = 8;
|
matr[0][2] = 8;
|
||||||
matr.at(1,0) = 2;
|
matr[1][0] = 2;
|
||||||
matr.at(1,1) = 1;
|
matr[1][1] = 1;
|
||||||
matr.at(1,2) = 4;
|
matr[1][2] = 4;
|
||||||
matr.at(2,0) = 6;
|
matr[2][0] = 6;
|
||||||
matr.at(2,1) = 2;
|
matr[2][1] = 2;
|
||||||
matr.at(2,2) = 5;
|
matr[2][2] = 5;
|
||||||
matrix = matr.toUpperTriangular();
|
matrix = matr.toUpperTriangular();
|
||||||
d1 = matrix.determinant();
|
d1 = matrix.determinant();
|
||||||
for(uint i = 0; i < cols; i++)
|
for(uint i = 0; i < cols; i++)
|
||||||
@@ -444,15 +444,15 @@ TEST(PIMathMatrixT_Test, transposed) {
|
|||||||
PIMathMatrixT<rows, cols, double> matrix2;
|
PIMathMatrixT<rows, cols, double> matrix2;
|
||||||
PIMathMatrixT<rows, cols, double> matr;
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
double d1, d2;
|
double d1, d2;
|
||||||
matr.at(0,0) = 3;
|
matr[0][0] = 3;
|
||||||
matr.at(0,1) = 6;
|
matr[0][1] = 6;
|
||||||
matr.at(0,2) = 8;
|
matr[0][2] = 8;
|
||||||
matr.at(1,0) = 2;
|
matr[1][0] = 2;
|
||||||
matr.at(1,1) = 1;
|
matr[1][1] = 1;
|
||||||
matr.at(1,2) = 4;
|
matr[1][2] = 4;
|
||||||
matr.at(2,0) = 6;
|
matr[2][0] = 6;
|
||||||
matr.at(2,1) = 2;
|
matr[2][1] = 2;
|
||||||
matr.at(2,2) = 5;
|
matr[2][2] = 5;
|
||||||
d1 = matr.determinant();
|
d1 = matr.determinant();
|
||||||
matrix1 = matr.transposed();
|
matrix1 = matr.transposed();
|
||||||
d2 = matrix1.determinant();
|
d2 = matrix1.determinant();
|
||||||
|
|||||||
@@ -24,14 +24,16 @@ TEST(PIMathVector_Test, resize) {
|
|||||||
PIMathVector<double> vector;
|
PIMathVector<double> vector;
|
||||||
vector.resize(newSize, a);
|
vector.resize(newSize, a);
|
||||||
ASSERT_TRUE(cmpVectorWithValue(vector, a, vector.size()));
|
ASSERT_TRUE(cmpVectorWithValue(vector, a, vector.size()));
|
||||||
|
ASSERT_TRUE(vector.size() == newSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathVector_Test, resized) {
|
TEST(PIMathVector_Test, resized) {
|
||||||
uint newSize = 4u;
|
uint newSize = 4u;
|
||||||
double a = 5.0;
|
double a = 5.0;
|
||||||
PIMathVector<double> vector;
|
PIMathVector<double> vector;
|
||||||
vector.resized(newSize, a);
|
auto vect = vector.resized(newSize, a);
|
||||||
ASSERT_TRUE(cmpVectorWithValue(vector, a, vector.size()));
|
ASSERT_TRUE(cmpVectorWithValue(vect, a, vect.size()) && vect.size() == newSize);
|
||||||
|
ASSERT_TRUE(vect.size() == newSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathVector_Test, fill) {
|
TEST(PIMathVector_Test, fill) {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ bool cmpVectorWithValue(PIMathVectorT<SIZE, double> vector, double val, int num)
|
|||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathVectorT_Test, SIZE) {
|
TEST(PIMathVectorT_Test, size) {
|
||||||
PIMathVectorT<SIZE, double> vector;
|
PIMathVectorT<SIZE, double> vector;
|
||||||
ASSERT_TRUE(vector.size() == SIZE);
|
ASSERT_TRUE(vector.size() == SIZE);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user