Z3
Loading...
Searching...
No Matches
rcf_num Class Reference

Wrapper for Z3 Real Closed Field (RCF) numerals. More...

#include <z3++.h>

Public Member Functions

 rcf_num (context &c, Z3_rcf_num n)
 rcf_num (context &c, int val)
 rcf_num (context &c, char const *val)
 rcf_num (rcf_num const &other)
rcf_numoperator= (rcf_num const &other)
 ~rcf_num ()
 operator Z3_rcf_num () const
Z3_context ctx () const
std::string to_string (bool compact=false) const
 Return string representation of the RCF numeral.
std::string to_decimal (unsigned precision=10) const
 Return decimal string representation with given precision.
rcf_num operator+ (rcf_num const &other) const
rcf_num operator- (rcf_num const &other) const
rcf_num operator* (rcf_num const &other) const
rcf_num operator/ (rcf_num const &other) const
rcf_num operator- () const
rcf_num power (unsigned k) const
 Return the power of this number raised to k.
rcf_num inv () const
 Return the multiplicative inverse (1/this).
bool operator< (rcf_num const &other) const
bool operator> (rcf_num const &other) const
bool operator<= (rcf_num const &other) const
bool operator>= (rcf_num const &other) const
bool operator== (rcf_num const &other) const
bool operator!= (rcf_num const &other) const
bool is_rational () const
bool is_algebraic () const
bool is_infinitesimal () const
bool is_transcendental () const

Friends

std::ostream & operator<< (std::ostream &out, rcf_num const &n)

Detailed Description

Wrapper for Z3 Real Closed Field (RCF) numerals.

RCF numerals can represent:

  • Rational numbers
  • Algebraic numbers (roots of polynomials)
  • Transcendental extensions (e.g., pi, e)
  • Infinitesimal extensions

Definition at line 4922 of file z3++.h.

Constructor & Destructor Documentation

◆ rcf_num() [1/4]

rcf_num ( context & c,
Z3_rcf_num n )
inline

◆ rcf_num() [2/4]

rcf_num ( context & c,
int val )
inline

Definition at line 4935 of file z3++.h.

4935 : m_ctx(c) {
4936 m_num = Z3_rcf_mk_small_int(c, val);
4937 }
Z3_rcf_num Z3_API Z3_rcf_mk_small_int(Z3_context c, int val)
Return a RCF small integer.

◆ rcf_num() [3/4]

rcf_num ( context & c,
char const * val )
inline

Definition at line 4939 of file z3++.h.

4939 : m_ctx(c) {
4940 m_num = Z3_rcf_mk_rational(c, val);
4941 }
Z3_rcf_num Z3_API Z3_rcf_mk_rational(Z3_context c, Z3_string val)
Return a RCF rational using the given string.

◆ rcf_num() [4/4]

rcf_num ( rcf_num const & other)
inline

Definition at line 4943 of file z3++.h.

4943 : m_ctx(other.m_ctx) {
4944 // Create a copy by converting to string and back
4945 std::string str = Z3_rcf_num_to_string(m_ctx, other.m_num, false, false);
4946 m_num = Z3_rcf_mk_rational(m_ctx, str.c_str());
4947 }
Z3_string Z3_API Z3_rcf_num_to_string(Z3_context c, Z3_rcf_num a, bool compact, bool html)
Convert the RCF numeral into a string.

◆ ~rcf_num()

~rcf_num ( )
inline

Definition at line 4959 of file z3++.h.

4959 {
4960 Z3_rcf_del(m_ctx, m_num);
4961 }
void Z3_API Z3_rcf_del(Z3_context c, Z3_rcf_num a)
Delete a RCF numeral created using the RCF API.

Member Function Documentation

◆ ctx()

Z3_context ctx ( ) const
inline

Definition at line 4964 of file z3++.h.

4964{ return m_ctx; }

◆ inv()

rcf_num inv ( ) const
inline

Return the multiplicative inverse (1/this).

Definition at line 5021 of file z3++.h.

5021 {
5022 return rcf_num(*const_cast<context*>(reinterpret_cast<context const*>(&m_ctx)),
5023 Z3_rcf_inv(m_ctx, m_num));
5024 }
Z3_rcf_num Z3_API Z3_rcf_inv(Z3_context c, Z3_rcf_num a)
Return the value 1/a.

