исправление ошибок в документации

This commit is contained in:
Tamerlan Baziev
2022-08-01 12:29:42 +03:00
parent bbc83128b0
commit d6758a8562
3 changed files with 144 additions and 127 deletions

View File

@@ -46,7 +46,7 @@ public:
//! Пустой конструктор. //! Пустой конструктор.
//! \details //! \details
//! При выполнении пустого конструктора координаты не изменяются. //! При выполнении пустого конструктора координаты не изменяются.
//! p0 == p1 //! Начало и конец совпадают.
PILine() {} PILine() {}
//! \~russian //! \~russian
@@ -109,7 +109,7 @@ public:
return *this; return *this;
} }
//! Создать копию отрезка и сдвинуть её на \a x, \a y. //! Создать копию отрезка и сдвинуть её на `x` и `y`.
PILine<Type> translated(Type x, Type y) const { PILine<Type> translated(Type x, Type y) const {
PILine<Type> l(*this); PILine<Type> l(*this);
l.translate(x, y); l.translate(x, y);
@@ -177,7 +177,7 @@ public:
bool operator !=(const PILine<Type> & r) const {return (p1 != r.p1 || p1 != r.p1);} bool operator !=(const PILine<Type> & r) const {return (p1 != r.p1 || p1 != r.p1);}
}; };
//! \~russian Перегруженный оператор для вывода координат. //! \~russian Перегруженный оператор для вывода координат в \a PICout.
template<typename Type> template<typename Type>
PICout operator <<(PICout & s, const PILine<Type> & v) { PICout operator <<(PICout & s, const PILine<Type> & v) {
s.setControl(0, true); s.setControl(0, true);

View File

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

View File

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