Commit ba9a60b5 authored by Martin Heistermann's avatar Martin Heistermann

CholmodSolver: EXPERIMENTAL long mode support

parent d3d3bdc6
Pipeline #12190 failed with stages
in 8 minutes and 18 seconds
......@@ -72,8 +72,8 @@ CholmodSolver::~CholmodSolver()
//-----------------------------------------------------------------------------
bool CholmodSolver::calc_system( const std::vector<int>& _colptr,
const std::vector<int>& _rowind,
bool CholmodSolver::calc_system( const std::vector<SuiteSparseInt>& _colptr,
const std::vector<SuiteSparseInt>& _rowind,
const std::vector<double>& _values)
{
if(show_timings_) sw_.start();
......@@ -98,7 +98,7 @@ bool CholmodSolver::calc_system( const std::vector<int>& _colptr,
// matA.stype = -1;
matA.stype = 1;
matA.itype = CHOLMOD_INT;
matA.itype = SuiteSparseITYPE;
matA.xtype = CHOLMOD_REAL;
matA.dtype = CHOLMOD_DOUBLE;
matA.sorted = 1;
......@@ -154,11 +154,11 @@ bool CholmodSolver::calc_system( const std::vector<int>& _colptr,
//-----------------------------------------------------------------------------
bool CholmodSolver::calc_system_prepare_pattern( const std::vector<int>& _colptr,
const std::vector<int>& _rowind,
bool CholmodSolver::calc_system_prepare_pattern( const std::vector<SuiteSparseInt>& _colptr,
const std::vector<SuiteSparseInt>& _rowind,
const std::vector<double>& _values,
const std::vector<int>& _colptr2,
const std::vector<int>& _rowind2,
const std::vector<SuiteSparseInt>& _colptr2,
const std::vector<SuiteSparseInt>& _rowind2,
const std::vector<double>& _values2 )
{
if(show_timings_) sw_.start();
......@@ -179,12 +179,12 @@ bool CholmodSolver::calc_system_prepare_pattern( const std::vector<int>& _col
matA.p = &colptr_[0];
matA.i = &rowind_[0];
matA.x = &values_[0];
matA.nz = 0;
matA.z = 0;
matA.nz = nullptr;
matA.z = nullptr;
// matA.stype = -1;
matA.stype = 1;
matA.itype = CHOLMOD_INT;
matA.itype = SuiteSparseITYPE;
matA.xtype = CHOLMOD_REAL;
matA.dtype = CHOLMOD_DOUBLE;
matA.sorted = 1;
......@@ -197,15 +197,15 @@ bool CholmodSolver::calc_system_prepare_pattern( const std::vector<int>& _col
matA_pattern.ncol = n;
matA_pattern.nzmax = _values2.size();
matA_pattern.p = (int*)(&_colptr2[0]);
matA_pattern.i = (int*)(&_rowind2[0]);
matA_pattern.x = (double*)(&_values2[0]);
matA_pattern.nz = 0;
matA_pattern.z = 0;
matA_pattern.p = (void*)(&_colptr2[0]);
matA_pattern.i = (void*)(&_rowind2[0]);
matA_pattern.x = (void*)(&_values2[0]);
matA_pattern.nz = nullptr;
matA_pattern.z = nullptr;
// matA_pattern.stype = -1;
matA_pattern.stype = 1;
matA_pattern.itype = CHOLMOD_INT;
matA_pattern.itype = SuiteSparseITYPE;
matA_pattern.xtype = CHOLMOD_REAL;
matA_pattern.dtype = CHOLMOD_DOUBLE;
matA_pattern.sorted = 1;
......@@ -221,7 +221,7 @@ bool CholmodSolver::calc_system_prepare_pattern( const std::vector<int>& _col
// compute permutation based on full pattern
std::vector<int> perm(matA_pattern.nrow);
std::vector<SuiteSparseInt> perm(matA_pattern.nrow);
// cholmod_metis(&matA_pattern, 0, 0, 0, perm.data(), mp_cholmodCommon) ;
cholmod_amd(&matA_pattern, 0, 0, perm.data(), mp_cholmodCommon) ;
......@@ -272,8 +272,8 @@ bool CholmodSolver::calc_system_prepare_pattern( const std::vector<int>& _col
//-----------------------------------------------------------------------------
bool CholmodSolver::update_system( const std::vector<int>& _colptr,
const std::vector<int>& _rowind,
bool CholmodSolver::update_system( const std::vector<SuiteSparseInt>& _colptr,
const std::vector<SuiteSparseInt>& _rowind,
const std::vector<double>& _values )
{
if( !mp_L )
......@@ -298,7 +298,7 @@ bool CholmodSolver::update_system( const std::vector<int>& _colptr,
// matA.stype = -1;
matA.stype = 1;
matA.itype = CHOLMOD_INT;
matA.itype = SuiteSparseITYPE;
matA.xtype = CHOLMOD_REAL;
matA.dtype = CHOLMOD_DOUBLE;
matA.sorted = 1;
......@@ -318,8 +318,8 @@ bool CholmodSolver::update_system( const std::vector<int>& _colptr,
//-----------------------------------------------------------------------------
bool CholmodSolver::update_downdate_factor( const std::vector<int>& _colptr,
const std::vector<int>& _rowind,
bool CholmodSolver::update_downdate_factor( const std::vector<SuiteSparseInt>& _colptr,
const std::vector<SuiteSparseInt>& _rowind,
const std::vector<double>& _values,
const bool _upd)
{
......@@ -344,14 +344,14 @@ bool CholmodSolver::update_downdate_factor( const std::vector<int>& _colptr,
matA.z = 0;
matA.stype = 0;
matA.itype = CHOLMOD_INT;
matA.itype = SuiteSparseITYPE;
matA.xtype = CHOLMOD_REAL;
matA.dtype = CHOLMOD_DOUBLE;
matA.sorted = 1;
matA.packed = 1;
// get permuted matrix
cholmod_sparse* matAp = cholmod_submatrix ( &matA, (int*)mp_L->Perm, mp_L->n, 0, -1, true, true, mp_cholmodCommon);
cholmod_sparse* matAp = cholmod_submatrix ( &matA, (SuiteSparseInt*)mp_L->Perm, mp_L->n, 0, -1, true, true, mp_cholmodCommon);
if(show_timings_)
{
std::cerr << " Cholmod conversion Timing: " << sw_.stop()/1000.0 << "s\n";
......@@ -417,9 +417,14 @@ bool CholmodSolver::solve( double * _x, double * _b)
//-----------------------------------------------------------------------------
int CholmodSolver::dimension()
size_t CholmodSolver::dimension()
{
return std::max(int(0), (int)(colptr_.size()-1));
size_t s = colptr_.size();
if (s == 0) {
return 0;
} else {
return s - 1;
}
}
//-----------------------------------------------------------------------------
......
......@@ -52,6 +52,31 @@
// typedef struct cholmod_factor_struct cholmod_factor;
#ifndef USE_CHOLMOD_LONG_MODE
# define USE_CHOLMOD_LONG_MODE 0
#endif
#if USE_CHOLMOD_LONG_MODE
# define SuiteSparseInt SuiteSparse_long
# define SuiteSparseITYPE CHOLMOD_LONG
# define cholmod_amd cholmod_l_amd
# define cholmod_analyze cholmod_l_analyze
# define cholmod_analyze_p cholmod_l_analyze_p
# define cholmod_factorize cholmod_l_factorize
# define cholmod_finish cholmod_l_finish
# define cholmod_free_sparse cholmod_l_free_sparse
# define cholmod_free_dense cholmod_l_free_dense
# define cholmod_free_factor cholmod_l_free_factor
# define cholmod_metis cholmod_l_metis
# define cholmod_solve cholmod_l_solve
# define cholmod_start cholmod_l_start
# define cholmod_submatrix cholmod_l_submatrix
# define cholmod_updown cholmod_l_updown
#else
# define SuiteSparseInt int
# define SuiteSparseITYPE CHOLMOD_INT
#endif
//== NAMESPACES ===============================================================
namespace COMISO {
......@@ -65,15 +90,15 @@ public:
CholmodSolver();
~CholmodSolver();
bool calc_system( const std::vector<int>& _colptr,
const std::vector<int>& _rowind,
bool calc_system( const std::vector<SuiteSparseInt>& _colptr,
const std::vector<SuiteSparseInt>& _rowind,
const std::vector<double>& _values );
bool calc_system_prepare_pattern( const std::vector<int>& _colptr,
const std::vector<int>& _rowind,
bool calc_system_prepare_pattern( const std::vector<SuiteSparseInt>& _colptr,
const std::vector<SuiteSparseInt>& _rowind,
const std::vector<double>& _values,
const std::vector<int>& _colptr2,
const std::vector<int>& _rowind2,
const std::vector<SuiteSparseInt>& _colptr2,
const std::vector<SuiteSparseInt>& _rowind2,
const std::vector<double>& _values2 );
......@@ -88,8 +113,8 @@ public:
bool calc_system_eigen_prepare_pattern( const Eigen_MatrixT& _mat, const Eigen_MatrixT& _mat_pattern);
bool update_system( const std::vector<int>& _colptr,
const std::vector<int>& _rowind,
bool update_system( const std::vector<SuiteSparseInt>& _colptr,
const std::vector<SuiteSparseInt>& _rowind,
const std::vector<double>& _values );
......@@ -100,8 +125,8 @@ public:
bool update_system_eigen( const Eigen_MatrixT& _mat);
bool update_downdate_factor( const std::vector<int>& _colptr,
const std::vector<int>& _rowind,
bool update_downdate_factor( const std::vector<SuiteSparseInt>& _colptr,
const std::vector<SuiteSparseInt>& _rowind,
const std::vector<double>& _values,
const bool _upd);
......@@ -115,7 +140,7 @@ public:
bool& show_timings();
int dimension();
size_t dimension();
private:
......@@ -124,8 +149,8 @@ private:
cholmod_factor * mp_L;
std::vector<double> values_;
std::vector<int> colptr_;
std::vector<int> rowind_;
std::vector<SuiteSparseInt> colptr_;
std::vector<SuiteSparseInt> rowind_;
bool show_timings_;
Base::StopWatch sw_;
......
......@@ -42,8 +42,8 @@ namespace COMISO {
template< class GMM_MatrixT>
bool CholmodSolver::calc_system_gmm( const GMM_MatrixT& _mat)
{
// std::vector<int> colptr;
// std::vector<int> rowind;
// std::vector<SuiteSparseInt> colptr;
// std::vector<SuiteSparseInt> rowind;
// std::vector<double> values;
......@@ -71,8 +71,8 @@ bool CholmodSolver::calc_system_gmm( const GMM_MatrixT& _mat)
template< class GMM_MatrixT>
bool CholmodSolver::update_system_gmm( const GMM_MatrixT& _mat)
{
// std::vector<int> colptr;
// std::vector<int> rowind;
// std::vector<SuiteSparseInt> colptr;
// std::vector<SuiteSparseInt> rowind;
// std::vector<double> values;
COMISO_GMM::get_ccs_symmetric_data( _mat,
......@@ -126,8 +126,8 @@ bool CholmodSolver::calc_system_eigen_prepare_pattern( const Eigen_MatrixT& _mat
#endif
std::vector<double> values2;
std::vector<int> colptr2;
std::vector<int> rowind2;
std::vector<SuiteSparseInt> colptr2;
std::vector<SuiteSparseInt> rowind2;
#if COMISO_EIGEN3_AVAILABLE
COMISO_EIGEN::get_ccs_symmetric_data( _mat_pattern,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment