mqc

    Quantum computing library for MoonBit.

    quantum
    qubits
    quantum-simulation
    state-vector
    quantum-computing
    Download zip
    Author
    Version
    0.1.6
    License
    MIT
    Last updated
    2 hours ago
    Downloads
    42

    No dependencies

    #MQC

    Quantum computing library for MoonBit.

    #Getting Started

    Installation:
    moon add Arcelyth/mqc

    A simple example:
    ///|
    using @mqc {h, measure, type Circuit, type QubitId, type StateVectorSimulator}

    ///|
    fn main raise {
    let qubit = QubitId(0UL)
    let circuit = Circuit::from_op([h(qubit), measure([qubit], key="m")])
    println("Circuit:")
    println(circuit)

    let simulator = StateVectorSimulator::new()
    let result = simulator.run(circuit.compile(), repetitions=20)
    println("Results:")
    println(result)
    }

    output:
    Circuit: 0: ───H───M("m")─── Results: 01010000010101010011

    See more examples here.

    #LICENSE

    Channel

    A quantum channel defined by Kraus operators.

    The channel transforms a density matrix as follows.

    Circuit

    Represent a quantum circuit which shares the operation sequence.

    Complex

    A complex number. Components are immutable.

    Condition

    A predicate over the current shot. Implement this trait to compare digits across keys or to supply a different rule for selecting a branch.

    ConditionalEffect

    Execute the inner effect only when the measurement satisfies the condition.

    DensityMatrix

    A quantum state represented by a complex density matrix. For a Bell pair, the wire dimensions are [2, 2]. The basis order is 00, 01, 10, 11.

    The real and imaginary arrays store entries in row-major order. The imaginary entries are all zero in this example. For a matrix of dimension d, the flat index is

    DensityMatrixSimulator

    DensityMatrixState

    Mutable density-matrix execution data.

    Effect

    A quantum action on an ordered local wire shape such as Gate, Channel, and Program.

    An effect describes an operation independently of the physical wires it is applied to. Its local wire indices are mapped onto the enclosing operation's target wires when it is added to a program or circuit.

    ExecutionResult

    A backend's result for one or more experiments, in submission order.

    ExecutionStatus

    Completion of one experiment or a whole batch.

    ExperimentResult

    One execution's result.

    ForLoop

    A counted loop captures its body at construction.

    Gate

    An immutable unitary effect.

    IfElse

    A classical condition and the two instruction sequences it selects between. The branch bodies capture the circuits as they were when if_else was called.

    Instruction

    A circuit instruction uses logical wire IDs before compilation and integer wire indices afterwards. Only a quantum operation has target wires.

    LinearKernel

    A linear map from a local complex vector to one of the same size.

    MeasurementCondition

    Combine named measurement tests with Boolean operators.

    MeasurementRecord

    Measurement results available to a condition during one shot. Digits are returned in target order. Reading a key before its measurement raises InvalidCondition.

    NoiseModel

    Operation

    A circuit operation bound to distinct, ordered quantum IDs.

    Program

    QError

    Qid

    using @Arcelyth/mqc/circuit { trait Qid }

    Identifies a quantum object. Equal IDs must have the same, fixed dimension. Dimensions must be at least two.

    QuantumError

    using @Arcelyth/mqc/error { type QError as QuantumError }

    QubitId

    A logical qubit ID with no device position.

    QuditId

    Identifies a qudit, a quantum system with a finite-dimensional state space. The levels field specifies the dimension of its local Hilbert space.

    ResultData

    Named output data from one experiment. Only requested outputs are stored.

    Sampler

    A backend that samples a compiled program.

    SamplerResult

    Measurement results produced by sampling a quantum program. An if_else block uses as many columns as its wider arm. Unused trailing columns in the selected arm contain -1, outside the range of basis digits.

    SimulationState

    Mutable backend state. Copies must own independent mutable storage.

    SimulationStateBase

    Common data for backends that need randomness and measurement records.

    Simulator

    Execute programs using a backend state implementation.

    StateVector

    A quantum state represented by a complex state vector. For a Bell pair, the wire dimensions are [2, 2]. The basis order is 00, 01, 10, 11.

    The real array stores the four amplitudes shown above. The imaginary array contains zeros.

    StateVectorSimulator

    StateVectorState

    Mutable state-vector execution data.

    StepResult

    A state snapshot after the instruction at zero-based instruction_index.

    TrialResult

    The final backend state and actual measurement records for one execution.

    UnitaryKernel

    A linear kernel that preserves inner products.

    WhileLoop

    A measurement-controlled loop captures its body once. The iteration bound determines how many measurement columns the loop reserves in each shot.

    reset

    Reset the target qubit or qudit to its ground state. The wire can be used again by later operations in the same circuit.

    Source Files