README

CAIMEOX/moon_floating/ctx/mp does not have a README file

#
MPError

pub(all) suberror MPError {
ValueError(String)
DomainError(String)
PoleError(String)
ComplexResult(String)
ConvergenceError(String)
} derive(Eq,
Debug
)

impl Show for MPError

#
MPContext

High-level arbitrary-precision numerical context.
impl Show for MPContext

#
MPContext::abs

Absolute value with context rounding.

#
MPContext::augment

#alias(extend, deprecated="`extend` is deprecated, use `augment` instead")
fn MPContext::augment(self : MPContext, a : MpfMatrix, rhs : ArrayView[
RawMpf
]) -> MpfMatrix raise MPError

#
MPContext::chebyfit

Polynomial least-error fit on [a,b] using Chebyshev nodes.

Returns (coeffs, estimated_max_error) with coefficient order controlled by asc.

#
MPContext::cholesky

#
MPContext::cli_eval_division

fn MPContext::cli_eval_division(self : MPContext, numer : Int, denom : Int, dps? : Int) -> String raise MPError

Evaluate a simple integer division expression (numer/denom) in CLI mode.

#
MPContext::cli_eval_literal

fn MPContext::cli_eval_literal(self : MPContext, literal : String, dps? : Int) -> String raise MPError

Parse and evaluate a numeric literal in CLI compatibility mode.

This mirrors the non-interactive literal path used by mpmath's CLI tests.

#
MPContext::complex_gamma

Complex gamma function.

Raises MPError::PoleError at non-positive integers on the real axis.

#
MPContext::complex_log

Complex principal logarithm.

Equivalent to mpmath principal branch log(z). Explicitly rejects z=0 with MPError::PoleError.

#
MPContext::complex_pow

Complex power z^w on principal branches.

Matches mpmath's principal-branch definition and explicitly guards the ambiguous 0^w cases with non-positive/complex exponents.

#
MPContext::complex_sqrt

Complex principal square root.

Branch behavior follows mpmath principal square root convention.

#
MPContext::complex_to_string

fn MPContext::complex_to_string(self : MPContext, z :
RawMpc
, dps? : Int) -> String

Convert an mpc value to string in (re + im*j) style.

dps controls displayed digits. Behavior follows mpmath.nstr-style compact conversion for complex numbers.

#
MPContext::complex_zeta

Complex zeta continuation.

At s=1, returns pole error for standard zeta and log(2) for alternating zeta (alt=true), consistent with mpmath expectations.

#
MPContext::cond

#
MPContext::cosm

fn MPContext::cosm(self : MPContext, a : MpfMatrix, max_terms? : Int) -> MpfMatrix raise MPError

Matrix cosine via power series.

#
MPContext::diff

Numerical derivative d^n f(x) for unary real functions.

Semantics aligned with mpmath diff subset:
  • n=0 returns f(x).
  • n=1 supports one-sided derivative with direction.
  • n>=2 uses symmetric finite-difference formulas, and for higher order derivatives uses central stencil + Richardson correction.

#
MPContext::diff_partial3

Mixed partial derivative for 3-variable real functions.

orders=(nx, ny, nz) computes d^(nx+ny+nz) f / (dx^nx dy^ny dz^nz) at (x, y, z).

#
MPContext::differint

Fractional differintegral subset.

Currently supports a <= 0 (fractional integrals) for finite positive x.

#
MPContext::diffs

