luna-complex provides a generic Complex[T] core for algebraic complex arithmetic in LunaFlow, with Double-specific analytic and transcendental helpers split into the Luna-Flow/luna-complex/double_ext subpackage.
Complex[T]is a mutable struct with explicitre/imfields for in-place updates when desired.- The root package keeps only the generic core: construction, mutation, conjugation, identities, and basic arithmetic under algebraic trait constraints.
Luna-Flow/luna-complex/double_extcarries the currentComplex[Double]elementary, trigonometric, and hyperbolic implementation.- The
double_extinternals are now split between function-level APIs andDouble-specific numeric-stability helpers. double_extcurrently exposes free functions such as@double_ext.log(z)and@double_ext.sin(z). MoonBit does not allow this subpackage to add methods to the root-packageComplex[T]type directly.- This split is intentional so future real-function / transcendental trait constraints can replace the
Doubleextension layer cleanly.
- Source is organized into a generic core package plus a
double_extsubpackage forDouble-specific analytic behavior. double_extusesLuna-Flow/arithmeticfor the elementary-function capability surface while keepingDouble-only stability logic local to the subpackage.- Generic tests cover algebraic behavior, including nested values such as
Complex[Complex[Double]]. double_exttests cover both smoke behavior and representative stability regressions for the split-outDoublenumeric layer.- The repository now uses
moon.mod/moon.pkgmanifests and a publish workflow that requires explicit version confirmation.
using @core {type Complex}
let z : Complex[Double] = Complex::new(1.0, 2.0)
let nested : Complex[Complex[Double]] = Complex::new(z, Complex::zero())
let sum = z + Complex::one()
let product = z * z
let nested_inverse = nested.inv()using @core {type Complex}
let z : Complex[Double] = Complex::new(1.0, 2.0)
let w = @double_ext.polar(2.0, 0.7853981633974483)
let magnitude = @double_ext.abs(z)
let principal_log = @double_ext.log(z)
let inverse_sine = @double_ext.asin(z)- Root package
Luna-Flow/luna-complex: genericComplex[T], trait implementations, and basic algebraic operations. - Subpackage
Luna-Flow/luna-complex/double_ext:Complex[Double]helpers such aspolar,arg,abs,sqrt,log,sin,cos,asin,acosh,atanh, and related functions. - Internal numeric helpers in
double_extare intentionally not part of the public API surface. - If you need method-style transcendental APIs again later, that will require moving those definitions back into the root package or introducing a different wrapper design.
API documentation is available at mooncakes.io.
When browsing docs, check both the root package and the double_ext subpackage because the analytic Double APIs are no longer in the root package.
Contribution guidance is available in:
- English:
doc/en_US/CONTRIBUTING.md - 简体中文:
doc/zh_CN/CONTRIBUTING.md - 日本語:
doc/ja_JP/CONTRIBUTING.md
Useful local commands:
moon fmt
moon check
moon test --enable-coverage
moon info
./ready_to_pr.shready_to_pr.sh formats the code, runs checks, refreshes coverage artifacts, and regenerates pkg.generated.mbti.
Before publishing to mooncakes:
- Update
moon.modto a new unreleased version. - Update
README.mdif the package summary or release notes no longer match the repository state. - Run
moon checkandmoon test --enable-coverage. - Trigger the
publish-packageworkflow and enter the exact version frommoon.mod.
If mooncakes reports that the version already exists, bump the version before retrying.