Commit a0e47ef4 authored by Martin Marinov's avatar Martin Marinov

Minor improvements to code whitespace style and clarity. Add some progress ticks.

parent dcc31ac2
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* Copyright (C) 2008-2009 by Computer Graphics Group, RWTH Aachen * * Copyright (C) 2008-2009 by Computer Graphics Group, RWTH Aachen *
* www.rwth-graphics.de * * www.rwth-graphics.de *
* * * *
*---------------------------------------------------------------------------* *---------------------------------------------------------------------------*
* This file is part of CoMISo. * * This file is part of CoMISo. *
* * * *
* CoMISo is free software: you can redistribute it and/or modify * * CoMISo is free software: you can redistribute it and/or modify *
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
* You should have received a copy of the GNU General Public License * * You should have received a copy of the GNU General Public License *
* along with CoMISo. If not, see <http://www.gnu.org/licenses/>. * * along with CoMISo. If not, see <http://www.gnu.org/licenses/>. *
* * * *
\*===========================================================================*/ \*===========================================================================*/
//============================================================================= //=============================================================================
...@@ -48,24 +48,22 @@ namespace COMISO { ...@@ -48,24 +48,22 @@ namespace COMISO {
//== IMPLEMENTATION ========================================================== //== IMPLEMENTATION ==========================================================
template<class RMatrixT, class CMatrixT, class VectorT, class VectorIT > template<class RMatrixT, class CMatrixT, class VectorT, class VectorIT >
void void
ConstrainedSolver:: ConstrainedSolver::solve_const(const RMatrixT& _constraints,
solve_const( const RMatrixT& _constraints, const CMatrixT& _A,
const CMatrixT& _A, VectorT& _x,
VectorT& _x, const VectorT& _rhs,
const VectorT& _rhs, const VectorIT& _idx_to_round,
const VectorIT& _idx_to_round, double _reg_factor,
double _reg_factor, bool _show_miso_settings,
bool _show_miso_settings, bool _show_timings)
bool _show_timings )
{ {
// copy matrices // copy matrices
RMatrixT constraints( gmm::mat_nrows(_constraints), gmm::mat_ncols(_constraints)); RMatrixT constraints(gmm::mat_nrows(_constraints), gmm::mat_ncols(_constraints));
gmm::copy(_constraints, constraints); gmm::copy(_constraints, constraints);
CMatrixT A( gmm::mat_nrows(_A), gmm::mat_ncols(_A)); CMatrixT A(gmm::mat_nrows(_A), gmm::mat_ncols(_A));
gmm::copy(_A, A); gmm::copy(_A, A);
// ... and vectors // ... and vectors
...@@ -74,13 +72,13 @@ solve_const( const RMatrixT& _constraints, ...@@ -74,13 +72,13 @@ solve_const( const RMatrixT& _constraints,
// call non-const function // call non-const function
solve(constraints, solve(constraints,
A, A,
_x, _x,
rhs, rhs,
idx_to_round, idx_to_round,
_reg_factor, _reg_factor,
_show_miso_settings, _show_miso_settings,
_show_timings); _show_timings);
} }
...@@ -89,20 +87,19 @@ solve_const( const RMatrixT& _constraints, ...@@ -89,20 +87,19 @@ solve_const( const RMatrixT& _constraints,
template<class RMatrixT, class VectorT, class VectorIT > template<class RMatrixT, class VectorT, class VectorIT >
void void
ConstrainedSolver:: ConstrainedSolver::solve_const(const RMatrixT& _constraints,
solve_const( const RMatrixT& _constraints, const RMatrixT& _B,
const RMatrixT& _B, VectorT& _x,
VectorT& _x, const VectorIT& _idx_to_round,
const VectorIT& _idx_to_round, double _reg_factor,
double _reg_factor, bool _show_miso_settings,
bool _show_miso_settings, bool _show_timings)
bool _show_timings )
{ {
// copy matrices // copy matrices
RMatrixT constraints( gmm::mat_nrows(_constraints), gmm::mat_ncols(_constraints)); RMatrixT constraints(gmm::mat_nrows(_constraints), gmm::mat_ncols(_constraints));
gmm::copy(_constraints, constraints); gmm::copy(_constraints, constraints);
RMatrixT B( gmm::mat_nrows(_B), gmm::mat_ncols(_B)); RMatrixT B(gmm::mat_nrows(_B), gmm::mat_ncols(_B));
gmm::copy(_B, B); gmm::copy(_B, B);
// ... and vectors // ... and vectors
...@@ -110,12 +107,12 @@ solve_const( const RMatrixT& _constraints, ...@@ -110,12 +107,12 @@ solve_const( const RMatrixT& _constraints,
// call non-const function // call non-const function
solve(constraints, solve(constraints,
B, B,
_x, _x,
idx_to_round, idx_to_round,
_reg_factor, _reg_factor,
_show_miso_settings, _show_miso_settings,
_show_timings); _show_timings);
} }
...@@ -123,16 +120,15 @@ solve_const( const RMatrixT& _constraints, ...@@ -123,16 +120,15 @@ solve_const( const RMatrixT& _constraints,
template<class RMatrixT, class VectorT, class VectorIT > template<class RMatrixT, class VectorT, class VectorIT >
void void
ConstrainedSolver:: ConstrainedSolver::solve(
solve( RMatrixT& _constraints,
RMatrixT& _constraints, RMatrixT& _B,
RMatrixT& _B, VectorT& _x,
VectorT& _x, VectorIT& _idx_to_round,
VectorIT& _idx_to_round, double _reg_factor,
double _reg_factor, bool _show_miso_settings,
bool _show_miso_settings, bool _show_timings)
bool _show_timings )
{ {
// convert into quadratic system // convert into quadratic system
VectorT rhs; VectorT rhs;
...@@ -140,59 +136,59 @@ solve( ...@@ -140,59 +136,59 @@ solve(
COMISO_GMM::factored_to_quadratic(_B, A, rhs); COMISO_GMM::factored_to_quadratic(_B, A, rhs);
// solve // solve
solve( _constraints, A, _x, rhs, solve(_constraints, A, _x, rhs,
_idx_to_round, _reg_factor, _idx_to_round, _reg_factor,
_show_miso_settings, _show_miso_settings,
_show_timings); _show_timings);
// int nrows = gmm::mat_nrows(_B); // int nrows = gmm::mat_nrows(_B);
// int ncols = gmm::mat_ncols(_B); // int ncols = gmm::mat_ncols(_B);
// int ncons = gmm::mat_nrows(_constraints); // int ncons = gmm::mat_nrows(_constraints);
// if( _show_timings) std::cerr << __FUNCTION__ << "\n Initial dimension: " << nrows << " x " << ncols << ", number of constraints: " << ncons << std::endl; // if( _show_timings) std::cerr << __FUNCTION__ << "\n Initial dimension: " << nrows << " x " << ncols << ", number of constraints: " << ncons << std::endl;
// // StopWatch for Timings
// Base::StopWatch sw, sw2; sw.start(); sw2.start();
// // c_elim[i] = index of variable which is eliminated in condition i // // StopWatch for Timings
// // or -1 if condition is invalid // Base::StopWatch sw, sw2; sw.start(); sw2.start();
// std::vector<int> c_elim( ncons);
// // apply sparse gauss elimination to make subsequent _constraints independent // // c_elim[i] = index of variable which is eliminated in condition i
// make_constraints_independent( _constraints, _idx_to_round, c_elim); // // or -1 if condition is invalid
// double time_gauss = sw.stop()/1000.0; sw.start(); // std::vector<int> c_elim( ncons);
// // eliminate conditions and return column matrix Bcol // // apply sparse gauss elimination to make subsequent _constraints independent
// gmm::col_matrix< gmm::rsvector< double > > Bcol( nrows, ncols); // make_constraints_independent( _constraints, _idx_to_round, c_elim);
// double time_gauss = sw.stop()/1000.0; sw.start();
// // reindexing vector // // eliminate conditions and return column matrix Bcol
// std::vector<int> new_idx; // gmm::col_matrix< gmm::rsvector< double > > Bcol( nrows, ncols);
// eliminate_constraints( _constraints, _B, _idx_to_round, c_elim, new_idx, Bcol); // // reindexing vector
// double time_eliminate = sw.stop()/1000.0; // std::vector<int> new_idx;
// if( _show_timings) std::cerr << "Eliminated dimension: " << gmm::mat_nrows(Bcol) << " x " << gmm::mat_ncols(Bcol) << std::endl; // eliminate_constraints( _constraints, _B, _idx_to_round, c_elim, new_idx, Bcol);
// double time_eliminate = sw.stop()/1000.0;
// // setup and solve system // if( _show_timings) std::cerr << "Eliminated dimension: " << gmm::mat_nrows(Bcol) << " x " << gmm::mat_ncols(Bcol) << std::endl;
// double time_setup = setup_and_solve_system( Bcol, _x, _idx_to_round, _reg_factor, _show_miso_settings);
// sw.start();
// // double time_setup_solve = sw.stop()/1000.0; sw.start(); // // setup and solve system
// double time_setup = setup_and_solve_system( Bcol, _x, _idx_to_round, _reg_factor, _show_miso_settings);
// // restore eliminated vars to fulfill the given conditions // sw.start();
// restore_eliminated_vars( _constraints, _x, c_elim, new_idx);
// double time_resubstitute = sw.stop()/1000.0; sw.start(); // // double time_setup_solve = sw.stop()/1000.0; sw.start();
// // double time_total = sw2.stop()/1000.0; // // restore eliminated vars to fulfill the given conditions
// restore_eliminated_vars( _constraints, _x, c_elim, new_idx);
// if( _show_timings) std::cerr << "Timings: \n\t" << // double time_resubstitute = sw.stop()/1000.0; sw.start();
// "Gauss Elimination " << time_gauss << " s\n\t" <<
// "System Elimination " << time_eliminate << " s\n\t" << // // double time_total = sw2.stop()/1000.0;
// "Setup " << time_setup << " s\n\t" <<
// // "Setup + Mi-Solver " << time_setup_solve << " s\n\t" << // if( _show_timings) std::cerr << "Timings: \n\t" <<
// "Resubstitution " << time_resubstitute << " s\n\t" << std::endl << std::endl; // "Gauss Elimination " << time_gauss << " s\n\t" <<
// //"Total " << time_total << std::endl; // "System Elimination " << time_eliminate << " s\n\t" <<
// "Setup " << time_setup << " s\n\t" <<
// // "Setup + Mi-Solver " << time_setup_solve << " s\n\t" <<
// "Resubstitution " << time_resubstitute << " s\n\t" << std::endl << std::endl;
// //"Total " << time_total << std::endl;
} }
...@@ -200,52 +196,51 @@ solve( ...@@ -200,52 +196,51 @@ solve(
template<class RMatrixT, class CMatrixT, class VectorT, class VectorIT> template<class RMatrixT, class CMatrixT, class VectorT, class VectorIT>
void void
ConstrainedSolver:: ConstrainedSolver::solve(
solve( RMatrixT& _constraints,
RMatrixT& _constraints, CMatrixT& _A,
CMatrixT& _A, VectorT& _x,
VectorT& _x, VectorT& _rhs,
VectorT& _rhs, VectorIT& _idx_to_round,
VectorIT& _idx_to_round, double _reg_factor,
double _reg_factor, bool _show_miso_settings,
bool _show_miso_settings, bool _show_timings)
bool _show_timings )
{ {
DEB_enter_func; DEB_enter_func;
// show options dialog // show options dialog
if( _show_miso_settings) if (_show_miso_settings)
miso_.show_options_dialog(); miso_.show_options_dialog();
gmm::size_type nrows = gmm::mat_nrows(_A); gmm::size_type nrows = gmm::mat_nrows(_A);
gmm::size_type ncols = gmm::mat_ncols(_A); gmm::size_type ncols = gmm::mat_ncols(_A);
gmm::size_type ncons = gmm::mat_nrows(_constraints); gmm::size_type ncons = gmm::mat_nrows(_constraints);
DEB_out_if( _show_timings, 1, "Initital dimension: " << nrows << " x " << ncols DEB_out_if(_show_timings, 1, "Initital dimension: " << nrows << " x " << ncols
<< ", number of constraints: " << ncons << ", number of constraints: " << ncons
<< " use reordering: " << use_constraint_reordering() << "\n") << " use reordering: " << use_constraint_reordering() << "\n")
// StopWatch for Timings // StopWatch for Timings
Base::StopWatch sw, sw2; sw.start(); sw2.start(); Base::StopWatch sw, sw2; sw.start(); sw2.start();
// c_elim[i] = index of variable which is eliminated in condition i // c_elim[i] = index of variable which is eliminated in condition i
// or -1 if condition is invalid // or -1 if condition is invalid
std::vector<int> c_elim( ncons); std::vector<int> c_elim(ncons);
// apply sparse gauss elimination to make subsequent _conditions independent // apply sparse gauss elimination to make subsequent _conditions independent
if(use_constraint_reordering()) if (use_constraint_reordering())
make_constraints_independent_reordering( _constraints, _idx_to_round, c_elim); make_constraints_independent_reordering(_constraints, _idx_to_round, c_elim);
else else
make_constraints_independent( _constraints, _idx_to_round, c_elim); make_constraints_independent(_constraints, _idx_to_round, c_elim);
double time_gauss = sw.stop()/1000.0; sw.start(); double time_gauss = sw.stop() / 1000.0; sw.start();
// re-indexing vector // re-indexing vector
std::vector<int> new_idx; std::vector<int> new_idx;
gmm::csc_matrix< double > Acsc; gmm::csc_matrix< double > Acsc;
eliminate_constraints( _constraints, _A, _x, _rhs, _idx_to_round, c_elim, new_idx, Acsc); eliminate_constraints(_constraints, _A, _x, _rhs, _idx_to_round, c_elim, new_idx, Acsc);
double time_eliminate = sw.stop()/1000.0; double time_eliminate = sw.stop() / 1000.0;
/// TODO: temporary disable this since it was causing performance issues /// TODO: temporary disable this since it was causing performance issues
//DEB_out_if( _show_timings, 2, //DEB_out_if( _show_timings, 2,
...@@ -253,21 +248,21 @@ solve( ...@@ -253,21 +248,21 @@ solve(
// << "\n#nonzeros: " << gmm::nnz(Acsc) << "\n"); // << "\n#nonzeros: " << gmm::nnz(Acsc) << "\n");
sw.start(); sw.start();
miso_.solve( Acsc, _x, _rhs, _idx_to_round); miso_.solve(Acsc, _x, _rhs, _idx_to_round);
double time_miso = sw.stop()/1000.0; sw.start(); double time_miso = sw.stop() / 1000.0; sw.start();
rhs_update_table_.store(_constraints, c_elim, new_idx); rhs_update_table_.store(_constraints, c_elim, new_idx);
// restore eliminated vars to fulfill the given conditions // restore eliminated vars to fulfill the given conditions
restore_eliminated_vars( _constraints, _x, c_elim, new_idx); restore_eliminated_vars(_constraints, _x, c_elim, new_idx);
double time_resubstitute = sw.stop()/1000.0; sw.start(); double time_resubstitute = sw.stop() / 1000.0; sw.start();
double time_total = time_gauss + time_eliminate + time_miso + time_resubstitute; double time_total = time_gauss + time_eliminate + time_miso + time_resubstitute;
DEB_out_if( _show_timings, 1,"Timings: \n\t" << DEB_out_if(_show_timings, 1, "Timings: \n\t" <<
"\tGauss Elimination " << time_gauss << " s\n\t" << "\tGauss Elimination " << time_gauss << " s\n\t" <<
"\tSystem Elimination " << time_eliminate << " s\n\t" << "\tSystem Elimination " << time_eliminate << " s\n\t" <<
"\tMi-Solver " << time_miso << " s\n\t" << "\tMi-Solver " << time_miso << " s\n\t" <<
"\tResubstitution " << time_resubstitute << " s\n\t" << "\tResubstitution " << time_resubstitute << " s\n\t" <<
"\tTotal " << time_total << "\n\n"); "\tTotal " << time_total << "\n\n");
} }
...@@ -276,18 +271,17 @@ solve( ...@@ -276,18 +271,17 @@ solve(
template<class RMatrixT, class VectorT > template<class RMatrixT, class VectorT >
void void
ConstrainedSolver:: ConstrainedSolver::resolve(
resolve( const RMatrixT& _B,
const RMatrixT& _B, VectorT& _x,
VectorT& _x, VectorT* _constraint_rhs,
VectorT* _constraint_rhs, bool _show_timings)
bool _show_timings )
{ {
// extract rhs from quadratic system // extract rhs from quadratic system
VectorT rhs; VectorT rhs;
// gmm::col_matrix< gmm::rsvector< double > > A; // gmm::col_matrix< gmm::rsvector< double > > A;
// COMISO_GMM::factored_to_quadratic(_B, A, rhs); // COMISO_GMM::factored_to_quadratic(_B, A, rhs);
//TODO only compute rhs, not complete A for efficiency //TODO only compute rhs, not complete A for efficiency
gmm::size_type m = gmm::mat_nrows(_B); gmm::size_type m = gmm::mat_nrows(_B);
gmm::size_type n = gmm::mat_ncols(_B); gmm::size_type n = gmm::mat_ncols(_B);
...@@ -297,20 +291,20 @@ resolve( ...@@ -297,20 +291,20 @@ resolve(
typedef typename gmm::linalg_traits<CRowT>::const_iterator RIter; typedef typename gmm::linalg_traits<CRowT>::const_iterator RIter;
typedef typename gmm::linalg_traits<CRowT>::value_type VecValT; typedef typename gmm::linalg_traits<CRowT>::value_type VecValT;
gmm::resize(rhs, n-1); gmm::resize(rhs, n - 1);
gmm::clear(rhs); gmm::clear(rhs);
for(unsigned int i = 0; i < m; ++i) for (unsigned int i = 0; i < m; ++i)
{ {
// get current condition row // get current condition row
CRowT row = gmm::mat_const_row( _B, i); CRowT row = gmm::mat_const_row(_B, i);
RIter row_it = gmm::vect_const_begin( row); RIter row_it = gmm::vect_const_begin(row);
RIter row_end = gmm::vect_const_end( row); RIter row_end = gmm::vect_const_end(row);
if(row_end == row_it) continue; if (row_end == row_it) continue;
--row_end; --row_end;
if(row_end.index() != n-1) continue; if (row_end.index() != n - 1) continue;
VecValT n_i = *row_end; VecValT n_i = *row_end;
while(row_end != row_it) while (row_end != row_it)
{ {
--row_end; --row_end;
rhs[row_end.index()] -= (*row_end) * n_i; rhs[row_end.index()] -= (*row_end) * n_i;
...@@ -319,7 +313,7 @@ resolve( ...@@ -319,7 +313,7 @@ resolve(
// solve // solve
resolve(_x, _constraint_rhs, &rhs, resolve(_x, _constraint_rhs, &rhs,
_show_timings); _show_timings);
} }
...@@ -328,12 +322,11 @@ resolve( ...@@ -328,12 +322,11 @@ resolve(
template<class VectorT > template<class VectorT >
void void
ConstrainedSolver:: ConstrainedSolver::resolve(
resolve( VectorT& _x,
VectorT& _x, VectorT* _constraint_rhs,
VectorT* _constraint_rhs, VectorT* _rhs,
VectorT* _rhs , bool _show_timings)
bool _show_timings )
{ {
DEB_enter_func; DEB_enter_func;
// StopWatch for Timings // StopWatch for Timings
...@@ -341,7 +334,7 @@ resolve( ...@@ -341,7 +334,7 @@ resolve(
sw.start(); sw.start();
// apply stored updates and eliminations to exchanged rhs // apply stored updates and eliminations to exchanged rhs
if(_constraint_rhs) if (_constraint_rhs)
{ {
// apply linear transformation of Gaussian elimination // apply linear transformation of Gaussian elimination
rhs_update_table_.cur_constraint_rhs_.resize(gmm::mat_nrows(rhs_update_table_.D_)); rhs_update_table_.cur_constraint_rhs_.resize(gmm::mat_nrows(rhs_update_table_.D_));
...@@ -349,10 +342,10 @@ resolve( ...@@ -349,10 +342,10 @@ resolve(
// update rhs of stored constraints // update rhs of stored constraints
gmm::size_type nc = gmm::mat_ncols(rhs_update_table_.constraints_p_); gmm::size_type nc = gmm::mat_ncols(rhs_update_table_.constraints_p_);
for(gmm::size_type i=0; i<rhs_update_table_.cur_constraint_rhs_.size(); ++i) for (gmm::size_type i = 0; i < rhs_update_table_.cur_constraint_rhs_.size(); ++i)
rhs_update_table_.constraints_p_(i,nc-1) = -rhs_update_table_.cur_constraint_rhs_[i]; rhs_update_table_.constraints_p_(i, nc - 1) = -rhs_update_table_.cur_constraint_rhs_[i];
} }
if(_rhs) if (_rhs)
rhs_update_table_.cur_rhs_ = *_rhs; rhs_update_table_.cur_rhs_ = *_rhs;
std::vector<double> rhs_red = rhs_update_table_.cur_rhs_; std::vector<double> rhs_red = rhs_update_table_.cur_rhs_;
...@@ -369,17 +362,17 @@ resolve( ...@@ -369,17 +362,17 @@ resolve(
miso_.resolve(_x, rhs_red); miso_.resolve(_x, rhs_red);
double time_miso = sw.stop()/1000.0; sw.start(); double time_miso = sw.stop() / 1000.0; sw.start();
// restore eliminated vars to fulfill the given conditions // restore eliminated vars to fulfill the given conditions
restore_eliminated_vars( rhs_update_table_.constraints_p_, _x, rhs_update_table_.c_elim_, rhs_update_table_.new_idx_); restore_eliminated_vars(rhs_update_table_.constraints_p_, _x, rhs_update_table_.c_elim_, rhs_update_table_.new_idx_);
double time_resubstitute = sw.stop()/1000.0; sw.start(); double time_resubstitute = sw.stop() / 1000.0; sw.start();
double time_total = time_miso + time_resubstitute; double time_total = time_miso + time_resubstitute;
DEB_out_if( _show_timings, 1, "Timings: \n\t" << DEB_out_if(_show_timings, 1, "Timings: \n\t" <<
"\tMi-Solver " << time_miso << " s\n\t" << "\tMi-Solver " << time_miso << " s\n\t" <<
"\tResubstitution " << time_resubstitute << " s\n\t" << "\tResubstitution " << time_resubstitute << " s\n\t" <<
"\tTotal " << time_total << "\n\n"); "\tTotal " << time_total << "\n\n");
} }
...@@ -387,19 +380,18 @@ resolve( ...@@ -387,19 +380,18 @@ resolve(
template<class RMatrixT, class VectorIT > template<class RMatrixT, class VectorIT >
void void
ConstrainedSolver:: ConstrainedSolver::make_constraints_independent(
make_constraints_independent( RMatrixT& _constraints,
RMatrixT& _constraints, VectorIT& _idx_to_round,
VectorIT& _idx_to_round, std::vector<int>& _c_elim)
std::vector<int>& _c_elim)
{ {
DEB_enter_func; DEB_enter_func;
// setup linear transformation for rhs, start with identity // setup linear transformation for rhs, start with identity
gmm::size_type nr = gmm::mat_nrows(_constraints); gmm::size_type nr = gmm::mat_nrows(_constraints);
gmm::resize(rhs_update_table_.D_, nr, nr); gmm::resize(rhs_update_table_.D_, nr, nr);
gmm::clear(rhs_update_table_.D_); gmm::clear(rhs_update_table_.D_);
for(gmm::size_type i=0; i<nr; ++i) rhs_update_table_.D_(i,i) = 1.0; for (gmm::size_type i = 0; i < nr; ++i) rhs_update_table_.D_(i, i) = 1.0;
// Base::StopWatch sw; // Base::StopWatch sw;
// number of variables // number of variables
...@@ -407,11 +399,11 @@ make_constraints_independent( ...@@ -407,11 +399,11 @@ make_constraints_independent(
// TODO Check: HZ added 14.08.09 // TODO Check: HZ added 14.08.09
_c_elim.clear(); _c_elim.clear();
_c_elim.resize( gmm::mat_nrows(_constraints), -1); _c_elim.resize(gmm::mat_nrows(_constraints), -1);
// build round map // build round map
std::vector<bool> roundmap( n_vars, false); std::vector<bool> roundmap(n_vars, false);
for(unsigned int i=0; i<_idx_to_round.size(); ++i) for (unsigned int i = 0; i < _idx_to_round.size(); ++i)
roundmap[_idx_to_round[i]] = true; roundmap[_idx_to_round[i]] = true;
// copy constraints into column matrix (for faster update via iterators) // copy constraints into column matrix (for faster update via iterators)
...@@ -422,7 +414,7 @@ make_constraints_independent( ...@@ -422,7 +414,7 @@ make_constraints_independent(
gmm::copy(_constraints, constraints_c); gmm::copy(_constraints, constraints_c);
// for all conditions // for all conditions
for(unsigned int i=0; i<gmm::mat_nrows(_constraints); ++i) for (unsigned int i = 0; i < gmm::mat_nrows(_constraints); ++i)
{ {
// get elimination variable // get elimination variable
int elim_j = -1; int elim_j = -1;
...@@ -438,28 +430,28 @@ make_constraints_independent( ...@@ -438,28 +430,28 @@ make_constraints_independent(
typedef typename gmm::linalg_traits<CRowT>::const_iterator RIter; typedef typename gmm::linalg_traits<CRowT>::const_iterator RIter;
// get current condition row // get current condition row
CRowT row = gmm::mat_const_row( _constraints, i); CRowT row = gmm::mat_const_row(_constraints, i);
RIter row_it = gmm::vect_const_begin( row); RIter row_it = gmm::vect_const_begin(row);
RIter row_end = gmm::vect_const_end( row); RIter row_end = gmm::vect_const_end(row);
double elim_val = FLT_MAX; double elim_val = FLT_MAX;
double max_elim_val = -FLT_MAX; double max_elim_val = -FLT_MAX;
// new: gcd // new: gcd
std::vector<int> v_gcd; std::vector<int> v_gcd;
v_gcd.resize(gmm::nnz(row),-1); v_gcd.resize(gmm::nnz(row), -1);
int n_ints(0); int n_ints(0);
bool gcd_update_valid(true); bool gcd_update_valid(true);
for(; row_it != row_end; ++row_it) for (; row_it != row_end; ++row_it)
{ {
int cur_j = static_cast<int>(row_it.index()); int cur_j = static_cast<int>(row_it.index());
// do not use the constant part // do not use the constant part
if (cur_j != (int)n_vars - 1 ) if (cur_j != (int)n_vars - 1)
{ {
// found real valued var? -> finished (UPDATE: no not any more, find biggest real value to avoid x/1e-13) // found real valued var? -> finished (UPDATE: no not any more, find biggest real value to avoid x/1e-13)
if( !roundmap[ cur_j ]) if (!roundmap[cur_j])
{ {
if( fabs(*row_it) > max_elim_val) if (fabs(*row_it) > max_elim_val)
{ {
elim_j = (int)cur_j; elim_j = (int)cur_j;
max_elim_val = fabs(*row_it); max_elim_val = fabs(*row_it);
...@@ -477,7 +469,7 @@ make_constraints_independent( ...@@ -477,7 +469,7 @@ make_constraints_independent(
// the warning below to DEB_line at high verbosity. // the warning below to DEB_line at high verbosity.
if ((double(int(cur_row_val)) - cur_row_val) != 0.0) if ((double(int(cur_row_val)) - cur_row_val) != 0.0)
{ {
DEB_line(11, "coefficient of integer variable is NOT integer : " << DEB_line(11, "coefficient of integer variable is NOT integer : " <<
cur_row_val); cur_row_val);
gcd_update_valid = false; gcd_update_valid = false;