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
omega-mv / om / arboris_gate_cubic.om
| 1 | note SPDX-License-Identifier: AGPL-3.0-only |
| 2 | note Experimental cubic Hermite gate on unit intervals of |x|. Table rows |
| 3 | note hold s(i), s'(i), 3*(s(i+1)-s(i))-2*s'(i)-s'(i+1), and |
| 4 | note 2*(s(i)-s(i+1))+s'(i)+s'(i+1), for s(z)=1/(1+exp(z)). |
| 5 | note Initialize the 256-byte table once at model load. Reference v1 remains separate. |
| 6 | fn arboris_cubic_table coeff edit uint 64 to void |
| 7 | put coeff 0 0x3f000000 |
| 8 | put coeff 1 0xbe800000 |
| 9 | put coeff 2 0x3b6131d3 |
| 10 | put coeff 3 0x3c7e09a0 |
| 11 | put coeff 4 0x3e89b2b1 |
| 12 | put coeff 5 0xbe4954a3 |
| 13 | put coeff 6 0x3d48b646 |
| 14 | put coeff 7 0xbb0b7ea4 |
| 15 | put coeff 8 0x3df420a9 |
| 16 | put coeff 9 0xbdd706e0 |
| 17 | put coeff 10 0x3d232799 |
| 18 | put coeff 11 0xbbd8cc44 |
| 19 | put coeff 12 0x3d4241a2 |
| 20 | put coeff 13 0xbd390b29 |
| 21 | put coeff 14 0x3ca15bae |
| 22 | put coeff 15 0xbb81c338 |
| 23 | put coeff 16 0x3c9357d1 |
| 24 | put coeff 17 0xbc90b161 |
| 25 | put coeff 18 0x3c049a25 |
| 26 | put coeff 19 0xbae1f958 |
| 27 | put coeff 20 0x3bdb4fb4 |
| 28 | put coeff 21 0xbbd9d7f1 |
| 29 | put coeff 22 0x3b4b49e8 |
| 30 | put coeff 23 0xba30b6c9 |
| 31 | put coeff 24 0x3b220bbc |
| 32 | put coeff 25 0xbb21a529 |
| 33 | put coeff 26 0x3a97d99c |
| 34 | put coeff 27 0xb984f3cf |
| 35 | put coeff 28 0x3a6ed39c |
| 36 | put coeff 29 0xba6e9be9 |
| 37 | put coeff 30 0x39e0b29c |
| 38 | put coeff 31 0xb8c54052 |
| 39 | put coeff 32 0x39afd1ef |
| 40 | put coeff 33 0xb9afc2d7 |
| 41 | put coeff 34 0x3925a997 |
| 42 | put coeff 35 0xb8119130 |
| 43 | put coeff 36 0x3901637b |
| 44 | put coeff 37 0xb9015f64 |
| 45 | put coeff 38 0x3873f589 |
| 46 | put coeff 39 0xb756712b |
| 47 | put coeff 40 0x383e6997 |
| 48 | put coeff 41 0xb83e6761 |
| 49 | put coeff 42 0x37b38b7d |
| 50 | put coeff 43 0xb69dd78b |
| 51 | put coeff 44 0x378c1a08 |
| 52 | put coeff 45 0xb78c196e |
| 53 | put coeff 46 0x37041d7f |
| 54 | put coeff 47 0xb5e84d54 |
| 55 | put coeff 48 0x36ce2a0f |
| 56 | put coeff 49 0xb6ce29bc |
| 57 | put coeff 50 0x36426acd |
| 58 | put coeff 51 0xb52aed80 |
| 59 | put coeff 52 0x3617b013 |
| 60 | put coeff 53 0xb617affd |
| 61 | put coeff 54 0x358f0bd1 |
| 62 | put coeff 55 0xb47b873f |
| 63 | put coeff 56 0x355f362c |
| 64 | put coeff 57 0xb55f3620 |
| 65 | put coeff 58 0x34d27efc |
| 66 | put coeff 59 0xb3b910c9 |
| 67 | put coeff 60 0x34a43ae2 |
| 68 | put coeff 61 0xb4a43ade |
| 69 | put coeff 62 0x341adfe7 |
| 70 | put coeff 63 0xb30829fc |
| 71 | end |
| 72 | |
| 73 | fn arboris_cubic_gate x f32 coeff view uint 64 to f32 |
| 74 | magnitude = fabs x |
| 75 | tail = f32 0 |
| 76 | if lt magnitude f32 16 |
| 77 | interval = ulong magnitude |
| 78 | offset = sub magnitude f32 interval |
| 79 | index = mul 4 interval |
| 80 | tail = fma offset f32of ulong get coeff add index 3 f32of ulong get coeff add index 2 |
| 81 | tail = fma offset tail f32of ulong get coeff add index 1 |
| 82 | tail = fma offset tail f32of ulong get coeff index |
| 83 | end |
| 84 | if lt x f32 0 |
| 85 | ret tail |
| 86 | end |
| 87 | ret sub f32 1 tail |
| 88 | end |