qurs

Crates.ioqurs
lib.rsqurs
version0.2.0
sourcesrc
created_at2021-10-30 13:02:31.182416
updated_at2022-10-26 10:30:46.767928
descriptionQulacs implementation in Rust
homepage
repositoryhttps://github.com/QunaSys/qurs
max_upload_size
id474381
size1,937,197
Chusei Kiumi (CKiumi)

documentation

README

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());
}
Commit count: 69

cargo fmt