MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / complexAt

Function complexAt

scripts/rubi/benchmark.ts:133–157  ·  view source on GitHub ↗
(
  expr: BoxedExpression,
  x: string,
  value: number | C
)

Source from the content-addressed store, hash-verified

131function containsOperator(expr: BoxedExpression, op: string): boolean {
132 if (expr.operator === op) return true;
133 if (expr.ops) return expr.ops.some((x) => containsOperator(x, op));
134 return false;
135}
136
137type C = { re: number; im: number };
138
139function complexAt(
140 expr: BoxedExpression,
141 x: string,
142 value: number | C
143): C | null {
144 const xv =
145 typeof value === 'number' ? value : expr.engine.number(value);
146 // Each point runs inside a `withTimeLimit` span and throws
147 // CancellationError when a single evaluation runs too long (a slow
148 // ₂F₁/Appell point); treat that as an unusable point (null), not a harness
149 // error. The span is required: the engine has no ambient time limit (the
150 // `ce.timeLimit` property was retired), so an unwrapped N() is unbounded.
151 let v: BoxedExpression;
152 try {
153 v = expr.engine.withTimeLimit(
154 { ms: POINT_TIME_LIMIT_MS, label: 'rubi:benchmark:point' },
155 () => expr.subs({ [x]: xv as any }).N()
156 );
157 } catch (e) {
158 if (e instanceof Error && e.constructor.name === 'CancellationError')
159 return null;
160 throw e;

Callers 3

atFunction · 0.85
checkPointFunction · 0.85
runProblemFunction · 0.85

Calls 5

isNumberFunction · 0.90
numberMethod · 0.65
NMethod · 0.65
subsMethod · 0.65
isFiniteMethod · 0.45

Tested by

no test coverage detected