◆ is_algebraic()

bool is_algebraic ( ) const
inline

Definition at line 5062 of file z3++.h.

5062 {
5063 return Z3_rcf_is_algebraic(m_ctx, m_num);
5064 }
bool Z3_API Z3_rcf_is_algebraic(Z3_context c, Z3_rcf_num a)
Return true if a represents an algebraic number.

◆ is_infinitesimal()

bool is_infinitesimal ( ) const
inline

Definition at line 5066 of file z3++.h.

5066 {
5067 return Z3_rcf_is_infinitesimal(m_ctx, m_num);
5068 }
bool Z3_API Z3_rcf_is_infinitesimal(Z3_context c, Z3_rcf_num a)
Return true if a represents an infinitesimal.

◆ is_rational()

bool is_rational ( ) const
inline

Definition at line 5058 of file z3++.h.

5058 {
5059 return Z3_rcf_is_rational(m_ctx, m_num);
5060 }
bool Z3_API Z3_rcf_is_rational(Z3_context c, Z3_rcf_num a)
Return true if a represents a rational number.

◆ is_transcendental()

bool is_transcendental ( ) const
inline

Definition at line 5070 of file z3++.h.

5070 {
5071 return Z3_rcf_is_transcendental(m_ctx, m_num);
5072 }
bool Z3_API Z3_rcf_is_transcendental(Z3_context c, Z3_rcf_num a)
Return true if a represents a transcendental number.

◆ operator Z3_rcf_num()

operator Z3_rcf_num ( ) const
inline

Definition at line 4963 of file z3++.h.

4963{ return m_num; }

◆ operator!=()

bool operator!= ( rcf_num const & other) const
inline

Definition at line 5052 of file z3++.h.

5052 {
5053 check_context(other);
5054 return Z3_rcf_neq(m_ctx, m_num, other.m_num);
5055 }
bool Z3_API Z3_rcf_neq(Z3_context c, Z3_rcf_num a, Z3_rcf_num b)
Return true if a != b.
void check_context(object const &a, object const &b)
Definition z3++.h:548

◆ operator*()

rcf_num operator* ( rcf_num const & other) const
inline

Definition at line 4993 of file z3++.h.

4993 {
4994 check_context(other);
4995 return rcf_num(*const_cast<context*>(reinterpret_cast<context const*>(&m_ctx)),
4996 Z3_rcf_mul(m_ctx, m_num, other.m_num));
4997 }
Z3_rcf_num Z3_API Z3_rcf_mul(Z3_context c, Z3_rcf_num a, Z3_rcf_num b)
Return the value a * b.

◆ operator+()

rcf_num operator+ ( rcf_num const & other) const
inline

Definition at line 4981 of file z3++.h.

4981 {
4982 check_context(other);
4983 return rcf_num(*const_cast<context*>(reinterpret_cast<context const*>(&m_ctx)),
4984 Z3_rcf_add(m_ctx, m_num, other.m_num));
4985 }
Z3_rcf_num Z3_API Z3_rcf_add(Z3_context c, Z3_rcf_num a, Z3_rcf_num b)
Return the value a + b.

◆ operator-() [1/2]

rcf_num operator- ( ) const
inline

Definition at line 5005 of file z3++.h.

5005 {
5006 return rcf_num(*const_cast<context*>(reinterpret_cast<context const*>(&m_ctx)),
5007 Z3_rcf_neg(m_ctx, m_num));
5008 }
Z3_rcf_num Z3_API Z3_rcf_neg(Z3_context c, Z3_rcf_num a)
Return the value -a.

◆ operator-() [2/2]

rcf_num operator- ( rcf_num const & other) const
inline

Definition at line 4987 of file z3++.h.

4987 {
4988 check_context(other);
4989 return rcf_num(*const_cast<context*>(reinterpret_cast<context const*>(&m_ctx)),
4990 Z3_rcf_sub(m_ctx, m_num, other.m_num));
4991 }
Z3_rcf_num Z3_API Z3_rcf_sub(Z3_context c, Z3_rcf_num a, Z3_rcf_num b)
Return the value a - b.

◆ operator/()

rcf_num operator/ ( rcf_num const & other) const
inline

Definition at line 4999 of file z3++.h.

