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/research/atemporal/at0/model/at0_hamiltonian.c # 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 / research / atemporal / at0 / model / at0_hamiltonian.c` 80 lines ยท 3621 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 2 * Copyright 2026 Drake Stapleton (AIEN / aien-dev) 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 /* Hamiltonian construction: H_S = h0 I + hx X + hy Y + hz Z with its exact 18 * rational spectrum h0 +/- |h| and binary64 eigenvectors; H_total applied as 19 * H_C (x) I + I (x) H_S on the combined state. */ 20 #include "at0_model.h" 21 #include 22 #include 23 24 at0_status at0_hamiltonian_system(const at0_case *c, at0_system_hamiltonian *out) 25 { 26 if (!c || !out) return AT0_ERR_ARGUMENT; 27 memset(out, 0, sizeof *out); 28 at0_status st; 29 double h0 = at0_rat_to_double(c->h0), hx = at0_rat_to_double(c->hx); 30 double hy = at0_rat_to_double(c->hy), hz = at0_rat_to_double(c->hz); 31 double r = at0_rat_to_double(c->h_norm); 32 out->eig[0] = h0 - r; 33 out->eig[1] = h0 + r; 34 out->hs.m[0][0] = h0 + hz; out->hs.m[0][1] = hx - I * hy; 35 out->hs.m[1][0] = hx + I * hy; out->hs.m[1][1] = h0 - hz; 36 if (at0_rat_is_zero(c->h_norm)) { 37 /* H_S = h0 I: any basis is an eigenbasis; use the computational one */ 38 out->degenerate = 1; 39 out->vec[0].v[0] = 1.0; out->vec[0].v[1] = 0.0; 40 out->vec[1].v[0] = 0.0; out->vec[1].v[1] = 1.0; 41 return AT0_OK; 42 } 43 at0_i128 A, D; /* exact a = |h| + hz = A / D, never a reduced rational (its denominator can exceed 2^62) */ 44 if ((st = at0_exact_norm_plus_hz(c->hx, c->hy, c->hz, c->h_norm, &A, &D)) != AT0_OK) return st; 45 if (A == 0) { 46 /* h = (0, 0, -|h|): eigenvalue -|h| on |0>, +|h| on |1> */ 47 out->vec[0].v[0] = 1.0; out->vec[0].v[1] = 0.0; 48 out->vec[1].v[0] = 0.0; out->vec[1].v[1] = 1.0; 49 return AT0_OK; 50 } 51 double a = r + hz; 52 double norm = sqrt(2.0 * r * a); /* |(a, hx + i hy)| = sqrt(a^2 + hx^2 + hy^2) = sqrt(2 r a) */ 53 if (!(norm > 0.0) || !isfinite(norm)) return AT0_ERR_NONFINITE; 54 /* eigenvalue h0 - |h| */ 55 out->vec[0].v[0] = -(hx - I * hy) / norm; 56 out->vec[0].v[1] = a / norm; 57 /* eigenvalue h0 + |h| */ 58 out->vec[1].v[0] = a / norm; 59 out->vec[1].v[1] = (hx + I * hy) / norm; 60 return AT0_OK; 61 } 62 63 at0_status at0_hamiltonian_apply_total(const at0_case *c, const at0_system_hamiltonian *hs, 64 const at0_state *in, at0_state *out) 65 { 66 if (!c || !hs || !in || !out || in->clock_dim != c->clock_dim) return AT0_ERR_ARGUMENT; 67 at0_status st = at0_state_init(out, c->clock_dim); 68 if (st != AT0_OK) return st; 69 for (int j = 0; j < c->clock_dim; j++) { 70 double ej = at0_rat_to_double(c->clock_energies[j]); 71 double complex a0, a1; 72 if ((st = at0_state_get(in, j, 0, &a0)) != AT0_OK) return st; 73 if ((st = at0_state_get(in, j, 1, &a1)) != AT0_OK) return st; 74 double complex b0 = ej * a0 + hs->hs.m[0][0] * a0 + hs->hs.m[0][1] * a1; 75 double complex b1 = ej * a1 + hs->hs.m[1][0] * a0 + hs->hs.m[1][1] * a1; 76 if ((st = at0_state_set(out, j, 0, b0)) != AT0_OK) return st; 77 if ((st = at0_state_set(out, j, 1, b1)) != AT0_OK) return st; 78 } 79 return at0_state_check_finite(out); 80 }