refactor(lp): NDEBUG ==> LEAN_DEBUG
This commit is contained in:
parent
fbb3ed8911
commit
1841d17544
14 changed files with 141 additions and 141 deletions
|
@ -34,7 +34,7 @@ Author: Lev Nachmanson
|
|||
using namespace lean;
|
||||
using namespace std;
|
||||
unsigned seed = 1;
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
unsigned lp_settings::ddd = 0;
|
||||
#endif
|
||||
std::unordered_map<unsigned, std::string> default_column_names(unsigned n) {
|
||||
|
@ -154,7 +154,7 @@ void tst1() {
|
|||
|
||||
test_matrix(m10by9);
|
||||
std::cout <<"zeroing m10by9\n";
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
for (unsigned int i = 0; i < m10by9.dimension(); i++)
|
||||
for (unsigned int j = 0; j < m10by9.column_count(); j++)
|
||||
m10by9.set(i, j, 0);
|
||||
|
@ -180,7 +180,7 @@ void test_small_lu(lp_settings & settings) {
|
|||
m(1, 1) = 4; m(1, 4) = 7;
|
||||
m(2, 0) = 1.8; m(2, 2) = 5; m(2, 4) = 2; m(2, 5) = 8;
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
print_matrix(m);
|
||||
#endif
|
||||
vector<int> heading = allocate_basis_heading(m.column_count());
|
||||
|
@ -193,7 +193,7 @@ void test_small_lu(lp_settings & settings) {
|
|||
l.prepare_entering(2, w); // to init vector w
|
||||
l.replace_column(0, 0, w);
|
||||
l.change_basis(2, 0);
|
||||
// #ifndef NDEBUG
|
||||
// #ifdef LEAN_DEBUG
|
||||
// cout << "we were factoring " << endl;
|
||||
// print_matrix(get_B(l));
|
||||
// #endif
|
||||
|
@ -203,7 +203,7 @@ void test_small_lu(lp_settings & settings) {
|
|||
l.replace_column(3, 0, w);
|
||||
l.change_basis(4, 3);
|
||||
cout << "we were factoring " << endl;
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
print_matrix(get_B(l));
|
||||
#endif
|
||||
lean_assert(l.is_correct());
|
||||
|
@ -213,7 +213,7 @@ void test_small_lu(lp_settings & settings) {
|
|||
l.replace_column(1, 0, w);
|
||||
l.change_basis(5, 1);
|
||||
cout << "we were factoring " << endl;
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
print_matrix(get_B(l));
|
||||
#endif
|
||||
lean_assert(l.is_correct());
|
||||
|
@ -222,7 +222,7 @@ void test_small_lu(lp_settings & settings) {
|
|||
l.replace_column(2, 0, w);
|
||||
l.change_basis(3, 2);
|
||||
cout << "we were factoring " << endl;
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
print_matrix(get_B(l));
|
||||
#endif
|
||||
lean_assert(l.is_correct());
|
||||
|
@ -285,7 +285,7 @@ void fill_larger_sparse_matrix(static_matrix<double, double> & m){
|
|||
|
||||
int perm_id = 0;
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
void test_larger_lu_exp(lp_settings & settings) {
|
||||
std::cout << " test_larger_lu_exp" << std::endl;
|
||||
static_matrix<double, double> m(6, 12);
|
||||
|
@ -481,7 +481,7 @@ void test_lp_1() {
|
|||
m(1, 0) = -1; m(1, 2) = 3; m(1, 4) = 1;
|
||||
m(2, 0) = 2; m(2, 1) = -1; m(2, 2) = 2; m(2, 5) = 1;
|
||||
m(3, 0) = 2; m(3, 1) = 3; m(3, 2) = -1; m(3, 6) = 1;
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
print_matrix(m);
|
||||
#endif
|
||||
std::vector<double> x_star(7);
|
||||
|
@ -529,7 +529,7 @@ void test_lp_primal_core_solver() {
|
|||
test_lp_0();
|
||||
test_lp_1();
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
template <typename T, typename X>
|
||||
void test_swap_rows_with_permutation(sparse_matrix<T, X>& m){
|
||||
cout << "testing swaps" << endl;
|
||||
|
@ -553,7 +553,7 @@ void test_swap_rows_with_permutation(sparse_matrix<T, X>& m){
|
|||
#endif
|
||||
template <typename T, typename X>
|
||||
void fill_matrix(sparse_matrix<T, X>& m); // forward definition
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
void matrix_repro_test() {
|
||||
unsigned dim = 10;
|
||||
sparse_matrix<double, double> m(dim);
|
||||
|
@ -686,7 +686,7 @@ void test_pivot_like_swaps_and_pivot(){
|
|||
m(target_row, 3) = 0;
|
||||
m(target_row, 5) = 0;
|
||||
m(pivot_row, 6) = 0;
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
print_matrix(m);
|
||||
#endif
|
||||
|
||||
|
@ -707,7 +707,7 @@ void test_pivot_like_swaps_and_pivot(){
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
void test_swap_rows() {
|
||||
sparse_matrix<float, float> m(10);
|
||||
fill_matrix(m);
|
||||
|
@ -917,7 +917,7 @@ void test_swap_operations() {
|
|||
test_swap_columns();
|
||||
}
|
||||
#endif
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
void test_dense_matrix() {
|
||||
dense_matrix<double, double> d(3, 2);
|
||||
d.set_elem(0, 0, 1);
|
||||
|
@ -953,7 +953,7 @@ void test_conjugate_eta_matrix() {
|
|||
p[4] = 0;
|
||||
|
||||
cout << "p="; p.print();
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
eta_matrix<double, double> l(2, 5);
|
||||
#else
|
||||
eta_matrix<double, double> l(2);
|
||||
|
@ -1072,7 +1072,7 @@ void test_apply_reverse_from_right_to_perm(permutation_matrix<double, double> &
|
|||
pclone[4] = 1;
|
||||
|
||||
p.multiply_by_reverse_from_right(l);
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
auto rev = l.get_inverse();
|
||||
auto rs = pclone * rev;
|
||||
lean_assert(p == rs)
|
||||
|
@ -1090,7 +1090,7 @@ void test_permutations() {
|
|||
test_apply_reverse_from_right();
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
void test_perm_apply_reverse_from_right() {
|
||||
permutation_generator<double, double> allp(5);
|
||||
vector<double> w(6);
|
||||
|
@ -1378,7 +1378,7 @@ void test_binary_priority_queue() {
|
|||
q.dequeue();
|
||||
q.remove(33);
|
||||
q.enqueue(0, 0);
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
unsigned t = 0;
|
||||
#endif
|
||||
while (q.size() > 0) {
|
||||
|
@ -1854,7 +1854,7 @@ void test_init_U() {
|
|||
m(0, 0) = 10; m(0, 1) = 11; m(0, 2) = 12; m(0, 3) = 13; m(0, 4) = 14;
|
||||
m(1, 0) = 20; m(1, 1) = 21; m(1, 2) = 22; m(1, 3) = 23; m(1, 5) = 24;
|
||||
m(2, 0) = 30; m(2, 1) = 31; m(2, 2) = 32; m(2, 3) = 33; m(2, 6) = 34;
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
print_matrix(m);
|
||||
#endif
|
||||
std::vector<unsigned> basis(3);
|
||||
|
@ -2524,12 +2524,12 @@ void check_lu_from_file(string lufile_name) {
|
|||
vector<unsigned> non_basic_columns;
|
||||
lu<double, double> lsuhl(A, basis, basis_heading, settings, non_basic_columns);
|
||||
vector<double> d(A.row_count());
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
lp_settings::ddd = 1;
|
||||
#endif
|
||||
unsigned entering = 26;
|
||||
lsuhl.solve_Bd(entering, d, v);
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
auto B = get_B(lsuhl);
|
||||
vector<double> a(m);
|
||||
A.copy_column_to_vector(entering, a);
|
||||
|
@ -2550,7 +2550,7 @@ void test_square_dense_submatrix() {
|
|||
for (unsigned i = index_start; i < parent_dim; i++)
|
||||
for (unsigned j = index_start; j < parent_dim; j++)
|
||||
d[i][j] = i*3+j*2;
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
unsigned dim = parent_dim - index_start;
|
||||
dense_matrix<double, double> m(dim, dim);
|
||||
for (unsigned i = index_start; i < parent_dim; i++)
|
||||
|
@ -2561,7 +2561,7 @@ void test_square_dense_submatrix() {
|
|||
for (unsigned i = index_start; i < parent_dim; i++)
|
||||
for (unsigned j = index_start; j < parent_dim; j++)
|
||||
d[i][j] = d[j][i];
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
for (unsigned i = index_start; i < parent_dim; i++)
|
||||
for (unsigned j = index_start; j < parent_dim; j++)
|
||||
m[i-index_start][j-index_start] = d[i][j];
|
||||
|
@ -2593,7 +2593,7 @@ int main(int argn, char * const * argv) {
|
|||
return finalize(0);
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
if (args_parser.option_is_used("--test_swaps")) {
|
||||
sparse_matrix<double, double> m(10);
|
||||
fill_matrix(m);
|
||||
|
@ -2624,7 +2624,7 @@ int main(int argn, char * const * argv) {
|
|||
return finalize(ret);
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
lp_settings settings;
|
||||
update_settings(args_parser, settings);
|
||||
if (args_parser.option_is_used("--test_lu")) {
|
||||
|
@ -2674,7 +2674,7 @@ int main(int argn, char * const * argv) {
|
|||
return finalize(0);
|
||||
test_init_U();
|
||||
test_replace_column();
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
test_perm_apply_reverse_from_right();
|
||||
test_conjugate_perm();
|
||||
sparse_matrix_with_permutaions_test();
|
||||
|
|
|
@ -12,20 +12,20 @@ namespace lean {
|
|||
template <typename T, typename X>
|
||||
class eta_matrix
|
||||
: public tail_matrix<T, X> {
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
unsigned m_length;
|
||||
#endif
|
||||
unsigned m_column_index;
|
||||
sparse_vector<T> m_column_vector;
|
||||
T m_diagonal_element;
|
||||
public:
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
eta_matrix(unsigned column_index, unsigned length):
|
||||
#else
|
||||
eta_matrix(unsigned column_index):
|
||||
#endif
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
m_length(length),
|
||||
#endif
|
||||
m_column_index(column_index) {
|
||||
|
@ -101,7 +101,7 @@ namespace lean {
|
|||
}
|
||||
|
||||
void apply_from_right(vector<T> & w) {
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// dense_matrix<T, X> deb(*this);
|
||||
// auto clone_w = clone_vector<T>(w, get_number_of_rows());
|
||||
// deb.apply_from_right(clone_w);
|
||||
|
@ -111,14 +111,14 @@ namespace lean {
|
|||
t += w[it.index()] * it.value();
|
||||
}
|
||||
w[m_column_index] = t;
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// lean_assert(vectors_are_equal<T>(clone_w, w, get_number_of_rows()));
|
||||
// delete clone_w;
|
||||
#endif
|
||||
}
|
||||
|
||||
// void apply_from_right(indexed_vector<T> & w) {
|
||||
// #ifndef NDEBUG
|
||||
// #ifdef LEAN_DEBUG
|
||||
// // dense_matrix<T, X> deb(*this);
|
||||
// // auto clone_w = clone_vector<T>(w, get_number_of_rows());
|
||||
// // deb.apply_from_right(clone_w);
|
||||
|
@ -131,7 +131,7 @@ namespace lean {
|
|||
// w.m_index.push_back(m_column_index);
|
||||
// }
|
||||
// w[m_column_index] = t; // we might get a zero here
|
||||
// #ifndef NDEBUG
|
||||
// #ifdef LEAN_DEBUG
|
||||
// // lean_assert(vectors_are_equal<T>(clone_w, w, get_number_of_rows()));
|
||||
// // delete clone_w;
|
||||
// #endif
|
||||
|
@ -147,7 +147,7 @@ namespace lean {
|
|||
|
||||
return i == j ? numeric_traits<T>::one() : numeric_traits<T>::zero();
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
unsigned row_count() const { return m_length; }
|
||||
unsigned column_count() const { return m_length; }
|
||||
void set_number_of_rows(unsigned /*m*/) { }
|
||||
|
@ -162,7 +162,7 @@ namespace lean {
|
|||
}
|
||||
void conjugate_by_permutation(permutation_matrix<T, X> & p) {
|
||||
// this = p * this * p(-1)
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// auto rev = p.get_reverse();
|
||||
// auto deb = ((*this) * rev);
|
||||
// deb = p * deb;
|
||||
|
@ -171,7 +171,7 @@ namespace lean {
|
|||
for (auto & pair : m_column_vector.m_data) {
|
||||
pair.first = p.get_rev(pair.first);
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// lean_assert(deb == *this);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ public:
|
|||
|
||||
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
bool is_OK() const {
|
||||
int size = 0;
|
||||
for (unsigned i = 0; i < m_data.size(); i++) {
|
||||
|
|
|
@ -178,7 +178,7 @@ class lar_solver {
|
|||
for (auto & t : m_column_indices_to_canonic_left_sides)
|
||||
if (valid_index(t.second->m_row_index))
|
||||
add_row_to_A(A, i++, t.second);
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// print_matrix(m_A);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -170,7 +170,7 @@ public:
|
|||
void solve_Bd(unsigned entering) {
|
||||
m_factorization->solve_Bd(entering, m_ed, m_w);
|
||||
update_index_of_ed();
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// auto B = get_B(m_factorization);
|
||||
// vector<T> a(m_m);
|
||||
// m_A.copy_column_to_vector(entering, a);
|
||||
|
|
|
@ -576,7 +576,7 @@ public: // todo : move public lower ; it is for debug only
|
|||
m_low_bound_values_dummy.resize(A.column_count(), zero_of_type<T>());
|
||||
m_enter_price_eps = numeric_traits<T>::precise() ? numeric_traits<T>::zero() : T(1e-5);
|
||||
this->m_column_norm_update_counter = settings.column_norms_update_frequency;
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// check_correctness();
|
||||
#endif
|
||||
}
|
||||
|
@ -618,7 +618,7 @@ public: // todo : move public lower ; it is for debug only
|
|||
return true;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
void check_Ax_equal_b() {
|
||||
dense_matrix<T, X> d(this->m_A);
|
||||
T * ls = d.apply_from_left_with_different_dims(this->m_x);
|
||||
|
@ -646,7 +646,7 @@ public: // todo : move public lower ; it is for debug only
|
|||
// the basis structures have not changed yet
|
||||
void update_reduced_costs_from_pivot_row(unsigned entering, int leaving) {
|
||||
// the basis heading has changed already
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
auto & basis_heading = this->m_factorization->m_basis_heading;
|
||||
lean_assert(basis_heading[entering] >= 0 && basis_heading[entering] < this->m_ed.size());
|
||||
lean_assert(basis_heading[leaving] < 0);
|
||||
|
@ -942,7 +942,7 @@ public: // todo : move public lower ; it is for debug only
|
|||
|
||||
void forget_last_columns(unsigned how_many_to_forget) {
|
||||
lean_assert(this->m_n > how_many_to_forget);
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
for (unsigned i = 0; i < this->m_A.row_count(); i++) {
|
||||
lean_assert(this->m_basis[i] < this->m_n - how_many_to_forget);
|
||||
}
|
||||
|
|
|
@ -196,7 +196,7 @@ struct lp_settings {
|
|||
unsigned column_norms_update_frequency = 1000;
|
||||
bool scale_with_ratio = true;
|
||||
double density_threshold = 0.7; // need to tune it up, todo
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
bool dense_deb;
|
||||
static unsigned ddd; // used for debugging
|
||||
#endif
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
namespace lean {
|
||||
template <typename T>
|
||||
std::string T_to_string(const T & t); // forward definition
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
template <typename T, typename X> // print the nr x nc submatrix at the top left corner
|
||||
void print_submatrix(sparse_matrix<T, X> & m, unsigned mr, unsigned nc) {
|
||||
vector<vector<string>> A;
|
||||
|
@ -99,7 +99,7 @@ class one_elem_on_diag: public tail_matrix<T, X> {
|
|||
T m_val;
|
||||
public:
|
||||
one_elem_on_diag(unsigned i, T val) : m_i(i), m_val(val) {
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
m_one_over_val = numeric_traits<T>::one() / m_val;
|
||||
#endif
|
||||
}
|
||||
|
@ -108,13 +108,13 @@ public:
|
|||
m_i = o.m_i;
|
||||
m_val = o.m_val;
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
m_m = m_n = o.m_m;
|
||||
m_one_over_val = numeric_traits<T>::one() / o.m_val;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
unsigned m_m;
|
||||
unsigned m_n;
|
||||
virtual void set_number_of_rows(unsigned m) { m_m = m; m_n = m; }
|
||||
|
@ -153,14 +153,14 @@ public:
|
|||
|
||||
void conjugate_by_permutation(permutation_matrix<T, X> & p) {
|
||||
// this = p * this * p(-1)
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// auto rev = p.get_reverse();
|
||||
// auto deb = ((*this) * rev);
|
||||
// deb = p * deb;
|
||||
#endif
|
||||
m_i = p.apply_reverse(m_i);
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// lean_assert(*this == deb);
|
||||
#endif
|
||||
}
|
||||
|
@ -209,7 +209,7 @@ public:
|
|||
m_basis_heading(basis_heading),
|
||||
m_non_basic_columns(non_basic_columns),
|
||||
m_row_eta_work_vector(A.row_count()){
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
debug_test_of_basis(A, basis);
|
||||
#endif
|
||||
create_initial_factorization();
|
||||
|
@ -221,7 +221,7 @@ public:
|
|||
}
|
||||
return;
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// lean_assert(check_correctness());
|
||||
#endif
|
||||
}
|
||||
|
@ -325,7 +325,7 @@ public:
|
|||
m_U.solve_y_U(y); // got y*U=cb*R(-1)
|
||||
m_Q.apply_reverse_from_right(y); //
|
||||
for (auto e = m_tail.rbegin(); e != m_tail.rend(); ++e) {
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
(*e)->set_number_of_columns(m_dim);
|
||||
#endif
|
||||
(*e)->apply_from_right(y);
|
||||
|
@ -501,7 +501,7 @@ public:
|
|||
return column_to_replace;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
void check_vector_w(unsigned entering) {
|
||||
T * w = new T[m_dim];
|
||||
m_A.copy_column_to_vector(entering, w);
|
||||
|
@ -572,7 +572,7 @@ public:
|
|||
}
|
||||
|
||||
bool is_correct() {
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
if (get_status() != LU_status::OK) {
|
||||
return false;
|
||||
}
|
||||
|
@ -589,7 +589,7 @@ public:
|
|||
return m_basis_heading[j];
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
dense_matrix<T, X> tail_product() {
|
||||
lean_assert(tail_size() > 0);
|
||||
dense_matrix<T, X> left_side = permutation_matrix<T, X>(m_dim);
|
||||
|
@ -776,7 +776,7 @@ public:
|
|||
pivot_and_solve_the_system(replaced_column, lowest_row_of_the_bump);
|
||||
T denom = std::max(T(1), abs(pivot_elem_for_checking));
|
||||
if (
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
!is_zero(pivot_elem_for_checking) &&
|
||||
#endif
|
||||
!m_settings.abs_val_is_smaller_than_pivot_tolerance((m_row_eta_work_vector[lowest_row_of_the_bump] - pivot_elem_for_checking) / denom)) {
|
||||
|
@ -785,7 +785,7 @@ public:
|
|||
// cout << "diagonal element is off" << endl;
|
||||
return nullptr;
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
auto ret = new row_eta_matrix<T, X>(replaced_column, lowest_row_of_the_bump, m_dim);
|
||||
#else
|
||||
auto ret = new row_eta_matrix<T, X>(replaced_column, lowest_row_of_the_bump);
|
||||
|
@ -848,7 +848,7 @@ public:
|
|||
|
||||
void calculate_Lwave_Pwave_for_last_row(unsigned lowest_row_of_the_bump, T diagonal_element) {
|
||||
auto l = new one_elem_on_diag<T, X>(lowest_row_of_the_bump, diagonal_element);
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
l->set_number_of_columns(m_dim);
|
||||
#endif
|
||||
push_matrix_to_tail(l);
|
||||
|
@ -872,7 +872,7 @@ void init_factorization(lu<T, X>* & factorization, static_matrix<T, X> & m_A, st
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
template <typename T, typename X>
|
||||
dense_matrix<T, X> get_B(lu<T, X>& f) {
|
||||
dense_matrix<T, X> B(f.dimension(), f.dimension());
|
||||
|
|
|
@ -186,7 +186,7 @@ namespace lean {
|
|||
return r;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// used for debugging purposes only
|
||||
template <typename T, typename X>
|
||||
class matrix {
|
||||
|
@ -231,7 +231,7 @@ namespace lean {
|
|||
// These matrices appear at the end of the list
|
||||
template <typename T, typename X>
|
||||
class tail_matrix
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
: public matrix<T, X>
|
||||
#endif
|
||||
{
|
||||
|
@ -242,7 +242,7 @@ namespace lean {
|
|||
virtual ~tail_matrix() {}
|
||||
};
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
template <typename T, typename X>
|
||||
void apply_to_vector(matrix<T, X> & m, T * w) {
|
||||
// here m is a square matrix
|
||||
|
@ -548,7 +548,7 @@ namespace lean {
|
|||
cout << ' ';
|
||||
}
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
inline void print_matrix_with_widths(vector<vector<string>> & A, vector<unsigned> & ws) {
|
||||
for (unsigned i = 0; i < A.size(); i++) {
|
||||
for (unsigned j = 0; j < A[i].size(); j++) {
|
||||
|
@ -638,7 +638,7 @@ namespace lean {
|
|||
return m_rev[i];
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
permutation_matrix get_inverse() const {
|
||||
return permutation_matrix(m_length, m_rev);
|
||||
}
|
||||
|
@ -678,7 +678,7 @@ namespace lean {
|
|||
|
||||
template <typename L>
|
||||
void apply_from_left_perm(vector<L> & w) {
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// dense_matrix<L, X> deb(*this);
|
||||
// L * deb_w = clone_vector<L>(w, row_count());
|
||||
// deb.apply_from_left(deb_w);
|
||||
|
@ -692,7 +692,7 @@ namespace lean {
|
|||
w[i] = t[i];
|
||||
}
|
||||
delete [] t;
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// lean_assert(vectors_are_equal<L>(deb_w, w, row_count()));
|
||||
// delete [] deb_w;
|
||||
#endif
|
||||
|
@ -709,7 +709,7 @@ namespace lean {
|
|||
|
||||
template <typename L>
|
||||
void apply_from_left_perm(indexed_vector<L> & w, lp_settings &) {
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// dense_matrix<T, L> deb(*this);
|
||||
// T * deb_w = clone_vector<T>(w.m_data, row_count());
|
||||
// deb.apply_from_right(deb_w);
|
||||
|
@ -725,7 +725,7 @@ namespace lean {
|
|||
w[j] = t[i];
|
||||
w.m_index[i] = j;
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// lean_assert(vectors_are_equal<T>(deb_w, w.m_data, row_count()));
|
||||
// delete [] deb_w;
|
||||
#endif
|
||||
|
@ -733,7 +733,7 @@ namespace lean {
|
|||
|
||||
|
||||
void apply_from_right(vector<T> & w) {
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// dense_matrix<T, X> deb(*this);
|
||||
// T * deb_w = clone_vector<T>(w, row_count());
|
||||
// deb.apply_from_right(deb_w);
|
||||
|
@ -747,7 +747,7 @@ namespace lean {
|
|||
w[i] = t[i];
|
||||
}
|
||||
delete [] t;
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// lean_assert(vectors_are_equal<T>(deb_w, w, row_count()));
|
||||
// delete [] deb_w;
|
||||
#endif
|
||||
|
@ -755,7 +755,7 @@ namespace lean {
|
|||
|
||||
// void apply_from_right(indexed_vector<T> & w) {
|
||||
// lean_assert(false); // i think it is never called
|
||||
// #ifndef NDEBUG
|
||||
// #ifdef LEAN_DEBUG
|
||||
// // dense_matrix<T, X> deb(*this);
|
||||
// // T * deb_w = clone_vector<T>(w.m_data, row_count());
|
||||
// // deb.apply_from_right(deb_w);
|
||||
|
@ -774,7 +774,7 @@ namespace lean {
|
|||
// for (unsigned i = 0; i < m_length; i++) {
|
||||
// w[i] = t[i];
|
||||
// }
|
||||
// #ifndef NDEBUG
|
||||
// #ifdef LEAN_DEBUG
|
||||
// // lean_assert(vectors_are_equal<T>(deb_w, w.m_data, row_count()));
|
||||
// // delete [] deb_w;
|
||||
// #endif
|
||||
|
@ -803,7 +803,7 @@ namespace lean {
|
|||
template <typename L>
|
||||
void apply_reverse_from_left(indexed_vector<L> & w) {
|
||||
// the result will be w = p(-1) * w
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// dense_matrix<L, X> deb(get_reverse());
|
||||
// L * deb_w = clone_vector<L>(w.m_data, row_count());
|
||||
// deb.apply_from_left(deb_w);
|
||||
|
@ -821,7 +821,7 @@ namespace lean {
|
|||
w[j] = t[i];
|
||||
w.m_index[i] = j;
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// lean_assert(vectors_are_equal<L>(deb_w, w.m_data, row_count()));
|
||||
// delete [] deb_w;
|
||||
#endif
|
||||
|
@ -830,7 +830,7 @@ namespace lean {
|
|||
template <typename L>
|
||||
void apply_reverse_from_left(std::vector<L> & w) {
|
||||
// the result will be w = p(-1) * w
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// dense_matrix<T, X> deb(get_reverse());
|
||||
// T * deb_w = clone_vector<T>(w, row_count());
|
||||
// deb.apply_from_left(deb_w);
|
||||
|
@ -843,7 +843,7 @@ namespace lean {
|
|||
for (unsigned i = 0; i < m_length; i++) {
|
||||
w[i] = t[i];
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// lean_assert(vectors_are_equal<T>(deb_w, w, row_count()));
|
||||
// delete [] deb_w;
|
||||
#endif
|
||||
|
@ -851,7 +851,7 @@ namespace lean {
|
|||
template <typename L>
|
||||
void apply_reverse_from_right(vector<L> & w) {
|
||||
// the result will be w = w * p(-1)
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// dense_matrix<T, X> deb(get_reverse());
|
||||
// T * deb_w = clone_vector<T>(w, row_count());
|
||||
// deb.apply_from_right(deb_w);
|
||||
|
@ -865,7 +865,7 @@ namespace lean {
|
|||
w[i] = t[i];
|
||||
}
|
||||
delete [] t;
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// lean_assert(vectors_are_equal<T>(deb_w, w, row_count()));
|
||||
// delete deb_w;
|
||||
#endif
|
||||
|
@ -898,7 +898,7 @@ namespace lean {
|
|||
set_val(i, pj);
|
||||
set_val(j, pi);
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
T get_elem(unsigned i, unsigned j) const{
|
||||
return m_permutation[i] == j? numeric_traits<T>::one() : numeric_traits<T>::zero();
|
||||
}
|
||||
|
@ -980,7 +980,7 @@ namespace lean {
|
|||
unsigned * values() const { return m_permutation; }
|
||||
}; // end of the permutation class
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
template <typename T, typename X>
|
||||
class permutation_generator {
|
||||
unsigned m_n;
|
||||
|
@ -1114,25 +1114,25 @@ namespace lean {
|
|||
}
|
||||
|
||||
one_off_diagonal_matrix(const one_off_diagonal_matrix<T, X> * o):m_i(o.m_i), m_j(o.m_j), m_val_jj(o.m_val_jj), m_val_ij(o.m_val_ij) {
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
m_m = m_n = o.m_m;
|
||||
#endif
|
||||
}
|
||||
|
||||
void conjugate_by_permutation(permutation_matrix<T, X> & p) {
|
||||
// this = p * this * p(-1)
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// auto rev = p.get_reverse();
|
||||
// auto deb = ((*this) * rev);
|
||||
// deb = p * deb;
|
||||
#endif
|
||||
m_j = p.get_rev(m_j);
|
||||
m_i = p.get_rev(m_i);
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// lean_assert(deb == *this);
|
||||
#endif
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
unsigned m_m;
|
||||
unsigned m_n;
|
||||
virtual void set_number_of_rows(unsigned m) { m_n = m_m = m; }
|
||||
|
@ -1156,7 +1156,7 @@ namespace lean {
|
|||
unsigned column_count() const { return m_n; } // not defined }
|
||||
#endif
|
||||
void apply_from_left(vector<X> & w, lp_settings &) {
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// dense_matrix<T, X> deb(*this);
|
||||
// T * deb_w = clone_vector<T>(w, row_count());
|
||||
// deb.apply_from_left(deb_w);
|
||||
|
@ -1164,7 +1164,7 @@ namespace lean {
|
|||
auto wj = w[m_j];
|
||||
w[m_j] = wj / m_val_jj;
|
||||
w[m_i] += wj * m_val_ij;
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// lean_assert(vectors_are_equal<T>(deb_w, w, row_count()));
|
||||
// delete deb_w;
|
||||
#endif
|
||||
|
@ -1172,7 +1172,7 @@ namespace lean {
|
|||
|
||||
template <typename L>
|
||||
void apply_from_left_local(indexed_vector<L> & w, lp_settings & settings) {
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// dense_matrix<T, X> deb(*this);
|
||||
// T * deb_w = clone_vector<T>(w.m_data, row_count());
|
||||
// deb.apply_from_left(deb_w);
|
||||
|
@ -1193,7 +1193,7 @@ namespace lean {
|
|||
|
||||
lean_assert(check_vector_for_small_values(w, settings ));
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// lean_assert(vectors_are_equal<T>(deb_w, w.m_data, row_count()));
|
||||
// delete deb_w;
|
||||
#endif
|
||||
|
@ -1203,20 +1203,20 @@ namespace lean {
|
|||
apply_from_left_local(w, settings);
|
||||
}
|
||||
void apply_from_right(vector<T> & w) {
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// dense_matrix<T, X> deb(*this);
|
||||
// T * deb_w = clone_vector<T>(w, row_count());
|
||||
// deb.apply_from_right(deb_w);
|
||||
#endif
|
||||
w[m_j] = w[m_j] / m_val_jj + m_val_ij * w[m_i];
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// lean_assert(vectors_are_equal<T>(deb_w, w, row_count()));
|
||||
// delete deb_w;
|
||||
#endif
|
||||
}
|
||||
|
||||
// void apply_from_right(indexed_vector<T> & w) {
|
||||
// #ifndef NDEBUG
|
||||
// #ifdef LEAN_DEBUG
|
||||
// // dense_matrix<T, X> deb(*this);
|
||||
// // vector<T> deb_w(w.m_data);
|
||||
// // deb.apply_from_right(deb_w);
|
||||
|
@ -1228,7 +1228,7 @@ namespace lean {
|
|||
// w[m_j] = m_val_ij * w[m_i];
|
||||
// w.m_index.push_back(m_j);
|
||||
// }
|
||||
// #ifndef NDEBUG
|
||||
// #ifdef LEAN_DEBUG
|
||||
// // lean_assert(vectors_are_equal<T>(deb_w, w.m_data, row_count()));
|
||||
// // delete deb_w;
|
||||
// #endif
|
||||
|
|
|
@ -26,20 +26,20 @@ namespace lean {
|
|||
template <typename T, typename X>
|
||||
class row_eta_matrix
|
||||
: public tail_matrix<T, X> {
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
unsigned m_dimension;
|
||||
#endif
|
||||
unsigned m_row_start;
|
||||
unsigned m_row;
|
||||
sparse_vector<T> m_row_vector;
|
||||
public:
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
row_eta_matrix(unsigned row_start, unsigned row, unsigned dim):
|
||||
#else
|
||||
row_eta_matrix(unsigned row_start, unsigned row):
|
||||
#endif
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
m_dimension(dim),
|
||||
#endif
|
||||
m_row_start(row_start), m_row(row) {
|
||||
|
@ -55,11 +55,11 @@ public:
|
|||
}
|
||||
|
||||
void apply_from_left(vector<X> & w, lp_settings &
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// settings
|
||||
#endif
|
||||
) {
|
||||
// #ifndef NDEBUG
|
||||
// #ifdef LEAN_DEBUG
|
||||
// dense_matrix<T> deb(*this);
|
||||
// auto clone_w = clone_vector<T>(w, m_dimension);
|
||||
// deb.apply_from_left(clone_w, settings);
|
||||
|
@ -69,7 +69,7 @@ public:
|
|||
w_at_row += w[it.index()] * it.value();
|
||||
}
|
||||
w[m_row] = w_at_row;
|
||||
// #ifndef NDEBUG
|
||||
// #ifdef LEAN_DEBUG
|
||||
// lean_assert(vectors_are_equal<T>(clone_w, w, m_dimension));
|
||||
// delete [] clone_w;
|
||||
// #endif
|
||||
|
@ -77,7 +77,7 @@ public:
|
|||
|
||||
template <typename L>
|
||||
void apply_from_left_local(indexed_vector<L> & w, lp_settings & settings) {
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// dense_matrix<T> deb(*this);
|
||||
// auto clone_w = clone_vector<T>(w.m_data, m_dimension);
|
||||
// deb.apply_from_left(clone_w);
|
||||
|
@ -100,7 +100,7 @@ public:
|
|||
w.m_index.erase(it);
|
||||
}
|
||||
lean_assert(check_vector_for_small_values(w, settings));
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// lean_assert(vectors_are_equal<T>(clone_w, w.m_data, m_dimension));
|
||||
// delete clone_w;
|
||||
#endif
|
||||
|
@ -117,7 +117,7 @@ public:
|
|||
void apply_from_right(vector<T> & w) {
|
||||
T w_row = w[m_row];
|
||||
if (numeric_traits<T>::is_zero(w_row)) return;
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// dense_matrix<T> deb(*this);
|
||||
// auto clone_w = clone_vector<T>(w, m_dimension);
|
||||
// deb.apply_from_right(clone_w);
|
||||
|
@ -125,7 +125,7 @@ public:
|
|||
for (auto it = sparse_vector_iterator<T>(m_row_vector); !it.done(); it.move()) {
|
||||
w[it.index()] += w_row * it.value();
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// lean_assert(vectors_are_equal<T>(clone_w, w, m_dimension));
|
||||
// delete clone_w;
|
||||
#endif
|
||||
|
@ -134,7 +134,7 @@ public:
|
|||
void apply_from_right(indexed_vector<T> & w) {
|
||||
T w_row = w[m_row];
|
||||
if (numeric_traits<T>::is_zero(w_row)) return;
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// dense_matrix<T> deb(*this);
|
||||
// auto clone_w = clone_vector<T>(w.m_data, m_dimension);
|
||||
// deb.apply_from_right(clone_w);
|
||||
|
@ -150,7 +150,7 @@ public:
|
|||
w.m_index.erase(w_it);
|
||||
}
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// lean_assert(vectors_are_equal<T>(clone_w, w.m_data, m_dimension));
|
||||
// for (unsigned i = 0; i < m_dimension; i++) {
|
||||
// if (!numeric_traits<T>::is_zero(w.m_data[i])) {
|
||||
|
@ -163,7 +163,7 @@ public:
|
|||
|
||||
void conjugate_by_permutation(permutation_matrix<T, X> & p) {
|
||||
// this = p * this * p(-1)
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// auto rev = p.get_reverse();
|
||||
// auto deb = ((*this) * rev);
|
||||
// deb = p * deb;
|
||||
|
@ -177,7 +177,7 @@ public:
|
|||
for (unsigned i = columns.size(); i-- > 0;) {
|
||||
m_row_vector.m_data[i].first = p.get_rev(columns[i]);
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// lean_assert(deb == *this);
|
||||
#endif
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ public:
|
|||
|
||||
return col == row ? numeric_traits<T>::one() : numeric_traits<T>::zero();
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
unsigned row_count() const { return m_dimension; }
|
||||
unsigned column_count() const { return m_dimension; }
|
||||
void set_number_of_rows(unsigned /*m*/) { }
|
||||
|
|
|
@ -29,7 +29,7 @@ using std::cout;
|
|||
// it is a square matrix
|
||||
template <typename T, typename X>
|
||||
class sparse_matrix
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
: public matrix<T, X>
|
||||
#endif
|
||||
{
|
||||
|
@ -55,7 +55,7 @@ public:
|
|||
permutation_matrix<T, X> m_row_permutation;
|
||||
permutation_matrix<T, X> m_column_permutation;
|
||||
indexed_vector<T> m_work_pivot_vector;
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// dense_matrix<T> m_dense;
|
||||
#endif
|
||||
/*
|
||||
|
@ -233,7 +233,7 @@ public:
|
|||
|
||||
unsigned dimension() const {return m_row_permutation.size();}
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
unsigned row_count() const {return dimension();}
|
||||
unsigned column_count() const {return dimension();}
|
||||
#endif
|
||||
|
@ -398,7 +398,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
lean_assert(numeric_traits<T>::is_zero(m_work_pivot_vector[pivot_col]));
|
||||
#endif
|
||||
if (!set_row_from_work_vector_and_clean_work_vector(i0)) {
|
||||
|
@ -580,7 +580,7 @@ public:
|
|||
// solving x * this = y, and putting the answer into y
|
||||
// the matrix here has to be upper triangular
|
||||
void solve_y_U(std::vector<T> & y) const { // works by rows
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// T * rs = clone_vector<T>(y, dimension());
|
||||
#endif
|
||||
unsigned end = dimension() - 1;
|
||||
|
@ -596,7 +596,7 @@ public:
|
|||
}
|
||||
}
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// dense_matrix<T> deb(*this);
|
||||
// T * clone_y = clone_vector<T>(y, dimension());
|
||||
// deb.apply_from_right(clone_y);
|
||||
|
@ -635,7 +635,7 @@ public:
|
|||
// solving this * x = y, and putting the answer into y
|
||||
// the matrix here has to be upper triangular
|
||||
void solve_U_y_(T * y) { // the row wise version
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// T * rs = clone_vector<T>(y, dimension());
|
||||
#endif
|
||||
lean_assert(dimension() == dimension());
|
||||
|
@ -650,7 +650,7 @@ public:
|
|||
y[i] -= y[col] * c.m_value;
|
||||
}
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// dense_matrix<T> deb(*this);
|
||||
// T * clone_y = clone_vector<T>(y, dimension());
|
||||
// deb.apply_from_left(clone_y);
|
||||
|
@ -662,7 +662,7 @@ public:
|
|||
// solving this * x = y, and putting the answer into y
|
||||
// the matrix here has to be upper triangular
|
||||
void solve_U_y(T * y) { // the columns have to be correct - it is a column wise version
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// T * rs = clone_vector<T>(y, dimension());
|
||||
#endif
|
||||
for (unsigned j = dimension() - 1; j > 0; j--) {
|
||||
|
@ -676,7 +676,7 @@ public:
|
|||
}
|
||||
}
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// dense_matrix<T> deb(*this);
|
||||
// T * clone_y = clone_vector<T>(y, dimension());
|
||||
// deb.apply_from_left(clone_y);
|
||||
|
@ -713,7 +713,7 @@ public:
|
|||
// the matrix here has to be upper triangular
|
||||
template <typename L>
|
||||
void solve_U_y(std::vector<L> & y) { // it is a column wise version
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// T * rs = clone_vector<T>(y, dimension());
|
||||
#endif
|
||||
|
||||
|
@ -728,7 +728,7 @@ public:
|
|||
}
|
||||
}
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// dense_matrix<T> deb(*this);
|
||||
// T * clone_y = clone_vector<T>(y, dimension());
|
||||
// deb.apply_from_left(clone_y);
|
||||
|
@ -736,7 +736,7 @@ public:
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
T get_elem(unsigned i, unsigned j) const { return get(i, j); }
|
||||
unsigned get_number_of_rows() const { return dimension(); }
|
||||
unsigned get_number_of_columns() const { return dimension(); }
|
||||
|
@ -999,7 +999,7 @@ public:
|
|||
lean_assert(cnz > 0);
|
||||
return m_rows[i].m_values.size() * (cnz - 1);
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
bool can_improve_score_for_row(unsigned row, unsigned score, T const & c_partial_pivoting, unsigned k) {
|
||||
unsigned arow = adjust_row(row);
|
||||
auto & row_vals = m_rows[arow].m_values;
|
||||
|
@ -1080,7 +1080,7 @@ public:
|
|||
if (j_inv < k) continue;
|
||||
int small = elem_is_too_small(i, j, c_partial_pivoting);
|
||||
if (!small) {
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// if (!really_best_pivot(i, j, c_partial_pivoting, k)) {
|
||||
// print_active_matrix(k);
|
||||
// lean_assert(false);
|
||||
|
@ -1182,7 +1182,7 @@ public:
|
|||
return;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
*eta = new eta_matrix<T, X>(j, dimension());
|
||||
#else
|
||||
*eta = new eta_matrix<T, X>(j);
|
||||
|
@ -1311,7 +1311,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
void check_matrix() {
|
||||
check_rows_vs_columns();
|
||||
check_columns_vs_rows();
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
void push_back(unsigned index, T val) {
|
||||
m_data.emplace_back(index, val);
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
T operator[] (unsigned i) const {
|
||||
for (auto t : m_data) {
|
||||
if (t.first == i) return t.second;
|
||||
|
|
|
@ -266,7 +266,7 @@ public:
|
|||
|
||||
template <typename L>
|
||||
void apply_from_left_local(indexed_vector<L> & w, lp_settings & settings) {
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// dense_matrix<T, X> deb(*this);
|
||||
// vector<L> deb_w(w.m_data.size());
|
||||
// for (unsigned i = 0; i < w.m_data.size(); i++)
|
||||
|
@ -318,7 +318,7 @@ public:
|
|||
w.m_data[i] = v;
|
||||
}
|
||||
#endif
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// cout << "w final" << endl;
|
||||
// print_vector(w.m_data);
|
||||
// lean_assert(vectors_are_equal<T>(deb_w, w.m_data));
|
||||
|
@ -348,7 +348,7 @@ public:
|
|||
for (unsigned i = 0; i < m_parent->dimension(); i++) {
|
||||
w[i] = t[i];
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// cout << "w final" << endl;
|
||||
// print_vector(w.m_data);
|
||||
// lean_assert(vectors_are_equal<L>(deb_w, w));
|
||||
|
@ -388,7 +388,7 @@ public:
|
|||
}
|
||||
|
||||
void apply_from_right(vector<T> & w) {
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// dense_matrix<T, X> deb(*this);
|
||||
// vector<T> deb_w(w);
|
||||
// deb.apply_from_right(deb_w);
|
||||
|
@ -403,7 +403,7 @@ public:
|
|||
// std::copy(t.begin(), t.end(), w); // does not compile
|
||||
lean_assert(w.size() == t.size());
|
||||
w = t;
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
// lean_assert(vectors_are_equal<T>(deb_w, w));
|
||||
#endif
|
||||
}
|
||||
|
@ -411,7 +411,7 @@ public:
|
|||
|
||||
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
|
||||
T get_elem (unsigned i, unsigned j) const {
|
||||
i = adjust_row(i);
|
||||
|
|
|
@ -53,11 +53,11 @@ private:
|
|||
// each assignment for this matrix should be issued only once!!!
|
||||
template <typename T, typename X>
|
||||
class static_matrix
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
: public matrix<T, X>
|
||||
#endif
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
std::set<pair<unsigned, unsigned>> m_domain;
|
||||
#endif
|
||||
public:
|
||||
|
@ -123,7 +123,7 @@ public:
|
|||
m_work_pivot_vector.clear();
|
||||
m_rows.clear();
|
||||
m_columns.clear();
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
m_domain.clear();
|
||||
#endif
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
void regen_domain() {
|
||||
m_domain.clear();
|
||||
for (int i = 0; i < m_rows.size(); i++){
|
||||
|
@ -252,7 +252,7 @@ public:
|
|||
void set(unsigned row, unsigned col, T const & val) {
|
||||
if (numeric_traits<T>::is_zero(val)) return;
|
||||
lean_assert(row < row_count() && col < column_count());
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
pair<unsigned, unsigned> p(row, col);
|
||||
lean_assert(m_domain.find(p) == m_domain.end());
|
||||
m_domain.insert(p);
|
||||
|
@ -350,7 +350,7 @@ public:
|
|||
return ret;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
void check_consistency() {
|
||||
unordered_map<std::pair<unsigned, unsigned>, T> by_rows;
|
||||
for (int i = 0; i < m_rows.size(); i++){
|
||||
|
@ -383,13 +383,13 @@ public:
|
|||
|
||||
|
||||
void cross_out_row(unsigned k) {
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
check_consistency();
|
||||
#endif
|
||||
cross_out_row_from_columns(k, m_rows[k]);
|
||||
fix_row_indices_in_each_column_for_crossed_row(k);
|
||||
m_rows.erase(m_rows.begin() + k);
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
regen_domain();
|
||||
check_consistency();
|
||||
#endif
|
||||
|
@ -454,7 +454,7 @@ public:
|
|||
}
|
||||
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef LEAN_DEBUG
|
||||
unsigned get_number_of_rows() const { return row_count(); }
|
||||
unsigned get_number_of_columns() const { return column_count(); }
|
||||
virtual void set_number_of_rows(unsigned /*m*/) { }
|
||||
|
|
Loading…
Reference in a new issue