Return derivatives [f(x), f'(x), ..., f^(n)(x)].

This mirrors mpmath diffs for unary real functions.

#
MPContext::diffun

Build the unary function x -> d^n f(x).

Runtime derivative errors are mapped to nan, matching the permissive high-level behavior expected by mpmath-compatible helper paths.

#
MPContext::div

Context-aware floating-point division.

Raises MPError::PoleError for division-by-zero paths and maps other libmp errors into structured MPError.

#
MPContext::e1

Complex principal value of E1(x) for real x.

For negative reals this follows the principal branch E1(x) = -Ei(-x) - i*pi.

#
MPContext::e1_real

Real-valued E1(x) helper.

For x < 0, real E1 is not single-valued; this API reports MPError::ComplexResult to force callers to use complex principal value.

#
MPContext::expint

Exponential integral family wrapper:
  • gamma=false: E_n(x)
  • gamma=true: upper incomplete gamma form.

For negative real arguments in the non-gamma form, this function returns the complex principal value instead of failing, matching mpmath branch behavior.

#
MPContext::expm

fn MPContext::expm(self : MPContext, a : MpfMatrix, max_terms? : Int) -> MpfMatrix raise MPError

Matrix exponential via power series.

#
MPContext::eye

fn MPContext::eye(self : MPContext, n : Int) -> MpfMatrix raise MPError

#
MPContext::findroot

Scalar root finder for real functions.

  • With x1: secant method.
  • Without x1: Newton method with automatic secant fallback when slope is near zero. Raises MPError::ConvergenceError when the iteration budget is exhausted.

#
MPContext::findroot2

Two-dimensional nonlinear system solver using Newton iteration.

Solves:
  • f1(x,y)=0
  • f2(x,y)=0 with numerically estimated Jacobian from central differences. This is the current mpmath-like multidimensional findroot subset.

#
MPContext::findroot_interval

Bracketed root finder on a real interval using bisection.

Requires opposite signs at interval endpoints (or an endpoint root). This corresponds to mpmath findroot(..., solver='bisect') subset.

#
MPContext::format

fn MPContext::format(self : MPContext, x :
RawMpf
, format_spec : String, dps? : Int) -> String raise MPError

Format an mpf using mpmath/Python-like format mini-language subset.

format_spec is forwarded to @mpf.format_mpf (alignment, sign, percent, base/precision options implemented by libmp).

#
MPContext::fourier

Fourier coefficients on interval [a,b] up to order n.

Returns (c, s) where f(x) ~ c0 + sum_{k>=1}(c[k] cos(k*w*(x-a)) + s[k] sin(k*w*(x-a))).

#
MPContext::fprod

Product of an array of mpf values with context-aware rounding.

Mirrors mpmath fprod behavior for real inputs.

#
MPContext::fsum

High-precision compensated summation helper.

Mirrors mpmath fsum subset:
  • absolute=true: sum of absolute values.
  • squared=true: sum of squares (optionally after absolute). Uses extra working precision to reduce cancellation error.

#
MPContext::gamma

Euler gamma Gamma(x) for real arguments.

Pole/domain behavior is mapped to MPError::PoleError and MPError::DomainError, matching mpmath-style semantics.

#
MPContext::hessenberg

#
MPContext::hilbert

fn MPContext::hilbert(self : MPContext, n : Int) -> MpfMatrix raise MPError

#
MPContext::identify

Minimal symbolic identify subset for Stage-B migration.

Supported patterns:
  • small integer/rational values
  • exp(n), log(n) for small integers
  • linear/rational combinations against provided constants
  • basic builtins (pi, log(2), pi**4)

#
MPContext::inverse

fn MPContext::inverse(self : MPContext, a : MpfMatrix) -> MpfMatrix raise MPError

#
MPContext::invertlaplace

Inverse Laplace transform subset with method-compatible interface.

Implemented using a Stehfest core for positive real t; accepted methods: talbot, stehfest, dehoog, cohen.

#
MPContext::levin

Sequence acceleration entrypoint used by nsum/nprod.

Accepts a sequence of partial sums and returns (estimate, error). Supported methods: auto, levin, l, shanks, euler, sidi, u/v/t (aliases), and richardson / r.

#
MPContext::limit

Numerical limit for real-valued unary functions.

Supports finite points and x = +/-inf.

#
MPContext::ln

Natural logarithm ln(x) on reals.

Raises MPError::DomainError when called outside the real domain.

#
MPContext::make_complex

Build a complex number from real and imaginary mpf parts.

#
MPContext::make_float

fn MPContext::make_float(self : MPContext, s : String) ->
RawMpf
raise MPError

Parse a decimal string into an mpf using context precision.

Compatible with mpmath-style numeric spellings (inf, nan, exponents, signed literals). Parse failures are normalized to MPError::ValueError.

#
MPContext::make_int

Construct an mpf value from an integer using this context precision.

#
MPContext::matrix

fn MPContext::matrix(self : MPContext, rows : Int, cols : Int, fill? :
RawMpf
) -> MpfMatrix raise MPError

#
MPContext::matrix_add

fn MPContext::matrix_add(self : MPContext, a : MpfMatrix, b : MpfMatrix) -> MpfMatrix raise MPError

#
MPContext::matrix_add_scalar

#
MPContext::matrix_copy

fn MPContext::matrix_copy(self : MPContext, a : MpfMatrix) -> MpfMatrix

#
MPContext::matrix_div_scalar

#
MPContext::matrix_from_rows

#
MPContext::matrix_from_vector

#
MPContext::matrix_mul

fn MPContext::matrix_mul(self : MPContext, a : MpfMatrix, b : MpfMatrix) -> MpfMatrix raise MPError

#
MPContext::matrix_norm_1

#
MPContext::matrix_norm_fro

#
MPContext::matrix_norm_inf

#
MPContext::matrix_pos

fn MPContext::matrix_pos(self : MPContext, a : MpfMatrix) -> MpfMatrix

#
MPContext::matrix_pow

fn MPContext::matrix_pow(self : MPContext, a : MpfMatrix, n : Int) -> MpfMatrix raise MPError

#
MPContext::matrix_rsub_scalar

#
MPContext::matrix_scale

#
MPContext::matrix_set_slice

fn MPContext::matrix_set_slice(self : MPContext, a : MpfMatrix, src : MpfMatrix, row_start? : Int, row_end? : Int, col_start? : Int, col_end? : Int) -> Unit raise MPError

#
MPContext::matrix_set_slice_scalar

fn MPContext::matrix_set_slice_scalar(self : MPContext, a : MpfMatrix, value :
RawMpf
, row_start? : Int, row_end? : Int, col_start? : Int, col_end? : Int) -> Unit raise MPError

#
MPContext::matrix_slice

fn MPContext::matrix_slice(self : MPContext, a : MpfMatrix, row_start? : Int, row_end? : Int, col_start? : Int, col_end? : Int) -> MpfMatrix raise MPError

#
MPContext::matrix_sub

fn MPContext::matrix_sub(self : MPContext, a : MpfMatrix, b : MpfMatrix) -> MpfMatrix raise MPError

#
MPContext::matrix_sub_scalar

#
MPContext::matrix_sum

#
MPContext::matrix_transpose

fn MPContext::matrix_transpose(self : MPContext, a : MpfMatrix) -> MpfMatrix raise MPError

#
MPContext::mnorm

#
MPContext::neg

Unary negation with context rounding.

#
MPContext::nprod

fn MPContext::nprod(self : MPContext, f : (Int) ->
RawMpf
, start : Int, stop? : Int, algo? : String, tol? :
RawMpf
, max_terms? : Int) ->
RawMpf
raise MPError

Integer-indexed numerical products with optional acceleration.

Infinite products are evaluated through accelerated summation of logarithms and therefore require strictly positive finite terms.

#
MPContext::nsum

fn MPContext::nsum(self : MPContext, f : (Int) ->
RawMpf
, start : Int, stop? : Int, algo? : String, tol? :
RawMpf
, max_terms? : Int) ->
RawMpf
raise MPError

Integer-indexed numerical summation with optional convergence acceleration.

  • stop=Some(b): finite summation over [start, b].
  • stop=None: infinite tail, accelerated by method.

#
MPContext::ones

fn MPContext::ones(self : MPContext, rows : Int, cols? : Int) -> MpfMatrix raise MPError

#
MPContext::pade

Pade approximation from a power-series prefix a.

Returns numerator/denominator coefficient arrays (p, q) in ascending order.

#
MPContext::polyroots

fn MPContext::polyroots(self : MPContext, coeffs : ArrayView[
RawMpf
], asc? : Bool, max_steps? : Int, cleanup? : Bool, extraprec? : Int) -> Array[
RawMpc
] raise MPError

Polynomial roots for real coefficients.

#
MPContext::polyroots_error

fn MPContext::polyroots_error(self : MPContext, coeffs : ArrayView[
RawMpf
], asc? : Bool, max_steps? : Int, cleanup? : Bool, extraprec? : Int) -> (Array[
RawMpc
],
RawMpf
) raise MPError

#
MPContext::polyroots_with_init_error

fn MPContext::polyroots_with_init_error(self : MPContext, coeffs : ArrayView[
RawMpf
], roots_init : ArrayView[
RawMpf
], asc? : Bool, max_steps? : Int, cleanup? : Bool, extraprec? : Int) -> (Array[
RawMpc
],
RawMpf
) raise MPError

Polynomial roots with explicit initial guesses and error estimate.

#
MPContext::polyval

Polynomial evaluation helper aligned with mpmath polyval.

  • asc=true: coefficients are [a0, a1, ...].
  • asc=false: coefficients are [an, ..., a0].

#
MPContext::polyval_with_derivative

Polynomial evaluation with derivative (f(x), f'(x)).

#
MPContext::pow_int

Integer power x^n in the current context.

Uses fast exponentiation in libmp and propagates structured errors for invalid edge cases.

#
MPContext::precision

fn MPContext::precision(self : MPContext) -> Int

Return the context precision in bits.

#
MPContext::qr

#
MPContext::quad

Piecewise one-dimensional numerical integration over multiple breakpoints.

points=[x0, x1, ..., xn] integrates each adjacent segment and sums the results. Supports finite and selected infinite endpoint combinations.

#
MPContext::quadgl

One-dimensional numerical integration (Gauss-Legendre-style entrypoint).

This currently shares the same adaptive core as quadts, providing mpmath API compatibility for the migrated subset.

#
MPContext::quadts

One-dimensional numerical integration (tanh-sinh-style entrypoint).

Current implementation supports finite and infinite endpoints via variable transformations; API shape matches mpmath quadts subset.

#
MPContext::randmatrix

fn MPContext::randmatrix(self : MPContext, rows : Int, cols? : Int) -> MpfMatrix raise MPError

#
MPContext::rank

#
MPContext::round_mode

Return the context rounding mode.

#
MPContext::schur

fn MPContext::schur(self : MPContext, a : MpfMatrix, tol? :
RawMpf
, max_steps? : Int) -> (MpfMatrix, MpfMatrix) raise MPError

#
MPContext::sinm

fn MPContext::sinm(self : MPContext, a : MpfMatrix, max_terms? : Int) -> MpfMatrix raise MPError

Matrix sine via power series.

#
MPContext::sqrt

Principal square root on real inputs.

Raises MPError::DomainError for negative finite real values, matching mpmath real-domain semantics.

#
MPContext::summation

fn MPContext::summation(self : MPContext, f : (Int) ->
RawMpf
, start : Int, stop : Int, step? : Int) ->
RawMpf
raise MPError

Finite integer-index summation sum(f(k), k=start..stop, step).

#
MPContext::swap_row

fn MPContext::swap_row(self : MPContext, a : MpfMatrix, r0 : Int, r1 : Int) -> Unit raise MPError

#
MPContext::taylor

Return Taylor coefficients [a0, ..., an] around x, where a_k = f^(k)(x) / k!.

#
MPContext::to_string

fn MPContext::to_string(self : MPContext, x :
RawMpf
, dps? : Int) -> String raise MPError

Convert an mpf to a plain decimal string with optional dps.

This wraps @mpf.to_str_opts and follows mpmath's default user-facing conversion style for finite/special values.

#
MPContext::vector_norm

#
MPContext::zeros

fn MPContext::zeros(self : MPContext, rows : Int, cols? : Int) -> MpfMatrix raise MPError

#
MPContext::zeta

Riemann zeta zeta(s) (or alternating eta form when alt=true) on reals.

alt=true maps to mpmath's alternate zeta continuation behavior.

#
MpfMatrix

pub struct MpfMatrix {
rows : Int
cols : Int
data : Array[
RawMpf
]
} derive(Eq,
Debug
)

impl Show for MpfMatrix

#
MpfMatrix::get

#
MpfMatrix::get_at

fn MpfMatrix::get_at(self : MpfMatrix, r : Int, c : Int) ->
RawMpf
raise MPError

#
MpfMatrix::len

fn MpfMatrix::len(self : MpfMatrix) -> Int

#
MpfMatrix::set

fn MpfMatrix::set(self : MpfMatrix, r : Int, c : Int, v :
RawMpf
) -> Unit raise MPError

#
MpfMatrix::set_at

fn MpfMatrix::set_at(self : MpfMatrix, r : Int, c : Int, v :
RawMpf
) -> Unit raise MPError

#
MpfMatrix::vget

#
MpfMatrix::vset

fn MpfMatrix::vset(self : MpfMatrix, idx : Int, v :
RawMpf
) -> Unit raise MPError

#
PlotAxes

pub struct PlotAxes {
xlabel : String
ylabel : String
} derive(Eq,
Debug
)

Minimal axis container used by plot/cplot APIs.
impl Show for PlotAxes

#
cli_version

fn cli_version() -> String

Version string used by CLI-style integrations.

#
mbmath_version

let mbmath_version : String

Version reported by CLI integrations.

#
new

Create a high-level arbitrary-precision context.

This is the MoonBit counterpart of constructing an mpmath.mp-like runtime state. prec is binary precision (bits), and rounding controls final rounding for wrapper operations.

#
plot_axes

fn plot_axes() -> PlotAxes

Create an empty plot axes object.