diff options
| author | hachem <im@hachem.wtf> | 2025-12-10 11:11:53 +0100 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2025-12-10 11:11:53 +0100 |
| commit | 645846fe8e8ff185f57d5fd70c07c8d8d212bfc3 (patch) | |
| tree | 86b03099b980c580acf7df2aa28a2e9c79d4672e /libpsi-core/src/core/circuit.rs | |
| parent | 8066223d25be51627416fb7a05c5234d8c499e55 (diff) | |
[add]: composable runtime pipeline
Diffstat (limited to 'libpsi-core/src/core/circuit.rs')
| -rw-r--r-- | libpsi-core/src/core/circuit.rs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/libpsi-core/src/core/circuit.rs b/libpsi-core/src/core/circuit.rs index e5d7847..d0e4450 100644 --- a/libpsi-core/src/core/circuit.rs +++ b/libpsi-core/src/core/circuit.rs @@ -1,4 +1,4 @@ -use super::{CustomGate, QuantumState, Runtime}; +use super::{CustomGate, QuantumState, Runtime, RuntimeConfig}; use crate::{format_amplitude, format_probability, Vector}; use core::fmt; use std::sync::Arc; @@ -193,6 +193,15 @@ impl QuantumCircuit { self.computed_state.as_ref().unwrap() } + pub fn compute_with_config(&mut self, config: RuntimeConfig) -> &QuantumState { + if self.computed_state.is_some() { + return self.computed_state.as_ref().unwrap(); + } + + self.computed_state = Some(config.compute(self.num_qubits, &self.operations)); + self.computed_state.as_ref().unwrap() + } + pub fn state(&mut self) -> &QuantumState { self.compute() } @@ -201,6 +210,10 @@ impl QuantumCircuit { self.compute_with(runtime) } + pub fn state_with_config(&mut self, config: RuntimeConfig) -> &QuantumState { + self.compute_with_config(config) + } + pub fn h(&mut self, target: usize) -> &mut Self { self.operations.push(GateOp::H(target)); self.computed_state = None; |
