Modified, due to porting of interval_support from EXACUS2CGAL. The new

interval_support is now in the Number_types package.
This commit is contained in:
Ralf Schindlbeck 2008-02-14 09:44:46 +00:00
parent d590c9e011
commit d38238d834
4 changed files with 851 additions and 20 deletions

View File

@ -33,9 +33,10 @@
#include <CGAL/leda_bigfloat.h>
#include <CGAL/leda_real.h>
#ifdef CGAL_INTERN_USE_BFI
#include <CGAL/Algebraic_kernel_d/leda_interval_support.h>
#endif //CGAL_INTERN_USE_BFI
// #ifdef CGAL_INTERN_USE_BFI
// #include <CGAL/Algebraic_kernel_d/leda_interval_support.h>
#include <CGAL/leda_interval_support.h>
// #endif //CGAL_INTERN_USE_BFI
#endif // CGAL_USE_LEDA
@ -76,11 +77,12 @@ public:
//! exact root expressions, constructible from integers and rationals
typedef leda_real Field_with_sqrt;
#ifdef CGAL_INTERN_USE_BFI
// #ifdef CGAL_INTERN_USE_BFI
// undocumented
typedef leda_bigfloat Bigfloat;
typedef CGALi::leda_bigfloat_interval Bigfloat_interval;
#endif //CGAL_INTERN_USE_BFI
// typedef CGALi::leda_bigfloat_interval Bigfloat_interval;
typedef leda_bigfloat_interval Bigfloat_interval;
// #endif //CGAL_INTERN_USE_BFI
};
#endif // CGAL_USE_LEDA
@ -99,11 +101,11 @@ public:
typedef CORE::BigRat Rational;
//! exact root expressions, constructible from integers and rationals
typedef CORE::Expr Field_with_sqrt;
#ifdef CGAL_INTERN_USE_BFI
// #ifdef CGAL_INTERN_USE_BFI
// undocumented
typedef CORE::BigFloat Bigfloat;
typedef CORE::BigFloat Bigfloat_interval;
#endif //CGAL_INTERN_USE_BFI
// #endif //CGAL_INTERN_USE_BFI
};
#endif // CGAL_USE_CORE
@ -195,7 +197,7 @@ struct Lazy_exact_arithmetic_kernel{
};
#ifdef CGAL_INTERN_USE_BFI
// #ifdef CGAL_INTERN_USE_BFI
namespace CGALi {
template< class NT > struct Get_arithmetic_kernel;
@ -241,7 +243,7 @@ template< class NT > struct Get_arithmetic_kernel;
} // namespace CGALi
#endif //CGAL_INTERN_USE_BFI
// #endif //CGAL_INTERN_USE_BFI
CGAL_END_NAMESPACE

View File

@ -26,21 +26,41 @@
CGAL_BEGIN_NAMESPACE
//template<typename BFI> class Bigfloat_interval_traits;
// forward declarations of interval support
namespace CGALi {
// namespace CGALi {
CORE::BigFloat
inline
round(const CORE::BigFloat& x, long rel_prec );
//TODO
// functions: upper and lower are defined twice the time,
// please correct this unaesthetic thing
CORE::BigFloat
inline
upper(CORE::BigFloat x);
upper(CORE::BigFloat x){
CORE::BigFloat result = ::CORE::BigFloat(x.m()+x.err(),0,x.exp());
CGAL_postcondition(result >= x);
return result;
}
CORE::BigFloat
inline
lower(CORE::BigFloat x);
lower(CORE::BigFloat x){
CORE::BigFloat result = ::CORE::BigFloat(x.m()-x.err(),0,x.exp());
CGAL_postcondition(result <= x);
return result;
}
// CORE::BigFloat
// inline
// upper(CORE::BigFloat x);
//
// CORE::BigFloat
// inline
// lower(CORE::BigFloat x);
} // namespace CGALi
// } // namespace CGALi
//
// Algebraic structure traits
@ -62,7 +82,7 @@ template <> class Algebraic_structure_traits< CORE::BigFloat >
CGAL_precondition(::CORE::defRelPrec.toLong() > 0);
CGAL_precondition(x > 0);
Type a = CGALi::round(x, ::CORE::defRelPrec.toLong()*2);
Type a = CGAL::round(x, ::CORE::defRelPrec.toLong()*2);
CGAL_postcondition(a > 0);
Type tmp1 =
@ -179,8 +199,8 @@ template <> class Real_embeddable_traits< CORE::BigFloat >
double lb,ub;
Type x_lower = CGALi::lower(CGALi::round(CGALi::lower(x),52));
Type x_upper = CGALi::upper(CGALi::round(CGALi::upper(x),52));
Type x_lower = CGAL::lower(CGAL::round(CGAL::lower(x),52));
Type x_upper = CGAL::upper(CGAL::round(CGAL::upper(x),52));
// since matissa has 52 bits only, conversion to double is exact
lb = x_lower.doubleValue();
@ -189,16 +209,432 @@ template <> class Real_embeddable_traits< CORE::BigFloat >
CGAL_postcondition(ub == x_upper);
std::pair<double, double> result(lb,ub);
CGAL_postcondition( result.first <= CORE::Expr(CGALi::lower(x)));
CGAL_postcondition( result.second >= CORE::Expr(CGALi::upper(x)));
CGAL_postcondition( result.first <= CORE::Expr(CGAL::lower(x)));
CGAL_postcondition( result.second >= CORE::Expr(CGAL::upper(x)));
return result;
}
};
};
//**********************NEW**********************
// Specialization of CGAL::Float_traits_kernel for CORE::BigFloat
template <> class Float_traits_kernel< ::CORE::BigFloat > {
public:
typedef ::CORE::BigFloat FT;
typedef ::CORE::BigInt IT;
typedef ::CGAL::Float_number_tag Float_type;
typedef CGAL::Precision_type Precision_type;
class Get_precision {
public:
typedef CGAL::Precision_type result_type;
CGAL::Precision_type operator()() const {
return CGAL::Precision_type( ::CORE::defRelPrec.toLong());
}
};
class Set_precision {
public:
typedef void result_type;
typedef CGAL::Precision_type first_argument_type;
void operator()( const CGAL::Precision_type& precision ) const {
::CORE::defRelPrec = precision;
::CORE::defBFdivRelPrec = precision;
}
};
class Get_rounding_mode {
public:
typedef CGAL::Rounding_mode result_type;
/*??
CGAL::Rounding_mode operator()() const {
return CGAL::Rounding_mode( CORE::BigFloat::get_rounding_mode() );
}
*/
};
class Set_rounding_mode {
public:
typedef void result_type;
typedef CGAL::Rounding_mode first_argument_type;
/* ??
void operator()( const CGAL::Rounding_mode& rounding_mode ) const {
CORE::BigFloat::set_rounding_mode( (CORE::rounding_modes)rounding_mode );
}
*/
};
};
// Specialization of CGAL::Float_traits for CORE::BigFloat
template <> class Float_traits< ::CORE::BigFloat >
: public Float_traits_base< Float_traits_kernel< ::CORE::BigFloat> > {
private:
/* ??
static Rounding_mode get_rounding_mode() {
return Rounding_mode( CORE::BigFloat::get_rounding_mode() );
};
*/
static Precision_type get_precision() {
return Precision_type( ::CORE::defRelPrec.toLong() );
};
public:
typedef Float_traits_kernel< CORE::BigFloat > FT_kernel;
typedef FT_kernel::FT FT;
typedef FT_kernel::IT IT;
typedef FT_kernel::Float_type Float_type;
class Construct
: public Float_traits_base< FT_kernel >::Construct {
public:
FT operator() ( const IT& m, const IT& e = IT(0) ) {
return FT(m,0,0)*FT::exp2(e.intValue());
}
}; // class Constructor
class Set_precision {
public:
// type for the \c AdaptableUnaryFunction concept.
typedef long argument_type;
// type for the \c AdaptableUnaryFunction concept.
typedef long result_type;
long operator() ( long prec ) const {
FT_kernel::Set_precision set_precision;
FT_kernel::Get_precision get_precision;
long old_precision = get_precision();
set_precision(prec);
return old_precision;
}
};
class Get_precision {
public:
// type for the \c AdaptableGenerator concept.
typedef long result_type;
long operator() () const {
FT_kernel::Get_precision get_precision;
return get_precision();
}
};
/*
class Construct_special_value {
public:
FT operator()( const Special_value& sv ) {
switch( sv ) {
case SV_N_ZERO: return leda::bigfloat::nZero;
case SV_P_ZERO: return leda::bigfloat::pZero;
case SV_N_INF: return leda::bigfloat::nInf;
case SV_P_INF: return leda::bigfloat::pInf;
case SV_NAN: return leda::bigfloat::NaN;
default: return FT(0);
}
}
};
*/
/* ??
class Is_special_value {
public:
bool operator()( const FT& bf ) const {
return leda::isSpecial( bf );
}
};
*/
/* ??
class Get_special_value {
public:
Special_value operator()( const FT& bf ) const {
if( leda::isNaN( bf ) )
return SV_NAN;
else if( leda::isnZero( bf ) )
return SV_N_ZERO;
else if( leda::ispZero( bf ) )
return SV_P_ZERO;
else if( leda::isnInf( bf ) )
return SV_N_INF;
else if( leda::ispInf( bf ) )
return SV_P_INF;
else
return SV_NONE;
}
};
*/
class Is_zero {
public:
bool operator()( const FT& bf ) const {
CGAL_precondition(bf.isExact());
return bf == FT(0);
}
};
/* ??
class Is_inf {
public:
bool operator()( const FT& bf ) const {
return leda::isInf( bf );
}
};
*/
class Get_mantissa
: public Float_traits_base< FT_kernel >::Get_mantissa {
public:
//! type for the \c AdaptableUnaryFunction concept.
typedef IT result_type;
//! type for the \c AdaptableUnaryFunction concept.
typedef FT argument_type;
IT operator()( const FT& a ) const {
return a.m();
}
}; // class GetMantissa
class Get_exponent
: public Float_traits_base< FT_kernel >::Get_exponent {
public:
//! type for the \c AdaptableUnaryFunction concept.
typedef long result_type;
//! type for the \c AdaptableUnaryFunction concept.
typedef FT argument_type;
result_type operator()( const FT& a ) const {
return 14*a.exp(); // The basis is 8092
}
}; // class GetExponent
class Get_mantissa_and_exponent
: public Float_traits_base< FT_kernel >::Get_mantissa_and_exponent {
public:
//! type for the \c AdaptableUnaryFunction concept.
typedef std::pair< IT, long > result_type;
//! type for the \c AdaptableUnaryFunction concept.
typedef FT argument_type;
result_type operator()( const FT& a ) const {
IT m = a.m();
long e = 14*a.exp();
result_type p( m, e );
return p;
}
}; // class GetMantissaAndExponent
/* ??
class Round_relative
: public Float_traits_base< FT_kernel >::Round_relative {
public:
//! type for the \c AdaptableTernaryFunction concept.
typedef FT result_type;
//! type for the \c AdaptableTernaryFunction concept.
typedef FT first_argument_type;
//! type for the \c AdaptableTernaryFunction concept.
typedef CGAL::Precision_type second_argument_type;
//! type for the \c AdaptableTernaryFunction concept.
typedef CGAL::Rounding_mode third_argument_type;
FT operator()( const FT& a,
const CGAL::Precision_type& p = get_precision(),
const CGAL::Rounding_mode& m = get_rounding_mode() ) const {
return leda::round(a,(leda::sz_t)p,(leda::rounding_modes)m ) ;
}
}; // class Round
*/
/* ??
class Round_absolute : public Float_traits_base< FT_kernel >::Round_absolute {
public:
//! type for the \c AdaptableTernaryFunction concept.
typedef FT result_type;
//! type for the \c AdaptableTernaryFunction concept.
typedef FT first_argument_type;
//! type for the \c AdaptableTernaryFunction concept.
typedef IT second_argument_type;
//! type for the \c AdaptableTernaryFunction concept.
typedef CGAL::Rounding_mode third_argument_type;
FT operator()( const FT& a,
const IT& new_exponent,
const CGAL::Rounding_mode& r_mode = get_rounding_mode() ) const {
typedef CGAL::Float_number<IT> FN;
FN fn( a.get_significant(), a.get_exponent() );
fn = fn.round_absolute( new_exponent, r_mode );
return FT( fn.get_mantissa(), fn.get_exponent() );
}
};
*/
// special functors ( only for Big_float )
/* ??
class Add
: public Float_traits_base< FT_kernel >::Add {
public:
typedef FT result_type;
typedef FT first_argument_type;
typedef FT second_argument_type;
typedef CGAL::Rounding_mode third_argument_type;
typedef CGAL::Precision_type fourth_argument_type;
FT operator()( const FT& a, const FT& b,
const Rounding_mode& m = get_rounding_mode(),
const Precision_type& p = get_precision() ) const {
return leda::add(a,b,(leda::sz_t)p,(leda::rounding_modes)m);
}
}; // class Add
class Sub
: public Float_traits_base< FT_kernel >::Sub{
public:
typedef FT result_type;
typedef FT first_argument_type;
typedef FT second_argument_type;
typedef CGAL::Rounding_mode third_argument_type;
typedef CGAL::Precision_type fourth_argument_type;
FT operator()( const FT& a, const FT& b ,
const Rounding_mode& m = get_rounding_mode(),
const Precision_type& p = get_precision() ) const {
return leda::sub(a,b,(leda::sz_t)p,(leda::rounding_modes)m);
}
}; // class Sub
class Mul
: public Float_traits_base< FT_kernel >::Mul {
public:
typedef FT result_type;
typedef FT first_argument_type;
typedef FT second_argument_type;
typedef CGAL::Rounding_mode third_argument_type;
typedef CGAL::Precision_type fourth_argument_type;
FT operator()( const FT& a, const FT& b ,
const Rounding_mode& m = get_rounding_mode(),
const Precision_type& p = get_precision() ) const {
return leda::mul(a,b,(leda::sz_t)p,(leda::rounding_modes)m);
}
}; // class Mul
class Div
: public Float_traits_base< FT_kernel >::Div{
public:
typedef FT result_type;
typedef FT first_argument_type;
typedef FT second_argument_type;
typedef CGAL::Rounding_mode third_argument_type;
typedef CGAL::Precision_type fourth_argument_type;
FT operator()( const FT& a, const FT& b ,
const Rounding_mode& m = get_rounding_mode(),
const Precision_type& p = get_precision() ) const {
return leda::div(a,b,(leda::sz_t)p,(leda::rounding_modes)m);
}
}; // class Div
class Sqrt
: public Float_traits_base< FT_kernel >::Sqrt{
public:
typedef FT result_type;
typedef FT first_argument_type;
typedef CGAL::Rounding_mode second_argument_type;
typedef CGAL::Precision_type third_argument_type;
FT operator()( const FT& bf,
const Rounding_mode& r_mode = get_rounding_mode(),
const Precision_type& prec = get_precision() ) const {
return leda::sqrt( bf, (leda::sz_t)prec, (leda::rounding_modes)r_mode);
}
}; // class Sqrt
*/
class Mul_by_pow_of_2
: public Float_traits_base< FT_kernel >::Mul_by_pow_of_2{
public:
//! type for the \c AdaptableBinaryFunction concept.
typedef FT result_type;
//! type for the \c AdaptableBinaryFunction concept.
typedef FT first_argument_type;
//! type for the \c AdaptableBinaryFunction concept.
typedef IT second_argument_type;
FT operator()( const FT& a, const IT& e ) const {
return a*FT::exp2(e.intValue());
}
}; // class Mul_by_pow_of_2
class Div_by_pow_of_2
: public Float_traits_base< FT_kernel >::Div_by_pow_of_2{
public:
//! type for the \c AdaptableBinaryFunction concept.
typedef FT result_type;
//! type for the \c AdaptableBinaryFunction concept.
typedef FT first_argument_type;
//! type for the \c AdaptableBinaryFunction concept.
typedef IT second_argument_type;
FT operator()( const FT& a, const IT& e ) const {
return a*FT::exp2(-e.intValue());
}
}; // class Div_by_pow_of_2
class Floor {
public:
typedef IT result_type;
typedef FT argument_type;
IT operator()( const FT& fn ) const {
IT fl = fn.BigIntValue();
if(fn.sign() < 0 && fn.cmp(fl)!=0) {
fl--;
}
return fl;
}
};
class Ceil {
public:
typedef IT result_type;
typedef FT argument_type;
IT operator()( const FT& fn ) const {
IT fl = fn.BigIntValue();
if(fn.sign() >0 && fn.cmp(fl)!=0) {
fl++;
}
return fl;
}
};
};
//**********************NEW**********************
CGAL_END_NAMESPACE
#include <CGAL/Number_types/core_interval_support.h>
// #include <CGAL/Number_types/core_interval_support.h>
#include <CGAL/core_interval_support.h>
//since types are included by CORE_coercion_traits.h:
#include <CGAL/CORE_Expr.h>

View File

@ -23,6 +23,8 @@
#ifndef CGAL_NUMBER_TYPES_CORE_INTERVAL_SUPPORT_H
#define CGAL_NUMBER_TYPES_CORE_INTERVAL_SUPPORT_H
#if 0
#include <CGAL/basic.h>
#ifndef CGAL_USE_CORE
@ -312,4 +314,7 @@ convert_to_bfi(const ::CORE::BigRat& x){
CGAL_END_NAMESPACE
#endif // CGAL_USE_CORE
#endif
#endif // CGAL_NUMBER_TYPES_CORE_INTERVAL_SUPPORT_H

View File

@ -42,6 +42,7 @@
#include <LEDA/numbers/bigfloat.h>
#endif
#include <CGAL/Float_traits.h>
CGAL_BEGIN_NAMESPACE
@ -146,6 +147,393 @@ class Is_valid< leda_bigfloat >
}
};
//**********************NEW**********************
// Specialization of CGAL::Float_traits_kernel for leda::bigfloat
template <> class Float_traits_kernel< ::leda::bigfloat > {
public:
typedef ::leda::bigfloat FT;
typedef ::leda::integer IT;
typedef ::CGAL::Float_number_tag Float_type;
typedef CGAL::Precision_type Precision_type;
class Get_precision {
public:
typedef CGAL::Precision_type result_type;
CGAL::Precision_type operator()() const {
return CGAL::Precision_type( leda::bigfloat::get_precision() );
}
};
class Set_precision {
public:
typedef void result_type;
typedef CGAL::Precision_type first_argument_type;
void operator()( const CGAL::Precision_type& precision ) const {
leda::bigfloat::set_precision( (leda::sz_t)precision );
}
};
class Get_rounding_mode {
public:
typedef CGAL::Rounding_mode result_type;
CGAL::Rounding_mode operator()() const {
return CGAL::Rounding_mode( leda::bigfloat::get_rounding_mode() );
}
};
class Set_rounding_mode {
public:
typedef void result_type;
typedef CGAL::Rounding_mode first_argument_type;
void operator()( const CGAL::Rounding_mode& rounding_mode ) const {
leda::bigfloat::set_rounding_mode( (leda::rounding_modes)rounding_mode );
}
};
};
// Specialization of CGAL::Float_traits for leda::bigfloat
template <> class Float_traits< ::leda::bigfloat >
: public Float_traits_base< Float_traits_kernel< ::leda::bigfloat> > {
private:
static Rounding_mode get_rounding_mode() {
return Rounding_mode( leda::bigfloat::get_rounding_mode() );
};
static Precision_type get_precision() {
return Precision_type( leda::bigfloat::get_precision() );
};
public:
typedef Float_traits_kernel< leda::bigfloat > FT_kernel;
typedef FT_kernel::FT FT;
typedef FT_kernel::IT IT;
typedef FT_kernel::Float_type Float_type;
class Set_precision {
public:
// type for the \c AdaptableUnaryFunction concept.
typedef long argument_type;
// type for the \c AdaptableUnaryFunction concept.
typedef long result_type;
long operator() ( long prec ) const {
FT_kernel::Set_precision set_precision;
FT_kernel::Get_precision get_precision;
long old_precision = get_precision();
set_precision(prec);
return old_precision;
}
};
class Get_precision {
public:
// type for the \c AdaptableGenerator concept.
typedef long result_type;
long operator() () const {
FT_kernel::Get_precision get_precision;
return get_precision();
}
};
class Construct
: public Float_traits_base< FT_kernel >::Construct {
public:
FT operator() ( const IT& m, const IT& e = IT(0) ) {
return FT( m, e);
}
}; // class Constructor
class Construct_special_value {
public:
FT operator()( const Special_value& sv ) {
switch( sv ) {
case SV_N_ZERO: return leda::bigfloat::nZero;
case SV_P_ZERO: return leda::bigfloat::pZero;
case SV_N_INF: return leda::bigfloat::nInf;
case SV_P_INF: return leda::bigfloat::pInf;
case SV_NAN: return leda::bigfloat::NaN;
default: return FT(0);
}
}
};
class Is_special_value {
public:
bool operator()( const FT& bf ) const {
return leda::isSpecial( bf );
}
};
class Get_special_value {
public:
Special_value operator()( const FT& bf ) const {
if( leda::isNaN( bf ) )
return SV_NAN;
else if( leda::isnZero( bf ) )
return SV_N_ZERO;
else if( leda::ispZero( bf ) )
return SV_P_ZERO;
else if( leda::isnInf( bf ) )
return SV_N_INF;
else if( leda::ispInf( bf ) )
return SV_P_INF;
else
return SV_NONE;
}
};
class Is_zero {
public:
bool operator()( const FT& bf ) const {
return leda::isZero( bf ) || bf == FT(0);
}
};
class Is_inf {
public:
bool operator()( const FT& bf ) const {
return leda::isInf( bf );
}
};
class Get_mantissa
: public Float_traits_base< FT_kernel >::Get_mantissa {
public:
//! type for the \c AdaptableUnaryFunction concept.
typedef IT result_type;
//! type for the \c AdaptableUnaryFunction concept.
typedef FT argument_type;
IT operator()( const FT& a ) const {
return a.get_significant();
}
}; // class GetMantissa
class Get_exponent
: public Float_traits_base< FT_kernel >::Get_exponent {
public:
//! type for the \c AdaptableUnaryFunction concept.
typedef long result_type;
//! type for the \c AdaptableUnaryFunction concept.
typedef FT argument_type;
long operator()( const FT& a ) const {
return a.get_exponent().to_long();
}
}; // class GetMantissa
class Get_mantissa_and_exponent
: public Float_traits_base< FT_kernel >::Get_mantissa_and_exponent {
public:
//! type for the \c AdaptableUnaryFunction concept.
typedef std::pair< IT, IT > result_type;
//! type for the \c AdaptableUnaryFunction concept.
typedef FT argument_type;
std::pair< IT, IT > operator()( const FT& a ) const {
IT m = a.get_significant();
IT e = a.get_exponent();
std::pair< IT, IT > p( m, e );
return p;
}
}; // class GetMantissaAndExponent
class Round_relative
: public Float_traits_base< FT_kernel >::Round_relative {
public:
//! type for the \c AdaptableTernaryFunction concept.
typedef FT result_type;
//! type for the \c AdaptableTernaryFunction concept.
typedef FT first_argument_type;
//! type for the \c AdaptableTernaryFunction concept.
typedef CGAL::Precision_type second_argument_type;
//! type for the \c AdaptableTernaryFunction concept.
typedef CGAL::Rounding_mode third_argument_type;
FT operator()( const FT& a,
const CGAL::Precision_type& p = get_precision(),
const CGAL::Rounding_mode& m = get_rounding_mode() ) const {
return leda::round(a,(leda::sz_t)p,(leda::rounding_modes)m ) ;
}
}; // class Round
//TODO
//porting Round_absolute and NiX::Float_number from EXACUS2CGAL
// class Round_absolute : public Float_traits_base< FT_kernel >::Round_absolute {
// public:
// //! type for the \c AdaptableTernaryFunction concept.
// typedef FT result_type;
// //! type for the \c AdaptableTernaryFunction concept.
// typedef FT first_argument_type;
// //! type for the \c AdaptableTernaryFunction concept.
// typedef IT second_argument_type;
// //! type for the \c AdaptableTernaryFunction concept.
// typedef CGAL::Rounding_mode third_argument_type;
//
// FT operator()( const FT& a,
// const IT& new_exponent,
// const CGAL::Rounding_mode& r_mode = get_rounding_mode() ) const {
// typedef NiX::Float_number<IT> FN;
// FN fn( a.get_significant(), a.get_exponent() );
// fn = fn.round_absolute( new_exponent, r_mode );
// return FT( fn.get_mantissa(), fn.get_exponent() );
// }
// };
// special functors ( only for Big_float )
class Add
: public Float_traits_base< FT_kernel >::Add {
public:
typedef FT result_type;
typedef FT first_argument_type;
typedef FT second_argument_type;
typedef CGAL::Rounding_mode third_argument_type;
typedef CGAL::Precision_type fourth_argument_type;
FT operator()( const FT& a, const FT& b,
const Rounding_mode& m = get_rounding_mode(),
const Precision_type& p = get_precision() ) const {
return leda::add(a,b,(leda::sz_t)p,(leda::rounding_modes)m);
}
}; // class Add
class Sub
: public Float_traits_base< FT_kernel >::Sub{
public:
typedef FT result_type;
typedef FT first_argument_type;
typedef FT second_argument_type;
typedef CGAL::Rounding_mode third_argument_type;
typedef CGAL::Precision_type fourth_argument_type;
FT operator()( const FT& a, const FT& b ,
const Rounding_mode& m = get_rounding_mode(),
const Precision_type& p = get_precision() ) const {
return leda::sub(a,b,(leda::sz_t)p,(leda::rounding_modes)m);
}
}; // class Sub
class Mul
: public Float_traits_base< FT_kernel >::Mul {
public:
typedef FT result_type;
typedef FT first_argument_type;
typedef FT second_argument_type;
typedef CGAL::Rounding_mode third_argument_type;
typedef CGAL::Precision_type fourth_argument_type;
FT operator()( const FT& a, const FT& b ,
const Rounding_mode& m = get_rounding_mode(),
const Precision_type& p = get_precision() ) const {
return leda::mul(a,b,(leda::sz_t)p,(leda::rounding_modes)m);
}
}; // class Mul
class Div
: public Float_traits_base< FT_kernel >::Div{
public:
typedef FT result_type;
typedef FT first_argument_type;
typedef FT second_argument_type;
typedef CGAL::Rounding_mode third_argument_type;
typedef CGAL::Precision_type fourth_argument_type;
FT operator()( const FT& a, const FT& b ,
const Rounding_mode& m = get_rounding_mode(),
const Precision_type& p = get_precision() ) const {
return leda::div(a,b,(leda::sz_t)p,(leda::rounding_modes)m);
}
}; // class Div
class Sqrt
: public Float_traits_base< FT_kernel >::Sqrt{
public:
typedef FT result_type;
typedef FT first_argument_type;
typedef CGAL::Rounding_mode second_argument_type;
typedef CGAL::Precision_type third_argument_type;
FT operator()( const FT& bf,
const Rounding_mode& r_mode = get_rounding_mode(),
const Precision_type& prec = get_precision() ) const {
return leda::sqrt( bf, (leda::sz_t)prec, (leda::rounding_modes)r_mode);
}
}; // class Sqrt
class Mul_by_pow_of_2
: public Float_traits_base< FT_kernel >::Mul_by_pow_of_2{
public:
//! type for the \c AdaptableBinaryFunction concept.
typedef FT result_type;
//! type for the \c AdaptableBinaryFunction concept.
typedef FT first_argument_type;
//! type for the \c AdaptableBinaryFunction concept.
typedef IT second_argument_type;
FT operator()( const FT& a, const IT& e ) const {
return FT(a.get_significant(), a.get_exponent()+e);
}
}; // class Mul_by_pow_of_2
class Div_by_pow_of_2
: public Float_traits_base< FT_kernel >::Div_by_pow_of_2{
public:
//! type for the \c AdaptableBinaryFunction concept.
typedef FT result_type;
//! type for the \c AdaptableBinaryFunction concept.
typedef FT first_argument_type;
//! type for the \c AdaptableBinaryFunction concept.
typedef IT second_argument_type;
FT operator()( const FT& a, const IT& e ) const {
return FT(a.get_significant(), a.get_exponent()-e);
}
}; // class Div_by_pow_of_2
class Floor {
public:
typedef IT result_type;
typedef FT argument_type;
IT operator()( const FT& fn ) const {
return leda::to_integer( fn, leda::TO_N_INF );
}
};
class Ceil {
public:
typedef IT result_type;
typedef FT argument_type;
IT operator()( const FT& fn ) const {
return leda::to_integer( fn, leda::TO_P_INF );
}
};
};
//**********************NEW**********************
CGAL_END_NAMESPACE
// Unary + is missing for leda::bigfloat