Skip to content

Commit

Permalink
v0.13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
WrathfulSpatula committed Oct 19, 2024
1 parent 4873dc7 commit 6b79206
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "qook"
version = "0.12.0"
version = "0.13.0"
license = "MIT"
description = "qook - Pure Rust unitaryfund/qrack Wrapper"
documentation = "https://pyqrack.readthedocs.io/en/latest/"
Expand Down
2 changes: 2 additions & 0 deletions include/pinvoke_api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,13 +304,15 @@ MICROSOFT_QUANTUM_DECL void Hash(_In_ uintq sid, _In_ uintq n, _In_reads_(n) uin
MICROSOFT_QUANTUM_DECL bool TrySeparate1Qb(_In_ uintq sid, _In_ uintq qi1);
MICROSOFT_QUANTUM_DECL bool TrySeparate2Qb(_In_ uintq sid, _In_ uintq qi1, _In_ uintq qi2);
MICROSOFT_QUANTUM_DECL bool TrySeparateTol(_In_ uintq sid, _In_ uintq n, _In_reads_(n) uintq* q, _In_ double tol);
MICROSOFT_QUANTUM_DECL void Separate(_In_ uintq sid, _In_ uintq n, _In_reads_(n) uintq* q);
MICROSOFT_QUANTUM_DECL double GetUnitaryFidelity(_In_ uintq sid);
MICROSOFT_QUANTUM_DECL void ResetUnitaryFidelity(_In_ uintq sid);
MICROSOFT_QUANTUM_DECL void SetSdrp(_In_ uintq sid, _In_ double sdrp);
MICROSOFT_QUANTUM_DECL void SetNcrp(_In_ uintq sid, _In_ double ncrp);
MICROSOFT_QUANTUM_DECL void SetReactiveSeparate(_In_ uintq sid, _In_ bool irs);
MICROSOFT_QUANTUM_DECL void SetTInjection(_In_ uintq sid, _In_ bool iti);
MICROSOFT_QUANTUM_DECL void SetNoiseParameter(_In_ uintq sid, _In_ double np);
MICROSOFT_QUANTUM_DECL void Normalize(_In_ uintq sid);

#if !(FPPOW < 6 && !defined(ENABLE_COMPLEX_X2))
MICROSOFT_QUANTUM_DECL void TimeEvolve(_In_ uintq sid, _In_ double t, _In_ uintq n,
Expand Down
53 changes: 53 additions & 0 deletions src/qrack_simulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3187,6 +3187,24 @@ impl QrackSimulator {
Ok(result)
}

pub fn separate(&self, qs: Vec<u64>) -> Result<(), QrackError> {
// Force manual multi-qubits seperation
//
// Force separation as per `try_separate_tolerance`.
//
// Args:
// qs: list of qubits to be decomposed
//
// Raises:
// Runtimeerror: QrackSimulator raised an exception.

let mut _qs = qs.to_vec();
unsafe {
qrack_system::Separate(self.sid, _qs.len() as u64, _qs.as_mut_ptr());
}
self.check_error()
}

pub fn get_unitary_fidelity(&self) -> Result<f64, QrackError> {
// Get fidelity estimate
//
Expand Down Expand Up @@ -3289,4 +3307,39 @@ impl QrackSimulator {
}
self.check_error()
}

pub fn set_noise_parameter(self, np: f64) -> Result<(), QrackError> {
// Set noise parameter option
//
// If noisy simulation is on, then this set the depolarization
// parameter per qubit per gate. (Default is 0.01.)
//
// Args:
// np(f64): depolarizing noise parameter
//
// Raises:
// RuntimeError: QrackSimulator raised an exception.

unsafe {
qrack_system::SetNoiseParameter(self.sid, np);
}
self.check_error()
}

pub fn normalize(self) -> Result<(), QrackError> {
// Normalize the state
//
// This should never be necessary to use unless
// decompose() is "abused." ("Abusing" decompose()
// might lead to efficient entanglement-breaking
// channels, though.)
//
// Raises:
// RuntimeError: QrackSimulator raised an exception.

unsafe {
qrack_system::Normalize(self.sid);
}
self.check_error()
}
}
Loading

0 comments on commit 6b79206

Please sign in to comment.