mirror of
https://github.com/Z3Prover/z3
synced 2026-05-24 10:59:38 +00:00
Format code with prettier for RCF API implementation
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
This commit is contained in:
parent
b1291041e0
commit
b5b1af3de7
4 changed files with 57 additions and 56 deletions
|
|
@ -76,9 +76,9 @@ async function rcfRootsExample() {
|
||||||
// Find roots of x^2 - 2 = 0
|
// Find roots of x^2 - 2 = 0
|
||||||
// Polynomial: -2 + 0*x + 1*x^2
|
// Polynomial: -2 + 0*x + 1*x^2
|
||||||
const coeffs = [
|
const coeffs = [
|
||||||
RCFNum(-2), // constant term
|
RCFNum(-2), // constant term
|
||||||
RCFNum(0), // x coefficient
|
RCFNum(0), // x coefficient
|
||||||
RCFNum(1) // x^2 coefficient
|
RCFNum(1), // x^2 coefficient
|
||||||
];
|
];
|
||||||
|
|
||||||
const roots = RCFNum.roots(coeffs);
|
const roots = RCFNum.roots(coeffs);
|
||||||
|
|
|
||||||
|
|
@ -2136,9 +2136,9 @@ describe('high-level', () => {
|
||||||
// x^2 - 2 = 0 has roots ±√2
|
// x^2 - 2 = 0 has roots ±√2
|
||||||
// Polynomial: -2 + 0*x + 1*x^2
|
// Polynomial: -2 + 0*x + 1*x^2
|
||||||
const coeffs = [
|
const coeffs = [
|
||||||
RCFNum(-2), // constant term
|
RCFNum(-2), // constant term
|
||||||
RCFNum(0), // x coefficient
|
RCFNum(0), // x coefficient
|
||||||
RCFNum(1) // x^2 coefficient
|
RCFNum(1), // x^2 coefficient
|
||||||
];
|
];
|
||||||
|
|
||||||
const roots = RCFNum.roots(coeffs);
|
const roots = RCFNum.roots(coeffs);
|
||||||
|
|
|
||||||
|
|
@ -835,27 +835,24 @@ export function createApi(Z3: Z3Core): Z3HighLevel {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const RCFNum = Object.assign(
|
const RCFNum = Object.assign((value: string | number) => new RCFNumImpl(value), {
|
||||||
(value: string | number) => new RCFNumImpl(value),
|
pi: () => new RCFNumImpl(check(Z3.rcf_mk_pi(contextPtr))),
|
||||||
{
|
|
||||||
pi: () => new RCFNumImpl(check(Z3.rcf_mk_pi(contextPtr))),
|
|
||||||
|
|
||||||
e: () => new RCFNumImpl(check(Z3.rcf_mk_e(contextPtr))),
|
e: () => new RCFNumImpl(check(Z3.rcf_mk_e(contextPtr))),
|
||||||
|
|
||||||
infinitesimal: () => new RCFNumImpl(check(Z3.rcf_mk_infinitesimal(contextPtr))),
|
infinitesimal: () => new RCFNumImpl(check(Z3.rcf_mk_infinitesimal(contextPtr))),
|
||||||
|
|
||||||
roots: (coefficients: RCFNum<Name>[]) => {
|
roots: (coefficients: RCFNum<Name>[]) => {
|
||||||
assert(coefficients.length > 0, 'Polynomial coefficients cannot be empty');
|
assert(coefficients.length > 0, 'Polynomial coefficients cannot be empty');
|
||||||
const coeffPtrs = coefficients.map(c => (c as RCFNumImpl).ptr);
|
const coeffPtrs = coefficients.map(c => (c as RCFNumImpl).ptr);
|
||||||
const { rv: numRoots, roots: rootPtrs } = Z3.rcf_mk_roots(contextPtr, coeffPtrs);
|
const { rv: numRoots, roots: rootPtrs } = Z3.rcf_mk_roots(contextPtr, coeffPtrs);
|
||||||
const result: RCFNum<Name>[] = [];
|
const result: RCFNum<Name>[] = [];
|
||||||
for (let i = 0; i < numRoots; i++) {
|
for (let i = 0; i < numRoots; i++) {
|
||||||
result.push(new RCFNumImpl(rootPtrs[i]));
|
result.push(new RCFNumImpl(rootPtrs[i]));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
}
|
}) as RCFNumCreation<Name>;
|
||||||
) as RCFNumCreation<Name>;
|
|
||||||
|
|
||||||
const BitVec = {
|
const BitVec = {
|
||||||
sort<Bits extends number>(bits: Bits): BitVecSort<Bits, Name> {
|
sort<Bits extends number>(bits: Bits): BitVecSort<Bits, Name> {
|
||||||
|
|
@ -1776,7 +1773,11 @@ export function createApi(Z3: Z3Core): Z3HighLevel {
|
||||||
return new FuncDeclImpl(check(Z3.mk_transitive_closure(contextPtr, f.ptr)));
|
return new FuncDeclImpl(check(Z3.mk_transitive_closure(contextPtr, f.ptr)));
|
||||||
}
|
}
|
||||||
|
|
||||||
async function polynomialSubresultants(p: Arith<Name>, q: Arith<Name>, x: Arith<Name>): Promise<AstVector<Name, Arith<Name>>> {
|
async function polynomialSubresultants(
|
||||||
|
p: Arith<Name>,
|
||||||
|
q: Arith<Name>,
|
||||||
|
x: Arith<Name>,
|
||||||
|
): Promise<AstVector<Name, Arith<Name>>> {
|
||||||
const result = await Z3.polynomial_subresultants(contextPtr, p.ast, q.ast, x.ast);
|
const result = await Z3.polynomial_subresultants(contextPtr, p.ast, q.ast, x.ast);
|
||||||
return new AstVectorImpl<ArithImpl>(check(result));
|
return new AstVectorImpl<ArithImpl>(check(result));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue