#include <iostream>
#include <vector>
#include <algorithm>
#include <CGAL/Random.h>
#include <CGAL/QP_models.h>
#include <CGAL/QP_functions.h>
#ifdef CGAL_USE_GMP
#else
#endif
int n = 4;
int s = 10;
CGAL::Random rd;
int main() {
std::vector<std::vector<CGAL::Quotient<ET> > >
inv_a;
for (int j=0; j<n; ++j)
for (int i=0; i<n; ++i)
lp.set_a (j, i, rd.get_int (-s, s));
for (int j=0; j<n; ++j) {
lp.set_b (j, 1);
if (s.is_infeasible()) {
std::cout << "matrix is singular" << std::endl;
return 0;
} else {
std::copy (s.variable_values_begin(), s.variable_values_end(),
std::back_inserter (inv_a[j]));
}
lp.set_b (j, 0);
}
std::cout << "Random matrix A...:" << std::endl;
Program::A_iterator a = lp.get_a();
for (int i=0; i<n; ++i) {
for (int j=0; j<n; ++j)
std::cout << (*(a+j))[i] << " ";
std::cout << std::endl;
}
std::cout << std::endl << "...and its inverse: " << std::endl;
for (int i=0; i<n; ++i) {
for (int j=0; j<n; ++j)
std::cout << inv_a[j][i] << " ";
std::cout << std::endl;
}
for (int i=0; i<n; ++i)
for (int j=0; j<n; ++j) {
for (int k=0; k<n; ++k) val += (*(a+k))[i] * inv_a[j][k];
assert (val == (i == j ? 1 : 0));
}
return 0;
}
An object of class Quadratic_program_solution represents the solution of a linear or convex quadratic...
Definition: QP_solution.h:65
An object of class Quadratic_program describes a convex quadratic program of the form.
Definition: QP_models.h:788
Quadratic_program_solution< ET > solve_linear_program(const LinearProgram &lp, const ET &, const Quadratic_program_options &options=Quadratic_program_options())
This function solves a linear program, using some exact Integral Domain ET for its computations.