core API
役割
arithmetic は luna-generic の上に解析 capability を積み増します。 平方根、対数、三角関数などの traits と、checked/contextual 算術境界を 定義するのが責務です。
Unchecked capability traits
Sqrt、Cbrt、RadicalExponentialLogarithmicPowerTrigonometric、InverseTrigonometricHyperbolic、InverseHyperbolicConstants
これらは src/elementary.mbt にあります。
Checked / contextual surface
共有型
FpClassRoundingModeArithmeticContextArithmeticErrorKindArithmeticError
Checked traits
SqrtCheckedDivCheckedCompareCheckedPowNatCheckedPowIntCheckedParseChecked
Enclosure 関係
ContainsOverlapsDefinitelyLtDefinitelyLeMaybeEq
これらは src/checked.mbt にあります。
同梱インスタンス
FloatとDoubleはKaida-Amethyst/mathを通じて広い elementary surface を実装します。FloatとDoubleはsqrt_checked、div_checked、compare_checked、pow_nat_checked、pow_int_checkedも実装します。BigIntと整数族は閉じた正確部分集合、特に整数Powerを実装します。
意味論メモ
- unchecked traits の定義域や branch は具体インスタンス依存です。
- 符号付き整数と
BigIntに対するPowerは非負指数を要求し、負指数は 実行時 abort になります。 ArithmeticContext::newは precision を最低1に補正します。PowNatCheckedはx^0を乗法単位元として扱い、0^0も含みます。- enclosure traits は関係であり、全順序ではありません。