diff --git a/libs/main/math/piline.h b/libs/main/math/piline.h index 4ceba624..b26e9f42 100644 --- a/libs/main/math/piline.h +++ b/libs/main/math/piline.h @@ -46,7 +46,7 @@ public: //! Пустой конструктор. //! \details //! При выполнении пустого конструктора координаты не изменяются. - //! p0 == p1 + //! Начало и конец совпадают. PILine() {} //! \~russian @@ -109,7 +109,7 @@ public: return *this; } - //! Создать копию отрезка и сдвинуть её на \a x, \a y. + //! Создать копию отрезка и сдвинуть её на `x` и `y`. PILine translated(Type x, Type y) const { PILine l(*this); l.translate(x, y); @@ -177,7 +177,7 @@ public: bool operator !=(const PILine & r) const {return (p1 != r.p1 || p1 != r.p1);} }; -//! \~russian Перегруженный оператор для вывода координат. +//! \~russian Перегруженный оператор для вывода координат в \a PICout. template PICout operator <<(PICout & s, const PILine & v) { s.setControl(0, true); diff --git a/libs/main/math/pimathmatrix.h b/libs/main/math/pimathmatrix.h index 9d6f394a..1a7ee0a9 100644 --- a/libs/main/math/pimathmatrix.h +++ b/libs/main/math/pimathmatrix.h @@ -44,7 +44,7 @@ //! \tparam `Сols` columns number of matrix. //! \tparam `Type` is the data type of the matrix. There are can be basic C++ language data and different classes where the arithmetic operators(=, +=, -=, *=, /=, ==, !=, +, -, *, /) //! of the C++ language are implemented -//! \~english +//! \~russian //! \brief Класс, работающий с операциями над квадратными матрицами, входными данными которого являются столбцы, строки и матричный типа данных. //! \tparam `Rows` количество строк матрицы. //! \tparam `Сols` количество столбцов матрицы. @@ -77,9 +77,9 @@ public: } //! \~english - //! \brief Contructs \a PIMathMatrixT from C++11 initializer list. + //! \brief Contructs \a PIMathMatrixT from [C++11 initializer list](https://en.cppreference.com/w/cpp/utility/initializer_list). //! \~russian - //! \brief Создает \a PIMathMatrixT и заполняет её списка инициализации C++11. + //! \brief Создает \a PIMathMatrixT и заполняет её из [списка инициализации C++11](https://ru.cppreference.com/w/cpp/utility/initializer_list). PIMathMatrixT(std::initializer_list init_list) { assert(Rows*Cols == init_list.size()); int i = 0; @@ -92,8 +92,8 @@ public: //! \~russian //! \brief Создает матрицу, главная диагональ которой заполнена единицами, а остальные элементы — нулями. //! \return единичная матрица типа \a PIMathMatrixT. - static _CMatrix identity() { - _CMatrix tm = _CMatrix(); + static PIMathMatrixT identity() { + PIMathMatrixT tm = PIMathMatrixT(); PIMM_FOR tm.m[r][c] = (c == r ? Type(1) : Type(0)); return tm; } @@ -124,8 +124,8 @@ public: //! \details Если вы введете индекс вне границ матрицы, то поведение не определено ("undefined behavior"). //! \param index номер выбранного столбца. //! \return столбец в формате \a PIMathVectorT. - _CMCol col(uint index) { - _CMCol tv; + PIMathVectorT col(uint index) { + PIMathVectorT tv; PIMM_FOR_R tv[i] = m[i][index]; return tv; } @@ -139,8 +139,8 @@ public: //! \details Если вы введете индекс вне границ матрицы, то поведение не определено ("undefined behavior"). //! \param index номер выбранной строки. //! \return строка в формате \a PIMathVectorT. - _CMRow row(uint index) { - _CMRow tv; + PIMathVectorT row(uint index) { + PIMathVectorT tv; PIMM_FOR_C tv[i] = m[index][i]; return tv; } @@ -149,15 +149,15 @@ public: //! \brief Set the selected column in matrix. //! \details If you enter an index out of the border of the matrix there will be "undefined behavior". //! \param index is the number of the selected column. - //! \param v is a vector of the type _CMCol that needs to fill the column. - //! \return matrix type _CMatrix. + //! \param v is a vector of the type \a PIMathVectorT that needs to fill the column. + //! \return matrix type \a PIMathMatrixT. //! \~russian //! \brief Определить выбранный столбец матрицы. //! \details Если вы введете индекс вне границ матрицы, то поведение не определено ("undefined behavior"). //! \param index номер выбранного столбца. - //! \param v вектор типа \a _CMCol, которым необходимо заполнить столбец. - //! \return матрица типа \a _CMatrix. - _CMatrix &setCol(uint index, const _CMCol &v) { + //! \param v вектор типа \a PIMathVectorT, которым необходимо заполнить столбец. + //! \return матрица типа \a PIMathMatrixT. + PIMathMatrixT &setCol(uint index, const PIMathVectorT &v) { PIMM_FOR_R m[i][index] = v[i]; return *this; } @@ -166,15 +166,15 @@ public: //! \brief Set the selected row in matrix. //! \details If you enter an index out of the border of the matrix there will be "undefined behavior". //! \param index is the number of the selected row. - //! \param v is a vector of the type _CMCol that needs to fill the row. - //! \return matrix type _CMatrix + //! \param v is a vector of the type PIMathVectorT that needs to fill the row. + //! \return matrix type PIMathMatrixT //! \~russian //! \brief Определить выбранную строку матрицы. //! \details Если вы введете индекс вне границ матрицы, то поведение не определено ("undefined behavior"). //! \param index номер выбранной строки. - //! \param v вектор типа \a _CMCol, которым необходимо заполнить строку. - //! \return матрица типа \a _CMatrix. - _CMatrix &setRow(uint index, const _CMRow &v) { + //! \param v вектор типа \a PIMathVectorT, которым необходимо заполнить строку. + //! \return матрица типа \a PIMathMatrixT. + PIMathMatrixT &setRow(uint index, const PIMathVectorT &v) { PIMM_FOR_C m[index][i] = v[i]; return *this; } @@ -184,14 +184,14 @@ public: //! \details If you enter an index out of the border of the matrix there will be "undefined behavior" //! \param rf is the number of the first selected row //! \param rs is the number of the second selected row - //! \return matrix type _CMatrix + //! \return matrix type \a PIMathMatrixT //! \~russian //! \brief Метод, меняющий местами выбранные строки в матрице. //! \details Если вы введете индекс вне границ матрицы, то поведение не определено ("undefined behavior"). //! \param rf номер первой выбранной строки. //! \param rs номер второй выбранной строки. - //! \return матрица типа \a _CMatrix. - _CMatrix &swapRows(uint rf, uint rs) { + //! \return матрица типа \a PIMathMatrixT. + PIMathMatrixT &swapRows(uint rf, uint rs) { PIMM_FOR_C piSwap(m[rf][i], m[rs][i]); return *this; } @@ -201,14 +201,14 @@ public: //! \details If you enter an index out of the border of the matrix there will be "undefined behavior" //! \param cf is the number of the first selected column //! \param cs is the number of the second selected column - //! \return matrix type _CMatrix + //! \return matrix type \a PIMathMatrixT //! \~russian //! \brief Метод, меняющий местами выбранные столбцы в матрице. //! \details Если вы введете индекс вне границ матрицы, то поведение не определено ("undefined behavior"). //! \param rf номер первого выбранного столбца. //! \param rs номер второго выбранного столбца. - //! \return матрица типа \a _CMatrix. - _CMatrix &swapCols(uint cf, uint cs) { + //! \return матрица типа \a PIMathMatrixT. + PIMathMatrixT &swapCols(uint cf, uint cs) { PIMM_FOR_R piSwap(m[i][cf], m[i][cs]); return *this; } @@ -216,12 +216,12 @@ public: //! \~english //! \brief Method which fills the matrix with selected value. //! \param v is a parameter the type and value of which is selected and later filled into the matrix. - //! \return filled matrix type _CMatrix. + //! \return filled matrix type \a PIMathMatrixT. //! \~russian //! \brief Метод, заполняющий матрицу выбранным значением. //! \param v параметр тип и значения, которого выбираются и заносятся в матрицу. - //! \return заполненная матрица типа \a _CMatrix. - _CMatrix &fill(const Type &v) { + //! \return заполненная матрица типа \a PIMathMatrixT. + PIMathMatrixT &fill(const Type &v) { PIMM_FOR m[r][c] = v; return *this; } @@ -331,7 +331,7 @@ public: //! \brief Сравнение матриц. //! \param sm матрица для сравнения. //! \return если матрицы равны true, иначе false. - bool operator==(const _CMatrix &sm) const { + bool operator==(const PIMathMatrixT &sm) const { PIMM_FOR if (m[r][c] != sm.m[r][c]) return false; return true; } @@ -344,7 +344,7 @@ public: //! \brief Отрицательное сравнение матриц. //! \param sm матрица для сравнения. //! \return если матрицы не равны true, иначе false. - bool operator!=(const _CMatrix &sm) const { return !(*this == sm); } + bool operator!=(const PIMathMatrixT &sm) const { return !(*this == sm); } //! \~english //! \brief Addition assignment with matrix `sm`. @@ -352,7 +352,7 @@ public: //! \~russian //! \brief Сложение с присваиванием с матрицей `sm`. //! \param sm матрица для сложения с присваиванием. - void operator+=(const _CMatrix &sm) {PIMM_FOR m[r][c] += sm.m[r][c];} + void operator+=(const PIMathMatrixT &sm) {PIMM_FOR m[r][c] += sm.m[r][c];} //! \~english //! \brief Subtraction assignment with matrix `sm`. @@ -360,7 +360,7 @@ public: //! \~russian //! \brief Вычитание с присваиванием с матрицей `sm`. //! \param sm матрица для вычитания с присваиванием. - void operator-=(const _CMatrix &sm) {PIMM_FOR m[r][c] -= sm.m[r][c];} + void operator-=(const PIMathMatrixT &sm) {PIMM_FOR m[r][c] -= sm.m[r][c];} //! \~english //! \brief Multiplication assignment with value `v`. @@ -389,8 +389,8 @@ public: //! \~russian //! \brief Операция отрицания //! \return копия отрицательной матрицы - _CMatrix operator-() const { - _CMatrix tm; + PIMathMatrixT operator-() const { + PIMathMatrixT tm; PIMM_FOR tm.m[r][c] = -m[r][c]; return tm; } @@ -403,8 +403,8 @@ public: //! \brief Матричное сложение. //! \param sm матричное слагаемое. //! \return результат матричного сложения. - _CMatrix operator+(const _CMatrix &sm) const { - _CMatrix tm = _CMatrix(*this); + PIMathMatrixT operator+(const PIMathMatrixT &sm) const { + PIMathMatrixT tm = PIMathMatrixT(*this); PIMM_FOR tm.m[r][c] += sm.m[r][c]; return tm; } @@ -417,43 +417,43 @@ public: //! \brief Матричная разность. //! \param sm матричное вычитаемое. //! \return результат матричной разности. - _CMatrix operator-(const _CMatrix &sm) const { - _CMatrix tm = _CMatrix(*this); + PIMathMatrixT operator-(const PIMathMatrixT &sm) const { + PIMathMatrixT tm = PIMathMatrixT(*this); PIMM_FOR tm.m[r][c] -= sm.m[r][c]; return tm; } //! \~english - //! \brief Matrix multiplication. + //! \brief Matrix multiplication by a constant. //! \param v is value factor. //! \return the result of matrix multiplication. //! \~russian - //! \brief Матричное произведение. + //! \brief Умножение матрицы на константу. //! \param v множитель. //! \return результат произведения. - _CMatrix operator*(const Type &v) const { - _CMatrix tm = _CMatrix(*this); + PIMathMatrixT operator*(const Type &v) const { + PIMathMatrixT tm = PIMathMatrixT(*this); PIMM_FOR tm.m[r][c] *= v; return tm; } //! \~english - //! \brief Matrix division. + //! \brief Division a matrix by a constant. //! \param v is value divider. //! \return the result of matrix division. //! \~russian - //! \brief Матричное деление. + //! \brief Деление матрицы на константу. //! \param v делитель. //! \return результат деления. - _CMatrix operator/(const Type &v) const { + PIMathMatrixT operator/(const Type &v) const { assert(piAbs(v) > PIMATHVECTOR_ZERO_CMP); - _CMatrix tm = _CMatrix(*this); + PIMathMatrixT tm = PIMathMatrixT(*this); PIMM_FOR tm.m[r][c] /= v; return tm; } //! \~english - //! \brief ​Calculate Determinant of the matrix. + //! \brief Calculate Determinant of the matrix. //! \details Works only with square matrix, nonzero matrices and invertible matrix. //! \param ok is a parameter with which we can find out if the method worked correctly. //! \return matrix determinant. @@ -463,7 +463,7 @@ public: //! \param ok это параметр, с помощью которого мы можем узнать, правильно ли сработал метод. //! \return опеределитель матрицы. Type determinant(bool *ok = 0) const { - _CMatrix m(*this); + PIMathMatrixT m(*this); bool k; Type ret = Type(0); m.toUpperTriangular(&k); @@ -495,15 +495,15 @@ public: //! \brief Transforming matrix to upper triangular. //! \details Works only with square matrix, nonzero matrices and invertible matrix. //! \param ok is a parameter with which we can find out if the method worked correctly. - //! \return copy of transformed upper triangular matrix. + //! \return a transformed upper triangular matrix. //! \~russian //! \brief Преобразование матрицы в верхнетреугольную. //! \details Работает только с квадратными, ненулевыми и обратимыми матрицами. //! \param ok это параметр, с помощью которого мы можем узнать, правильно ли сработал метод. - //! \return копия преобразованной верхнетреугольной матрицы. - _CMatrix &toUpperTriangular(bool *ok = 0) { + //! \return преобразованная верхнетреугольная матрицы. + PIMathMatrixT &toUpperTriangular(bool *ok = 0) { static_assert(Rows == Cols, "Works only with square matrix"); - _CMatrix smat(*this); + PIMathMatrixT smat(*this); bool ndet; uint crow; Type mul; @@ -545,9 +545,9 @@ public: //! \details Работает только с квадратными, ненулевыми и обратимыми матрицами. //! \param ok это параметр, с помощью которого мы можем узнать, правильно ли сработал метод. //! \return обратная матрица. - _CMatrix &invert(bool *ok = 0) { + PIMathMatrixT &invert(bool *ok = 0) { static_assert(Rows == Cols, "Works only with square matrix"); - _CMatrix mtmp = _CMatrix::identity(), smat(*this); + PIMathMatrixT mtmp = PIMathMatrixT::identity(), smat(*this); bool ndet; uint crow; Type mul, iddiv; @@ -603,8 +603,8 @@ public: //! \details Работает только с квадратными, ненулевыми и обратимыми матрицами. //! \param ok это параметр, с помощью которого мы можем узнать, правильно ли сработал метод. //! \return копия обратной матрицы. - _CMatrix inverted(bool *ok = 0) const { - _CMatrix tm(*this); + PIMathMatrixT inverted(bool *ok = 0) const { + PIMathMatrixT tm(*this); tm.invert(ok); return tm; } @@ -617,8 +617,8 @@ public: //! \brief Транспонирование матрицы. //! \details Работает только с квадратными, ненулевыми и обратимыми матрицами. //! \return копия транспонированной матрицы. - _CMatrixI transposed() const { - _CMatrixI tm; + PIMathMatrixT transposed() const { + PIMathMatrixT tm; PIMM_FOR tm[c][r] = m[r][c]; return tm; } @@ -631,7 +631,7 @@ public: //! \brief Операция поворота матрицы. //! \details Работает только с матрицами 2x2. //! \return повернутая матрица. - _CMatrix rotate(Type angle) { + PIMathMatrixT rotate(Type angle) { static_assert(Rows == 2 && Cols == 2, "Works only with 2x2 matrix"); Type c = std::cos(angle); Type s = std::sin(angle); @@ -643,6 +643,27 @@ public: return *this; } + //! \~english + //! \brief Matrix rotation operation. + //! \details Works only with 2x2 matrix. + //! \return copy of rotated matrix. + //! \~russian + //! \brief Операция поворота матрицы. + //! \details Работает только с матрицами 2x2. + //! \return копия повернутой матрицы. + PIMathMatrixT& rotated(Type angle) { + static_assert(Rows == 2 && Cols == 2, "Works only with 2x2 matrix"); + PIMathMatrixT outm; + Type c = std::cos(angle); + Type s = std::sin(angle); + PIMathMatrixT<2u, 2u> tm; + tm[0][0] = tm[1][1] = c; + tm[0][1] = -s; + tm[1][0] = s; + outm = outm * tm; + return outm; + } + private: Type m[Rows][Cols]; }; @@ -675,7 +696,7 @@ inline std::ostream & operator <<(std::ostream & s, const PIMathMatrixT inline PICout operator<<(PICout s, const PIMathMatrixT &m) { s << "{"; @@ -692,13 +713,11 @@ inline PICout operator<<(PICout s, const PIMathMatrixT &m) { //! \~english //! \brief Multiplying matrices by each other. -//! \details If you enter an index out of the border of the matrix there will be "undefined behavior". //! \param fm first matrix multiplier. //! \param sm second matrix multiplier. //! \return matrix that is the result of multiplication. //! \~russian //! \brief Умножение матриц друг на друга. -//! \details Если вы введете индекс вне границ матрицы, то поведение не определено ("undefined behavior"). //! \param fm первый множитель-матрица. //! \param sm второй множитель-матрица. //! \return матрица, являющаяся результатом умножения. @@ -720,13 +739,11 @@ inline PIMathMatrixT operator*(const PIMathMatrixT operator*(const PIMathMatrixT //! \~english //! \brief Multiplying a vector by a matrix. -//! \details If you enter an index out of the border of the matrix there will be "undefined behavior". //! \param sv first vector multiplier //! \param fm second matrix multiplier //! \return vector that is the result of multiplication //! \~russian //! \brief Умножения вектора на матрицу. -//! \details Если вы введете индекс вне границ матрицы, то поведение не определено ("undefined behavior"). //! \param sv второй множитель-вектор. //! \param fm первый множитель-матрица. //! \return вектор, являющийся результатом умножения. @@ -893,8 +908,8 @@ public: //! \param cols количество столбов матрицы типа \a uint. //! \param rows количество строк матрицы типа \a uint. //! \return единичная матрица matrix(`cols`, `rows`) - static _CMatrix identity(const uint cols, const uint rows) { - _CMatrix tm(cols, rows); + static PIMathMatrix identity(const uint cols, const uint rows) { + PIMathMatrix tm(cols, rows); for (uint r = 0; r < rows; ++r) for (uint c = 0; c < cols; ++c) tm.element(r, c) = (c == r ? Type(1) : Type(0)); return tm; } @@ -907,7 +922,7 @@ public: //! \brief Создает матрицу-строку, каждый элемент которой равен каждому элементу вектора //! \param val вектор типа \a PIMathVector //! \return матрица-строка, каждый элемент которой равен каждому элементу вектора - static _CMatrix matrixRow(const PIMathVector &val) {return _CMatrix(val.size(), 1, val.toVector());} + static PIMathMatrix matrixRow(const PIMathVector &val) {return PIMathMatrix(val.size(), 1, val.toVector());} //! \~english //! \brief Creates a column matrix of every element that is equal to every element of the vector @@ -917,23 +932,23 @@ public: //! \brief Создает матрицу-столбец, каждый элемент которой равен каждому элементу вектора //! \param val вектор типа \a PIMathVector //! \return матрица-столбец, каждый элемент которой равен каждому элементу вектора - static _CMatrix matrixCol(const PIMathVector &val) {return _CMatrix(1, val.size(), val.toVector());} + static PIMathMatrix matrixCol(const PIMathVector &val) {return PIMathMatrix(1, val.size(), val.toVector());} //! \~english //! \brief Set the selected column in matrix. //! \details If there are more elements of the vector than elements in the column of the matrix //! or index larger than the number of columns otherwise there will be "undefined behavior". //! \param index is the number of the selected column. - //! \param v is a vector of the type \a _CMCol that needs to fill the column. - //! \return matrix type \a _CMatrix. + //! \param v is a vector of the type \a PIMathVector that needs to fill the column. + //! \return matrix type \a PIMathMatrix //! \~russian //! \brief Определить выбранный столбец матрицы. //! \details Если элементов в векторе больше, чем элементов в столбце матрицы //! или индекс больше количества стобцов, то поведение не определено ("undefined behavior"). //! \param index номер выбранного столбца. - //! \param v вектор типа \a _CMCol, которым нужно заполнить столбец. - //! \return матрица типа \a _CMatrix. - _CMatrix &setCol(uint index, const PIMathVector &v) { + //! \param v вектор типа \a PIMathVector, которым нужно заполнить столбец. + //! \return матрица типа \a PIMathMatrix. + PIMathMatrix &setCol(uint index, const PIMathVector &v) { assert(_V2D::rows() == v.size()); PIMM_FOR_R _V2D::element(i, index) = v[i]; return *this; @@ -944,16 +959,16 @@ public: //! \details If there are more elements of the vector than elements in the row of the matrix, //! or index larger than the number of rows otherwise there will be "undefined behavior". //! \param index is the number of the selected row. - //! \param v is a vector of the type \a _CMCol that needs to fill the row. - //! \return matrix type \a _CMatrix. + //! \param v is a vector of the type \a PIMathVector that needs to fill the row. + //! \return matrix type \a PIMathMatrix. //! \~russian //! \brief Определить выбранную строку матрицы. //! \details Если элементов в векторе больше, чем элементов в строке матрицы //! или индекс больше количества стобцов, то поведение не определено ("undefined behavior"). //! \param index номер выбранной строки. - //! \param v вектор типа \a _CMCol, которым нужно заполнить строку. - //! \return матрица типа \a _CMatrix. - _CMatrix &setRow(uint index, const PIMathVector &v) { + //! \param v вектор типа \a PIMathVector, которым нужно заполнить строку. + //! \return матрица типа \a PIMathMatrix. + PIMathMatrix &setRow(uint index, const PIMathVector &v) { assert(_V2D::cols() == v.size()); PIMM_FOR_C _V2D::element(index, i) = v[i]; return *this; @@ -965,15 +980,15 @@ public: //! otherwise there will be "undefined behavior". //! \param r0 is the number of the first selected column. //! \param r1 is the number of the second selected column. - //! \return matrix type \a _CMatrix. + //! \return matrix type \a PIMathMatrix. //! \~russian //! \brief Метод меняющий местами выбранные строки в матрице. //! \details Вы не можете использовать индекс, который больше количества столбцов, //! иначе будет неопределенное повередение ("undefined behavior"). //! \param r0 номер первой выбранного стобца. //! \param r1 номер второй выбранного столбца. - //! \return матрица типа \a _CMatrix. - _CMatrix &swapCols(uint r0, uint r1) { + //! \return матрица типа \a PIMathMatrix. + PIMathMatrix &swapCols(uint r0, uint r1) { PIMM_FOR_C piSwap(_V2D::element(i, r0), _V2D::element(i, r1)); return *this; } @@ -984,15 +999,15 @@ public: //! otherwise there will be "undefined behavior" //! \param c0 is the number of the first selected row. //! \param c1 is the number of the second selected row. - //! \return matrix type \a _CMatrix. + //! \return matrix type \a PIMathMatrix. //! \~russian //! \brief Метод меняющий местами выбранные строки в матрице. //! \details Вы не можете использовать индекс, который больше количества строк, //! иначе будет неопределенное повередение ("undefined behavior"). //! \param с0 номер первой выбранной строки. //! \param с1 номер второй выбранной строки. - //! \return матрица типа \a _CMatrix. - _CMatrix &swapRows(uint c0, uint c1) { + //! \return матрица типа \a PIMathMatrix. + PIMathMatrix &swapRows(uint c0, uint c1) { PIMM_FOR_R piSwap(_V2D::element(c0, i), _V2D::element(c1, i)); return *this; } @@ -1000,12 +1015,12 @@ public: //! \~english //! \brief Method which fills the matrix with selected value. //! \param v is a parameter the type and value of which is selected and later filled into the matrix. - //! \return filled matrix type \a _CMatrix. + //! \return filled matrix type \a PIMathMatrix. //! \~russian //! \brief Метод заполняющий матрицу выбранным значением. //! \param v параметр выбранного типа и значения, которым будет заполнена матрица. - //! \return заполненная матрица типа \a _CMatrix. - _CMatrix &fill(const Type &v) { + //! \return заполненная матрица типа \a PIMathMatrix. + PIMathMatrix &fill(const Type &v) { PIMM_FOR_A _V2D::mat[i] = v; return *this; } @@ -1054,7 +1069,7 @@ public: //! \~russian //! \brief Сложение с присваиванием с матрицей `sm`. //! \param sm матрица для сложения с присваиванием. - void operator+=(const _CMatrix &sm) { + void operator+=(const PIMathMatrix &sm) { assert(_V2D::rows() == sm.rows()); assert(_V2D::cols() == sm.cols()); PIMM_FOR_A _V2D::mat[i] += sm.mat[i]; @@ -1066,7 +1081,7 @@ public: //! \~russian //! \brief Вычитание с присваиванием с матрицей `sm`. //! \param sm матрица для вычитания с присваиванием. - void operator-=(const _CMatrix &sm) { + void operator-=(const PIMathMatrix &sm) { assert(_V2D::rows() == sm.rows()); assert(_V2D::cols() == sm.cols()); PIMM_FOR_A _V2D::mat[i] -= sm.mat[i]; @@ -1099,8 +1114,8 @@ public: //! \~russian //! \brief Операция отрицания //! \return копия отрицательной матрицы - _CMatrix operator-() const { - _CMatrix tm(*this); + PIMathMatrix operator-() const { + PIMathMatrix tm(*this); PIMM_FOR_A tm.mat[i] = -_V2D::mat[i]; return tm; } @@ -1113,8 +1128,8 @@ public: //! \brief Матричное сложение. //! \param sm матричное слагаемое. //! \return результат матричного сложения. - _CMatrix operator+(const _CMatrix &sm) const { - _CMatrix tm(*this); + PIMathMatrix operator+(const PIMathMatrix &sm) const { + PIMathMatrix tm(*this); assert(tm.rows() == sm.rows()); assert(tm.cols() == sm.cols()); PIMM_FOR_A tm.mat[i] += sm.mat[i]; @@ -1129,8 +1144,8 @@ public: //! \brief Матричная разность. //! \param sm матричное вычитаемое. //! \return результат матричной разности. - _CMatrix operator-(const _CMatrix &sm) const { - _CMatrix tm(*this); + PIMathMatrix operator-(const PIMathMatrix &sm) const { + PIMathMatrix tm(*this); assert(tm.rows() == sm.rows()); assert(tm.cols() == sm.cols()); PIMM_FOR_A tm.mat[i] -= sm.mat[i]; @@ -1145,8 +1160,8 @@ public: //! \brief Матричное произведение. //! \param v множитель. //! \return результат произведения. - _CMatrix operator*(const Type &v) const { - _CMatrix tm(*this); + PIMathMatrix operator*(const Type &v) const { + PIMathMatrix tm(*this); PIMM_FOR_A tm.mat[i] *= v; return tm; } @@ -1159,9 +1174,9 @@ public: //! \brief Матричное деление. //! \param v делитель. //! \return результат деления. - _CMatrix operator/(const Type &v) const { + PIMathMatrix operator/(const Type &v) const { assert(piAbs(v) > PIMATHVECTOR_ZERO_CMP); - _CMatrix tm(*this); + PIMathMatrix tm(*this); PIMM_FOR_A tm.mat[i] /= v; return tm; } @@ -1177,7 +1192,7 @@ public: //! \param ok это параметр, с помощью которого мы можем узнать, правильно ли сработал метод. //! \return опеределитель матрицы. Type determinant(bool *ok = 0) const { - _CMatrix m(*this); + PIMathMatrix m(*this); bool k; m.toUpperTriangular(&k); Type ret = Type(0); @@ -1218,9 +1233,9 @@ public: //! \details Работает только с квадратными, ненулевыми и обратимыми матрицами. //! \param ok это параметр, с помощью которого мы можем узнать, правильно ли сработал метод. //! \return копия преобразованной верхнетреугольной матрицы. - _CMatrix &toUpperTriangular(bool *ok = 0) { + PIMathMatrix &toUpperTriangular(bool *ok = 0) { assert(isSquare()); - _CMatrix smat(*this); + PIMathMatrix smat(*this); bool ndet; uint crow; Type mul; @@ -1262,9 +1277,9 @@ public: //! \details Работает только с квадратными, ненулевыми и обратимыми матрицами. //! \param ok это параметр, с помощью которого мы можем узнать, правильно ли сработал метод. //! \return обратная матрица. - _CMatrix &invert(bool *ok = 0, PIMathVector *sv = 0) { + PIMathMatrix &invert(bool *ok = 0, PIMathVector *sv = 0) { assert(isSquare()); - _CMatrix mtmp = _CMatrix::identity(_V2D::cols_, _V2D::rows_), smat(*this); + PIMathMatrix mtmp = PIMathMatrix::identity(_V2D::cols_, _V2D::rows_), smat(*this); bool ndet; uint crow; Type mul, iddiv; @@ -1324,8 +1339,8 @@ public: //! \details Работает только с квадратными, ненулевыми и обратимыми матрицами. //! \param ok это параметр, с помощью которого мы можем узнать, правильно ли сработал метод. //! \return копия обратной матрицы. - _CMatrix inverted(bool *ok = 0) const { - _CMatrix tm(*this); + PIMathMatrix inverted(bool *ok = 0) const { + PIMathMatrix tm(*this); tm.invert(ok); return tm; } @@ -1338,8 +1353,8 @@ public: //! \brief Транспонирование матрицы. //! \details Работает только с квадратными, ненулевыми и обратимыми матрицами. //! \return копия транспонированной матрицы. - _CMatrix transposed() const { - _CMatrix tm(_V2D::rows_, _V2D::cols_); + PIMathMatrix transposed() const { + PIMathMatrix tm(_V2D::rows_, _V2D::cols_); PIMM_FOR tm.element(c, r) = _V2D::element(r, c); return tm; } @@ -1360,7 +1375,7 @@ inline std::ostream & operator <<(std::ostream & s, const PIMathMatrix & m //! \brief Inline-оператор для вывода матрицы в консоль. //! \param s типа \a PICout. //! \param m типа \a PIMathMatrixT. -//! \return непечатанная в консоль \a PIMathMatrix. +//! \return непечатанная в консоль \a PICout. template inline PICout operator<<(PICout s, const PIMathMatrix &m) { s << "Matrix{"; @@ -1376,15 +1391,15 @@ inline PICout operator<<(PICout s, const PIMathMatrix &m) { } //! \~english -//! \brief Inline operator for serializing a matrix into a PIByteArray. -//! \param s PIByteArray type. -//! \param v PIMathMatrix type. -//! \return PIBiteArray serialized PIMathMatrix. +//! \brief Inline operator for serializing a matrix into a \a PIBinaryStream. +//! \param s \a PIBinaryStream type. +//! \param v \a PIMathMatrix type. +//! \return \a PIBinaryStream serialized \a PIMathMatrix. //! \~russian -//! \brief Inline-оператор для сериализации матрицы в \a PIByteArray. -//! \param s типа \a PIByteArray. +//! \brief Inline-оператор для сериализации матрицы в \a PIBinaryStream. +//! \param s типа \a PIBinaryStream. //! \param v типа \a PIMathMatrix. -//! \return сериализованная в \a PIBiteArray матрица \a PIMathMatrix. +//! \return сериализованная в \a PIBinaryStream матрица \a PIMathMatrix. template inline PIBinaryStream

