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_observable.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_observable.c` 53 lines ยท 2235 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 /* Observable probabilities: P(sigma = +/-1) = Tr(rho (I +/- sigma)/2), each 18 * sign computed directly from rho (never as one minus the other). */ 19 #include "at0_model.h" 20 #include 21 22 at0_status at0_pauli_matrix(at0_axis axis, at0_qubit_op *out) 23 { 24 if (!out) return AT0_ERR_ARGUMENT; 25 switch (axis) { 26 case AT0_AXIS_X: out->m[0][0] = 0; out->m[0][1] = 1; out->m[1][0] = 1; out->m[1][1] = 0; return AT0_OK; 27 case AT0_AXIS_Y: out->m[0][0] = 0; out->m[0][1] = -I; out->m[1][0] = I; out->m[1][1] = 0; return AT0_OK; 28 case AT0_AXIS_Z: out->m[0][0] = 1; out->m[0][1] = 0; out->m[1][0] = 0; out->m[1][1] = -1; return AT0_OK; 29 default: return AT0_ERR_ARGUMENT; 30 } 31 } 32 33 at0_status at0_observable_probability(const at0_qubit_op *rho, at0_axis axis, at0_sign sign, double *out) 34 { 35 if (!rho || !out) return AT0_ERR_ARGUMENT; 36 if (sign != AT0_SIGN_PLUS && sign != AT0_SIGN_MINUS) return AT0_ERR_ARGUMENT; 37 at0_qubit_op sigma; 38 at0_status st = at0_pauli_matrix(axis, &sigma); 39 if (st != AT0_OK) return st; 40 double sgn = sign == AT0_SIGN_PLUS ? 1.0 : -1.0; 41 /* projector Pi = (I + sgn * sigma) / 2 ; probability = Tr(rho Pi) = sum_ab rho[a][b] Pi[b][a] */ 42 double complex tr = 0.0; 43 for (int a = 0; a < AT0_SYSTEM_DIM; a++) { 44 for (int b = 0; b < AT0_SYSTEM_DIM; b++) { 45 double complex pi_ba = 0.5 * ((a == b ? 1.0 : 0.0) + sgn * sigma.m[b][a]); 46 tr += rho->m[a][b] * pi_ba; 47 } 48 } 49 double p = creal(tr); 50 if (!isfinite(p)) return AT0_ERR_NONFINITE; 51 *out = p; 52 return AT0_OK; 53 }