1 #include <Eigen/MPRealSupport>
This module provides support for multi precision floating point numbers via the MPFR C++ library which itself is built upon MPFR/GMP.
- Warning
- MPFR C++ is licensed under the GPL.
You can find a copy of MPFR C++ that is known to be compatible in the unsupported/test/mpreal folder.
Here is an example:
2 #include <Eigen/MPRealSupport>
8 // set precision to 256 bits (double has only 53 bits)
9 mpreal::set_default_prec(256);
10 // Declare matrix and vector types with multi-precision scalar type
11 typedef Matrix<mpreal,Dynamic,Dynamic> MatrixXmp;
12 typedef Matrix<mpreal,Dynamic,1> VectorXmp;
14 MatrixXmp A = MatrixXmp::Random(100,100);
15 VectorXmp b = VectorXmp::Random(100);
17 // Solve Ax=b using LU
18 VectorXmp x = A.lu().solve(b);
19 std::cout << "relative error: " << (A*x - b).norm() / b.norm() << std::endl;