ruxla-kernels 0.1.0

Internal crate of ruxla (use the `ruxla` crate): semantics of ruxla's operations, shared by the native backend and the IR interpreter
Documentation
//! The coefficients of the special functions, copied verbatim from
//! StableHLO's `ChloLegalizeToStablehlo.cpp` and `jax._src.lax.special`.

// The literals are kept as written in the sources, with more digits than
// the types hold, so that they round exactly as there.
#![allow(clippy::excessive_precision, clippy::unreadable_literal)]

pub(super) const ERFC_P_F64: [f64; 9] = [
    2.46196981473530512524E-10,
    5.64189564831068821977E-1,
    7.46321056442269912687E0,
    4.86371970985681366614E1,
    1.96520832956077098242E2,
    5.26445194995477358631E2,
    9.34528527171957607540E2,
    1.02755188689515710272E3,
    5.57535335369399327526E2,
];
pub(super) const ERFC_Q_F64: [f64; 9] = [
    1.00000000000000000000E0,
    1.32281951154744992508E1,
    8.67072140885989742329E1,
    3.54937778887819891062E2,
    9.75708501743205489753E2,
    1.82390916687909736289E3,
    2.24633760818710981792E3,
    1.65666309194161350182E3,
    5.57535340817727675546E2,
];
pub(super) const ERFC_R_F64: [f64; 6] = [
    5.64189583547755073984E-1,
    1.27536670759978104416E0,
    5.01905042251180477414E0,
    6.16021097993053585195E0,
    7.40974269950448939160E0,
    2.97886665372100240670E0,
];
pub(super) const ERFC_S_F64: [f64; 7] = [
    1.00000000000000000000E0,
    2.26052863220117276590E0,
    9.39603524938001434673E0,
    1.20489539808096656605E1,
    1.70814450747565897222E1,
    9.60896809063285878198E0,
    3.36907645100081516050E0,
];
pub(super) const ERF_T_F64: [f64; 5] = [
    9.60497373987051638749E0,
    9.00260197203842689217E1,
    2.23200534594684319226E3,
    7.00332514112805075473E3,
    5.55923013010394962768E4,
];
pub(super) const ERF_U_F64: [f64; 6] = [
    1.00000000000000000000E0,
    3.35617141647503099647E1,
    5.21357949780152679795E2,
    4.59432382970980127987E3,
    2.26290000613890934246E4,
    4.92673942608635921086E4,
];
pub(super) const ERFC_P_F32: [f32; 9] = [
    2.326819970068386E-2,
    -1.387039388740657E-1,
    3.687424674597105E-1,
    -5.824733027278666E-1,
    6.210004621745983E-1,
    -4.944515323274145E-1,
    3.404879937665872E-1,
    -2.741127028184656E-1,
    5.638259427386472E-1,
];
pub(super) const ERFC_R_F32: [f32; 8] = [
    -1.047766399936249E+1,
    1.297719955372516E+1,
    -7.495518717768503E+0,
    2.921019019210786E+0,
    -1.015265279202700E+0,
    4.218463358204948E-1,
    -2.820767439740514E-1,
    5.641895067754075E-1,
];
pub(super) const ERF_T_F32: [f32; 7] = [
    7.853861353153693E-5,
    -8.010193625184903E-4,
    5.188327685732524E-3,
    -2.685381193529856E-2,
    1.128358514861418E-1,
    -3.761262582423300E-1,
    1.128379165726710E+0,
];
pub(super) const ERF_ALPHA_F32: [f32; 7] = [
    -2.72614225801306e-10,
    2.77068142495902e-08,
    -2.10102402082508e-06,
    -5.69250639462346e-05,
    -7.34990630326855e-04,
    -2.95459980854025e-03,
    -1.60960333262415e-02,
];
pub(super) const ERF_BETA_F32: [f32; 5] = [
    -1.45660718464996e-05,
    -2.13374055278905e-04,
    -1.68282697438203e-03,
    -7.37332916720468e-03,
    -1.42647390514189e-02,
];
pub(super) const I1E_A_F32: [f32; 17] = [
    9.38153738649577178388E-9,
    -4.44505912879632808065E-8,
    2.00329475355213526229E-7,
    -8.56872026469545474066E-7,
    3.47025130813767847674E-6,
    -1.32731636560394358279E-5,
    4.78156510755005422638E-5,
    -1.61760815825896745588E-4,
    5.12285956168575772895E-4,
    -1.51357245063125314899E-3,
    4.15642294431288815669E-3,
    -1.05640848946261981558E-2,
    2.47264490306265168283E-2,
    -5.29459812080949914269E-2,
    1.02643658689847095384E-1,
    -1.76416518357834055153E-1,
    2.52587186443633654823E-1,
];
pub(super) const I1E_B_F32: [f32; 7] = [
    -3.83538038596423702205E-9,
    -2.63146884688951950684E-8,
    -2.51223623787020892529E-7,
    -3.88256480887769039346E-6,
    -1.10588938762623716291E-4,
    -9.76109749136146840777E-3,
    7.78576235018280120474E-1,
];
pub(super) const I1E_A_F64: [f64; 29] = [
    2.77791411276104639959E-18,
    -2.11142121435816608115E-17,
    1.55363195773620046921E-16,
    -1.10559694773538630805E-15,
    7.60068429473540693410E-15,
    -5.04218550472791168711E-14,
    3.22379336594557470981E-13,
    -1.98397439776494371520E-12,
    1.17361862988909016308E-11,
    -6.66348972350202774223E-11,
    3.62559028155211703701E-10,
    -1.88724975172282928790E-9,
    9.38153738649577178388E-9,
    -4.44505912879632808065E-8,
    2.00329475355213526229E-7,
    -8.56872026469545474066E-7,
    3.47025130813767847674E-6,
    -1.32731636560394358279E-5,
    4.78156510755005422638E-5,
    -1.61760815825896745588E-4,
    5.12285956168575772895E-4,
    -1.51357245063125314899E-3,
    4.15642294431288815669E-3,
    -1.05640848946261981558E-2,
    2.47264490306265168283E-2,
    -5.29459812080949914269E-2,
    1.02643658689847095384E-1,
    -1.76416518357834055153E-1,
    2.52587186443633654823E-1,
];
pub(super) const I1E_B_F64: [f64; 25] = [
    7.51729631084210481353E-18,
    4.41434832307170791151E-18,
    -4.65030536848935832153E-17,
    -3.20952592199342395980E-17,
    2.96262899764595013876E-16,
    3.30820231092092828324E-16,
    -1.88035477551078244854E-15,
    -3.81440307243700780478E-15,
    1.04202769841288027642E-14,
    4.27244001671195135429E-14,
    -2.10154184277266431302E-14,
    -4.08355111109219731823E-13,
    -7.19855177624590851209E-13,
    2.03562854414708950722E-12,
    1.41258074366137813316E-11,
    3.25260358301548823856E-11,
    -1.89749581235054123450E-11,
    -5.58974346219658380687E-10,
    -3.83538038596423702205E-9,
    -2.63146884688951950684E-8,
    -2.51223623787020892529E-7,
    -3.88256480887769039346E-6,
    -1.10588938762623716291E-4,
    -9.76109749136146840777E-3,
    7.78576235018280120474E-1,
];
pub(super) const LANCZOS_COEFFICIENTS: [f64; 8] = [
    676.520368121885098567009190444019,
    -1259.13921672240287047156078755283,
    771.3234287776530788486528258894,
    -176.61502916214059906584551354,
    12.507343278686904814458936853,
    -0.13857109526572011689554707,
    9.984369578019570859563e-6,
    1.50563273514931155834e-7,
];
pub(super) const ZETA_COEFFS: [f64; 12] = [
    -7.1661652561756670113e18,
    1.8152105401943546773e17,
    -4.5979787224074726105e15,
    1.1646782814350067249e14,
    -2.950130727918164224e12,
    7.47242496e10,
    -1.8924375803183791606e9,
    47900160.0,
    -1209600.0,
    30240.0,
    -720.0,
    12.0,
];
pub(super) const I0E_A_F32: [f64; 18] = [
    -1.30002500998624804212E-8,
    6.04699502254191894932E-8,
    -2.67079385394061173391E-7,
    1.11738753912010371815E-6,
    -4.41673835845875056359E-6,
    1.64484480707288970893E-5,
    -5.75419501008210370398E-5,
    1.88502885095841655729E-4,
    -5.76375574538582365885E-4,
    1.63947561694133579842E-3,
    -4.32430999505057594430E-3,
    1.05464603945949983183E-2,
    -2.37374148058994688156E-2,
    4.93052842396707084878E-2,
    -9.49010970480476444210E-2,
    1.71620901522208775349E-1,
    -3.04682672343198398683E-1,
    6.76795274409476084995E-1,
];
pub(super) const I0E_B_F32: [f64; 7] = [
    3.39623202570838634515E-9,
    2.26666899049817806459E-8,
    2.04891858946906374183E-7,
    2.89137052083475648297E-6,
    6.88975834691682398426E-5,
    3.36911647825569408990E-3,
    8.04490411014108831608E-1,
];
pub(super) const I0E_A_F64: [f64; 30] = [
    -4.41534164647933937950E-18,
    3.33079451882223809783E-17,
    -2.43127984654795469359E-16,
    1.71539128555513303061E-15,
    -1.16853328779934516808E-14,
    7.67618549860493561688E-14,
    -4.85644678311192946090E-13,
    2.95505266312963983461E-12,
    -1.72682629144155570723E-11,
    9.67580903537323691224E-11,
    -5.18979560163526290666E-10,
    2.65982372468238665035E-9,
    -1.30002500998624804212E-8,
    6.04699502254191894932E-8,
    -2.67079385394061173391E-7,
    1.11738753912010371815E-6,
    -4.41673835845875056359E-6,
    1.64484480707288970893E-5,
    -5.75419501008210370398E-5,
    1.88502885095841655729E-4,
    -5.76375574538582365885E-4,
    1.63947561694133579842E-3,
    -4.32430999505057594430E-3,
    1.05464603945949983183E-2,
    -2.37374148058994688156E-2,
    4.93052842396707084878E-2,
    -9.49010970480476444210E-2,
    1.71620901522208775349E-1,
    -3.04682672343198398683E-1,
    6.76795274409476084995E-1,
];
pub(super) const I0E_B_F64: [f64; 25] = [
    -7.23318048787475395456E-18,
    -4.83050448594418207126E-18,
    4.46562142029675999901E-17,
    3.46122286769746109310E-17,
    -2.82762398051658348494E-16,
    -3.42548561967721913462E-16,
    1.77256013305652638360E-15,
    3.81168066935262242075E-15,
    -9.55484669882830764870E-15,
    -4.15056934728722208663E-14,
    1.54008621752140982691E-14,
    3.85277838274214270114E-13,
    7.18012445138366623367E-13,
    -1.79417853150680611778E-12,
    -1.32158118404477131188E-11,
    -3.14991652796324136454E-11,
    1.18891471078464383424E-11,
    4.94060238822496958910E-10,
    3.39623202570838634515E-9,
    2.26666899049817806459E-8,
    2.04891858946906374183E-7,
    2.89137052083475648297E-6,
    6.88975834691682398426E-5,
    3.36911647825569408990E-3,
    8.04490411014108831608E-1,
];
pub(super) const BASE_LANCZOS_COEFF: f64 = 0.99999999999980993227684700473478;
pub(super) const ERFC_MAXLOG_F64: f64 = 7.09782712893383996843E2;
pub(super) const ERFC_MAXLOG_F32: f64 = 88.72283905206835;
pub(super) const ERF_INV_LT5_F32: [f32; 9] = [
    2.81022636e-08,
    3.43273939e-07,
    -3.5233877e-06,
    -4.39150654e-06,
    0.00021858087,
    -0.00125372503,
    -0.00417768164,
    0.246640727,
    1.50140941,
];
pub(super) const ERF_INV_GE5_F32: [f32; 9] = [
    -0.000200214257,
    0.000100950558,
    0.00134934322,
    -0.00367342844,
    0.00573950773,
    -0.0076224613,
    0.00943887047,
    1.00167406,
    2.83297682,
];
pub(super) const ERF_INV_LT625_F64: [f64; 23] = [
    -3.6444120640178196996e-21,
    -1.685059138182016589e-19,
    1.2858480715256400167e-18,
    1.115787767802518096e-17,
    -1.333171662854620906e-16,
    2.0972767875968561637e-17,
    6.6376381343583238325e-15,
    -4.0545662729752068639e-14,
    -8.1519341976054721522e-14,
    2.6335093153082322977e-12,
    -1.2975133253453532498e-11,
    -5.4154120542946279317e-11,
    1.051212273321532285e-09,
    -4.1126339803469836976e-09,
    -2.9070369957882005086e-08,
    4.2347877827932403518e-07,
    -1.3654692000834678645e-06,
    -1.3882523362786468719e-05,
    0.0001867342080340571352,
    -0.00074070253416626697512,
    -0.0060336708714301490533,
    0.24015818242558961693,
    1.6536545626831027356,
];
pub(super) const ERF_INV_LT16_F64: [f64; 19] = [
    2.2137376921775787049e-09,
    9.0756561938885390979e-08,
    -2.7517406297064545428e-07,
    1.8239629214389227755e-08,
    1.5027403968909827627e-06,
    -4.013867526981545969e-06,
    2.9234449089955446044e-06,
    1.2475304481671778723e-05,
    -4.7318229009055733981e-05,
    6.8284851459573175448e-05,
    2.4031110387097893999e-05,
    -0.0003550375203628474796,
    0.00095328937973738049703,
    -0.0016882755560235047313,
    0.0024914420961078508066,
    -0.0037512085075692412107,
    0.005370914553590063617,
    1.0052589676941592334,
    3.0838856104922207635,
];
pub(super) const ERF_INV_GE16_F64: [f64; 17] = [
    -2.7109920616438573243e-11,
    -2.5556418169965252055e-10,
    1.5076572693500548083e-09,
    -3.7894654401267369937e-09,
    7.6157012080783393804e-09,
    -1.4960026627149240478e-08,
    2.9147953450901080826e-08,
    -6.7711997758452339498e-08,
    2.2900482228026654717e-07,
    -9.9298272942317002539e-07,
    4.5260625972231537039e-06,
    -1.9681778105531670567e-05,
    7.5995277030017761139e-05,
    -0.00021503011930044477347,
    -0.00013871931833623122026,
    1.0103004648645343977,
    4.8499064014085844221,
];