Legacy compatibility entry points

oracq.applications.legacy

Open, bindable assembly examples for QFVM and QHAM.

class oracq.applications.legacy.QfvmInputs(position, reverse_slot, column_position, column_reverse_slot, flow, boundary, physical_entry, amplitude, residual, cell_width, slot_width, field_width, value_width)[source]

Bases: object

All open input declarations and layout constants of the QFVM assembly example.

Variables:
position
reverse_slot
column_position
column_reverse_slot
flow
boundary
physical_entry
amplitude
residual
cell_width
slot_width
field_width
value_width
oracq.applications.legacy.qfvm_inputs(name='Qfvm', *, cell_width=1, slot_width=1, field_width=1, value_width=2)[source]

Build all open input declarations of the QFVM assembly example.

Parameters:
  • name – Declaration name prefix, prepended to each slot module name.

  • cell_width – Bit width of spatial cell coordinates.

  • slot_width – Bit width of column slots.

  • field_width – Width of flux and boundary words.

  • value_width – Width of physical entry values.

Returns:

Input bundle with the six XOR databases, the physical-entry and amplitude open declarations, and the residual preparation.

Return type:

QfvmInputs

oracq.applications.legacy.qfvm_block_encoding(inputs, *, alpha=2.0)[source]

Compose the QFVM access isometries into a block encoding with the T_L†SWAP T_R structure.

Parameters:
  • inputs – Open input bundle built by qfvm_inputs.

  • alpha – Normalization constant written into the be_alpha attribute.

Returns:

Block encoding view with spatial cells as the target and the access-graph workspace as the signal.

Return type:

BlockEncoding

oracq.applications.legacy.qfvm_step(inputs, qlss, *, alpha=2.0)[source]

Hand the QFVM block encoding and residual preparation to the linear-system solver protocol.

Parameters:
  • inputs – Open input bundle built by qfvm_inputs.

  • qlss – Solver protocol accepting a block encoding and a state preparation and returning a StateOracle.

  • alpha – Normalization constant passed to the block encoding.

Returns:

QFVM stepping solution-state oracle produced by the solver protocol.

Return type:

StateOracle

oracq.applications.legacy.embed_block(a, global_width, row_offset, column_offset)[source]

Embed a block encoding at a diagonal-block position of a larger global matrix.

The target is first wrapped by subtracting the column offset and the padding region flagged on the high bits, then a is invoked and the row offset added to the whole register.

Parameters:
  • a – The embedded block encoding.

  • global_width – Bit width of the global target register.

  • row_offset – Row offset of the target block in the global matrix.

  • column_offset – Column offset of the target block in the global matrix.

Returns:

Block encoding with target width global_width and the same alpha as a.

Return type:

BlockEncoding

Raises:

ValidationError – The embedded block crosses the global matrix boundary.

oracq.applications.legacy.qham_lift_m1(linear, fold, *, h=-0.25, hfun=1.0)[source]

Lift the linear and folding terms into block encodings of the QHAM m=1 closed system.

The linear terms sit on diagonal blocks along the three coordinate blocks and two two-coordinate tensor-product terms, the folding terms appear on two coupling blocks with weight -h*hfun, and the whole is combined by LCU.

Parameters:
  • linear – Block encoding of the single-coordinate linear operator.

  • fold – Block encoding of the two-coordinate folding operator; its width must be twice that of linear.

  • h – Folding coupling constant.

  • hfun – Scaling factor of the folding coefficient; the product h*hfun serves as the coupling weight.

Returns:

LCU-combined block encoding of the lifted system.

Return type:

BlockEncoding

Raises:

ValidationError – The folding matrix is not padded to the two-coordinate space.

oracq.applications.legacy.qham_initial_vector(values)[source]

Build the initial-state amplitude tuple of the QHAM m=1 lifted system.

Arranged as [v, v, 0, v⊗v] and zero-padded to a power-of-two length for state preparation binding.

Parameters:

values – Sequence of physical-channel initial-state amplitudes.

Returns:

Complex amplitude tuple zero-padded to a power-of-two length.

Return type:

tuple[complex, …]

oracq.applications.legacy.qham_m1(linear, fold, initial, solver, *, final_time=0.1, h=-0.25, hfun=1.0, via_pde=False)[source]

Assemble and solve the QHAM m=1 lifted system, selecting the physical-channel subspace.

Parameters:
  • linear – Block encoding of the single-coordinate linear operator.

  • fold – Block encoding of the two-coordinate folding operator.

  • initial – Physical-channel initial-state preparation.

  • solver – Solver protocol for the lifted system; when via_pde is true it is called as (DiscretePDE, final time), otherwise as (block encoding, preparation, final time).

  • final_time – Final evolution time.

  • h – Folding coupling constant.

  • hfun – Scaling factor of the folding coefficient.

  • via_pde – Whether to wrap in DiscretePDE before handing over to the solver protocol.

Returns:

Solution-state oracle after selecting the physical subspace.

Return type:

StateOracle