Arithmetic capability traits and checked analytic operations for LunaFlow numeric types, with default real-valued instances.
Dependencies
using @lg { trait Add, trait Mul }
fn hypot2[T : Add + Mul + Sqrt](x : T, y : T) -> T {
Sqrt::sqrt(x * x + y * y)
}
fn polar_x[T : Mul + Trigonometric](r : T, theta : T) -> T {
r * Trigonometric::cos(theta)
}
inspect(hypot2(3.0, 4.0), content="5")
inspect(
polar_x(2.0, Constants::pi() / 3.0),
content="1.0000000000000002",
)moon check
moon testpub(open) trait Cbrt {
fn cbrt(Self) -> Self
}pub(open) trait Constants {
fn pi() -> Self
fn tau() -> Self
fn e() -> Self
}pub(open) trait Exponential {
fn exp(Self) -> Self
fn exp2(Self) -> Self
}pub(open) trait Hyperbolic {
fn sinh(Self) -> Self
fn cosh(Self) -> Self
fn tanh(Self) -> Self
}pub(open) trait InverseHyperbolic {
fn asinh(Self) -> Self
fn acosh(Self) -> Self
fn atanh(Self) -> Self
}pub(open) trait InverseTrigonometric {
fn asin(Self) -> Self
fn acos(Self) -> Self
fn atan(Self) -> Self
fn atan2(Self, Self) -> Self
}impl InverseTrigonometric for Floatpub(open) trait Logarithmic {
fn ln(Self) -> Self
fn log2(Self) -> Self
fn log10(Self) -> Self
}pub(open) trait Power {
fn pow(Self, Self) -> Self
}pub(open) trait Sqrt {
fn sqrt(Self) -> Self
}pub(open) trait Trigonometric {
fn sin(Self) -> Self
fn cos(Self) -> Self
fn tan(Self) -> Self
}Arithmetic capability traits and checked analytic operations for LunaFlow numeric types, with default real-valued instances.
Dependencies