Skip to content

Probabilities can be truncated to 0.00000% in stateAsString(true) #86

Description

@DanBlackwell

Not necessarily an issue - perhaps an enhancement though. Due to the truncation (or maybe rounding - haven't looked behind the scenes) some probabilities (as well as vector values) for viable states end up being output as 0.

Example program:

const QuantumCircuit = require('quantum-circuit');

let qc = new QuantumCircuit();
let qasm = "OPENQASM 2.0;\n" +
           "include \"qelib1.inc\";\n" +
           "qreg r1[1];\n" +
           "rx(0.0000000001) r1;\n";

qc.importQASM(qasm, (error) => {
    qc.run();
    console.log(qc.stateAsString(true));
})

Output:

 1.00000000+0.00000000i|0>	100.00000%
 0.00000000+0.00000000i|1>	  0.00000%

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions