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

Function gcd

src/compute-engine/interval/elementary.ts:963–983  ·  view source on GitHub ↗
(
  a: Interval | IntervalResult,
  b: Interval | IntervalResult
)

Source from the content-addressed store, hash-verified

961 *
962 * Has jump discontinuities at every integer.
963 */
964function ceilRaw(x: Interval | IntervalResult): IntervalResult {
965 const unwrapped = unwrapOrPropagate(x);
966 if (!Array.isArray(unwrapped)) return unwrapped;
967 const [xVal] = unwrapped;
968 if (isNaNInterval(xVal)) return ok(NAN_INTERVAL);
969 const clo = Math.ceil(xVal.lo);
970 const chi = Math.ceil(xVal.hi);
971 if (clo === chi) return ok({ lo: clo, hi: chi });
972 // Interval spans an integer boundary — a finite jump. ceil is
973 // left-continuous: lim_{x→n-} ceil(x) = ceil(n) = n. Its values on the
974 // interval lie in [ceil(lo), ceil(hi)], which is carried as the enclosure.
975 return jump(clo, 'left', { lo: clo, hi: chi });
976}
977
978// `isNaNInterval` and `NAN_INTERVAL` are defined near the top of this file:
979// the domain-restricted kernels above the step functions use them too.
980
981/**
982 * Sound enclosure of a step-rounding function on an interval, given its
983 * point-rounding rule. If both endpoints round to the same integer the function
984 * is constant on the interval; otherwise it spans a half-integer jump and the
985 * result is `singular` carrying the enclosure `[round(lo), round(hi)]`
986 * (mirrors the Floor/Ceil enclosure discipline).

Callers 1

Calls 5

unwrapOrPropagateFunction · 0.90
okFunction · 0.90
enumerateInteger2Function · 0.85
absMethod · 0.65
roundMethod · 0.45

Tested by

no test coverage detected