From 41b80bca32b680e6143feac6d1a06a38f4eb5d4c Mon Sep 17 00:00:00 2001 From: Agustin Borgna Date: Fri, 5 Jul 2024 08:52:56 +0100 Subject: [PATCH] fix: Use double precision when encoding matrix values --- src/circuit_json.rs | 2 +- src/opbox.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/circuit_json.rs b/src/circuit_json.rs index 9e50fb5..60d44a7 100644 --- a/src/circuit_json.rs +++ b/src/circuit_json.rs @@ -40,7 +40,7 @@ pub struct Bitstring { /// A 2D matrix. #[derive(Deserialize, Serialize, Clone, Debug, PartialEq, Eq, Hash)] #[serde(transparent)] -pub struct Matrix { +pub struct Matrix { /// A 2D vector of complex numbers. pub data: Vec>, } diff --git a/src/opbox.rs b/src/opbox.rs index ae8f30e..794e5a2 100644 --- a/src/opbox.rs +++ b/src/opbox.rs @@ -34,25 +34,25 @@ pub enum OpBox { Unitary1qBox { id: BoxID, /// 2x2 matrix of complex numbers - matrix: [[(f32, f32); 2]; 2], + matrix: [[(f64, f64); 2]; 2], }, /// Two-qubit operation defined as a unitary matrix. Unitary2qBox { id: BoxID, /// 4x4 matrix of complex numbers - matrix: [[(f32, f32); 4]; 4], + matrix: [[(f64, f64); 4]; 4], }, /// Three-qubit operation defined as a unitary matrix. Unitary3qBox { id: BoxID, /// 8x8 matrix of complex numbers - matrix: Box<[[(f32, f32); 8]; 8]>, + matrix: Box<[[(f64, f64); 8]; 8]>, }, /// Two-qubit operation defined in terms of a hermitian matrix and a phase. ExpBox { id: BoxID, /// 4x4 matrix of complex numbers - matrix: [[(f32, f32); 4]; 4], + matrix: [[(f64, f64); 4]; 4], /// Phase of the operation. phase: f64, },