tensorcircuit.templates.blocks#
Shortcuts for measurement patterns on circuit
- tensorcircuit.templates.blocks.Bell_pair_block(c: Any, links: Optional[Sequence[Tuple[int, int]]] = None) Any [源代码]#
For each pair in links, the input product state |00> is transformed as (01>-|10>)
- tensorcircuit.templates.blocks.Grid2D_entangling(c: Any, coord: tensorcircuit.templates.graphs.Grid2DCoord, unitary: Any, params: Any, **kws: Any) Any [源代码]#
- tensorcircuit.templates.blocks.QAOA_block(c: Any, g: Any, paramzz: Any, paramx: Any, **kws: Any) Any [源代码]#
- tensorcircuit.templates.blocks.example_block(c: Any, param: Any, nlayers: int = 2, is_split: bool = False) Any [源代码]#
The circuit ansatz is firstly one layer of Hadamard gates and then we have
nlayers
blocks of \(e^{i\theta Z_iZ_{i+1}}\) two-qubit gate in ladder layout, following rx gate.- 参数
c (Circuit) -- The circuit
param (Tensor) -- paramter tensor with 2*nlayer*n elements
nlayers (int, optional) -- number of ZZ+RX blocks, defaults to 2
is_split (bool, optional) -- whether use SVD split to reduce ZZ gate bond dimension, defaults to False
- 返回
The circuit with example ansatz attached
- 返回类型
- tensorcircuit.templates.blocks.qft(c: Any, *index: int, do_swaps: bool = True, inverse: bool = False, insert_barriers: bool = False) Any [源代码]#
This function applies quantum fourier transformation (QFT) to the selected circuit lines
- 参数
c (Circuit) -- Circuit in
*index --
the indices of the circuit lines to apply QFT
do_swaps (bool) -- Whether to include the final swaps in the QFT
inverse (bool) -- If True, the inverse Fourier transform is constructed
insert_barriers (bool) -- If True, barriers are inserted as visualization improvement
- 返回
Circuit c
- 返回类型
- tensorcircuit.templates.blocks.state_centric(f: Callable[[...], Any]) Callable[[...], Any] [源代码]#
Function decorator wraps the function with the first input and output in the format of circuit, the wrapped function has the first input and the output as the state tensor.
- 参数
f (Callable[..., Circuit]) -- Function with the fist input and the output as
Circuit
object.- 返回
Wrapped function with the first input and the output as the state tensor correspondingly.
- 返回类型
Callable[..., Tensor]