📄 mmatrix.h
字号:
boolean nextZero(long& row_index, long& col_index, long row_start, long col_start) const { return MMatrixMethods::nextZero(*this, row_index, col_index, row_start, col_start); } // method: nextNonZero // boolean nextNonZero(TIntegral& value, long& row_index, long& col_index, long row_start, long col_start) const { return MMatrixMethods::nextNonZero(*this, value, row_index, col_index, row_start, col_start); } // method: findRow // long findRow(const TVector& vector) const { return MMatrixMethods::findRow<TScalar,TIntegral>(*this, vector); } // resize methods // boolean setCapacity(long nrows, long ncols = DEF_SIZE, boolean preserve_values = true, Integral::MTYPE type = Integral::UNCHANGED); boolean setCapacity(const MMatrix& prototype_matrix, boolean preserve_values = true, Integral::MTYPE type = Integral::UNCHANGED); boolean setDimensions(long nrows, long ncols = DEF_SIZE, boolean preserve_values = true, Integral::MTYPE type = Integral::UNCHANGED); boolean setDimensions(const MMatrix& prototype_matrix, boolean preserve_values = true, Integral::MTYPE type = Integral::UNCHANGED); //--------------------------------------------------------------------------- // // class-specific public methods: // property checking methods // //--------------------------------------------------------------------------- // method: checkDimensions // check if the current matrix has the same dimension as the input matrix // template <class TAScalar, class TAIntegral> boolean checkDimensions(const MMatrix<TAScalar, TAIntegral>& matrix) const { return (getNumRows() == matrix.getNumRows() && getNumColumns() == matrix.getNumColumns()); } // method: changeType // change the type of the current matrix // boolean changeType(Integral::MTYPE type); // method: isTypePossible // check if it is possible to change the current matrix into a // matrix of the requested type // boolean isTypePossible(Integral::MTYPE type) const { return MMatrixMethods::isTypePossible<TScalar,TIntegral>(*this, type); } // method: isFull // boolean isFull() const { return MMatrixMethods::isTypePossible<TScalar,TIntegral> (*this, Integral::FULL); } // method: isDiagonal // boolean isDiagonal() const { return MMatrixMethods::isTypePossible<TScalar,TIntegral> (*this, Integral::DIAGONAL); } // method: isSymmetric // boolean isSymmetric() const { return MMatrixMethods::isTypePossible<TScalar,TIntegral> (*this, Integral::SYMMETRIC); } // method: isLowerTriangular // boolean isLowerTriangular() const { return MMatrixMethods::isTypePossible<TScalar,TIntegral> (*this, Integral::LOWER_TRIANGULAR); } // method: isUpperTriangular // boolean isUpperTriangular() const { return MMatrixMethods::isTypePossible<TScalar,TIntegral> (*this, Integral::UPPER_TRIANGULAR); } // method: isSparse // boolean isSparse() const { return (numEqual((TIntegral)0) > (nrows_d * ncols_d * THRESH_SPARSE)); } // method: isSquare // check if the current matrix is a square matrix // boolean isSquare() const { return isSquare(*this); } // method: isSquare // boolean isSquare(const MMatrix& matrix) const { return (matrix.getNumRows() == matrix.getNumColumns()); } // method: isSingular // check if the current matrix is singular // boolean isSingular(double thresh = 0) const { return isSingular(*this, thresh); } // method: isSingular // boolean isSingular(const MMatrix& matrix, double thresh = 0) const; // method: isOrthogonal() // boolean isOrthogonal() const { return MMatrixMethods::isOrthogonal<TScalar,TIntegral>(*this); } // method: isIdentity // boolean isIdentity() const { return MMatrixMethods::isIdentity<TScalar,TIntegral>(*this); } //--------------------------------------------------------------------------- // // class-specific public methods: // relational and logical methods // //--------------------------------------------------------------------------- // method: ne // boolean ne(TIntegral value) const { return (!eq(value)); } // method: ne // boolean ne(const MMatrix& matrix) const { return (!eq(matrix)); } // method: lt // boolean lt(TIntegral value) const { return MMatrixMethods::lt<TScalar,TIntegral>(*this, value); } // method: le // boolean le(TIntegral value) const { return MMatrixMethods::le<TScalar,TIntegral>(*this, value); } // method: gt // boolean gt(TIntegral value) const { return MMatrixMethods::gt<TScalar,TIntegral>(*this, value); } // method: ge // boolean ge(TIntegral value) const { return MMatrixMethods::ge<TScalar,TIntegral>(*this, value); } // method: operator == // boolean operator == (TIntegral arg) const { return eq(arg); } // method: operator != // boolean operator != (TIntegral arg) const { return ne(arg); } // method: operator < // boolean operator < (TIntegral arg) const { return lt(arg); } // method: operator <= // boolean operator <= (TIntegral arg) const { return le(arg); } // method: operator > // boolean operator > (TIntegral arg) const { return gt(arg); } // method: operator >= // boolean operator >= (TIntegral arg) const { return ge(arg); } // method: numEqual // long numEqual(TIntegral value) const { return MMatrixMethods::numEqual<TScalar,TIntegral>(*this, value); } // method: numNotEqual // long numNotEqual(TIntegral value) const { long nrows = getNumRows(); long ncols = getNumColumns(); return (nrows * ncols - numEqual(value)); } // almostEqual methods // boolean almostEqual(TIntegral value, double percent = Integral::DEF_PERCENTAGE, double bound = Integral::DEF_BOUND) const; boolean almostEqual(const MMatrix& matrix, double percent = Integral::DEF_PERCENTAGE, double bound = Integral::DEF_BOUND) const; //--------------------------------------------------------------------------- // // class-specific public methods: // concatenation methods // //-------------------------------------------------------------------------- // method: concatByRow // boolean concatByRow(const MMatrix& additional_rows) { return MMatrixMethods::concatByRow<TScalar,TIntegral>(*this, additional_rows); } // method: concatByRow // boolean concatByRow(const MMatrix& matrix1, const MMatrix& matrix2) { Integral::MTYPE old_type = type_d; return (assign(matrix1) && concatByRow(matrix2) && changeType(old_type)); } // method: concatByColumn // boolean concatByColumn(const MMatrix& additional_cols) { return MMatrixMethods::concatByColumn<TScalar,TIntegral>(*this, additional_cols); } // method: concatByColumn // boolean concatByColumn(const MMatrix& matrix1, const MMatrix& matrix2) { Integral::MTYPE old_type = type_d; return (assign(matrix1) && concatByColumn(matrix2) && changeType(old_type)); } //--------------------------------------------------------------------------- // // class-specific public methods: // ordering methods // //-------------------------------------------------------------------------- // method: reorderRows // boolean reorderRows(const MVector<Long,long>& indexes) { return MMatrixMethods::reorderRows<TScalar,TIntegral>(*this, indexes); } // method: reorderRows // boolean reorderRows(const MMatrix& matrix, const MVector<Long,long>& indices) { Integral::MTYPE old_type = (type_d == Integral::SPARSE) ? Integral::SPARSE : Integral::FULL; return (assign(matrix) && reorderRows(indices) && changeType(old_type)); } // method: reorderColumns // boolean reorderColumns(const MVector<Long,long>& indexes) { return MMatrixMethods::reorderColumns<TScalar,TIntegral>(*this, indexes); } // method: reorderColumns // boolean reorderColumns(const MMatrix& matrix, const MVector<Long,long>& indices) { Integral::MTYPE old_type = (type_d == Integral::SPARSE) ? Integral::SPARSE : Integral::FULL; return (assign(matrix) && reorderColumns(indices) && changeType(old_type)); } // method: swapRows // boolean swapRows(const MMatrix& arg, long row1, long row2) { return MMatrixMethods::swapRows<TScalar, TIntegral>(*this, arg, row1, row2); } // method: swapRows // boolean swapRows(long row1, long row2) { return MMatrixMethods::swapRows<TScalar, TIntegral>(*this, *this, row1, row2); } // method: swapColumns // boolean swapColumns(const MMatrix& arg, long col1, long col2) { return MMatrixMethods::swapColumns<TScalar, TIntegral>(*this, arg, col1, col2); } // method: swapColumns // boolean swapColumns(long col1, long col2) { return MMatrixMethods::swapColumns<TScalar, TIntegral>(*this, *this, col1, col2); } //--------------------------------------------------------------------------- // // class-specific public methods: // basic mathematical methods // //--------------------------------------------------------------------------- // method: add // template<class TAScalar, class TAIntegral> boolean add(const MMatrix<TAScalar, TAIntegral>& m1) { return MMatrixMethods::add<TScalar,TIntegral>(*this, m1); } // method: add // template<class TAScalar, class TAIntegral> boolean add(const MMatrix& m1, const MMatrix<TAScalar, TAIntegral>& m2) { return MMatrixMethods::add<TScalar,TIntegral>(*this, m1, m2); } // method: add // boolean add(TIntegral value) { return MMatrixMethods::add<TScalar,TIntegral>(*this, value); } // method: add // boolean add(const MMatrix& m1, TIntegral value) { Integral::MTYPE old_type = type_d; return (assign(m1) && add(value) && changeType(old_type)); } // method: sub // template<class TAScalar, class TAIntegral> boolean sub(const MMatrix<TAScalar, TAIntegral>& m1) { return MMatrixMethods::sub<TScalar,TIntegral>(*this, m1); } // method: sub // template<class TAScalar, class TAIntegral> boolean sub(const MMatrix& m1, const MMatrix<TAScalar, TAIntegral>& m2) { return MMatrixMethods::sub<TScalar,TIntegral>(*this, m1, m2); } // method: sub // boolean sub(TIntegral value) { return MMatrixMethods::sub<TScalar,TIntegral>(*this, value); } // method: sub // boolean sub(const MMatrix& m1, TIntegral value) { Integral::MTYPE old_type = type_d; return (assign(m1) && sub(value) && changeType(old_type)); } // method: mult // template<class TAScalar, class TAIntegral> boolean mult(const MMatrix<TAScalar, TAIntegral>& m1) { return MMatrixMethods::mult<TScalar,TIntegral>(*this, *this, m1); } // method: mult // template<class TAScalar, class TAIntegral> boolean mult(const MMatrix& m1, const MMatrix<TAScalar, TAIntegral>& m2) { return MMatrixMethods::mult<TScalar,TIntegral>(*this, m1, m2); } // method: mult // boolean mult(TIntegral value) { return m_d.mult(value); } // method: div // boolean div(TIntegral value) { return m_d.div(value); } // method: neg // boolean neg() { return m_d.neg(); } // method: neg // boolean neg(const MMatrix& m1) { Integral::MTYPE old_type = type_d; return (assign(m1) && neg() && changeType(old_type)); } //--------------------------------------------------------------------------- // // class-specific public methods: // other mathematical methods // //-------------------------------------------------------------------------- // method: min // find the minimum value // TIntegral min() const { static long row_pos; static long col_pos; return MMatrixMethods::min<TScalar,TIntegral>(*this, row_pos, col_pos); } // method: min // find the element with the minimum value // TIntegral min(long& row_index, long& col_index) const { return MMatrixMethods::min<TScalar,TIntegral>(*this, row_index, col_index); } // method: max // find the maximum value // TIntegral max() const { static long row_pos; static long col_pos; return MMatrixMethods::max<TScalar,TIntegral>(*this, row_pos, col_pos); } // method: max // find the element with the maximum value // TIntegral max(long& row_index, long& col_index) const { return MMatrixMethods::max<TScalar,TIntegral>(*this, row_index, col_index); } // method: minMag // find the minimum magnitude // double minMag() const { static long row_pos; static long col_pos; return MMatrixMethods::minMag<TScalar,TIntegral>(*this, row_pos, col_pos); } // method: minMag // find the element with the minimum magnitude // double minMag(long& row_index, long& col_index) const { return MMatrixMethods::minMag<TScalar,TIntegral>(*this, row_index, col_index); } // method: maxMag // find the maximum magnitude // double maxMag() const { static long row_pos; static long col_pos; return MMatrixMethods::maxMag<TScalar,TIntegral>(*this, row_pos, col_pos); } // method: maxMag // find the element with the maximum magnitude // double maxMag(long& row_index, long& col_index) const { return MMatrixMethods::maxMag<TScalar,TIntegral>(*this, row_index, col_index); } // random number generation methods // boolean rand(Random& generator = Random::GLOBAL_UNIFORM) { return MMatrixMethods::rand<TScalar, TIntegral>(*this, generator); } boolean rand(TIntegral min_val, TIntegral max_val, Random& generator = Random::GLOBAL_UNIFORM) { return MMatrixMethods::rand<TScalar, TIntegral>(*this, min_val, max_val, generator); } boolean grand(TIntegral mean, TIntegral stdev, Random& generator = Random::GLOBAL_GAUSSIAN) { return MMatrixMethods::grand<TScalar, TIntegral>(*this, mean, stdev, generator); } //--------------------------------------------------------------------------- // // class-specific public methods: // linear algebra related methods // //-------------------------------------------------------------------------- // method: determinant // TIntegral determinant() const { return MMatrixMethods::determinant<TScalar,TIntegral>(*this);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -