Bertini 2 - C++ Core
Software for Numerical Algebraic Geometry
Loading...
Searching...
No Matches
eigen_extensions.hpp File Reference

Bertini extensions of the Eigen linear algebra library. More...

#include "bertini2/num_traits.hpp"
#include <boost/serialization/complex.hpp>
#include <boost/serialization/array.hpp>
#include <boost/serialization/split_member.hpp>
#include <Eigen/Core>
#include <Eigen/Geometry>
#include <Eigen/Eigenvalues>
#include <Eigen/SVD>
#include <Eigen/Dense>
Include dependency graph for eigen_extensions.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Eigen::NumTraits< mpfr_complex >
 This templated struct permits us to use the mpfr_complex type in Eigen matrices. More...
 

Functions

template<typename Derived>
bool bertini::IsEmpty (Eigen::MatrixBase< Derived > const &v)
 Checks whether the number of rows and columns are either 0.
 
template<typename T>
bool bertini::IsLargeChange (T const &numerator, T const &denomenator)
 
template<typename T>
bool bertini::IsSmallValue (T const &testme)
 
template<typename T>
bool bertini::IsSymmRelDiffSmall (T const &a, T const &b, typename Eigen::NumTraits< T >::Real const &e)
 Check whether two values are very close to each other.
 
template<typename NumberType>
Eigen::Matrix< NumberType, Eigen::Dynamic, Eigen::Dynamic > bertini::KahanMatrix (unsigned int mat_size, NumberType c)
 Make a Kahan matrix with a given number type.
 
template<typename Derived>
MatrixSuccessCode bertini::LUPartialPivotDecompositionSuccessful (Eigen::MatrixBase< Derived > const &LU)
 Check the diagonal elements of an LU decomposition for small values and large ratios.
 
template<typename Derived>
void bertini::Precision (Eigen::MatrixBase< Derived > &v, unsigned prec)
 Set the precision of an Eigen object.
 
template<typename Derived>
unsigned bertini::Precision (Eigen::MatrixBase< Derived > const &v)
 Get the precision of an Eigen object. If the object is empty, it's the precision of a default-constructed Scalar. If it actually has content, then it's the precision of the first element.
 
template<typename Derived>
unsigned bertini::PrecisionRequireUniform (Eigen::MatrixBase< Derived > const &v)
 Query the precision of an Eigen object, requiring it to be non-empty, and of uniform precision.
 
template<typename NumberType>
Mat< NumberType > bertini::RandomOfUnits (uint rows, uint cols)
 Make a random matrix of units (numbers with norm 1).
 
template<typename NumberType>
Vec< NumberType > bertini::RandomOfUnits (uint size)
 Make a random vector of units (numbers with norm 1).
 

Detailed Description

Bertini extensions of the Eigen linear algebra library.

Function Documentation

◆ IsEmpty()

template<typename Derived>
bool bertini::IsEmpty ( Eigen::MatrixBase< Derived > const & v)
inline

Checks whether the number of rows and columns are either 0.

◆ IsLargeChange()

template<typename T>
bool bertini::IsLargeChange ( T const & numerator,
T const & denomenator )
inline

Test two numbers for having large ratio.

The basis for comparison is Eigen's fuzzy precision, Eigen::NumTraits<T>::dummy_precision();

Note
For doubles, the threshold is 1e-12, for mpfr_real is 1e3*current precision.
Parameters
numeratorThe numerator for the ratio.
denomenatorThe denomenator for the ratio.
Returns
true, if the ratio is very large, false otherwise

◆ IsSmallValue()

template<typename T>
bool bertini::IsSmallValue ( T const & testme)
inline

Test a numbers being very small.

Compares the number against machine epsilon (or software epsilon if a multiple precision type), times 100.

Note
Machine epsilon for doubles is about 1e-16, for mpfr_real, it's 10^-current precision.
Parameters
testmeThe number to test
Returns
true, if the number is very small. False otherwise.

◆ IsSymmRelDiffSmall()

template<typename T>
bool bertini::IsSymmRelDiffSmall ( T const & a,
T const & b,
typename Eigen::NumTraits< T >::Real const & e )
inline

Check whether two values are very close to each other.

The tolerance for being close See \url http://www.boost.org/doc/libs/1_34_0/libs/test/doc/components/test_tools/floating_point_comparison.html, for example.

◆ KahanMatrix()

template<typename NumberType>
Eigen::Matrix< NumberType, Eigen::Dynamic, Eigen::Dynamic > bertini::KahanMatrix ( unsigned int mat_size,
NumberType c )

Make a Kahan matrix with a given number type.

◆ LUPartialPivotDecompositionSuccessful()

template<typename Derived>
MatrixSuccessCode bertini::LUPartialPivotDecompositionSuccessful ( Eigen::MatrixBase< Derived > const & LU)

Check the diagonal elements of an LU decomposition for small values and large ratios.

Returns
Success if things are ok. LargeChange or SmallValue if one is found.

This function requires a square non-empty matrix.

Template Parameters
DerivedMatrix type from Eigen.

◆ Precision() [1/2]

template<typename Derived>
void bertini::Precision ( Eigen::MatrixBase< Derived > & v,
unsigned prec )

Set the precision of an Eigen object.

Parameters
vthe matrix to change
precthe new precision

◆ Precision() [2/2]

template<typename Derived>
unsigned bertini::Precision ( Eigen::MatrixBase< Derived > const & v)
inline

Get the precision of an Eigen object. If the object is empty, it's the precision of a default-constructed Scalar. If it actually has content, then it's the precision of the first element.

If you require that the object be of uniform precision when you check, use PrecisionRequireUniform

◆ PrecisionRequireUniform()

template<typename Derived>
unsigned bertini::PrecisionRequireUniform ( Eigen::MatrixBase< Derived > const & v)

Query the precision of an Eigen object, requiring it to be non-empty, and of uniform precision.

Exceptions
runtime_errorif not uniform precision Dies in an Eigen assert if empty (assuming you didn't disable these)

◆ RandomOfUnits() [1/2]

template<typename NumberType>
Mat< NumberType > bertini::RandomOfUnits ( uint rows,
uint cols )
inline

Make a random matrix of units (numbers with norm 1).

Returns
The random matrix of units.
Parameters
rowsThe number of rows.
colsThe number of columns.
Template Parameters
NumberTypethe type of number to fill the matrix with.

◆ RandomOfUnits() [2/2]

template<typename NumberType>
Vec< NumberType > bertini::RandomOfUnits ( uint size)
inline

Make a random vector of units (numbers with norm 1).

Returns
The random vector of units.
Parameters
sizeThe length of the vector.
Template Parameters
NumberTypethe type of number to fill the vector with.