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

Function log2

src/compute-engine/interval/elementary.ts:379–396  ·  view source on GitHub ↗
(x: Interval | IntervalResult)

Source from the content-addressed store, hash-verified

377 * Base-2 logarithm.
378 */
379export function log2(x: Interval | IntervalResult): IntervalResult {
380 const unwrapped = unwrapOrPropagate(x);
381 if (!Array.isArray(unwrapped)) return unwrapped;
382 const [xVal] = unwrapped;
383 if (xVal.hi <= 0) {
384 return { kind: 'empty' };
385 }
386
387 if (xVal.lo > 0) {
388 return ok({ lo: Math.log2(xVal.lo), hi: Math.log2(xVal.hi) });
389 }
390
391 return {
392 kind: 'partial',
393 value: { lo: -Infinity, hi: Math.log2(xVal.hi) },
394 domainClipped: 'lo',
395 };
396}
397
398/**
399 * Absolute value of an interval.

Callers

nothing calls this directly

Calls 2

unwrapOrPropagateFunction · 0.90
okFunction · 0.90

Tested by

no test coverage detected