Skip to content

Commit

Permalink
Weak sampling (v0.8.0)
Browse files Browse the repository at this point in the history
  • Loading branch information
WrathfulSpatula committed Jul 16, 2023
1 parent 12fc4d3 commit e2706a3
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 4 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.7.0"
version = "0.8.0"
license = "MIT"
description = "qook - Pure Rust unitaryfund/qrack Wrapper"
documentation = "https://pyqrack.readthedocs.io/en/latest/"
Expand Down
5 changes: 4 additions & 1 deletion include/pinvoke_api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ MICROSOFT_QUANTUM_DECL uintq init_clone(_In_ uintq sid);
MICROSOFT_QUANTUM_DECL void destroy(_In_ uintq sid);
MICROSOFT_QUANTUM_DECL void seed(_In_ uintq sid, _In_ uintq s);
MICROSOFT_QUANTUM_DECL void set_concurrency(_In_ uintq sid, _In_ uintq p);
MICROSOFT_QUANTUM_DECL void qstabilizer_out_to_file(_In_ uintq sid, _In_ char* f);
MICROSOFT_QUANTUM_DECL void qstabilizer_in_from_file(_In_ uintq sid, _In_ char* f);

// pseudo-quantum
MICROSOFT_QUANTUM_DECL double Prob(_In_ uintq sid, _In_ uintq q);
Expand Down Expand Up @@ -236,6 +238,7 @@ MICROSOFT_QUANTUM_DECL void ResetUnitaryFidelity(_In_ uintq sid);
MICROSOFT_QUANTUM_DECL void SetSdrp(_In_ uintq sid, _In_ double sdrp);
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 SetStabilizerWeakSampling(_In_ uintq sid, _In_ bool sws);

#if !(FPPOW < 6 && !ENABLE_COMPLEX_X2)
MICROSOFT_QUANTUM_DECL void TimeEvolve(_In_ uintq sid, _In_ double t, _In_ uintq n,
Expand Down Expand Up @@ -269,7 +272,7 @@ MICROSOFT_QUANTUM_DECL double qneuron_learn_cycle(_In_ uintq nid, _In_ bool e);
MICROSOFT_QUANTUM_DECL void qneuron_learn(_In_ uintq nid, _In_ double eta, _In_ bool e, _In_ bool r);
MICROSOFT_QUANTUM_DECL void qneuron_learn_permutation(_In_ uintq nid, _In_ double eta, _In_ bool e, _In_ bool r);

MICROSOFT_QUANTUM_DECL uintq init_qcircuit();
MICROSOFT_QUANTUM_DECL uintq init_qcircuit(_In_ bool collapse);
MICROSOFT_QUANTUM_DECL uintq init_qcircuit_clone(_In_ uintq cid);
MICROSOFT_QUANTUM_DECL void destroy_qcircuit(_In_ uintq cid);
MICROSOFT_QUANTUM_DECL uintq get_qcircuit_qubit_count(_In_ uintq cid);
Expand Down
2 changes: 1 addition & 1 deletion src/qrack_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl QrackCircuit {
pub fn new() -> Self {
let cid;
unsafe {
cid = qrack_system::init_qcircuit();
cid = qrack_system::init_qcircuit(false);
}
Self{cid}
}
Expand Down
18 changes: 18 additions & 0 deletions src/qrack_simulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2469,6 +2469,24 @@ impl QrackSimulator {
self.check_error()
}

pub fn set_weak_sampling(&self, sws: bool) -> Result<(), QrackError> {
// Set reactive separation option
//
// If reactive separation is available, then this method turns it off/on.
// Note that reactive separation is on by default.
//
// Args:
// irs(bool): on/off for aggressive separation
//
// Raises:
// RuntimeError: QrackSimulator raised an exception.

unsafe {
qrack_system::SetStabilizerWeakSampling(self.sid, sws);
}
self.check_error()
}

pub fn set_t_injection(self, iti: bool) -> Result<(), QrackError> {
// Set t-injection option
//
Expand Down
12 changes: 11 additions & 1 deletion src/qrack_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub const FPPOW: u32 = 5;
pub const PSTRIDEPOW: u32 = 11;
pub const QBCAPPOW: u32 = 12;
pub const UINTPOW: u32 = 6;
pub const CPP_STD: u32 = 14;
pub type size_t = ::std::os::raw::c_ulong;
#[repr(C)]
#[repr(align(16))]
Expand Down Expand Up @@ -109,6 +110,12 @@ extern "C" {
extern "C" {
pub fn set_concurrency(sid: uintq, p: uintq);
}
extern "C" {
pub fn qstabilizer_out_to_file(sid: uintq, f: *mut ::std::os::raw::c_char);
}
extern "C" {
pub fn qstabilizer_in_from_file(sid: uintq, f: *mut ::std::os::raw::c_char);
}
extern "C" {
pub fn Prob(sid: uintq, q: uintq) -> f64;
}
Expand Down Expand Up @@ -560,6 +567,9 @@ extern "C" {
extern "C" {
pub fn SetTInjection(sid: uintq, iti: bool);
}
extern "C" {
pub fn SetStabilizerWeakSampling(sid: uintq, sws: bool);
}
extern "C" {
pub fn TimeEvolve(
sid: uintq,
Expand Down Expand Up @@ -621,7 +631,7 @@ extern "C" {
pub fn qneuron_learn_permutation(nid: uintq, eta: f64, e: bool, r: bool);
}
extern "C" {
pub fn init_qcircuit() -> uintq;
pub fn init_qcircuit(collapse: bool) -> uintq;
}
extern "C" {
pub fn init_qcircuit_clone(cid: uintq) -> uintq;
Expand Down

0 comments on commit e2706a3

Please sign in to comment.