Z3
 
Loading...
Searching...
No Matches
Data Structures | Public Member Functions | Static Public Member Functions
RCFNum Class Reference
+ Inheritance diagram for RCFNum:

Public Member Functions

 RCFNum (Context ctx, String value)
 
 RCFNum (Context ctx, int value)
 
RCFNum add (RCFNum other)
 
RCFNum sub (RCFNum other)
 
RCFNum mul (RCFNum other)
 
RCFNum div (RCFNum other)
 
RCFNum neg ()
 
RCFNum inv ()
 
RCFNum power (int k)
 
boolean lt (RCFNum other)
 
boolean gt (RCFNum other)
 
boolean le (RCFNum other)
 
boolean ge (RCFNum other)
 
boolean eq (RCFNum other)
 
boolean neq (RCFNum other)
 
boolean isRational ()
 
boolean isAlgebraic ()
 
boolean isInfinitesimal ()
 
boolean isTranscendental ()
 
String toString (boolean compact)
 
String toString ()
 
String toDecimal (int precision)
 

Static Public Member Functions

static RCFNum mkPi (Context ctx)
 
static RCFNum mkE (Context ctx)
 
static RCFNum mkInfinitesimal (Context ctx)
 
static RCFNum[] mkRoots (Context ctx, RCFNum[] coefficients)
 
- Static Public Member Functions inherited from Z3Object
static long[] arrayToNative (Z3Object[] a)
 
static int arrayLength (Z3Object[] a)
 

Detailed Description

Real Closed Field (RCF) numerals.

RCF numerals can represent:

Definition at line 31 of file RCFNum.java.

Constructor & Destructor Documentation

◆ RCFNum() [1/2]

RCFNum ( Context  ctx,
String  value 
)
inline

Create an RCF numeral from a rational string.

Parameters
ctxZ3 context
valueString representation of a rational number (e.g., "3/2", "0.5", "42")
Exceptions
Z3Exceptionon error

Definition at line 39 of file RCFNum.java.

39 {
40 super(ctx, Native.rcfMkRational(ctx.nCtx(), value));
41 }

◆ RCFNum() [2/2]

RCFNum ( Context  ctx,
int  value 
)
inline

Create an RCF numeral from a small integer.

Parameters
ctxZ3 context
valueInteger value
Exceptions
Z3Exceptionon error

Definition at line 49 of file RCFNum.java.

49 {
50 super(ctx, Native.rcfMkSmallInt(ctx.nCtx(), value));
51 }

Member Function Documentation

◆ add()

RCFNum add ( RCFNum  other)
inline

Add two RCF numerals.

Parameters
otherThe RCF numeral to add
Returns
this + other
Exceptions
Z3Exceptionon error

Definition at line 129 of file RCFNum.java.

129 {
130 checkContext(other);
131 return new RCFNum(getContext(), Native.rcfAdd(getContext().nCtx(),
132 getNativeObject(),
133 other.getNativeObject()));
134 }
RCFNum(Context ctx, String value)
Definition RCFNum.java:39

Referenced by Solver.__iadd__().

◆ div()

RCFNum div ( RCFNum  other)
inline

Divide two RCF numerals.

Parameters
otherThe RCF numeral to divide by
Returns
this / other
Exceptions
Z3Exceptionon error

Definition at line 168 of file RCFNum.java.

168 {
169 checkContext(other);
170 return new RCFNum(getContext(), Native.rcfDiv(getContext().nCtx(),
171 getNativeObject(),
172 other.getNativeObject()));
173 }

◆ eq()

boolean eq ( RCFNum  other)
inline

Check if this RCF numeral is equal to another.

Parameters
otherThe RCF numeral to compare with
Returns
true if this == other
Exceptions
Z3Exceptionon error

Definition at line 260 of file RCFNum.java.

260 {
261 checkContext(other);
262 return Native.rcfEq(getContext().nCtx(), getNativeObject(),
263 other.getNativeObject());
264 }

Referenced by AstRef.__eq__(), and SortRef.cast().

◆ ge()

boolean ge ( RCFNum  other)
inline

Check if this RCF numeral is greater than or equal to another.

Parameters
otherThe RCF numeral to compare with
Returns
true if this >= other
Exceptions
Z3Exceptionon error

Definition at line 248 of file RCFNum.java.

