sp1-prover 5.0.8

SP1 is a performant, 100% open-source, contributor-friendly zkVM.
Documentation
use itertools::izip;

pub const INPUT_SIZE: usize = 90;

pub fn predict(input: &[usize; INPUT_SIZE / 2]) -> f64 {
    let input = [input.map(|x| x as f64), input.map(|x| 2f64.powi(x.try_into().unwrap()))].concat();
    // Asserts that the zip does not end early.
    assert_eq!(input.len(), INPUT_SIZE);
    izip!(input, &PARAMS.mean, &PARAMS.std, &PARAMS.coefs)
        .filter_map(|(x, &mu, &sigma, &b)| {
            let term = ((x - mu) / sigma) * b;
            (term.is_finite()).then_some(term)
        })
        .sum::<f64>() +
        PARAMS.intercept
}

pub(crate) struct Params<const N: usize> {
    pub mean: [f64; N],
    pub std: [f64; N],
    pub coefs: [f64; N],
    pub intercept: f64,
}

pub(crate) const APPROX_CYCLES_PER_RAW_GAS: f64 = 1492.48790519;

pub(crate) const OVERHEAD: f64 = 377.91;

pub(crate) const PARAMS: Params<INPUT_SIZE> = Params {
    mean: [
        18.089651214691067,
        19.678314098067972,
        0.11241471657208442,
        0.16610342408977874,
        0.062232991136899826,
        0.011222342664031116,
        0.0,
        0.031562838742587515,
        0.0569406363578397,
        0.0,
        0.006121277816744246,
        0.011222342664031116,
        0.6116814385002869,
        0.001721609385959319,
        0.001721609385959319,
        0.003443218771918638,
        0.010903526111075687,
        0.15162915258560225,
        0.0013390295224128036,
        0.19243767136389722,
        0.01428298157240324,
        0.007970413823885737,
        0.1613211757954473,
        0.03806669642287828,
        0.04941656570809157,
        0.0,
        9.641012561372186,
        1.4723586048587642,
        1.0083529936874323,
        18.061276541478033,
        15.332780717974877,
        15.034878530893325,
        14.99993623668941,
        14.744691704393292,
        16.50385768029076,
        16.791111394503602,
        15.498055219026972,
        15.669706051138174,
        15.498055219026972,
        9.641012561372186,
        0.4207740865905758,
        0.4554613275521265,
        17.33469361729261,
        18.035579927309826,
        16.0,
        1760253.5841356884,
        879919.9418478607,
        2362.2419180003826,
        3814.029458649493,
        57.131926289612956,
        0.24740164509341325,
        0.0,
        32.10814257476248,
        63.138940253777974,
        0.0,
        6.529363004527195,
        11.36109162787732,
        4650.620417012051,
        0.04182873174775234,
        0.04182873174775234,
        1.1222342664031117,
        8.977874131224894,
        174.20595549320922,
        0.2938213352037238,
        223.04304023464897,
        14.626793343110375,
        8.879933686156985,
        183.1731173882548,
        43.22438308997003,
        56.56060702671683,
        0.0,
        100716.7302174329,
        1308.8087738315373,
        139.72836829688197,
        1736541.027099407,
        218485.02250844863,
        197054.86960402984,
        195811.41771344768,
        125595.17031180259,
        528768.7100682268,
        719863.315947204,
        220031.69801696105,
        264880.5866224574,
        220031.69801696105,
        100716.7302174329,
        19282.057769559397,
        20781.134221768792,
        232823.74341643817,
        420282.39699037175,
        65536.0,
    ],
    std: [
        7.185413671836201,
        0.46712319834301286,
        1.4009591465489877,
        1.7234389168013917,
        0.9078311550888719,
        0.28028197283188055,
        0.0,
        0.6528048750279013,
        0.8848138901535522,
        0.0,
        0.2900518918023526,
        0.39054247474530956,
        3.1605546029505063,
        0.1109204895643801,
        0.1109204895643801,
        0.17491293070613714,
        0.3717307275305748,
        1.4448439987248158,
        0.11977041322017902,
        1.628611880329645,
        0.4403311411615897,
        0.332706091017571,
        1.487602220465997,
        0.7265329778062745,
        0.827178998034296,
        0.0,
        7.7031288622862295,
        4.171258628965202,
        3.016944070486259,
        7.1776454513877095,
        6.128937332017502,
        6.091545457668784,
        6.11845596595018,
        5.867991073305711,
        6.575759417105061,
        6.718066392276557,
        6.157338372334372,
        6.237795978054523,
        6.157338372334372,
        7.7031288622862295,
        2.8233763331197115,
        2.9482090283749764,
        2.824955436744104,
        1.3705752314257833,
        0.0,
        735923.7117484236,
        244907.08741286155,
        34387.232579135845,
        44001.17975936472,
        931.0176877827087,
        7.299847191884916,
        0.0,
        707.0905282561331,
        1007.8719922209924,
        0.0,
        322.0638731384559,
        420.2981751386446,
        24212.64466805616,
        3.06868970266315,
        3.0686897026631508,
        130.95479074750463,
        364.16036192502884,
        1677.3902701498555,
        32.960577558293856,
        1894.6271880562967,
        471.48531986642644,
        375.6739237065551,
        1717.8999743698937,
        837.3998649318718,
        959.8721375170222,
        0.0,
        126262.11739428798,
        4071.8389662509753,
        2597.7131723637035,
        747210.0471075532,
        152005.96006062094,
        180299.8406433669,
        178147.76116959084,
        77231.11374370914,
        311690.07023261784,
        469676.19828735146,
        91990.46396855295,
        148255.62145062396,
        91990.46396855295,
        126262.11739428798,
        139452.50223671072,
        143959.0439953704,
        66446.14564968774,
        441190.2675070037,
        0.0,
    ],
    coefs: [
        3.4394572520867,
        22.525353362109566,
        -10.090338675914923,
        -10.10478008699825,
        -1.4724570107647257,
        3.268324430205281,
        0.0,
        -4.630982448196246,
        -2.3839809326136208,
        0.0,
        0.10502160606864373,
        0.0856185165715647,
        32.134427548430736,
        2.0896409658630755,
        2.236213326613024,
        1.479742466919948,
        2.2987161438333197,
        -16.942603394377294,
        0.8940640171716817,
        -17.905414393423165,
        -8.58390581695243,
        1.0236036364907473,
        -11.854508171720484,
        -8.937984281732463,
        -5.3365117073997865,
        0.0,
        2.4752168865407764,
        -4.114874576581509,
        4.472360532623255,
        22.100415865174114,
        -22.851107896214632,
        -48.73613010064169,
        7.6038168534918436,
        -27.53739648101547,
        15.088373131176843,
        16.799183486787612,
        4.430796431293198,
        3.1608769958082332,
        4.430796431293227,
        2.4752168865401623,
        2.0637965495240937,
        -16.758389148094604,
        11.766633261229908,
        14.76686666257791,
        0.0,
        9.047673994631104,
        22.52535336203551,
        13.880959450302843,
        36.75178380770243,
        5.066167744942424,
        -1.827788082137982,
        0.0,
        8.636144115638078,
        4.913217602034882,
        0.0,
        1.5656015454530208,
        3.8725979844371627,
        101.35956896607317,
        -1.141731729918445,
        -1.0464056339756196,
        0.1912834042267063,
        1.2297738648015317,
        -13.732828954545042,
        -0.4566061857605234,
        -12.41481732206419,
        3.2404864241329854,
        -2.7037077040734583,
        -14.412650057316052,
        -2.3942039301877327,
        -2.9683124256459905,
        0.0,
        19.360142370373566,
        33.49009014354251,
        -0.4213681660329782,
        72.15776588470177,
        5.876110877345936,
        36.23803488104994,
        45.47410837729692,
        40.959535771363434,
        40.457739810022204,
        106.6265086543955,
        9.047673994635485,
        19.543107324297306,
        9.047673994635506,
        19.3601423703737,
        53.995150201829865,
        60.515898660880275,
        88.22315498928933,
        296.047004079781,
        0.0,
    ],
    intercept: 1549.6995043609004,
};