4999 {
5000 check_context(other);
5001 return rcf_num(*const_cast<context*>(reinterpret_cast<context const*>(&m_ctx)),
5002 Z3_rcf_div(m_ctx, m_num, other.m_num));
5003 }
Z3_rcf_num Z3_API Z3_rcf_div(Z3_context c, Z3_rcf_num a, Z3_rcf_num b)
Return the value a / b.

◆ operator<()

bool operator< ( rcf_num const & other) const
inline

Definition at line 5027 of file z3++.h.

5027 {
5028 check_context(other);
5029 return Z3_rcf_lt(m_ctx, m_num, other.m_num);
5030 }
bool Z3_API Z3_rcf_lt(Z3_context c, Z3_rcf_num a, Z3_rcf_num b)
Return true if a < b.

◆ operator<=()

bool operator<= ( rcf_num const & other) const
inline

Definition at line 5037 of file z3++.h.

5037 {
5038 check_context(other);
5039 return Z3_rcf_le(m_ctx, m_num, other.m_num);
5040 }
bool Z3_API Z3_rcf_le(Z3_context c, Z3_rcf_num a, Z3_rcf_num b)
Return true if a <= b.

◆ operator=()

rcf_num & operator= ( rcf_num const & other)
inline

Definition at line 4949 of file z3++.h.

4949 {
4950 if (this != &other) {
4951 Z3_rcf_del(m_ctx, m_num);
4952 m_ctx = other.m_ctx;
4953 std::string str = Z3_rcf_num_to_string(m_ctx, other.m_num, false, false);
4954 m_num = Z3_rcf_mk_rational(m_ctx, str.c_str());
4955 }
4956 return *this;
4957 }

◆ operator==()

bool operator== ( rcf_num const & other) const
inline

Definition at line 5047 of file z3++.h.

5047 {
5048 check_context(other);
5049 return Z3_rcf_eq(m_ctx, m_num, other.m_num);
5050 }
bool Z3_API Z3_rcf_eq(Z3_context c, Z3_rcf_num a, Z3_rcf_num b)
Return true if a == b.

◆ operator>()

bool operator> ( rcf_num const & other) const
inline

Definition at line 5032 of file z3++.h.

5032 {
5033 check_context(other);
5034 return Z3_rcf_gt(m_ctx, m_num, other.m_num);
5035 }
bool Z3_API Z3_rcf_gt(Z3_context c, Z3_rcf_num a, Z3_rcf_num b)
Return true if a > b.

◆ operator>=()

bool operator>= ( rcf_num const & other) const
inline

Definition at line 5042 of file z3++.h.

5042 {
5043 check_context(other);
5044 return Z3_rcf_ge(m_ctx, m_num, other.m_num);
5045 }
bool Z3_API Z3_rcf_ge(Z3_context c, Z3_rcf_num a, Z3_rcf_num b)
Return true if a >= b.

◆ power()

rcf_num power ( unsigned k) const
inline

Return the power of this number raised to k.

Definition at line 5013 of file z3++.h.

5013 {
5014 return rcf_num(*const_cast<context*>(reinterpret_cast<context const*>(&m_ctx)),
5015 Z3_rcf_power(m_ctx, m_num, k));
5016 }
Z3_rcf_num Z3_API Z3_rcf_power(Z3_context c, Z3_rcf_num a, unsigned k)
Return the value a^k.

◆ to_decimal()

std::string to_decimal ( unsigned precision = 10) const
inline

Return decimal string representation with given precision.

Definition at line 4976 of file z3++.h.

4976 {
4977 return std::string(Z3_rcf_num_to_decimal_string(m_ctx, m_num, precision));
4978 }
Z3_string Z3_API Z3_rcf_num_to_decimal_string(Z3_context c, Z3_rcf_num a, unsigned prec)
Convert the RCF numeral into a string in decimal notation.

◆ to_string()

std::string to_string ( bool compact = false) const
inline

Return string representation of the RCF numeral.

Definition at line 4969 of file z3++.h.

4969 {
4970 return std::string(Z3_rcf_num_to_string(m_ctx, m_num, compact, false));
4971 }

Referenced by operator<<.

◆ operator<<

std::ostream & operator<< ( std::ostream & out,
rcf_num const & n )
friend

Definition at line 5074 of file z3++.h.

5074 {
5075 return out << n.to_string();
5076 }