carl  24.04
Computer ARithmetic Library
Conversion.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <carl-common/config.h>
4 #include <type_traits>
5 #include <carl-arith/ran/ran.h>
6 
7 namespace carl {
8 
9 template<typename T, std::enable_if_t<is_ran_type<T>::value, int> = 0>
10 inline T convert(const T& r) {
11  return r;
12 }
13 
14 namespace convert_ran {
15 template<typename T, typename S>
16 struct ConvertHelper {};
17 
18 #ifdef USE_LIBPOLY
19 template<typename R>
20 struct ConvertHelper<LPRealAlgebraicNumber, IntRepRealAlgebraicNumber<R>> {
21  static LPRealAlgebraicNumber convert(const IntRepRealAlgebraicNumber<R>& r) {
22  if(r.is_numeric()){
23  return LPRealAlgebraicNumber(r.value()) ;
24  }
25  return LPRealAlgebraicNumber(r.polynomial(), r.interval());
26  }
27 };
28 
29 template<typename R>
30 struct ConvertHelper<IntRepRealAlgebraicNumber<R>, LPRealAlgebraicNumber> {
31  static IntRepRealAlgebraicNumber<R> convert(const LPRealAlgebraicNumber& r) {
32  if(r.is_numeric()){
33  return IntRepRealAlgebraicNumber<R>(r.value());
34  }
35  return IntRepRealAlgebraicNumber<R>(r.polynomial(), r.interval());
36  }
37 };
38 #endif
39 }
40 
41 template<typename T, typename S, std::enable_if_t<is_ran_type<T>::value && is_ran_type<S>::value && !std::is_same<T,S>::value, int> = 0>
42 inline T convert(const S& r) {
44 }
45 
46 }; // namespace carl
Represent a real algebraic number (RAN) in one of several ways:
carl is the main namespace for the library.
BasicConstraint< ToPoly > convert(const typename ToPoly::ContextType &context, const BasicConstraint< FromPoly > &c)
Definition: Conversion.h:9
T convert(const T &r)
Definition: Conversion.h:10
const auto & value() const
Definition: Ran.h:227
const auto & interval() const
Definition: Ran.h:222
const auto & polynomial() const
Definition: Ran.h:218
bool is_numeric() const
Definition: Ran.h:214