QMem-0.1.1 is not a library.
Visit the last successful build:
QMem-0.1.3
QMem
A quantum-inspired memory simulation library in Rust that allows bits to exist in superposition.
Overview
QMem is a Rust implementation of a quantum-inspired memory structure that simulates quantum bits (qubits). Unlike classical bits that can only be 0 or 1, QMem provides an abstraction where bits can exist in a superposition state (both 0 and 1 simultaneously) until they are measured.
Features
- 64-bit quantum-inspired memory simulation
- Bits can be in a definite state (0 or 1) or in superposition
- Measurement of superposition bits causes them to collapse to a random definite state
- Simple API for setting and measuring bits
Usage
Basic Example
use QMem;
Printing the State
QMem provides a print method to visualize the current state:
let mut q_array = new;
q_array.print;
// Output:
// State: 0000000000000000000000000000000000000000000000000000000000000000
// Superposition: 1111111111111111111111111111111111111111111111111111111111111111
API Reference
QMem::new() -> Self
Creates a new QMem instance with all 64 bits in superposition.
set_bit(&mut self, index: usize, value: Option<bool>)
Sets a bit at the specified index:
Some(true)- Sets the bit to 1Some(false)- Sets the bit to 0None- Places the bit in superposition
measure(&mut self, index: usize) -> bool
Measures a bit at the specified index:
- If the bit is in a definite state, returns that state
- If the bit is in superposition, randomly collapses it to 0 or 1 and returns the result
print(&self)
Displays the current state of the memory, showing:
- The definite states of all bits (0s and 1s)
- Which bits are in superposition
Implementation Details
QMem uses two 64-bit integers to track the state:
state: Stores the collapsed bit values (0 or 1)superposition: Bits set to 1 indicate superposition, bits set to 0 indicate a collapsed state