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

Function powerForm

src/compute-engine/boxed-expression/canonical.ts:305–314  ·  view source on GitHub ↗

* Apply the 'Power' form recursively. Each sub-expression is visited * and any `Power` at the current level is canonicalized via `canonicalPower`. * * Note: `divideForm` intentionally calls `powerForm` on its operands before * passing them to `canonicalDivide`, since division canonicalization be

(expr: Expression)

Source from the content-addressed store, hash-verified

303 }
304 if (ops.length === 2) {
305 const re = ops[0].re;
306 const im = ops[1].re;
307 if (im !== null && re !== null && !isNaN(im) && !isNaN(re)) {
308 if (im === 0 && re === 0) return ce.Zero;
309 if (im !== 0) return ce.number(ce._numericValue({ re, im }));
310 return ops[0];
311 }
312 return ce._fn(
313 'Add',
314 [ops[0], ce._fn('Multiply', [ops[1], ce.I], { canonical: false })],
315 { canonical: false }
316 );
317 }

Callers 2

canonicalFormFunction · 0.85
divideFormFunction · 0.85

Calls 4

isFunctionFunction · 0.90
canonicalPowerFunction · 0.90
mapMethod · 0.65
_fnMethod · 0.65

Tested by

no test coverage detected