248 {
249 checkContext(other);
250 return Native.rcfGe(getContext().nCtx(), getNativeObject(),
251 other.getNativeObject());
252 }

◆ gt()

boolean gt ( RCFNum  other)
inline

Check if this RCF numeral is greater than another.

Parameters
otherThe RCF numeral to compare with
Returns
true if this > other
Exceptions
Z3Exceptionon error

Definition at line 224 of file RCFNum.java.

224 {
225 checkContext(other);
226 return Native.rcfGt(getContext().nCtx(), getNativeObject(),
227 other.getNativeObject());
228 }

◆ inv()

RCFNum inv ( )
inline

Compute the multiplicative inverse.

Returns
1/this
Exceptions
Z3Exceptionon error

Definition at line 190 of file RCFNum.java.

190 {
191 return new RCFNum(getContext(), Native.rcfInv(getContext().nCtx(),
192 getNativeObject()));
193 }

◆ isAlgebraic()

boolean isAlgebraic ( )
inline

Check if this RCF numeral is an algebraic number.

Returns
true if this is algebraic
Exceptions
Z3Exceptionon error

Definition at line 292 of file RCFNum.java.

292 {
293 return Native.rcfIsAlgebraic(getContext().nCtx(), getNativeObject());
294 }

◆ isInfinitesimal()

boolean isInfinitesimal ( )
inline

Check if this RCF numeral is an infinitesimal.

Returns
true if this is infinitesimal
Exceptions
Z3Exceptionon error

Definition at line 301 of file RCFNum.java.

301 {
302 return Native.rcfIsInfinitesimal(getContext().nCtx(), getNativeObject());
303 }

◆ isRational()

boolean isRational ( )
inline

Check if this RCF numeral is a rational number.

Returns
true if this is rational
Exceptions
Z3Exceptionon error

Definition at line 283 of file RCFNum.java.

283 {
284 return Native.rcfIsRational(getContext().nCtx(), getNativeObject());
285 }

◆ isTranscendental()

boolean isTranscendental ( )
inline

Check if this RCF numeral is a transcendental number.

Returns
true if this is transcendental
Exceptions
Z3Exceptionon error

Definition at line 310 of file RCFNum.java.

310 {
311 return Native.rcfIsTranscendental(getContext().nCtx(), getNativeObject());
312 }

◆ le()

boolean le ( RCFNum  other)
inline

Check if this RCF numeral is less than or equal to another.

Parameters
otherThe RCF numeral to compare with
Returns
true if this <= other
Exceptions
Z3Exceptionon error

Definition at line 236 of file RCFNum.java.

236 {
237 checkContext(other);
238 return Native.rcfLe(getContext().nCtx(), getNativeObject(),
239 other.getNativeObject());
240 }

◆ lt()

boolean lt ( RCFNum  other)
inline

Check if this RCF numeral is less than another.

Parameters
otherThe RCF numeral to compare with
Returns
true if this < other
Exceptions
Z3Exceptionon error

Definition at line 212 of file RCFNum.java.

212 {
213 checkContext(other);
214 return Native.rcfLt(getContext().nCtx(), getNativeObject(),
215 other.getNativeObject());
216 }

◆ mkE()

static RCFNum mkE ( Context  ctx)
inlinestatic

Create an RCF numeral representing e (Euler's constant).

Parameters
ctxZ3 context
Returns
RCF numeral for e
Exceptions
Z3Exceptionon error

Definition at line 76 of file RCFNum.java.

76 {
77 return new RCFNum(ctx, Native.rcfMkE(ctx.nCtx()));
78 }

◆ mkInfinitesimal()

static RCFNum mkInfinitesimal ( Context  ctx)
inlinestatic

Create an RCF numeral representing an infinitesimal.

Parameters
ctxZ3 context
Returns
RCF numeral for an infinitesimal
Exceptions
Z3Exceptionon error

Definition at line 86 of file RCFNum.java.

86 {
87 return new RCFNum(ctx, Native.rcfMkInfinitesimal(ctx.nCtx()));
88 }

◆ mkPi()

static RCFNum mkPi ( Context  ctx)
inlinestatic

Create an RCF numeral representing pi.

Parameters
ctxZ3 context
Returns
RCF numeral for pi
Exceptions
Z3Exceptionon error

Definition at line 66 of file RCFNum.java.

66 {
67 return new RCFNum(ctx, Native.rcfMkPi(ctx.nCtx()));
68 }

◆ mkRoots()

static RCFNum[] mkRoots ( Context  ctx,
RCFNum[]  coefficients 
)
inlinestatic

Find roots of a polynomial.

The polynomial is a[n-1]*x^(n-1) + ... + a[1]*x + a[0].

Parameters
ctxZ3 context
coefficientsPolynomial coefficients (constant term first)
Returns
Array of RCF numerals representing the roots
Exceptions
Z3Exceptionon error

Definition at line 100 of file RCFNum.java.

100 {
101 if (coefficients == null || coefficients.length == 0) {
102 throw new Z3Exception("Polynomial coefficients cannot be empty");
103 }
104
105 int n = coefficients.length;
106 long[] a = new long[n];
107 long[] roots = new long[n];
108
109 for (int i = 0; i < n; i++) {
110 a[i] = coefficients[i].getNativeObject();
111 }
112
113 int numRoots = Native.rcfMkRoots(ctx.nCtx(), n, a, roots);
114
115 RCFNum[] result = new RCFNum[numRoots];
116 for (int i = 0; i < numRoots; i++) {
117 result[i] = new RCFNum(ctx, roots[i]);
118 }
119
120 return result;
121 }

◆ mul()

RCFNum mul ( RCFNum  other)
inline

Multiply two RCF numerals.

Parameters
otherThe RCF numeral to multiply
Returns
this * other
Exceptions
Z3Exceptionon error

Definition at line 155 of file RCFNum.java.

155 {
156 checkContext(other);
157 return new RCFNum(getContext(), Native.rcfMul(getContext().nCtx(),
158 getNativeObject(),
159 other.getNativeObject()));
160 }

◆ neg()

RCFNum neg ( )
inline

Negate this RCF numeral.

Returns
-this
Exceptions
Z3Exceptionon error

Definition at line 180 of file RCFNum.java.

180 {
181 return new RCFNum(getContext(), Native.rcfNeg(getContext().nCtx(),
182 getNativeObject()));
183 }

◆ neq()

boolean neq ( RCFNum  other)
inline

Check if this RCF numeral is not equal to another.

Parameters
otherThe RCF numeral to compare with
Returns
true if this != other
Exceptions
Z3Exceptionon error

Definition at line 272 of file RCFNum.java.

272 {
273 checkContext(other);
274 return Native.rcfNeq(getContext().nCtx(), getNativeObject(),
275 other.getNativeObject());
276 }

◆ power()

RCFNum power ( int  k)
inline

Raise this RCF numeral to a power.

Parameters
kThe exponent
Returns
this^k
Exceptions
Z3Exceptionon error

Definition at line 201 of file RCFNum.java.

201 {
202 return new RCFNum(getContext(), Native.rcfPower(getContext().nCtx(),
203 getNativeObject(), k));
204 }

◆ sub()

RCFNum sub ( RCFNum  other)
inline

Subtract two RCF numerals.

Parameters
otherThe RCF numeral to subtract
Returns
this - other
Exceptions
Z3Exceptionon error

Definition at line 142 of file RCFNum.java.

142 {
143 checkContext(other);
144 return new RCFNum(getContext(), Native.rcfSub(getContext().nCtx(),
145 getNativeObject(),
146 other.getNativeObject()));
147 }

◆ toDecimal()

String toDecimal ( int  precision)
inline

Convert this RCF numeral to a decimal string.

Parameters
precisionNumber of decimal places
Returns
Decimal string representation
Exceptions
Z3Exceptionon error

Definition at line 341 of file RCFNum.java.

341 {
342 return Native.rcfNumToDecimalString(getContext().nCtx(),
343 getNativeObject(), precision);
344 }

◆ toString() [1/2]

String toString ( )
inline

Convert this RCF numeral to a string (non-compact).

Returns
String representation
Exceptions
Z3Exceptionon error

Definition at line 331 of file RCFNum.java.

331 {
332 return toString(false);
333 }

Referenced by RCFNum.toString().

◆ toString() [2/2]

String toString ( boolean  compact)
inline

Convert this RCF numeral to a string.

Parameters
compactIf true, use compact representation
Returns
String representation
Exceptions
Z3Exceptionon error

Definition at line 320 of file RCFNum.java.

320 {
321 return Native.rcfNumToString(getContext().nCtx(), getNativeObject(),
322 compact, false);
323 }