3 unstable releases

0.2.0 Oct 26, 2022
0.1.1 Aug 7, 2022
0.1.0 Oct 30, 2021

#602 in Math

Download history 55/week @ 2023-05-16 88/week @ 2023-05-23 88/week @ 2023-05-30 264/week @ 2023-06-06 260/week @ 2023-06-13 125/week @ 2023-06-20 40/week @ 2023-06-27 115/week @ 2023-07-04 64/week @ 2023-07-11 42/week @ 2023-07-18 72/week @ 2023-07-25 47/week @ 2023-08-01 42/week @ 2023-08-08 25/week @ 2023-08-15 44/week @ 2023-08-22 124/week @ 2023-08-29

243 downloads per month

MIT license

1MB
22K SLoC

C++ 13K SLoC // 0.1% comments C 7.5K SLoC // 0.2% comments Rust 797 SLoC // 0.0% comments Python 785 SLoC JavaScript 223 SLoC // 0.0% comments Shell 53 SLoC // 0.1% comments Batch 40 SLoC

Qurs

Qurs is an implementation of Qulacs written in Rust. Qurs currently supports only a single processor and depends only on Qulacs C code (qulacs/src/csim).

Qulacs: https://github.com/qulacs

Qurs is licensed under the MIT license.

Build

Qurs uses cc and bindgen to build Qulacs code. The requirements for bindgen are listed in https://rust-lang.github.io/rust-bindgen/requirements.html

cargo build

Example

use num::{Complex, Zero};
use qurs::gate::{ry_gate, x_gate};
use qurs::prelude::*;
use qurs::{self, StateVec};
use std::f64::consts::PI;

fn main() {
	const N: usize = 5;

	//With array
	let mut state = [Complex::zero(); 2usize.pow(N as u32)];
	assert_eq!(state.qubit_count(), N);
	// initialize to |00000>
	state.set_zero_state();
	// initialize to |00101>
	state.set_computational_basis(0b00101);
	// initialize with a random quantum state
	state.set_haar_random_state();
	// Apply x_gate for state
	x_gate(0, &mut state);
	// Rotate PI/2 with respect to Y
	let angle = PI / 2.0;
	ry_gate(0, angle, &mut state);

	//With StateVec
	let mut state = StateVec::new(N);
	assert_eq!(state.qubit_count(), N);
	state.set_zero_state();
	state.set_computational_basis(0b00101);
	state.set_haar_random_state();
	x_gate(0, state.as_mut());
	ry_gate(0, angle, state.as_mut());
}

Dependencies

~0.7–2.8MB
~54K SLoC