30 for (
int i = 0; i < dim; ++i) {
31 for (
int j = 0; j < dim; ++j) {
40 for (
int i = 0; i < dim; ++i) {
41 for (
int j = 0; j < dim; ++j) {
42 im(i, j) = nums(i, j) * (sigma / dens(i, j));
47 (im.template cast<double>() / sigma - R).norm() / (dim * dim);
48 if (error > FLT_EPSILON) {
49 std::cout <<
"error=" << error << std::endl;
50 std::cout <<
"maxDen=" << maxDen << std::endl;
52 << std::setprecision(15) << std::scientific
53 << im.template cast<double>() / sigma << std::endl;
54 std::cout <<
"= 1/" << sigma <<
"*\n"
55 << std::setprecision(15) << std::scientific << im << std::endl;
57 << std::setprecision(15) << std::scientific << R << std::endl;
58 throw std::runtime_error(
"Rational Matrix failed, check maxDen");
61 return std::make_pair(im, sigma);
69 throw std::runtime_error(
"Rational Matrix construction failed: denominator matrix has zeros");
75 for (
int i = 0; i < dim; ++i)
77 for (
int j = 0; j < dim; ++j)
84 for (
int i = 0; i < dim; ++i)
86 for (
int j = 0; j < dim; ++j)
88 im(i, j) = RnReduced(i, j) * sigma / RdReduced(i, j);
92 std::cout << Rn << std::endl;
93 std::cout << Rd << std::endl;
94 std::cout << RnReduced << std::endl;
95 std::cout << RdReduced << std::endl;
96 std::cout << im << std::endl;
97 std::cout << sigma <<std::endl;
100 return std::make_pair(im, sigma);