5 #ifndef BPP_PHYL_LIKELIHOOD_DATAFLOW_EXTENDEDFLOATEIGEN_H
6 #define BPP_PHYL_LIKELIHOOD_DATAFLOW_EXTENDEDFLOATEIGEN_H
21 template<
typename Derived>
54 template<
int R,
int C>
57 template<
int R,
int C>
58 using EFArray = Eigen::Array<double, R, C>;
66 template<
int R,
int C,
template<
int R2,
int C2>
class EigenType>
78 template<
int R2,
int C2>
81 template<
int R2,
int C2>
158 template<
class Other>
202 return Self(MatType::Zero(
rows), 0);
212 return Self(MatType::Ones(
rows), 0);
232 return Self(MatType::Constant(
rows, value), 0);
256 template<
typename Derived>
280 auto max =
float_part().cwiseAbs().maxCoeff();
283 bool normalized =
false;
299 auto max = fabs.maxCoeff();
303 auto min = fabs.unaryExpr([max](
double d){
return d > 0 ? d : max;}).minCoeff();
304 bool normalized =
false;
332 template<
int R2,
int C2>
338 template<
typename Derived>
344 template<
typename Derived>
351 typename std::enable_if< std::is_floating_point<T>::value || std::is_integral<T>::value,
Self>::type
368 typename std::enable_if<std::is_same<T, Self>::value || std::is_same<T, ExtendedFloat>::value,
Self>::type
374 template<
typename Derived>
381 typename std::enable_if<std::is_floating_point<T>::value || std::is_integral<T>::value,
Self>::type
390 typename std::enable_if<std::is_same<T, Self>::value || std::is_same<T, ExtendedFloat>::value,
Self>::type
399 typename std::enable_if<std::is_same<T, Self>::value || std::is_same<T, ExtendedFloat>::value,
Self>::type
409 typename std::enable_if<std::is_floating_point<T>::value || std::is_integral<T>::value,
Self>::type
422 return Self(arr.
float_part().unaryExpr([
exp, rs](
double x){return std::pow(x, exp) * rs;}), e);
450 typename std::enable_if<std::is_same<T, Self>::value || std::is_same<T, ExtendedFloat>::value
451 || std::is_floating_point<T>::value || std::is_integral<T>::value,
Self>::type
459 template<
template<
int R2 = R,
int C2 = C>
class EigenType2>
468 typename std::enable_if<std::is_same<T, Self>::value || std::is_same<T, ExtendedFloat>::value
469 || std::is_floating_point<T>::value || std::is_integral<T>::value,
Self>::type
477 template<
int R2 = C,
int C2,
template<
int R3 = R2,
int C3 = C2>
class EigenType2>
486 template<
typename Derived>
495 typename std::enable_if<std::is_floating_point<T>::value || std::is_integral<T>::value || std::is_same<T, ExtendedFloat>::value,
Self>::type
504 typename std::enable_if<std::is_floating_point<T>::value || std::is_integral<T>::value || std::is_same<T, ExtendedFloat>::value,
Self>::type
512 template<
typename Derived>
520 template<
typename Derived>
528 template<
typename Derived>
536 template<
typename Obj>
560 typename std::enable_if<std::is_same<T, Self>::value || std::is_same<T, ExtendedFloat>::value,
Self&>::type
570 typename std::enable_if<std::is_floating_point<T>::value || std::is_integral<T>::value,
Self&>::type
578 template<
typename Derived>
586 template<
typename Derived>
597 typename std::enable_if<std::is_same<T, Self>::value || std::is_same<T, ExtendedFloat>::value,
Self&>::type
607 typename std::enable_if<std::is_floating_point<T>::value || std::is_integral<T>::value,
Self&>::type
616 typename std::enable_if<std::is_base_of<ExtendedFloatEigenCore, T>::value || std::is_same<T, ExtendedFloat>::value,
Self&>::type
633 typename std::enable_if<std::is_floating_point<T>::value || std::is_integral<T>::value,
Self&>::type
650 typename std::enable_if<std::is_same<T, Self>::value || std::is_same<T, ExtendedFloat>::value,
Self&>::type
667 typename std::enable_if<std::is_floating_point<T>::value || std::is_integral<T>::value,
Self&>::type
692 Eigen::Index maxRow, maxCol;
694 auto max = arrf.maxCoeff(&maxRow, &maxCol);
704 Self expM(c, std::get<0>(rcoeff));
743 template<
typename CustomNullaryOp>
746 return Self(MatType::NullaryExpr(
rows,
cols, func), func.exponent_part());
759 template<
typename M = MatType>
771 template<
typename M = MatType>
807 template<
typename M = MatType>
808 typename std::enable_if<std::is_same<M, EFArray<R, C>>::value,
const ExtendedFloat&>::type
878 template<
int R,
int C>
881 template<
int R,
int C>
901 template<
int R,
int C>
908 template<
int R,
int C,
template<
int R2 = R,
int C2 = C>
class MatType>
914 template<
int R,
int C>
922 template<
int R,
int C>
931 template<
int R,
int C,
template<
int R2 = R,
int C2 = C>
class MatType,
typename T>
932 typename std::enable_if<std::is_same<T, ExtendedFloat>::value
933 || std::is_floating_point<T>::value || std::is_integral<T>::value,
934 ExtendedFloatEigen<R, C, MatType>>::type
940 template<
int R,
int C,
template<
int R2 = R,
int C2 = C>
class MatType,
typename T>
941 typename std::enable_if<std::is_same<T, ExtendedFloat>::value
942 || std::is_floating_point<T>::value || std::is_integral<T>::value,
943 ExtendedFloatEigen<R, C, MatType>>::type
949 template<
int R,
int C,
template<
int R2 = R,
int C2 = C>
class MatType,
typename T>
950 typename std::enable_if<std::is_same<T, ExtendedFloat>::value
951 || std::is_floating_point<T>::value || std::is_integral<T>::value,
952 ExtendedFloatEigen<R, C, MatType>>::type
960 template<
typename Derived,
typename EFType>
961 inline EFType
operator*(
const Eigen::EigenBase<Derived>& lhs,
964 auto r = EFType::denorm_mul(lhs.derived(), rhs);
970 template<
int R,
int C>
1049 template<
int R,
int C>
Self operator+=(const Array &rhs)
Array operator*(const Self &rhs) const
ExtendedFloatArrayWrapper(ExtendedFloatMatrix< R, C > &other)
Self operator=(const Array &rhs)
Self operator*=(const Array &rhs)
Array operator*(const Array &rhs) const
ExtendedFloatMatrix< R, C > *const efm_
MatType float_part() const
ExtType exponent_part() const
ExtendedFloatNoAlias< Derived > noalias()
const Derived & derived() const
ExtendedFloatEigenBase(Derived &der)
OwnedExtendedFloat(const ExtendedFloatEigen &eigen)
void set_exponent_part(ExtendedFloat::ExtType x)
void set_float_part(double x)
const ExtendedFloat::ExtType & exponent_part() const
const ExtendedFloatEigen & eigen_
static Self Constant(Eigen::Index rows, Eigen::Index cols, double value)
void normalize() noexcept
static Self denorm_pow(const Self &arr, int exp)
std::enable_if< std::is_floating_point< T >::value||std::is_integral< T >::value, Self & >::type operator/=(const T &div)
virtual const ExtType & exponent_part() const
std::enable_if< std::is_floating_point< T >::value||std::is_integral< T >::value||std::is_same< T, ExtendedFloat >::value, Self >::type operator/(const T &fact) const
static Self denorm_mul(const Self &lhs, const ExtendedFloat &rhs)
std::enable_if< std::is_floating_point< T >::value||std::is_integral< T >::value, Self & >::type operator-=(const T &rhs)
bool operator==(const Self &rhs) const
std::enable_if< std::is_same< T, Self >::value||std::is_same< T, ExtendedFloat >::value||std::is_floating_point< T >::value||std::is_integral< T >::value, Self >::type operator+(const T &rhs) const
Eigen::Ref< EigenType< R, C > > RefMatType
static std::enable_if< std::is_same< T, Self >::value||std::is_same< T, ExtendedFloat >::value, Self >::type denorm_sub(const Self &lhs, const T &rhs)
Self & operator*=(const Eigen::DenseBase< Derived > &div)
bool operator!=(const Self &rhs) const
virtual const MatType & float_part() const
bool normalize_big() noexcept
ExtendedFloatEigen< R, C2, EigenType > operator*(const ExtendedFloatEigen< R2, C2, EigenType2 > &rhs) const
ExtendedFloatMatrix< C, R > transpose() const
static Self Zero(Eigen::Index rows, Eigen::Index cols)
const ExtendedFloat & operator()(Eigen::Index c) const
std::enable_if< std::is_same< M, EFArray< R, C > >::value, const ExtendedFloat & >::type operator[](Eigen::Index pos) const
std::enable_if< std::is_same< M, EFMatrix< R, C > >::value, ExtendedFloatRow< R, C, EigenType > >::type row(Eigen::Index pos)
ExtendedFloatEigen(const Eigen::internal::traits< MatType > &mat, ExtType exp=0)
ExtendedFloatEigen< R, C, EigenType > Self
ExtendedFloatEigen< R, 1, EigenType > col(Eigen::Index col) const
Eigen::Index size() const
static Self denorm_div(const Self &lhs, const ExtendedFloatEigenBase< Derived > &rhs)
static Self denorm_mul(const Eigen::EigenBase< Derived > &lhs, const Self &rhs)
static Self Zero(Eigen::Index rows)
ExtendedFloatEigen(int cols)
static Self Constant(Eigen::Index rows, const ExtendedFloat &value)
static Self Ones(Eigen::Index rows)
ExtendedFloat dot(const Eigen::DenseBase< Derived > &rhs) const
ExtendedFloatVectorwiseOp< Self, MatType, Eigen::Vertical > colwise()
ExtendedFloatEigen(const MatType &mat, ExtType exp=0)
static std::enable_if< std::is_floating_point< T >::value||std::is_integral< T >::value, Self >::type denorm_add(const Self &lhs, const T &rhs)
ExtendedFloatEigen & operator=(const ExtendedFloatEigen &other)
ExtendedFloatEigen(MatType &mat, ExtType exp=0)
static std::enable_if< std::is_same< T, Self >::value||std::is_same< T, ExtendedFloat >::value, Self >::type denorm_add(const Self &lhs, const T &rhs)
ExtendedFloatVectorwiseOp< const Self, const MatType, Eigen::Vertical > colwise() const
std::enable_if< std::is_base_of< ExtendedFloatEigenCore, T >::value||std::is_same< T, ExtendedFloat >::value, Self & >::type operator+=(const T &rhs)
ExtendedFloatEigen(const Eigen::DenseBase< MatType > &mat, ExtType exp=0)
static Self Constant(Eigen::Index rows, Eigen::Index cols, const ExtendedFloat &value)
static std::enable_if< std::is_same< T, Self >::value||std::is_same< T, ExtendedFloat >::value, Self >::type denorm_div(const Self &lhs, const T &rhs)
std::enable_if< std::is_same< T, Self >::value||std::is_same< T, ExtendedFloat >::value||std::is_floating_point< T >::value||std::is_integral< T >::value, Self >::type operator-(const T &rhs) const
virtual MatType & float_part()
std::enable_if< std::is_same< T, Self >::value||std::is_same< T, ExtendedFloat >::value, Self & >::type operator*=(const T &rhs)
std::enable_if< std::is_floating_point< T >::value||std::is_integral< T >::value||std::is_same< T, ExtendedFloat >::value, Self >::type operator*(const T &fact) const
ExtendedFloatEigen(Eigen::DenseBase< MatType > &mat, ExtType exp=0)
static Self denorm_pow(const Self &arr, double exp)
const ExtendedFloat & operator()(Eigen::Index r, Eigen::Index c) const
std::enable_if< std::is_floating_point< T >::value||std::is_integral< T >::value, Self & >::type operator+=(const T &rhs)
Self operator*(const Eigen::EigenBase< Derived > &rhs) const
Eigen::Index cols() const
ExtendedFloatEigen(const ExtendedFloatEigenBase< Other > &other)
ExtendedFloat dot(const Eigen::Ref< Obj > &rhs) const
ExtendedFloatEigen & operator=(const MatType &other)
std::enable_if< std::is_same< T, Self >::value||std::is_same< T, ExtendedFloat >::value, Self & >::type operator-=(const T &rhs)
Eigen::Index rows() const
static std::enable_if< std::is_floating_point< T >::value||std::is_integral< T >::value, Self >::type denorm_sub(const Self &lhs, const T &rhs)
ExtendedFloatEigen(const ExtendedFloatEigen &other)
std::enable_if< std::is_same< M, EFMatrix< R, C > >::value, ExtendedFloatCol< R, C, EigenType > >::type col(Eigen::Index pos)
static Self NullaryExpr(Eigen::Index rows, Eigen::Index cols, const CustomNullaryOp &func)
ExtendedFloat dot(const ExtendedFloatEigenBase< Derived > &rhs) const
std::enable_if< std::is_floating_point< T >::value||std::is_integral< T >::value, Self & >::type operator*=(const T &div)
virtual ExtType & exponent_part()
OwnedExtendedFloat EFtmp_
EigenType< R, C > MatType
std::enable_if< std::is_same< T, Self >::value||std::is_same< T, ExtendedFloat >::value, Self & >::type operator/=(const T &rhs)
virtual ~ExtendedFloatEigen()
static Self Identity(Eigen::Index rows)
static Self denorm_mul(const Self &lhs, const double &rhs)
Self & operator=(const ExtendedFloatEigenBase< Derived > &other)
ExtendedFloatEigen(int rows, int cols)
static Self Constant(Eigen::Index rows, double value)
friend std::ostream & operator<<(std::ostream &out, const Self &ef)
const ExtendedFloat & maxCoeff(size_t *pos=0) const
void resize(Eigen::Index rows, Eigen::Index cols)
Self operator+(const ExtendedFloatEigen< R, C, EigenType2 > &rhs) const
static Self Ones(Eigen::Index rows, Eigen::Index cols)
static std::enable_if< std::is_floating_point< T >::value||std::is_integral< T >::value, Self >::type denorm_mul(const Self &lhs, const T &rhs)
static Self denorm_mul(const Self &lhs, const Eigen::EigenBase< Derived > &rhs)
static ExtendedFloatEigen< R, C2, EigenType > denorm_mul(const Self &lhs, const ExtendedFloatEigen< R2, C2, EigenType > &rhs)
ExtendedFloatVectorwiseOp< Self, MatType, Eigen::Horizontal > rowwise()
const ExtendedFloat & sum() const
void resize(Eigen::Index rows)
Self & operator*=(const ExtendedFloatEigenBase< Derived > &div)
const ExtendedFloat & mean() const
Self operator/(const ExtendedFloatEigenBase< Derived > &rhs) const
ExtendedFloatVectorwiseOp< const Self, const MatType, Eigen::Horizontal > rowwise() const
static const double ln_radix
static constexpr FloatType normalize_big_factor
std::tuple< int, double > lround() const
static constexpr FloatType smallest_normalized_value
static constexpr FloatType normalize_small_factor
const FloatType & float_part() const noexcept
const ExtType & exponent_part() const noexcept
static constexpr FloatType biggest_normalized_value
static constexpr int biggest_normalized_radix_power
static constexpr int smallest_normalized_radix_power
static constexpr int radix
Defines the basic types of data flow nodes.
ExtendedFloatArray< Eigen::Dynamic, 1 > ExtendedFloatArrayXd
ExtendedFloatArray< R, C > pow(const ExtendedFloatArray< R, C > &obj, int exp)
Eigen::Array< double, R, C > EFArray
ExtendedFloat pow(const ExtendedFloat &ef, double exp)
ExtendedFloatRowVector< Eigen::Dynamic > ExtendedFloatRowVectorXd
Eigen::Matrix< double, R, C > EFMatrix
ExtendedFloatMatrix< Eigen::Dynamic, Eigen::Dynamic > ExtendedFloatMatrixXd
ExtendedFloatVector< Eigen::Dynamic > ExtendedFloatVectorXd