Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/tests/estimation/test_est_v4.om # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / tests / estimation / test_est_v4.om` 586 lines ยท 18229 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note ESTIMATION v4 families unit tests in pure seeded OM-2 (port of tests/estimation/test_est_v4.c). 3 4 global g_checks ulong 1 5 global g_fail ulong 1 6 7 const V4_QU f64 100.0 8 9 text V4_PREFIX "test_est_v4: " 10 text V4_CHECKS " checks, " 11 text V4_FAILED " failures\n" 12 text V4_PASS "test_est_v4: PASS\n" 13 text V4_FAIL "test_est_v4: FAIL\n" 14 text V4_FTAG "FAIL tag=" 15 text V4_NL "\n" 16 17 fn chk cond bool tag ulong to void 18 put g_checks 0 add get g_checks 0 1 19 if not cond 20 put g_fail 0 add get g_fail 0 1 21 est_eputs V4_FTAG 22 est_putu_fd 2 tag 23 est_eputs V4_NL 24 end 25 end 26 27 fn chk_st got long want long tag ulong to void 28 chk eq got want tag 29 end 30 31 fn chk_near x f64 y f64 tol f64 tag ulong to void 32 chk le fabs sub x y tol tag 33 end 34 35 fn chk_rel x f64 y f64 rt f64 tag ulong to void 36 chk_near x y add mul rt fabs y 1.0e-12f64 tag 37 end 38 39 fn v4_rr to f64 40 ret div mul V4_QU V4_QU 12.0f64 41 end 42 43 fn mk_base f ulong p edit Est4Params to void 44 put p family f 45 if eq f EST4_G2_AR 46 put p dyn 0.6f64 47 else 48 put p dyn 4.0f64 49 end 50 put p q 2500.0f64 51 put p lam 0.7f64 52 put p nu 1.5f64 53 put p c 0.6f64 54 put p phi 0.9f64 55 put p nu_h 0.8f64 56 put p c_h 0.4f64 57 put p quantum V4_QU 58 end 59 60 fn copy_params src view Est4Params dst edit Est4Params to void 61 put dst family get src family 62 put dst dyn get src dyn 63 put dst q get src q 64 put dst lam get src lam 65 put dst nu get src nu 66 put dst c get src c 67 put dst phi get src phi 68 put dst nu_h get src nu_h 69 put dst c_h get src c_h 70 put dst quantum get src quantum 71 end 72 73 fn test_params to void 74 p = new Est4Params ulong 0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 75 b = new Est4Params ulong 0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 76 for f0 ulong 3 77 f = add f0 1 78 mk_base f p 79 chk_st est4_params_check view p EST_OK 100 80 copy_params view p b 81 put b family 4 82 chk_st est4_params_check view b EST_ERR_KIND 101 83 copy_params view p b 84 put b q 0.0f64 85 chk ne est4_params_check view b EST_OK 102 86 put b q est_nan 87 chk_st est4_params_check view b EST_ERR_NONFINITE 103 88 copy_params view p b 89 put b lam 1.0f64 90 chk ne est4_params_check view b EST_OK 104 91 put b lam -0.1f64 92 chk ne est4_params_check view b EST_OK 105 93 copy_params view p b 94 put b phi 0.0f64 95 chk ne est4_params_check view b EST_OK 106 96 put b phi 1.01f64 97 chk ne est4_params_check view b EST_OK 107 98 copy_params view p b 99 put b nu 0.0f64 100 chk ne est4_params_check view b EST_OK 108 101 copy_params view p b 102 put b c -1.0f64 103 chk ne est4_params_check view b EST_OK 109 104 copy_params view p b 105 put b nu_h 0.0f64 106 chk ne est4_params_check view b EST_OK 110 107 copy_params view p b 108 put b c_h 0.0f64 109 chk ne est4_params_check view b EST_OK 111 110 put b c_h est_inf 111 chk ne est4_params_check view b EST_OK 112 112 copy_params view p b 113 put b quantum 0.0f64 114 chk ne est4_params_check view b EST_OK 113 115 copy_params view p b 116 if eq f 2 117 put b dyn 1.0f64 118 else 119 put b dyn 0.0f64 120 end 121 chk ne est4_params_check view b EST_OK 114 122 put b dyn -0.1f64 123 chk ne est4_params_check view b EST_OK 115 124 end 125 s = new Est4State ulong 0 f64 0.0 ulong 0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 ulong 0 f64 0.0 ulong 0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 ulong 0 126 mk_base EST4_G1_LAG b 127 put b nu est_nan 128 chk ne est4_init view b s EST_OK 116 129 end 130 131 fn chk_dig_diff b view Est4Params d0 view uchar 32 to void 132 d1 = new uchar 32 0 133 chk_st est4_params_digest b d1 EST_OK 120 134 chk not est_digest_eq d0 view d1 121 135 end 136 137 fn test_digest to void 138 p = new Est4Params ulong 0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 139 b = new Est4Params ulong 0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 140 mk_base EST4_G1_LAG p 141 d0 = new uchar 32 0 142 d1 = new uchar 32 0 143 chk_st est4_params_digest view p d0 EST_OK 122 144 chk_st est4_params_digest view p d1 EST_OK 123 145 chk est_digest_eq view d0 view d1 124 146 copy_params view p b 147 put b dyn mul get p dyn 0.5f64 148 chk_dig_diff view b view d0 149 copy_params view p b 150 put b q mul get p q 0.5f64 151 chk_dig_diff view b view d0 152 copy_params view p b 153 put b lam mul get p lam 0.5f64 154 chk_dig_diff view b view d0 155 copy_params view p b 156 put b nu mul get p nu 0.5f64 157 chk_dig_diff view b view d0 158 copy_params view p b 159 put b c mul get p c 0.5f64 160 chk_dig_diff view b view d0 161 copy_params view p b 162 put b phi mul get p phi 0.5f64 163 chk_dig_diff view b view d0 164 copy_params view p b 165 put b nu_h mul get p nu_h 0.5f64 166 chk_dig_diff view b view d0 167 copy_params view p b 168 put b c_h mul get p c_h 0.5f64 169 chk_dig_diff view b view d0 170 copy_params view p b 171 put b quantum mul get p quantum 0.5f64 172 chk_dig_diff view b view d0 173 copy_params view p b 174 put b family EST4_G3_TWO 175 chk_dig_diff view b view d0 176 end 177 178 fn set_state s edit Est4State p view Est4Params x view f64 3 gv f64 to void 179 chk_st est4_init p s EST_OK 130 180 put s has_anchor 1 181 put s anchor 1000.0f64 182 for i ulong get s d 183 put s x i get x i 184 end 185 for i ulong 9 186 put s P i 0.0f64 187 end 188 put s g gv 189 put s gl gv 190 end 191 192 fn check_law s view Est4State h ulong m f64 V f64 gbar f64 to void 193 pr = new Est4Pred ulong 0 f64 0.0 f64 0.0 f64 0.0 194 chk_st est4_predict s h pr EST_OK 140 195 chk_rel get pr loc m 1.0e-12f64 141 196 if eq h 1 197 chk_rel get pr scale mul get s pv 4 fsqrt mul get s g V 1.0e-12f64 142 198 chk eq get pr nu get s pv 3 143 199 else 200 chk_rel get pr scale mul get s pv 7 fsqrt mul gbar V 1.0e-12f64 144 201 chk eq get pr nu get s pv 6 145 202 end 203 end 204 205 fn test_g1_analytic to void 206 p = new Est4Params ulong 0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 207 s = new Est4State ulong 0 f64 0.0 ulong 0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 ulong 0 f64 0.0 ulong 0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 ulong 0 208 mk_base EST4_G1_LAG p 209 x = new f64 3 0.0 210 put x 0 1000.0f64 211 put x 1 5000.0f64 212 set_state s view p view x 1.7f64 213 a = est_exp div -1.0f64 get p dyn 214 for h0 ulong EST_PRED_MAX_H 215 h = add h0 1 216 m = add get x 1 mul est_powu a h sub get x 0 get x 1 217 V = v4_rr 218 for j0 ulong h bound 66 219 j = add j0 1 220 d = sub 1.0f64 est_powu a sub h j 221 V = add V mul get p q mul d d 222 end 223 check_law view s h m V 1.7f64 224 end 225 end 226 227 fn g2_var r f64 h ulong q f64 to f64 228 V = v4_rr 229 for j0 ulong h bound 66 230 w = f64 0.0 231 lim = sub h add j0 1 232 for i ulong add lim 1 bound 66 233 w = add w est_powu r i 234 end 235 V = add V mul q mul w w 236 end 237 ret V 238 end 239 240 fn test_g2_one_rho r f64 to void 241 p = new Est4Params ulong 0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 242 s = new Est4State ulong 0 f64 0.0 ulong 0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 ulong 0 f64 0.0 ulong 0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 ulong 0 243 x = new f64 3 0.0 244 put x 0 2000.0f64 245 put x 1 300.0f64 246 mk_base EST4_G2_AR p 247 put p dyn r 248 set_state s view p view x 0.8f64 249 for h0 ulong EST_PRED_MAX_H 250 h = add h0 1 251 sm = f64 0.0 252 for i0 ulong h bound 66 253 sm = add sm est_powu r add i0 1 254 end 255 V = g2_var r h get p q 256 check_law view s h add get x 0 mul get x 1 sm V 0.8f64 257 end 258 end 259 260 fn test_g2_analytic to void 261 test_g2_one_rho 0.0f64 262 test_g2_one_rho 0.6f64 263 test_g2_one_rho 0.95f64 264 end 265 266 fn g3_var af f64 asv f64 h ulong q f64 to f64 267 V = v4_rr 268 for j0 ulong h bound 66 269 e = sub h add j0 1 270 c1 = mul EST4_G3_W sub 1.0f64 est_powu af e 271 c2 = mul sub 1.0f64 EST4_G3_W sub 1.0f64 est_powu asv e 272 cj = add c1 c2 273 V = add V mul q mul cj cj 274 end 275 ret V 276 end 277 278 fn g3_mean x view f64 3 af f64 asv f64 h ulong to f64 279 afh = est_powu af h 280 ash = est_powu asv h 281 m1 = add mul afh get x 0 mul mul sub 1.0f64 afh EST4_G3_W get x 2 282 m2 = add mul ash get x 1 mul mul sub 1.0f64 ash sub 1.0f64 EST4_G3_W get x 2 283 ret add m1 m2 284 end 285 286 fn test_g3_analytic to void 287 p = new Est4Params ulong 0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 288 s = new Est4State ulong 0 f64 0.0 ulong 0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 ulong 0 f64 0.0 ulong 0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 ulong 0 289 mk_base EST4_G3_TWO p 290 x = new f64 3 0.0 291 put x 0 700.0f64 292 put x 1 300.0f64 293 put x 2 4000.0f64 294 set_state s view p view x 2.5f64 295 af = est_exp div -1.0f64 get p dyn 296 asv = est_exp div -1.0f64 mul get p dyn EST4_TAU_RATIO 297 for h0 ulong EST_PRED_MAX_H 298 h = add h0 1 299 mm = g3_mean view x af asv h 300 V = g3_var af asv h get p q 301 check_law view s h mm V 2.5f64 302 end 303 end 304 305 fn test_scale_reversion to void 306 p = new Est4Params ulong 0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 307 s = new Est4State ulong 0 f64 0.0 ulong 0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 ulong 0 f64 0.0 ulong 0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 ulong 0 308 mk_base EST4_G1_LAG p 309 x = new f64 3 1000.0 310 set_state s view p view x 1.0f64 311 put s g 9.0f64 312 put s gl 1.0f64 313 one = new Est4Pred ulong 0 f64 0.0 f64 0.0 f64 0.0 314 ten = new Est4Pred ulong 0 f64 0.0 f64 0.0 f64 0.0 315 chk_st est4_predict view s 1 one EST_OK 200 316 chk_st est4_predict view s 10 ten EST_OK 201 317 gb = f64 0.0 318 for j ulong 10 319 gb = add gb add 1.0f64 mul 8.0f64 est_powu get p phi j 320 end 321 gb = div gb 10.0f64 322 a = est_exp div -1.0f64 get p dyn 323 V = v4_rr 324 for j0 ulong 10 325 d = sub 1.0f64 est_powu a sub 9 j0 326 V = add V mul get p q mul d d 327 end 328 chk_rel get ten scale mul get p c_h fsqrt mul gb V 1.0e-12f64 202 329 chk_rel get one scale mul get p c fsqrt mul 9.0f64 v4_rr 1.0e-12f64 203 330 put s pv 5 1.0f64 331 chk_st est4_predict view s 10 ten EST_OK 204 332 chk_rel get ten scale mul get p c_h fsqrt mul 9.0f64 V 1.0e-12f64 205 333 end 334 335 fn test_ramp_const to void 336 p = new Est4Params ulong 0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 337 s = new Est4State ulong 0 f64 0.0 ulong 0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 ulong 0 f64 0.0 ulong 0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 ulong 0 338 ten = new Est4Pred ulong 0 f64 0.0 f64 0.0 f64 0.0 339 for f0 ulong 3 340 mk_base add f0 1 p 341 chk_st est4_init view p s EST_OK 307 342 for t ulong 500 343 chk_st est4_update s 1 4200.0f64 EST_OK 308 344 end 345 for h0 ulong 64 346 chk_st est4_predict view s add h0 1 ten EST_OK 309 347 chk_near get ten loc 4200.0f64 1.0e-6f64 310 348 end 349 end 350 end 351 352 fn test_ramp_check_h10 s view Est4State r f64 to void 353 sm = f64 0.0 354 for k0 ulong 10 355 sm = add sm est_powu r add k0 1 356 end 357 one = new Est4Pred ulong 0 f64 0.0 f64 0.0 f64 0.0 358 chk_st est4_predict s 10 one EST_OK 305 359 chk_rel get one loc add get s x 0 mul get s x 1 sm 1.0e-12f64 306 360 end 361 362 fn test_ramp_check s view Est4State r f64 q f64 slope f64 to void 363 p11r2 = add mul mul r r get s P 3 q 364 m00 = add add get s P 0 mul mul 2.0f64 r get s P 1 p11r2 365 m01 = add mul r get s P 1 p11r2 366 S = add m00 v4_rr 367 m00 = div m00 S 368 m01 = div m01 S 369 S = add mul r m01 mul sub 1.0f64 r m00 370 p11r2 = div mul sub 1.0f64 r slope S 371 m01 = div sub slope mul m00 p11r2 r 372 one = new Est4Pred ulong 0 f64 0.0 f64 0.0 f64 0.0 373 chk_st est4_predict s 1 one EST_OK 302 374 chk_rel sub mul slope 3000.0f64 get one loc p11r2 1.0e-6f64 303 375 chk_rel get s x 1 m01 1.0e-6f64 304 376 test_ramp_check_h10 s r 377 end 378 379 fn test_ramp to void 380 p = new Est4Params ulong 0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 381 s = new Est4State ulong 0 f64 0.0 ulong 0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 ulong 0 f64 0.0 ulong 0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 ulong 0 382 mk_base EST4_G2_AR p 383 put p dyn 0.9f64 384 chk_st est4_init view p s EST_OK 300 385 for t ulong 3000 386 chk_st est4_update s 1 mul 100.0f64 f64 t EST_OK 301 387 end 388 test_ramp_check view s get p dyn get p q 100.0f64 389 test_ramp_const 390 end 391 392 fn test_missing_gap to void 393 p = new Est4Params ulong 0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 394 s = new Est4State ulong 0 f64 0.0 ulong 0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 ulong 0 f64 0.0 ulong 0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 ulong 0 395 bef = new Est4Pred ulong 0 f64 0.0 f64 0.0 f64 0.0 396 aft = new Est4Pred ulong 0 f64 0.0 f64 0.0 f64 0.0 397 dp = new EstDPred uchar 0 ulong 0 ulong 0 ulong 0 f64 0.0 f64 0.0 398 pmf = new f64 801 0.0 399 for f0 ulong 3 400 mk_base add f0 1 p 401 chk_st est4_init view p s EST_OK 420 402 for t ulong 40 403 chk_st est4_update s 1 add 2000.0f64 mul 100.0f64 f64 t EST_OK 421 404 end 405 chk_st est4_predict view s 6 bef EST_OK 422 406 g0 = get s g 407 gen = get s generation 408 for k ulong 5 409 chk_st est4_update s and k 1 est_nan EST_OK 423 410 end 411 chk eq get s gap 5 424 412 chk eq get s generation add gen 5 424 413 chk eq get s g g0 424 414 chk eq get s anchor 5900.0f64 424 415 chk_st est4_predict view s 1 aft EST_OK 425 416 chk_rel get aft loc get bef loc 1.0e-12f64 426 417 chk_st est4_dpred view s view aft dp pmf EST_OK 427 418 chk eq get dp horizon 6 428 419 chk_st est4_predict view s 59 aft EST_OK 429 420 chk_st est4_dpred view s view aft dp pmf EST_OK 430 421 chk_st est4_predict view s 60 aft EST_OK 431 422 chk_st est4_dpred view s view aft dp pmf EST_ERR_TIME 432 423 end 424 end 425 426 fn test_scale_and_missing to void 427 p = new Est4Params ulong 0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 428 s = new Est4State ulong 0 f64 0.0 ulong 0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 ulong 0 f64 0.0 ulong 0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 ulong 0 429 pr = new Est4Pred ulong 0 f64 0.0 f64 0.0 f64 0.0 430 mk_base EST4_G1_LAG p 431 chk_st est4_init view p s EST_OK 400 432 chk_st est4_predict view s 1 pr EST_ERR_STALE 401 433 chk_st est4_update s 1 3000.0f64 EST_OK 402 434 chk eq get s has_anchor 1 403 435 chk eq get s anchor 3000.0f64 403 436 chk eq get s gap 0 403 437 for t ulong 50 438 chk_st est4_update s 1 add 3000.0f64 mul 100.0f64 f64 rem t 3 EST_OK 404 439 end 440 g0 = get s g 441 gl0 = get s gl 442 chk_st est4_predict view s 1 pr EST_OK 405 443 sc = div get pr scale get p c 444 V1 = div mul sc sc g0 445 chk_st est4_update s 1 add get pr loc 900.0f64 EST_OK 406 446 gn = add mul get p lam g0 mul sub 1.0f64 get p lam div 810000.0f64 V1 447 chk_rel get s g gn 1.0e-12f64 407 448 gl0 = add mul EST4_GL_LAMBDA gl0 mul sub 1.0f64 EST4_GL_LAMBDA gn 449 chk_rel get s gl gl0 1.0e-12f64 408 450 g0 = get s g 451 chk_st est4_predict view s 1 pr EST_OK 409 452 sc = div get pr scale get p c 453 V1 = div mul sc sc g0 454 chk_st est4_update s 1 get pr loc EST_OK 410 455 gn = mul get p lam g0 456 gn = add gn mul sub 1.0f64 get p lam div v4_rr V1 457 chk_rel get s g gn 1.0e-12f64 411 458 chk_st est4_predict view s 0 pr EST_ERR_TIME 412 459 chk_st est4_predict view s 65 pr EST_ERR_TIME 413 460 test_missing_gap 461 end 462 463 fn chk_fast_one s view Est4State pr view Est4Pred dp view EstDPred pmf view f64 801 kk long to void 464 yv = add get s anchor mul f64 kk V4_QU 465 flh = new f64 2 0.0 466 lf = est4_fast_logp pr V4_QU get s anchor yv flh 467 ob = new EstPObs f64 0.0 ulong 0 uchar 0 468 iv = new EstPInnov ulong 0 ulong 0 long 0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 469 put ob val yv 470 put ob cls EST_OBS_OK 471 put ob evidence 0 uchar 1 472 chk_st est_dpred_score dp pmf view ob iv EST_OK 505 473 ep1 = est_exp get iv logp 474 ep2 = est_exp lf 475 chk_near ep1 ep2 add 1.0e-15f64 mul 1.0e-11f64 ep2 506 476 chk_near get iv logp lf 1.0e-6f64 507 477 chk_near get iv F_lo get flh 0 1.0e-9f64 508 478 chk_near get iv F_hi get flh 1 1.0e-9f64 509 479 end 480 481 fn test_pmf_fast_h s view Est4State h ulong far view long 10 to void 482 pr = new Est4Pred ulong 0 f64 0.0 f64 0.0 f64 0.0 483 dp = new EstDPred uchar 0 ulong 0 ulong 0 ulong 0 f64 0.0 f64 0.0 484 pmf = new f64 801 0.0 485 chk_st est4_predict s h pr EST_OK 502 486 chk_st est4_dpred s view pr dp pmf EST_OK 503 487 sum = f64 0.0 488 for i ulong EST_PRED_N 489 sum = add sum get pmf i 490 chk gt get pmf i 0.0f64 504 491 end 492 chk_near sum 1.0f64 1.0e-12f64 504 493 for ki ulong 131 494 kk = sub long ki 60 495 if ge ki 121 496 kk = get far sub ki 121 497 end 498 chk_fast_one s view pr view dp view pmf kk 499 end 500 end 501 502 fn test_pmf_sym to void 503 p = new Est4Params ulong 0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 504 s = new Est4State ulong 0 f64 0.0 ulong 0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 ulong 0 f64 0.0 ulong 0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 ulong 0 505 mk_base EST4_G1_LAG p 506 x = new f64 3 1000.0 507 set_state s view p view x 1.0f64 508 pr = new Est4Pred ulong 0 f64 0.0 f64 0.0 f64 0.0 509 dp = new EstDPred uchar 0 ulong 0 ulong 0 ulong 0 f64 0.0 f64 0.0 510 pmf = new f64 801 0.0 511 chk_st est4_predict view s 10 pr EST_OK 510 512 chk_st est4_dpred view s view pr dp pmf EST_OK 511 513 asym = f64 0.0 514 for i ulong EST_PRED_N 515 asym = fmax asym fabs sub get pmf i get pmf sub 800 i 516 end 517 chk lt asym 1.0e-15f64 512 518 chk eq get dp family 0 513 519 chk eq get dp horizon 10 513 520 chk eq get dp anchor 1000.0f64 513 521 chk eq get dp quantum V4_QU 513 522 end 523 524 fn test_pmf_vs_fast to void 525 st = ulong 0x5eed1234 526 p = new Est4Params ulong 0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 527 s = new Est4State ulong 0 f64 0.0 ulong 0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 ulong 0 f64 0.0 ulong 0 f64 0.0 f64 0.0 f64 0.0 f64 0.0 ulong 0 528 nus = new f64 4 0.0 529 put nus 0 0.6f64 530 put nus 1 1.0f64 531 put nus 2 1.5f64 532 put nus 3 5.0f64 533 far = new long 10 0 534 put far 0 -1000 535 put far 1 -450 536 put far 2 -401 537 put far 3 -400 538 put far 4 -399 539 put far 5 399 540 put far 6 400 541 put far 7 401 542 put far 8 450 543 put far 9 1000 544 for f0 ulong 3 545 mk_base add f0 1 p 546 for k ulong 4 547 put p nu get nus k 548 put p nu_h get nus sub 3 k 549 chk_st est4_init view p s EST_OK 500 550 for t ulong 120 551 st = add mul st `6364136223846793005` `1442695040888963407` 552 v = add 3000.0f64 mul 100.0f64 f64 rem shr st 33 7 553 if gt t 60 554 v = add v 2000.0f64 555 end 556 chk_st est4_update s 1 v EST_OK 501 557 end 558 test_pmf_fast_h view s 1 view far 559 test_pmf_fast_h view s 10 view far 560 end 561 end 562 test_pmf_sym 563 end 564 565 fn main to int 566 test_params 567 test_digest 568 test_g1_analytic 569 test_g2_analytic 570 test_g3_analytic 571 test_scale_reversion 572 test_ramp 573 test_scale_and_missing 574 test_pmf_vs_fast 575 est_puts V4_PREFIX 576 est_putu get g_checks 0 577 est_puts V4_CHECKS 578 est_putu get g_fail 0 579 est_puts V4_FAILED 580 if gt get g_fail 0 0 581 est_puts V4_FAIL 582 ret 1 583 end 584 est_puts V4_PASS 585 ret 0 586 end