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 5053 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 5066 of file z3++.h.

5066 : m_ctx(c) {
5067 m_num = Z3_rcf_mk_small_int(c, val);
5068 }
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 5070 of file z3++.h.

5070 : m_ctx(c) {
5071 m_num = Z3_rcf_mk_rational(c, val);
5072 }
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 5074 of file z3++.h.

5074 : m_ctx(other.m_ctx) {
5075 // Create a copy by converting to string and back
5076 std::string str = Z3_rcf_num_to_string(m_ctx, other.m_num, false, false);
5077 m_num = Z3_rcf_mk_rational(m_ctx, str.c_str());
5078 }
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 5090 of file z3++.h.

5090 {
5091 Z3_rcf_del(m_ctx, m_num);
5092 }
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 5095 of file z3++.h.

5095{ return m_ctx; }

◆ inv()

rcf_num inv ( ) const
inline

Return the multiplicative inverse (1/this).

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

5152 {
5153 return rcf_num(*const_cast<context*>(reinterpret_cast<context const*>(&m_ctx)),
5154 Z3_rcf_inv(m_ctx, m_num));
5155 }
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 5193 of file z3++.h.

5193 {
5194 return Z3_rcf_is_algebraic(m_ctx, m_num);
5195 }
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 5197 of file z3++.h.

5197 {
5198 return Z3_rcf_is_infinitesimal(m_ctx, m_num);
5199 }
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 5189 of file z3++.h.

5189 {
5190 return Z3_rcf_is_rational(m_ctx, m_num);
5191 }
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 5201 of file z3++.h.

5201 {
5202 return Z3_rcf_is_transcendental(m_ctx, m_num);
5203 }
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 5094 of file z3++.h.

5094{ return m_num; }

◆ operator!=()

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

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

5183 {
5184 check_context(other);
5185 return Z3_rcf_neq(m_ctx, m_num, other.m_num);
5186 }
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:564

◆ operator*()

rcf_num operator* ( rcf_num const & other) const
inline

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

5124 {
5125 check_context(other);
5126 return rcf_num(*const_cast<context*>(reinterpret_cast<context const*>(&m_ctx)),
5127 Z3_rcf_mul(m_ctx, m_num, other.m_num));
5128 }
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 5112 of file z3++.h.

5112 {
5113 check_context(other);
5114 return rcf_num(*const_cast<context*>(reinterpret_cast<context const*>(&m_ctx)),
5115 Z3_rcf_add(m_ctx, m_num, other.m_num));
5116 }
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 5136 of file z3++.h.

5136 {
5137 return rcf_num(*const_cast<context*>(reinterpret_cast<context const*>(&m_ctx)),
5138 Z3_rcf_neg(m_ctx, m_num));
5139 }
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 5118 of file z3++.h.

5118 {
5119 check_context(other);
5120 return rcf_num(*const_cast<context*>(reinterpret_cast<context const*>(&m_ctx)),
5121 Z3_rcf_sub(m_ctx, m_num, other.m_num));
5122 }
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 5130 of file z3++.h.

5130 {
5131 check_context(other);
5132 return rcf_num(*const_cast<context*>(reinterpret_cast<context const*>(&m_ctx)),
5133 Z3_rcf_div(m_ctx, m_num, other.m_num));
5134 }
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 5158 of file z3++.h.

5158 {
5159 check_context(other);
5160 return Z3_rcf_lt(m_ctx, m_num, other.m_num);
5161 }
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 5168 of file z3++.h.

5168 {
5169 check_context(other);
5170 return Z3_rcf_le(m_ctx, m_num, other.m_num);
5171 }
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 5080 of file z3++.h.

5080 {
5081 if (this != &other) {
5082 Z3_rcf_del(m_ctx, m_num);
5083 m_ctx = other.m_ctx;
5084 std::string str = Z3_rcf_num_to_string(m_ctx, other.m_num, false, false);
5085 m_num = Z3_rcf_mk_rational(m_ctx, str.c_str());
5086 }
5087 return *this;
5088 }

◆ operator==()

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

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

5178 {
5179 check_context(other);
5180 return Z3_rcf_eq(m_ctx, m_num, other.m_num);
5181 }
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 5163 of file z3++.h.

5163 {
5164 check_context(other);
5165 return Z3_rcf_gt(m_ctx, m_num, other.m_num);
5166 }
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 5173 of file z3++.h.

5173 {
5174 check_context(other);
5175 return Z3_rcf_ge(m_ctx, m_num, other.m_num);
5176 }
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 5144 of file z3++.h.

5144 {
5145 return rcf_num(*const_cast<context*>(reinterpret_cast<context const*>(&m_ctx)),
5146 Z3_rcf_power(m_ctx, m_num, k));
5147 }
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 5107 of file z3++.h.

5107 {
5108 return std::string(Z3_rcf_num_to_decimal_string(m_ctx, m_num, precision));
5109 }
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 5100 of file z3++.h.

5100 {
5101 return std::string(Z3_rcf_num_to_string(m_ctx, m_num, compact, false));
5102 }

Referenced by operator<<.

◆ operator<<

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

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

5205 {
5206 return out << n.to_string();
5207 }