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

Function applyAngle

src/compute-engine/boxed-expression/trigonometry.ts:225–242  ·  view source on GitHub ↗
(
  angle: Expression,
  fn: (x: number) => number | Complex | Expression,
  bigFn?: (x: BigDecimal) => BigDecimal | Complex | number | Expression,
  complexFn?: (x: Complex) => number | Complex
)

Source from the content-addressed store, hash-verified

223 ],
224];
225
226function applyAngle(
227 angle: Expression,
228 fn: (x: number) => number | Complex | Expression,
229 bigFn?: (x: BigDecimal) => BigDecimal | Complex | number | Expression,
230 complexFn?: (x: Complex) => number | Complex
231): Expression | undefined {
232 const angle0 = canonicalAngle(angle);
233 if (angle0 === undefined) return undefined;
234 // `apply` below declines anything that is not a number LITERAL, and an
235 // expression with unknowns cannot become one — so numericizing it first is
236 // waste, and on a nested tree of user-function applications an exponential
237 // one. (This is the same walk `constructibleValues` skips on the exact path;
238 // `applyAngle` is the `.N()` path's copy of it.)
239 if (angle0.unknowns.length > 0) return undefined;
240 const theta = angle0.N();
241 // `apply`'s machine/bignum handlers can also yield an already-boxed
242 // expression (e.g. `ce.ComplexInfinity` for a `Tan` pole), which it boxes
243 // through `ce.number`; its public signature is narrower, so cast here.
244 return apply(
245 theta,

Callers 1

evalTrigFunction · 0.85

Calls 3

canonicalAngleFunction · 0.90
applyFunction · 0.90
NMethod · 0.65

Tested by

no test coverage detected