19using System.Diagnostics;
43 Debug.Assert(ctx !=
null);
54 Debug.Assert(ctx !=
null);
63 Debug.Assert(ctx !=
null);
73 return new RCFNum(ctx, Native.Z3_rcf_mk_pi(ctx.nCtx));
83 return new RCFNum(ctx, Native.Z3_rcf_mk_e(ctx.nCtx));
93 return new RCFNum(ctx, Native.Z3_rcf_mk_infinitesimal(ctx.nCtx));
106 if (coefficients ==
null || coefficients.Length == 0)
108 throw new Z3Exception(
"Polynomial coefficients cannot be empty");
111 uint n = (uint)coefficients.Length;
112 IntPtr[] a =
new IntPtr[n];
113 IntPtr[] roots =
new IntPtr[n];
115 for (uint i = 0; i < n; i++)
117 a[i] = coefficients[i].NativeObject;
120 uint numRoots = Native.Z3_rcf_mk_roots(ctx.nCtx, n, a, roots);
123 for (uint i = 0; i < numRoots; i++)
125 result[i] =
new RCFNum(ctx, roots[i]);
251 return 0 != Native.Z3_rcf_lt(
Context.nCtx, NativeObject, other.NativeObject);
262 return 0 != Native.Z3_rcf_gt(
Context.nCtx, NativeObject, other.NativeObject);
273 return 0 != Native.Z3_rcf_le(
Context.nCtx, NativeObject, other.NativeObject);
284 return 0 != Native.Z3_rcf_ge(
Context.nCtx, NativeObject, other.NativeObject);
295 return 0 != Native.Z3_rcf_eq(
Context.nCtx, NativeObject, other.NativeObject);
306 return 0 != Native.Z3_rcf_neq(
Context.nCtx, NativeObject, other.NativeObject);
346 if (ReferenceEquals(a, b))
return true;
347 if (ReferenceEquals(a,
null) || ReferenceEquals(b,
null))
return false;
365 return 0 != Native.Z3_rcf_is_rational(
Context.nCtx, NativeObject);
374 return 0 != Native.Z3_rcf_is_algebraic(
Context.nCtx, NativeObject);
383 return 0 != Native.Z3_rcf_is_infinitesimal(
Context.nCtx, NativeObject);
392 return 0 != Native.Z3_rcf_is_transcendental(
Context.nCtx, NativeObject);
402 return Native.Z3_rcf_num_to_string(
Context.nCtx, NativeObject, compact ? (
byte)1 : (byte)0, 0);
421 return Native.Z3_rcf_num_to_decimal_string(
Context.nCtx, NativeObject, precision);
431 return this == other;
441 return NativeObject.GetHashCode();
445 internal override void DecRef(IntPtr o)
447 Native.Z3_rcf_del(
Context.nCtx, o);
450 private void CheckContext(RCFNum other)
454 throw new Z3Exception(
"RCF numerals from different contexts");
The main interaction with Z3 happens via the Context.
Real Closed Field (RCF) numerals.
bool IsTranscendental()
Check if this RCF numeral is a transcendental number.
RCFNum Power(uint k)
Raise this RCF numeral to a power.
bool Le(RCFNum other)
Check if this RCF numeral is less than or equal to another.
RCFNum Div(RCFNum other)
Divide two RCF numerals.
RCFNum Sub(RCFNum other)
Subtract two RCF numerals.
bool Gt(RCFNum other)
Check if this RCF numeral is greater than another.
RCFNum Mul(RCFNum other)
Multiply two RCF numerals.
bool Ge(RCFNum other)
Check if this RCF numeral is greater than or equal to another.
static RCFNum[] MkRoots(Context ctx, RCFNum[] coefficients)
Find roots of a polynomial.
bool IsInfinitesimal()
Check if this RCF numeral is an infinitesimal.
static bool operator!=(RCFNum a, RCFNum b)
Operator overload for inequality.
RCFNum Inv()
Compute the multiplicative inverse.
static RCFNum operator*(RCFNum a, RCFNum b)
Operator overload for multiplication.
string ToDecimal(uint precision)
Convert this RCF numeral to a decimal string.
bool IsAlgebraic()
Check if this RCF numeral is an algebraic number.
static bool operator<=(RCFNum a, RCFNum b)
Operator overload for less than or equal.
override int GetHashCode()
Override GetHashCode for proper equality semantics.
static bool operator<(RCFNum a, RCFNum b)
Operator overload for less than.
RCFNum Add(RCFNum other)
Add two RCF numerals.
string ToString(bool compact)
Convert this RCF numeral to a string.
static RCFNum operator/(RCFNum a, RCFNum b)
Operator overload for division.
bool Neq(RCFNum other)
Check if this RCF numeral is not equal to another.
static RCFNum MkPi(Context ctx)
Create an RCF numeral representing pi.
RCFNum Neg()
Negate this RCF numeral.
static RCFNum operator+(RCFNum a, RCFNum b)
Operator overload for addition.
override string ToString()
Convert this RCF numeral to a string (non-compact).
override bool Equals(object obj)
Override Equals for proper equality semantics.
bool Lt(RCFNum other)
Check if this RCF numeral is less than another.
static RCFNum MkInfinitesimal(Context ctx)
Create an RCF numeral representing an infinitesimal.
static bool operator>=(RCFNum a, RCFNum b)
Operator overload for greater than or equal.
RCFNum(Context ctx, string value)
Create an RCF numeral from a rational string.
bool IsRational()
Check if this RCF numeral is a rational number.
static bool operator>(RCFNum a, RCFNum b)
Operator overload for greater than.
static RCFNum MkE(Context ctx)
Create an RCF numeral representing e (Euler's constant).
bool Eq(RCFNum other)
Check if this RCF numeral is equal to another.
RCFNum(Context ctx, int value)
Create an RCF numeral from a small integer.
static bool operator==(RCFNum a, RCFNum b)
Operator overload for equality.
static RCFNum operator-(RCFNum a, RCFNum b)
Operator overload for subtraction.
The exception base class for error reporting from Z3.
Internal base class for interfacing with native Z3 objects. Should not be used externally.
Context Context
Access Context object.
Z3_rcf_num Z3_API Z3_rcf_mk_rational(Z3_context c, Z3_string val)
Return a RCF rational using the given string.
Z3_rcf_num Z3_API Z3_rcf_mk_small_int(Z3_context c, int val)
Return a RCF small integer.