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

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

View File

@@ -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<Type> 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<Rows, Cols, Type> identity() {
PIMathMatrixT<Rows, Cols, Type> tm = PIMathMatrixT<Rows, Cols, Type>();
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<Rows, Type> col(uint index) {
PIMathVectorT<Rows, Type> 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<Cols, Type> row(uint index) {
PIMathVectorT<Cols, Type> 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<Rows, Type> that needs to fill the column.
//! \return matrix type \a PIMathMatrixT<Rows, Cols, Type>.
//! \~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<Rows, Type>, которым необходимо заполнить столбец.
//! \return матрица типа \a PIMathMatrixT<Rows, Cols, Type>.
PIMathMatrixT<Rows, Cols, Type> &setCol(uint index, const PIMathVectorT<Rows, Type> &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<Cols, Type> that needs to fill the row.
//! \return matrix type PIMathMatrixT<Rows, Cols, Type>
//! \~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<Cols, Type>, которым необходимо заполнить строку.
//! \return матрица типа \a PIMathMatrixT<Rows, Cols, Type>.
PIMathMatrixT<Rows, Cols, Type> &setRow(uint index, const PIMathVectorT<Cols, Type> &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<Rows, Cols, Type>
//! \~russian
//! \brief Метод, меняющий местами выбранные строки в матрице.
//! \details Если вы введете индекс вне границ матрицы, то поведение не определено ("undefined behavior").
//! \param rf номер первой выбранной строки.
//! \param rs номер второй выбранной строки.
//! \return матрица типа \a _CMatrix.
_CMatrix &swapRows(uint rf, uint rs) {
//! \return матрица типа \a PIMathMatrixT<Rows, Cols, Type>.
PIMathMatrixT<Rows, Cols, Type> &swapRows(uint rf, uint rs) {
PIMM_FOR_C piSwap<Type>(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<Rows, Cols, Type>
//! \~russian
//! \brief Метод, меняющий местами выбранные столбцы в матрице.
//! \details Если вы введете индекс вне границ матрицы, то поведение не определено ("undefined behavior").
//! \param rf номер первого выбранного столбца.
//! \param rs номер второго выбранного столбца.
//! \return матрица типа \a _CMatrix.
_CMatrix &swapCols(uint cf, uint cs) {
//! \return матрица типа \a PIMathMatrixT<Rows, Cols, Type>.
PIMathMatrixT<Rows, Cols, Type> &swapCols(uint cf, uint cs) {
PIMM_FOR_R piSwap<Type>(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<Rows, Cols, Type>.
//! \~russian
//! \brief Метод, заполняющий матрицу выбранным значением.
//! \param v параметр тип и значения, которого выбираются и заносятся в матрицу.
//! \return заполненная матрица типа \a _CMatrix.
_CMatrix &fill(const Type &v) {
//! \return заполненная матрица типа \a PIMathMatrixT<Rows, Cols, Type>.
PIMathMatrixT<Rows, Cols, Type> &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<Rows, Cols, Type> &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<Rows, Cols, Type> &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<Rows, Cols, Type> &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<Rows, Cols, Type> &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<Rows, Cols, Type> operator-() const {
PIMathMatrixT<Rows, Cols, Type> 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<Rows, Cols, Type> operator+(const PIMathMatrixT<Rows, Cols, Type> &sm) const {
PIMathMatrixT<Rows, Cols, Type> tm = PIMathMatrixT<Rows, Cols, Type>(*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<Rows, Cols, Type> operator-(const PIMathMatrixT<Rows, Cols, Type> &sm) const {
PIMathMatrixT<Rows, Cols, Type> tm = PIMathMatrixT<Rows, Cols, Type>(*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<Rows, Cols, Type> operator*(const Type &v) const {
PIMathMatrixT<Rows, Cols, Type> tm = PIMathMatrixT<Rows, Cols, Type>(*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<Rows, Cols, Type> operator/(const Type &v) const {
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;
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<Rows, Cols, Type> 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<Rows, Cols, Type> &toUpperTriangular(bool *ok = 0) {
static_assert(Rows == Cols, "Works only with square matrix");
_CMatrix smat(*this);
PIMathMatrixT<Rows, Cols, Type> smat(*this);
bool ndet;
uint crow;
Type mul;
@@ -545,9 +545,9 @@ public:
//! \details Работает только с квадратными, ненулевыми и обратимыми матрицами.
//! \param ok это параметр, с помощью которого мы можем узнать, правильно ли сработал метод.
//! \return обратная матрица.
_CMatrix &invert(bool *ok = 0) {
PIMathMatrixT<Rows, Cols, Type> &invert(bool *ok = 0) {
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;
uint crow;
Type mul, iddiv;
@@ -603,8 +603,8 @@ public:
//! \details Работает только с квадратными, ненулевыми и обратимыми матрицами.
//! \param ok это параметр, с помощью которого мы можем узнать, правильно ли сработал метод.
//! \return копия обратной матрицы.
_CMatrix inverted(bool *ok = 0) const {
_CMatrix tm(*this);
PIMathMatrixT<Rows, Cols, Type> inverted(bool *ok = 0) const {
PIMathMatrixT<Rows, Cols, Type> tm(*this);
tm.invert(ok);
return tm;
}
@@ -617,8 +617,8 @@ public:
//! \brief Транспонирование матрицы.
//! \details Работает только с квадратными, ненулевыми и обратимыми матрицами.
//! \return копия транспонированной матрицы.
_CMatrixI transposed() const {
_CMatrixI tm;
PIMathMatrixT<Cols, Rows, Type> transposed() const {
PIMathMatrixT<Cols, Rows, Type> 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<Rows, Cols, Type> 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<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:
Type m[Rows][Cols];
};
@@ -675,7 +696,7 @@ inline std::ostream & operator <<(std::ostream & s, const PIMathMatrixT<Rows, Co
//! \brief Inline-оператор для вывода матрицы в консоль.
//! \param s типа \a PICout.
//! \param m типа \a PIMathMatrixT.
//! \return непечатанная в консоль \a PIMathMatrix.
//! \return непечатанная в консоль \a PICout.
template<uint Rows, uint Cols, typename Type>
inline PICout operator<<(PICout s, const PIMathMatrixT<Rows, Cols, Type> &m) {
s << "{";
@@ -692,13 +713,11 @@ inline PICout operator<<(PICout s, const PIMathMatrixT<Rows, Cols, Type> &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<Rows0, Cols1, Type> operator*(const PIMathMatrixT<Rows0, CR
//! \~english
//! \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 sv second vector multiplier
//! \return vector that is the result of multiplication
//! \~russian
//! \brief Умножения матрицы на вектор.
//! \details Если вы введете индекс вне границ матрицы, то поведение не определено ("undefined behavior").
//! \param fm первый множитель-матрица.
//! \param sv второй множитель-вектор.
//! \return вектор, являющийся результатом умножения.
@@ -746,13 +763,11 @@ inline PIMathVectorT<Rows, Type> operator*(const PIMathMatrixT<Rows, Cols, Type>
//! \~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<Type> identity(const uint cols, const uint 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));
return tm;
}
@@ -907,7 +922,7 @@ public:
//! \brief Создает матрицу-строку, каждый элемент которой равен каждому элементу вектора
//! \param val вектор типа \a PIMathVector
//! \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
//! \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<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
//! \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<Type> that needs to fill the column.
//! \return matrix type \a PIMathMatrix<Type>
//! \~russian
//! \brief Определить выбранный столбец матрицы.
//! \details Если элементов в векторе больше, чем элементов в столбце матрицы
//! или индекс больше количества стобцов, то поведение не определено ("undefined behavior").
//! \param index номер выбранного столбца.
//! \param v вектор типа \a _CMCol, которым нужно заполнить столбец.
//! \return матрица типа \a _CMatrix.
_CMatrix &setCol(uint index, const PIMathVector<Type> &v) {
//! \param v вектор типа \a PIMathVector<Type>, которым нужно заполнить столбец.
//! \return матрица типа \a PIMathMatrix<Type>.
PIMathMatrix<Type> &setCol(uint index, const PIMathVector<Type> &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<Type> that needs to fill the row.
//! \return matrix type \a PIMathMatrix<Type>.
//! \~russian
//! \brief Определить выбранную строку матрицы.
//! \details Если элементов в векторе больше, чем элементов в строке матрицы
//! или индекс больше количества стобцов, то поведение не определено ("undefined behavior").
//! \param index номер выбранной строки.
//! \param v вектор типа \a _CMCol, которым нужно заполнить строку.
//! \return матрица типа \a _CMatrix.
_CMatrix &setRow(uint index, const PIMathVector<Type> &v) {
//! \param v вектор типа \a PIMathVector<Type>, которым нужно заполнить строку.
//! \return матрица типа \a PIMathMatrix<Type>.
PIMathMatrix<Type> &setRow(uint index, const PIMathVector<Type> &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<Type>.
//! \~russian
//! \brief Метод меняющий местами выбранные строки в матрице.
//! \details Вы не можете использовать индекс, который больше количества столбцов,
//! иначе будет неопределенное повередение ("undefined behavior").
//! \param r0 номер первой выбранного стобца.
//! \param r1 номер второй выбранного столбца.
//! \return матрица типа \a _CMatrix.
_CMatrix &swapCols(uint r0, uint r1) {
//! \return матрица типа \a PIMathMatrix<Type>.
PIMathMatrix<Type> &swapCols(uint r0, uint r1) {
PIMM_FOR_C piSwap<Type>(_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<Type>.
//! \~russian
//! \brief Метод меняющий местами выбранные строки в матрице.
//! \details Вы не можете использовать индекс, который больше количества строк,
//! иначе будет неопределенное повередение ("undefined behavior").
//! \param с0 номер первой выбранной строки.
//! \param с1 номер второй выбранной строки.
//! \return матрица типа \a _CMatrix.
_CMatrix &swapRows(uint c0, uint c1) {
//! \return матрица типа \a PIMathMatrix<Type>.
PIMathMatrix<Type> &swapRows(uint c0, uint c1) {
PIMM_FOR_R piSwap<Type>(_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<Type>.
//! \~russian
//! \brief Метод заполняющий матрицу выбранным значением.
//! \param v параметр выбранного типа и значения, которым будет заполнена матрица.
//! \return заполненная матрица типа \a _CMatrix.
_CMatrix &fill(const Type &v) {
//! \return заполненная матрица типа \a PIMathMatrix<Type>.
PIMathMatrix<Type> &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<Type> &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<Type> &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<Type> operator-() const {
PIMathMatrix<Type> 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<Type> operator+(const PIMathMatrix<Type> &sm) const {
PIMathMatrix<Type> 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<Type> operator-(const PIMathMatrix<Type> &sm) const {
PIMathMatrix<Type> 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<Type> operator*(const Type &v) const {
PIMathMatrix<Type> 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<Type> operator/(const Type &v) const {
assert(piAbs<Type>(v) > PIMATHVECTOR_ZERO_CMP);
_CMatrix tm(*this);
PIMathMatrix<Type> 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<Type> 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<Type> &toUpperTriangular(bool *ok = 0) {
assert(isSquare());
_CMatrix smat(*this);
PIMathMatrix<Type> smat(*this);
bool ndet;
uint crow;
Type mul;
@@ -1262,9 +1277,9 @@ public:
//! \details Работает только с квадратными, ненулевыми и обратимыми матрицами.
//! \param ok это параметр, с помощью которого мы можем узнать, правильно ли сработал метод.
//! \return обратная матрица.
_CMatrix &invert(bool *ok = 0, PIMathVector<Type> *sv = 0) {
PIMathMatrix<Type> &invert(bool *ok = 0, PIMathVector<Type> *sv = 0) {
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;
uint crow;
Type mul, iddiv;
@@ -1324,8 +1339,8 @@ public:
//! \details Работает только с квадратными, ненулевыми и обратимыми матрицами.
//! \param ok это параметр, с помощью которого мы можем узнать, правильно ли сработал метод.
//! \return копия обратной матрицы.
_CMatrix inverted(bool *ok = 0) const {
_CMatrix tm(*this);
PIMathMatrix<Type> inverted(bool *ok = 0) const {
PIMathMatrix<Type> 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<Type> transposed() const {
PIMathMatrix<Type> 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<Type> & m
//! \brief Inline-оператор для вывода матрицы в консоль.
//! \param s типа \a PICout.
//! \param m типа \a PIMathMatrixT.
//! \return непечатанная в консоль \a PIMathMatrix.
//! \return непечатанная в консоль \a PICout.
template<typename Type>
inline PICout operator<<(PICout s, const PIMathMatrix<Type> &m) {
s << "Matrix{";
@@ -1376,15 +1391,15 @@ inline PICout operator<<(PICout s, const PIMathMatrix<Type> &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 <typename P, typename T>
inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIMathMatrix<T> & v) {
s << (const PIVector2D<T> &) v;
@@ -1393,14 +1408,14 @@ inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & 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 <typename P, typename T>
inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, PIMathMatrix<T> & v) {
s >> (PIVector2D<T> &) v;

View File

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