mirror of
https://github.com/blackboxprogramming/BlackRoad-Operating-System.git
synced 2026-03-17 09:37:55 -05:00
Create comprehensive research-lab pack structure with mathematical and quantum computing modules from blackroad-prism-console: Math Modules: - hilbert_core.py: Hilbert space symbolic reasoning - collatz/: Distributed Collatz conjecture verification - linmath/: Linear mathematics C library - lucidia_math_forge/: Symbolic proof engine - lucidia_math_lab/: Experimental mathematics Quantum Modules: - lucidia_quantum/: Quantum core - quantum_engine/: Circuit simulation Experiments: - br_math/: Gödel gap, quantum experiments Includes pack.yaml manifest and comprehensive README. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
27 lines
503 B
Python
27 lines
503 B
Python
"""Utility metrics for quantum circuits."""
|
|
from __future__ import annotations
|
|
|
|
import torch
|
|
|
|
|
|
def expval(qdev) -> torch.Tensor:
|
|
return qdev.measure_all()
|
|
|
|
|
|
def kl_div(p: torch.Tensor, q: torch.Tensor) -> torch.Tensor:
|
|
p = p + 1e-9
|
|
q = q + 1e-9
|
|
return torch.sum(p * (torch.log(p) - torch.log(q)), dim=-1)
|
|
|
|
|
|
def energy(values: torch.Tensor) -> torch.Tensor:
|
|
return values.sum(dim=-1)
|
|
|
|
|
|
def depth(qdev) -> int:
|
|
return len(qdev.ops)
|
|
|
|
|
|
def two_qubit_count(qdev) -> int:
|
|
return 0
|