solmath 0.2.0

Deterministic fixed-point math and quantitative finance for Solana: Greeks, IV, American KBI, NIG, TWAP, and DeFi primitives.
Documentation
// @generated by scripts/generate_exp_coeffs.py; do not edit manually.

/// Split multiplier for converting a raw SCALE residual to Q63 without a
/// wide multiply. Together these approximate `2^64 / SCALE`.
pub(crate) const EXP_RAW_TO_Q63_HI: i64 = 18_446_744;
pub(crate) const EXP_RAW_TO_Q63_FRAC_Q28: i64 = 19_786_257;

/// `round((ln(2) - LN2_I / SCALE) * 2^96)`.
pub(crate) const EXP_LN2_RESIDUAL_Q96: i64 = -4_333_034_379_533_306;

/// `round((ln(2) / 32) * 2^63)`.
pub(crate) const EXP_STEP_Q63: i64 = 199_786_072_581_291_495;

pub(crate) const EXP_POLY_GUARD: i32 = 22;
pub(crate) const EXP_PHASE_BITS: i32 = 5;
pub(crate) const EXP_PHASES: usize = 1 << EXP_PHASE_BITS;

/// Degree-5 near-minimax coefficients for exp(r) on
/// `[-ln(2)/64, ln(2)/64]`, descending, at `SCALE * 2^22`.
pub(crate) const EXP_REMEZ_Q22: [i64; 6] = [
    34_952_728_565_492_453,
    174_763_691_635_588_304,
    699_050_666_653_069_566,
    2_097_151_999_954_914_874,
    4_194_304_000_000_000_252,
    4_194_304_000_000_000_294,
];

/// `round(2^(phase/32) * 2^62)`. These are reconstruction constants,
/// not sampled values of the exponential kernel.
pub(crate) const EXP2_PHASE_Q62: [i64; EXP_PHASES] = [
    4_611_686_018_427_387_904,
    4_712_668_792_719_003_884,
    4_815_862_801_830_788_490,
    4_921_316_465_500_308_116,
    5_029_079_263_719_320_435,
    5_139_201_759_950_318_048,
    5_251_735_624_851_448_219,
    5_366_733_660_520_940_721,
    5_484_249_825_272_419_512,
    5_604_339_258_952_723_100,
    5_727_058_308_814_112_983,
    5_852_464_555_953_009_676,
    5_980_616_842_327_661_685,
    6_111_575_298_367_424_380,
    6_245_401_371_186_603_363,
    6_382_157_853_416_100_552,
    6_521_908_912_666_391_106,
    6_664_720_121_635_655_541,
    6_810_658_488_877_194_079,
    6_959_792_490_240_559_659,
    7_112_192_101_001_162_095,
    7_267_928_828_693_418_961,
    7_427_075_746_662_858_866,
    7_589_707_528_352_920_109,
    7_755_900_482_342_532_474,
    7_925_732_588_150_922_155,
    8_099_283_532_826_439_817,
    8_276_634_748_336_579_668,
    8_457_869_449_776_733_335,
    8_643_072_674_415_606_502,
    8_832_331_321_595_618_838,
    9_025_734_193_507_008_925,
];