luna-complex

Luna-Flow/luna-complex provides complex numbers for Luna Flow. The root package defines the generic type Complex[T], the ring T[i]/(i2+1)T[i]/(i^2 + 1) over any scalar T, with its arithmetic and luna-generic structure instances. The float_backend package adds the analytic functions of Complex[Double] (roots, logarithms, powers, trigonometric and hyperbolic functions and their inverses) with numerically stable formulas, and the capability traits for floating-point scalars.

This manual documents the code of version 0.2.0 (the version in moon.mod) on MoonBit 0.10.

Packages

PackageImport pathRolePages
coreLuna-Flow/luna-complexgeneric Complex[T]: construction, mutation, arithmetic, conjugation, structure instancesAPI · tutorial · design
float_backendLuna-Flow/luna-complex/float_backendanalytic functions of Complex[Double]; FloatingAnalyticScalar, FloatingSpecialValues, FloatingBackendScalarAPI · tutorial · design

The root package is documented under the name core. float_backend replaces the former double_ext package.

Reading paths

First steps. Read the core tutorial for arithmetic, then the float_backend tutorial for sqrt, log, sin and the other functions.

Using the library. Keep the core API and the float_backend API at hand; the latter states the branch, special-value and abort behaviour of every function, including the known deviations on the negative real axis.

Contributing. Read the core design for the algebra and the lawfulness of the instances, the float_backend design for the derivations of the stable formulas and the branch cuts, and the contribution guide.

Installation

moon add Luna-Flow/luna-complex@0.2.0
import {
  "Luna-Flow/luna-complex" @complex,
  "Luna-Flow/luna-complex/float_backend" @fb,
}

Toolchain

MoonBit moonc 0.10 or newer with moon.mod / moon.pkg manifests. The tests run on wasm-gc, wasm, js and native.

Validation

moon check --target all
moon test
moon info