W3cubDocs

/Eigen3

Eigen::NumTraits

\defgroup MPRealSupport_Module MPFRC++ Support module
\code
#include <Eigen/MPRealSupport>
\endcode

This module provides support for multi precision floating point numbers
via the <a href="http://www.holoborodko.com/pavel/mpfr">MPFR C++</a>
library which itself is built upon <a href="http://www.mpfr.org/">MPFR</a>/<a href="http://gmplib.org/">GMP</a>.

\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:
#include <iostream>
#include <Eigen/MPRealSupport>
#include <Eigen/LU>
using namespace mpfr;
using namespace Eigen;
int main()
{
  // set precision to 256 bits (double has only 53 bits)
  mpreal::set_default_prec(256);
  // Declare matrix and vector types with multi-precision scalar type
  typedef Matrix<mpreal,Dynamic,Dynamic>  MatrixXmp;
  typedef Matrix<mpreal,Dynamic,1>        VectorXmp;
 
  MatrixXmp A = MatrixXmp::Random(100,100);
  VectorXmp b = VectorXmp::Random(100);
 
  // Solve Ax=b using LU
  VectorXmp x = A.lu().solve(b);
  std::cout << "relative error: " << (A*x - b).norm() / b.norm() << std::endl;
  return 0;
}

Inherits GenericNumTraits< mpfr::mpreal >.


The documentation for this struct was generated from the following file:
  • MPRealSupport