Fix code formatting & grammar mistakes

This commit is contained in:
2020-09-03 16:57:46 +03:00
committed by Gama
parent 8163a68e03
commit 42793522a4

View File

@@ -511,291 +511,287 @@ public:
* @brief Rotation the matrix by an "angle". Works only with 2x2 matrix, * @brief Rotation the matrix by an "angle". Works only with 2x2 matrix,
* else return default construction of PIMathMatrixT * else return default construction of PIMathMatrixT
* *
* @param angle is the angle of rotation of the matrix * @return type uint shows number of rows
* @return rotated matrix */
*/ uint rows() const { return Rows; }
static _CMatrix rotation(double angle) {return _CMatrix();}
/** /**
* @brief Rotation of the matrix by an "angle" along the X axis. Works only with 3x3 matrix, * @brief Method which returns the selected column in PIMathVectorT format
* else return default construction of PIMathMatrixT *
* * @param index is the number of the selected column
* @param angle is the angle of rotation of the matrix along the X axis * @return column in PIMathVectorT format
* @return rotated matrix */
*/ _CMCol col(uint index) {
static _CMatrix rotationX(double angle) {return _CMatrix();} _CMCol tv;
PIMM_FOR_R(i) tv[i] = m[i][index];
return tv;
}
/** /**
* @brief Rotation of the matrix by an "angle" along the Y axis. Works only with 3x3 matrix, * @brief Method which returns the selected row in PIMathVectorT format
* else return default construction of PIMathMatrixT *
* * @param index is the number of the selected row
* @param angle is the angle of rotation of the matrix along the Y axis * @return row in PIMathVectorT format
* @return rotated matrix */
*/ _CMRow row(uint index) {
static _CMatrix rotationY(double angle) {return _CMatrix();} _CMRow tv;
PIMM_FOR_C(i) tv[i] = m[index][i];
return tv;
}
/** /**
* @brief Rotation of the matrix by an "angle" along the Z axis. Works only with 3x3 matrix, * @brief Set the selected column in matrix
* else return default construction of PIMathMatrixT *
* * @param index is the number of the selected column
* @param angle is the angle of rotation of the matrix along the Z axis * @param v is a vector of the type _CMCol that needs to fill the column
* @return rotated matrix * @return matrix type _CMatrix
*/ */
static _CMatrix rotationZ(double angle) {return _CMatrix();} _CMatrix &setCol(uint index, const _CMCol &v) {
PIMM_FOR_R(i) m[i][index] = v[i];
return *this;
}
/** /**
* @brief Scaling the matrix along the X axis by the value "factor". Works only with 3x3 and 2x2 matrix, * @brief Set the selected row in matrix
* else return default construction of PIMathMatrixT *
* * @param index is the number of the selected row
* @param factor is the value of scaling by X axis * @param v is a vector of the type _CMCol that needs to fill the row
* @return rotated matrix * @return matrix type _CMatrix
*/ */
static _CMatrix scaleX(double factor) {return _CMatrix();} _CMatrix &setRow(uint index, const _CMRow &v) {
PIMM_FOR_C(i) m[index][i] = v[i];
return *this;
}
/** /**
* @brief Scaling the matrix along the Y axis by the value "factor". Works only with 3x3 and 2x2 matrix, * @brief Method which changes selected rows in a matrix
* else return default construction of PIMathMatrixT *
* * @param r0 is the number of the first selected row
* @param factor is the value of scaling by Y axis * @param r1 is the number of the second selected row
* @return rotated matrix * @return matrix type _CMatrix
*/ */
static _CMatrix scaleY(double factor) {return _CMatrix();} _CMatrix &swapRows(uint r0, uint r1) {
Type t;
PIMM_FOR_C(i) {
t = m[r0][i];
m[r0][i] = m[r1][i];
m[r1][i] = t;
}
return *this;
}
/** /**
* @brief Scaling the matrix along the Z axis by the value "factor". Works only with 3x3 matrix, * @brief Method which changes selected columns in a matrix
* else return default construction of PIMathMatrixT *
* * @param c0 is the number of the first selected column
* @param factor is the value of scaling by Z axis * @param c1 is the number of the second selected column
* @return rotated matrix * @return matrix type _CMatrix
*/ */
static _CMatrix scaleZ(double factor) {return _CMatrix();} _CMatrix &swapCols(uint c0, uint c1) {
Type t;
PIMM_FOR_R(i) {
t = m[i][c0];
m[i][c0] = m[i][c1];
m[i][c1] = t;
}
return *this;
}
/** /**
* @brief Method which returns number of columns in matrix * @brief Method which fills the matrix with selected value
* *
* @return type uint shows number of columns * @param v is a parameter the type and value of which is selected and later filled into the matrix
*/ * @return filled matrix type _CMatrix
uint cols() const {return Cols;} */
_CMatrix &fill(const Type &v) {
PIMM_FOR_WB(r, c) m[r][c] = v;
return *this;
}
/** /**
* @brief Method which returns number of rows in matrix * @brief Method which checks if matrix is square
* *
* @return type uint shows number of rows * @return true if matrix is square, else false
*/ */
uint rows() const {return Rows;} bool isSquare() const { return cols() == rows(); }
/** /**
* @brief Method which returns the selected column in PIMathVectorT format * @brief Method which checks if main diagonal of matrix consists of ones and another elements are zeros
* *
* @param index is the number of the selected column * @return true if matrix is identitied, else false
* @return column in PIMathVectorT format */
*/ bool isIdentity() const {
_CMCol col(uint index) {_CMCol tv; PIMM_FOR_R(i) tv[i] = m[i][index]; return tv;} PIMM_FOR_WB(r, c) if ((c == r) ? m[r][c] != Type(1) : m[r][c] != Type(0)) return false;
return true;
}
/** /**
* @brief Method which returns the selected row in PIMathVectorT format * @brief Method which checks if every elements of matrix are zeros
* *
* @param index is the number of the selected row * @return true if matrix is null, else false
* @return row in PIMathVectorT format */
*/ bool isNull() const {
_CMRow row(uint index) {_CMRow tv; PIMM_FOR_C(i) tv[i] = m[index][i]; return tv;} PIMM_FOR_WB(r, c) if (m[r][c] != Type(0)) return false;
return true;
}
/** /**
* @brief Set the selected column in matrix * @brief Full access to elements reference by row "row" and col "col"
* *
* @param index is the number of the selected column * @param row is a parameter that shows the row number of the matrix of the selected element
* @param v is a vector of the type _CMCol that needs to fill the column * @param col is a parameter that shows the column number of the matrix of the selected element
* @return matrix type _CMatrix * @return reference to element of matrix by row "row" and col "col"
*/ */
_CMatrix & setCol(uint index, const _CMCol & v) {PIMM_FOR_R(i) m[i][index] = v[i]; return *this;} Type &at(uint row, uint col) { return m[row][col]; }
/** /**
* @brief Set the selected row in matrix * @brief Full access to element by row "row" and col "col"
* *
* @param index is the number of the selected row * @param row is a parameter that shows the row number of the matrix of the selected element
* @param v is a vector of the type _CMCol that needs to fill the row * @param col is a parameter that shows the column number of the matrix of the selected element
* @return matrix type _CMatrix * @return element of matrix by row "row" and col "col"
*/ */
_CMatrix & setRow(uint index, const _CMRow & v) {PIMM_FOR_C(i) m[index][i] = v[i]; return *this;} Type at(uint row, uint col) const { return m[row][col]; }
/** /**
* @brief Method which changes selected rows in a matrix * @brief Full access to the matrix row pointer
* *
* @param r0 is the number of the first selected row * @param row is a row of necessary matrix
* @param r1 is the number of the second selected row * @return matrix row pointer
* @return matrix type _CMatrix */
*/ Type *operator[](uint row) { return m[row]; }
_CMatrix & swapRows(uint r0, uint r1) {Type t; PIMM_FOR_C(i) {t = m[r0][i]; m[r0][i] = m[r1][i]; m[r1][i] = t;} return *this;}
/** /**
* @brief Method which changes selected columns in a matrix * @brief Read-only access to the matrix row pointer
* *
* @param c0 is the number of the first selected column * @param row is a row of necessary matrix
* @param c1 is the number of the second selected column * @return matrix row pointer
* @return matrix type _CMatrix */
*/ const Type *operator[](uint row) const { return m[row]; }
_CMatrix & swapCols(uint c0, uint c1) {Type t; PIMM_FOR_R(i) {t = m[i][c0]; m[i][c0] = m[i][c1]; m[i][c1] = t;} return *this;}
/** /**
* @brief Method which fills the matrix with selected value * @brief Matrix assignment to matrix "sm"
* *
* @param v is a parameter the type and value of which is selected and later filled into the matrix * @param sm matrix for the assigment
* @return filled matrix type _CMatrix * @return matrix equal with sm
*/ */
_CMatrix & fill(const Type & v) {PIMM_FOR_WB(r, c) m[r][c] = v; return *this;} _CMatrix &operator=(const _CMatrix &sm) {
memcpy(m, sm.m, sizeof(Type) * Cols * Rows);
return *this;
}
/** /**
* @brief Method which checks if matrix is square * @brief Compare with matrix "sm"
* *
* @return true if matrix is square, else false * @param sm matrix for the compare
*/ * @return if matrices are equal true, else false
bool isSquare() const {return cols() == rows();} */
bool operator==(const _CMatrix &sm) const {
PIMM_FOR_WB(r, c) if (m[r][c] != sm.m[r][c]) return false;
return true;
}
/** /**
* @brief Method which checks if main diagonal of matrix consists of ones and another elements are zeros * @brief Compare with matrix "sm"
* *
* @return true if matrix is identitied, else false * @param sm matrix for the compare
*/ * @return if matrices are not equal true, else false
bool isIdentity() const {PIMM_FOR_WB(r, c) if ((c == r) ? m[r][c] != Type(1) : m[r][c] != Type(0)) return false; return true;} */
bool operator!=(const _CMatrix &sm) const { return !(*this == sm); }
/** /**
* @brief Method which checks if every elements of matrix are zeros * @brief Addition assignment with matrix "sm"
* *
* @return true if matrix is null, else false * @param sm matrix for the addition assigment
*/ */
bool isNull() const {PIMM_FOR_WB(r, c) if (m[r][c] != Type(0)) return false; return true;} void operator+=(const _CMatrix &sm) { PIMM_FOR_WB(r, c) m[r][c] += sm.m[r][c]; }
/** /**
* @brief Full access to elements reference by row "row" and col "col" * @brief Subtraction assignment with matrix "sm"
* *
* @param row is a parameter that shows the row number of the matrix of the selected element * @param sm matrix for the subtraction assigment
* @param col is a parameter that shows the column number of the matrix of the selected element */
* @return reference to element of matrix by row "row" and col "col" void operator-=(const _CMatrix &sm) { PIMM_FOR_WB(r, c) m[r][c] -= sm.m[r][c]; }
*/
Type & at(uint row, uint col) {return m[row][col];}
/** /**
* @brief Full access to element by row "row" and col "col" * @brief Multiplication assignment with value "v"
* *
* @param row is a parameter that shows the row number of the matrix of the selected element * @param v value for the multiplication assigment
* @param col is a parameter that shows the column number of the matrix of the selected element */
* @return element of matrix by row "row" and col "col" void operator*=(const Type &v) { PIMM_FOR_WB(r, c) m[r][c] *= v; }
*/
Type at(uint row, uint col) const {return m[row][col];}
/** /**
* @brief Full access to the matrix row pointer * @brief Division assignment with value "v"
* *
* @param row is a row of necessary matrix * @param v value for the division assigment
* @return matrix row pointer */
*/ void operator/=(const Type &v) { PIMM_FOR_WB(r, c) m[r][c] /= v; }
Type * operator [](uint row) {return m[row];}
/** /**
* @brief Read-only access to the matrix row pointer * @brief Matrix substraction
* *
* @param row is a row of necessary matrix * @return the result of matrix substraction
* @return matrix row pointer */
*/ _CMatrix operator-() const {
const Type * operator [](uint row) const {return m[row];} _CMatrix tm;
PIMM_FOR_WB(r, c) tm.m[r][c] = -m[r][c];
return tm;
}
/** /**
* @brief Matrix assignment to matrix "sm" * @brief Matrix addition
* *
* @param sm matrix for the assigment * @param sm is matrix term
* @return matrix equal with sm * @return the result of matrix addition
*/ */
_CMatrix & operator =(const _CMatrix & sm) {memcpy(m, sm.m, sizeof(Type) * Cols * Rows); return *this;} _CMatrix operator+(const _CMatrix &sm) const {
_CMatrix tm = _CMatrix(*this);
PIMM_FOR_WB(r, c) tm.m[r][c] += sm.m[r][c];
return tm;
}
/** /**
* @brief Compare with matrix "sm" * @brief Matrix substraction
* *
* @param sm matrix for the compare * @param sm is matrix subtractor
* @return if matrices are equal true, else false * @return the result of matrix substraction
*/ */
bool operator ==(const _CMatrix & sm) const {PIMM_FOR_WB(r, c) if (m[r][c] != sm.m[r][c]) return false; return true;} _CMatrix operator-(const _CMatrix &sm) const {
_CMatrix tm = _CMatrix(*this);
PIMM_FOR_WB(r, c) tm.m[r][c] -= sm.m[r][c];
return tm;
}
/** /**
* @brief Compare with matrix "sm" * @brief Matrix multiplication
* *
* @param sm matrix for the compare * @param v is value factor
* @return if matrices are not equal true, else false * @return the result of matrix multiplication
*/ */
bool operator !=(const _CMatrix & sm) const {return !(*this == sm);} _CMatrix operator*(const Type &v) const {
_CMatrix tm = _CMatrix(*this);
PIMM_FOR_WB(r, c) tm.m[r][c] *= v;
return tm;
}
/** /**
* @brief Addition assignment with matrix "sm" * @brief Matrix division
* *
* @param sm matrix for the addition assigment * @param v is value divider
*/ * @return the result of matrix division
void operator +=(const _CMatrix & sm) {PIMM_FOR_WB(r, c) m[r][c] += sm.m[r][c];} */
_CMatrix operator/(const Type &v) const {
_CMatrix tm = _CMatrix(*this);
PIMM_FOR_WB(r, c) tm.m[r][c] /= v;
return tm;
}
/** /**
* @brief Subtraction assignment with matrix "sm" * @brief Determinant of the matrix is calculated
* *
* @param sm matrix for the subtraction assigment * @return matrix determinant
*/ */
void operator -=(const _CMatrix & sm) {PIMM_FOR_WB(r, c) m[r][c] -= sm.m[r][c];} Type determinant(bool *ok = 0) const {
/**
* @brief Multiplication assignment with value "v"
*
* @param v value for the multiplication assigment
*/
void operator *=(const Type & v) {PIMM_FOR_WB(r, c) m[r][c] *= v;}
/**
* @brief Division assignment with value "v"
*
* @param v value for the division assigment
*/
void operator /=(const Type & v) {PIMM_FOR_WB(r, c) m[r][c] /= v;}
/**
* @brief Matrix substraction
*
* @return the result of matrix substraction
*/
_CMatrix operator -() const {_CMatrix tm; PIMM_FOR_WB(r, c) tm.m[r][c] = -m[r][c]; return tm;}
/**
* @brief Matrix addition
*
* @param sm is matrix term
* @return the result of matrix addition
*/
_CMatrix operator +(const _CMatrix & sm) const {_CMatrix tm = _CMatrix(*this); PIMM_FOR_WB(r, c) tm.m[r][c] += sm.m[r][c]; return tm;}
/**
* @brief Matrix substraction
*
* @param sm is matrix subtractor
* @return the result of matrix substraction
*/
_CMatrix operator -(const _CMatrix & sm) const {_CMatrix tm = _CMatrix(*this); PIMM_FOR_WB(r, c) tm.m[r][c] -= sm.m[r][c]; return tm;}
/**
* @brief Matrix multiplication
*
* @param v is value factor
* @return the result of matrix multiplication
*/
_CMatrix operator *(const Type & v) const {_CMatrix tm = _CMatrix(*this); PIMM_FOR_WB(r, c) tm.m[r][c] *= v; return tm;}
/**
* @brief Matrix division
*
* @param v is value divider
* @return the result of matrix division
*/
_CMatrix operator /(const Type & v) const {_CMatrix tm = _CMatrix(*this); PIMM_FOR_WB(r, c) tm.m[r][c] /= v; return tm;}
/**
* @brief Determinant of the matrix is calculated
*
* @return matrix determinant
*/
Type determinant(bool * ok = 0) const {
_CMatrix m(*this); _CMatrix m(*this);
bool k; bool k;
Type ret = Type(0); Type ret = Type(0);