mirror of
https://github.com/Z3Prover/z3
synced 2025-04-23 17:15:31 +00:00
rm lu
This commit is contained in:
parent
c251151d66
commit
9a7c99da33
3 changed files with 16 additions and 365 deletions
|
@ -611,142 +611,6 @@ void fill_larger_square_sparse_matrix(static_matrix<double, double> & m){
|
|||
|
||||
int perm_id = 0;
|
||||
|
||||
#ifdef Z3DEBUG
|
||||
void test_larger_lu_exp(lp_settings & settings) {
|
||||
std::cout << " test_larger_lu_exp" << std::endl;
|
||||
static_matrix<double, double> m(6, 12);
|
||||
vector<unsigned> basis(6);
|
||||
basis[0] = 1;
|
||||
basis[1] = 3;
|
||||
basis[2] = 0;
|
||||
basis[3] = 4;
|
||||
basis[4] = 5;
|
||||
basis[5] = 6;
|
||||
|
||||
|
||||
fill_larger_square_sparse_matrix_exp(m);
|
||||
// print_matrix(m);
|
||||
vector<int> heading = allocate_basis_heading(m.column_count());
|
||||
vector<unsigned> non_basic_columns;
|
||||
init_basis_heading_and_non_basic_columns_vector(basis, heading, non_basic_columns);
|
||||
lu<static_matrix<double, double>> l(m, basis, settings);
|
||||
|
||||
dense_matrix<double, double> left_side = l.get_left_side(basis);
|
||||
dense_matrix<double, double> right_side = l.get_right_side();
|
||||
lp_assert(left_side == right_side);
|
||||
int leaving = 3;
|
||||
int entering = 8;
|
||||
for (unsigned i = 0; i < m.row_count(); i++) {
|
||||
std::cout << static_cast<double>(m(i, entering)) << std::endl;
|
||||
}
|
||||
|
||||
indexed_vector<double> w(m.row_count());
|
||||
|
||||
l.prepare_entering(entering, w);
|
||||
l.replace_column(0, w, heading[leaving]);
|
||||
change_basis(entering, leaving, basis, non_basic_columns, heading);
|
||||
lp_assert(l.is_correct(basis));
|
||||
|
||||
l.prepare_entering(11, w); // to init vector w
|
||||
l.replace_column(0, w, heading[0]);
|
||||
change_basis(11, 0, basis, non_basic_columns, heading);
|
||||
lp_assert(l.is_correct(basis));
|
||||
}
|
||||
|
||||
void test_larger_lu_with_holes(lp_settings & settings) {
|
||||
std::cout << " test_larger_lu_with_holes" << std::endl;
|
||||
static_matrix<double, double> m(8, 9);
|
||||
vector<unsigned> basis(8);
|
||||
for (unsigned i = 0; i < m.row_count(); i++) {
|
||||
basis[i] = i;
|
||||
}
|
||||
m(0, 0) = 1; m(0, 1) = 2; m(0, 2) = 3; m(0, 3) = 4; m(0, 4) = 5; m(0, 8) = 99;
|
||||
/* */ m(1, 1) =- 6; m(1, 2) = 7; m(1, 3) = 8; m(1, 4) = 9;
|
||||
/* */ m(2, 2) = 10;
|
||||
/* */ m(3, 2) = 11; m(3, 3) = -12;
|
||||
/* */ m(4, 2) = 13; m(4, 3) = 14; m(4, 4) = 15;
|
||||
// the rest of the matrix is denser
|
||||
m(5, 4) = 28; m(5, 5) = -18; m(5, 6) = 19; m(5, 7) = 25;
|
||||
/* */ m(6, 5) = 20; m(6, 6) = -21;
|
||||
/* */ m(7, 5) = 22; m(7, 6) = 23; m(7, 7) = 24; m(7, 8) = 88;
|
||||
print_matrix(m, std::cout);
|
||||
vector<int> heading = allocate_basis_heading(m.column_count());
|
||||
vector<unsigned> non_basic_columns;
|
||||
init_basis_heading_and_non_basic_columns_vector(basis, heading, non_basic_columns);
|
||||
lu<static_matrix<double, double>> l(m, basis, settings);
|
||||
std::cout << "printing factorization" << std::endl;
|
||||
for (int i = l.tail_size() - 1; i >=0; i--) {
|
||||
auto lp = l.get_lp_matrix(i);
|
||||
lp->set_number_of_columns(m.row_count());
|
||||
lp->set_number_of_rows(m.row_count());
|
||||
print_matrix( *lp, std::cout);
|
||||
}
|
||||
|
||||
dense_matrix<double, double> left_side = l.get_left_side(basis);
|
||||
dense_matrix<double, double> right_side = l.get_right_side();
|
||||
if (!(left_side == right_side)) {
|
||||
std::cout << "different sides" << std::endl;
|
||||
}
|
||||
|
||||
indexed_vector<double> w(m.row_count());
|
||||
l.prepare_entering(8, w); // to init vector w
|
||||
l.replace_column(0, w, heading[0]);
|
||||
change_basis(8, 0, basis, non_basic_columns, heading);
|
||||
lp_assert(l.is_correct(basis));
|
||||
}
|
||||
|
||||
|
||||
void test_larger_lu(lp_settings& settings) {
|
||||
std::cout << " test_larger_lu" << std::endl;
|
||||
static_matrix<double, double> m(6, 12);
|
||||
vector<unsigned> basis(6);
|
||||
basis[0] = 1;
|
||||
basis[1] = 3;
|
||||
basis[2] = 0;
|
||||
basis[3] = 4;
|
||||
basis[4] = 5;
|
||||
basis[5] = 6;
|
||||
|
||||
|
||||
fill_larger_square_sparse_matrix(m);
|
||||
print_matrix(m, std::cout);
|
||||
|
||||
vector<int> heading = allocate_basis_heading(m.column_count());
|
||||
vector<unsigned> non_basic_columns;
|
||||
init_basis_heading_and_non_basic_columns_vector(basis, heading, non_basic_columns);
|
||||
auto l = lu<static_matrix<double, double>> (m, basis, settings);
|
||||
// std::cout << "printing factorization" << std::endl;
|
||||
// for (int i = lu.tail_size() - 1; i >=0; i--) {
|
||||
// auto lp = lu.get_lp_matrix(i);
|
||||
// lp->set_number_of_columns(m.row_count());
|
||||
// lp->set_number_of_rows(m.row_count());
|
||||
// print_matrix(* lp);
|
||||
// }
|
||||
|
||||
dense_matrix<double, double> left_side = l.get_left_side(basis);
|
||||
dense_matrix<double, double> right_side = l.get_right_side();
|
||||
if (!(left_side == right_side)) {
|
||||
std::cout << "left side" << std::endl;
|
||||
print_matrix(&left_side, std::cout);
|
||||
std::cout << "right side" << std::endl;
|
||||
print_matrix(&right_side, std::cout);
|
||||
|
||||
std::cout << "different sides" << std::endl;
|
||||
std::cout << "initial factorization is incorrect" << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
indexed_vector<double> w(m.row_count());
|
||||
l.prepare_entering(9, w); // to init vector w
|
||||
l.replace_column(0, w, heading[0]);
|
||||
change_basis(9, 0, basis, non_basic_columns, heading);
|
||||
lp_assert(l.is_correct(basis));
|
||||
}
|
||||
|
||||
|
||||
void test_lu(lp_settings & settings) {
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue