interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / tools / estimation / est_replay_main.om

119 lines · 2568 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note Copyright 2026 Drake Stapleton (AIEN / aien-dev)
3note
4note tools/estimation/est_replay_main.om -- standalone est_replay CLI entry point.
5note Composed after: est_defs.om est_math.om est_types.om est_kf.om est_mix.om est_replay.om.
6
7text t_rpm_usage "usage: est_replay model q r file\n"
8text t_rpm_bad "bad model, q or r\n"
9text t_rpm_fail "replay failed: "
10text t_rpm_s1 "steps="
11text t_rpm_s2 " coasts="
12text t_rpm_s3 " leading_missing="
13text t_rpm_s4 " bad_value="
14text t_rpm_s5 " bad_t="
15
16note strtol(s, &e, 10) with *e == 0 required: leading white space and a sign are accepted, and an
17note empty argument is 0 (no conversion leaves e at the empty string's end)
18fn rpm_arg_i64 idx ulong dst edit long 1 to bool
19 buf = new uchar 16384 0
20 u = new ulong 1 0
21 n = argread idx buf 0 16384
22 if lt n 0
23 ret false
24 end
25 if eq n 0
26 put dst 0 0
27 ret true
28 end
29 nu = ulong n
30 i = ulong 0
31 while lt i nu bound 16384
32 if not er_is_space get buf i
33 break
34 end
35 i = add i 1
36 end
37 if ge i nu
38 ret false
39 end
40 if ne er_parse_i64 view buf i nu dst u 0
41 ret false
42 end
43 ret eq add i get u 0 nu
44end
45
46note strtod(s, &e) with *e == 0 required (an empty argument is 0, as above)
47fn rpm_arg_f64 idx ulong dst edit f64 1 to bool
48 buf = new uchar 16384 0
49 u = new ulong 1 0
50 n = argread idx buf 0 16384
51 if lt n 0
52 ret false
53 end
54 if eq n 0
55 put dst 0 f64 0.0
56 ret true
57 end
58 if ne er_parse_f64 view buf 0 ulong n dst u 0
59 ret false
60 end
61 ret eq get u 0 ulong n
62end
63
64fn main to int
65 a4 = new uchar 16384 0
66 mo = new long 1 0
67 qo = new f64 1 0.0
68 ro = new f64 1 0.0
69 ac = argcnt
70 if ne ac 5
71 est_eputs t_rpm_usage
72 ret 2
73 end
74 if not rpm_arg_i64 1 mo
75 est_eputs t_rpm_bad
76 ret 2
77 end
78 if not rpm_arg_f64 2 qo
79 est_eputs t_rpm_bad
80 ret 2
81 end
82 if not rpm_arg_f64 3 ro
83 est_eputs t_rpm_bad
84 ret 2
85 end
86 l4 = argread 4 a4 0 16384
87 mid = get mo 0
88 if or lt l4 0 or lt mid 0 gt mid 2
89 est_eputs t_rpm_bad
90 ret 2
91 end
92 if ne er_file_load 0 view a4 ulong l4 0
93 er_err_print_ref
94 ret 1
95 end
96 if ne est_replay_run 0 ER_ALL_LINES ulong mid get qo 0 get ro 0 0 0
97 ob_init 2
98 ob_t t_rpm_fail
99 er_rp_err_ob 0
100 ob_nl
101 ob_flush
102 ret 1
103 end
104 est_replay_write_stream 1 0 ulong mid
105 ob_init 2
106 ob_t t_rpm_s1
107 ob_u get g_rp_meta 0
108 ob_t t_rpm_s2
109 ob_u get g_rp_meta 3
110 ob_t t_rpm_s3
111 ob_u get g_rp_meta 2
112 ob_t t_rpm_s4
113 ob_u get g_rp_meta 4
114 ob_t t_rpm_s5
115 ob_u get g_rp_meta 5
116 ob_nl
117 ob_flush
118 ret 0
119end