void CSparseMatrix::add_AB(const CSparseMatrix& A, const CSparseMatrix& B) { ASSERT_(A.cols() == B.cols() && A.rows() == B.rows()); cs* sm = cs_add(&(A.sparse_matrix), &(B.sparse_matrix), 1, 1); ASSERT_(sm); this->copy_fast(sm); cs_spfree(sm); }
void CSparseMatrix::multiply_AB(const CSparseMatrix& A, const CSparseMatrix& B) { ASSERT_(A.cols() == B.rows()); cs* sm = cs_multiply(&(A.sparse_matrix), &(B.sparse_matrix)); ASSERT_(sm); this->copy_fast(sm); cs_spfree(sm); }
/** Constructor from a square semidefinite-positive sparse matrix. * The actual Cholesky decomposition takes places in this constructor. * \exception std::runtime_error On non-square input matrix. * \exception mrpt::math::CExceptionNotDefPos On non-semidefinite-positive * matrix as input. */ CSparseMatrix::CholeskyDecomp::CholeskyDecomp(const CSparseMatrix& SM) : m_symbolic_structure(nullptr), m_numeric_structure(nullptr), m_originalSM(&SM) { ASSERT_(SM.cols() == SM.rows()); ASSERT_(SM.isColumnCompressed()); // symbolic decomposition: m_symbolic_structure = cs_schol(1 /* order */, &m_originalSM->sparse_matrix); // numeric decomposition: m_numeric_structure = cs_chol(&m_originalSM->sparse_matrix, m_symbolic_structure); if (!m_numeric_structure) throw mrpt::math::CExceptionNotDefPos( "CSparseMatrix::CholeskyDecomp: Not positive definite matrix."); }