Skip to content

Kraus[] arg nestedness not validated by several functions #234

@TysonRayJones

Description

@TysonRayJones

The Kraus[] operator accepts a list of matrices, e.g.

Kraus[ {   {{a,b},{c,d}},    {{e,f},{g,h}}   } ]

The passed structure depth must be 3. It is invalid to neglect the outer list, and pass e.g.

Kraus[   {{a,b},{c,d}},    {{e,f},{g,h}}   ]

or

Kraus[   {{a,b},{c,d}}   ]

Validation is not performed when the Kraus expression is formed, and is instead deferred to evaluation of functions ApplyCircuit (necessary for e.g. device specifications and circuit recompilation hijinks).

While functions like ApplyCircuit and DrawCircuit will fail when given the above invalid depth-2 Kraus arguments, other functions like CalcCircuitMatrix and CalcPauliTransferMatrix will proceed and silently output incorrect results! For example...

a = {{1, 2}, {3, 4}};
CalcCircuitMatrix[Subscript[Kraus, 0] @ a]    (* invalid *)
CalcCircuitMatrix[Subscript[Kraus, 0] @ {a}]  (* valid *)

will respectively output

{{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 10, 14}, {0, 0, 14, 20}}
{{1, 2, 2, 4}, {3, 4, 6, 8}, {3, 6, 4, 8}, {9, 12, 12, 16}}

The first is a silent error, eep!

Fix this! I would seek to make the depth 2 input valid, so that the outer list is completely optional, and the Kraus symbol can accept multiple arguments (as the distinct matrices).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions