pdft.circuit.CircuitCode#
- class pdft.circuit.CircuitCode(program, inverse=False, slices=True, merge_diagonals=True)[source]#
Bases:
objectcode(*tensors, pic): a program applied topicof shape(2,) * (m + n).The callable a basis keeps as
codeandinv_code. The qubit axes are the firstm + n; for a stack of images useapply_program. It compares and hashes by its fields (program, direction, arithmetic), so two bases with the same circuit and arithmetic share one compiled applier and have equal pytree structures.Two options change the arithmetic and not the operator, and both are on by default:
slicescomputes the one-qubit gates without a contraction (see_one_qubit), andmerge_diagonalsapplies each run ofCPgates as one diagonal (see_walk). With both off a code runs the arithmetic of pdft 0.3.0, and on a CPU gives its numbers bit for bit. To get that on a basis, construct it withcode=dataclasses.replace(basis.code, slices=False, merge_diagonals=False)(for aBlockedBasis, construct its inner basis so); the inverse code follows.- __init__(program, inverse=False, slices=True, merge_diagonals=True)#
Methods
__init__(program[, inverse, slices, ...])Attributes