diff --git a/libs/main/math/pimathmatrix.h b/libs/main/math/pimathmatrix.h index 897fe6ae..7d42fbc3 100644 --- a/libs/main/math/pimathmatrix.h +++ b/libs/main/math/pimathmatrix.h @@ -92,7 +92,7 @@ public: /** * @brief Constructor that calls the private resize method * - * @return identitied matrix of type PIMathMatrixT + * @return resized matrix of type PIMathMatrixT */ PIMathMatrixT() { resize(Rows, Cols); } @@ -100,7 +100,7 @@ public: * @brief Constructor that calls the private resize method * * @param val is the PIVector with which the matrix is ​​filled - * @return identitied matrix of type PIMathMatrixT + * @return resized matrix of type PIMathMatrixT */ PIMathMatrixT(const PIVector &val) { resize(Rows, Cols); diff --git a/libs/main/math/pimathvector.h b/libs/main/math/pimathvector.h index 190da7a9..09659fb2 100644 --- a/libs/main/math/pimathvector.h +++ b/libs/main/math/pimathvector.h @@ -1,5 +1,7 @@ /*! \file pimathvector.h * \brief PIMathVector + * + * This file declare math vector class, which performs various vector operations */ /* PIP - Platform Independent Primitives @@ -33,15 +35,44 @@ class PIMathMatrixT; #define PIMV_FOR(v, s) for (uint v = s; v < Size; ++v) +//! \brief A class that works with vector operations, the input data of which are size and the data type of the vector +//! @tparam Size number of matrix elements +//! @tparam Type is the data type of the vector. There are can be basic C++ language data and different classes where the arithmetic operators(=, +=, -=, *=, /=, ==, !=, +, -, *, /) +//! of the C++ language are implemented template class PIP_EXPORT PIMathVectorT { typedef PIMathVectorT _CVector; static_assert(std::is_arithmetic::value, "Type must be arithmetic"); public: + /** + * @brief Constructor that calls the private resize method + * + * @return resized vector of type PIMathMatrixT + */ PIMathVectorT() {resize();} + + /** + * @brief Constructor that fills a vector "PIMathVectorT" with the values ​​of another vector "PIVector" + * + * @tparam val vector of type PIVector which is identified PIMathVectorT + * @return vector of type PIMathVectorT with values ​​of vector val + */ PIMathVectorT(const PIVector & val) {resize(); PIMV_FOR(i, 0) c[i] = val[i];} + + /** + * @brief Constructor that fills a vector "PIMathVectorT" with the subtraction of two vectors + * + * @tparam st vector of type _CVector + * @tparam fn vector of type _CVector + * @return vector of type PIMathVectorT with values subtraction vectors "fn" and "st" + */ PIMathVectorT(const _CVector & st, const _CVector & fn) {resize(); set(st, fn);} + /** + * @brief Method which returns size of the vector + * + * @return type uint shows number of elements in this vector + */ uint size() const {return Size;} _CVector & fill(const Type & v) {PIMV_FOR(i, 0) c[i] = v; return *this;} _CVector & set(const _CVector & st, const _CVector & fn) {PIMV_FOR(i, 0) c[i] = fn[i] - st[i]; return *this;} @@ -69,7 +100,7 @@ public: _CVector & operator =(const _CVector & v) {memcpy(c, v.c, sizeof(Type) * Size); return *this;} _CVector & operator =(const Type & v) {PIMV_FOR(i, 0) c[i] = v; return *this;} 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 {return !(*this == v);} + bool operator !=(const _CVector & v) const {return !(*this == v);} 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];} void operator *=(const Type & v) {PIMV_FOR(i, 0) c[i] *= v;} @@ -195,7 +226,7 @@ public: _CVector & operator =(const _CVector & v) {c = v.c; return *this;} _CVector & operator =(const Type & v) {PIMV_FOR(i, 0) c[i] = v; return *this;} 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 {return !(*this == v);} + bool operator !=(const _CVector & v) const {return !(*this == v);} 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];} void operator *=(const Type & v) {PIMV_FOR(i, 0) c[i] *= v;} @@ -207,7 +238,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 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;} - _CVector operator *(const _CVector & v) const {if ((c.size() != 3) && (v.size() != 3)) return _CVector(); _CVector tv(3); tv.fill(Type(1)); tv[0] = c[1]*v[2] - v[1]*c[2]; tv[1] = v[0]*c[2] - c[0]*v[2]; tv[2] = c[0]*v[1] - v[0]*c[1]; return tv;} + _CVector operator *(const _CVector & v) const {if ((c.size() != 3) && (v.size() != 3)) return _CVector(); _CVector tv(3); tv.fill(Type(1)); tv[0] = c[1]*v[2] - v[1]*c[2]; tv[1] = v[0]*c[2] - c[0]*v[2]; tv[2] = c[0]*v[1] - v[0]*c[1]; return tv;} _CVector operator &(const _CVector & v) const {_CVector tv = _CVector(*this); PIMV_FOR(i, 0) tv[i] *= v[i]; return tv;} Type operator ^(const _CVector & v) const {Type tv(0); PIMV_FOR(i, 0) tv += c[i] * v[i]; return tv;}