& operator <<(PIBinaryStream

& s, const PIMathMatrix & v) { s << (const PIVector2D &) v; @@ -1393,14 +1408,14 @@ inline PIBinaryStream

& operator <<(PIBinaryStream

& s, const PIMathMatrix //! \~english //! \brief Inline operator to deserialize matrix from \a PIByteArray. -//! \param s \a PIByteArray type. +//! \param s \a PIBinaryStream type. //! \param v \a PIMathMatrix type. -//! \return \a PIMathMatrix deserialized from \a PIByteArray. +//! \return \a PIMathMatrix deserialized from \a PIBinaryStream . //! \~russian //! \brief Inline-оператор для сериализации матрицы в \a PIByteArray. -//! \param s типа \a PIByteArray. +//! \param s типа \a PIBinaryStream. //! \param v типа \a PIMathMatrix. -//! \return десериализованная из \a PIBiteArray матрица \a PIMathMatrix. +//! \return десериализованная из \a PIBinaryStream матрица \a PIMathMatrix. template inline PIBinaryStream

& operator >>(PIBinaryStream

& s, PIMathMatrix & v) { s >> (PIVector2D &) v; diff --git a/libs/main/math/pipoint.h b/libs/main/math/pipoint.h index 78884239..b9090050 100644 --- a/libs/main/math/pipoint.h +++ b/libs/main/math/pipoint.h @@ -123,7 +123,9 @@ public: //! \~russian Перевести копию точки из полярной системы координат в декартовую. static PIPoint fromPolar(const PIPoint & p) {return PIPoint(p.y * cos(p.x), p.y * sin(p.x));} - //! \~russian Прибавить координаты второй точки и сохранить. + //! \~russian + //! Прибавить координаты второй точки и сохранить. + //! \details Является копией метода \a translate(). void operator +=(const PIPoint & p) {translate(p);} //! \~russian Сложить координаты двух точек. @@ -148,7 +150,7 @@ public: bool operator !=(const PIPoint & p) const {return (x != p.x || y != p.y);} }; -//! \~russian Перегруженный оператор для вывода координат. +//! \~russian Перегруженный оператор для вывода координат в \a PICout. template PICout operator <<(PICout & s, const PIPoint & v) { s.setControl(0, true);