Sequential Quantum Gate Decomposer  v1.9.6
Powerful decomposition of general unitarias into one- and two-qubit gates gates
Classes | Functions | Variables
tests.gates.test_circuit Namespace Reference

Classes

class  TestApplyDerivateTo
 
class  TestApplyDerivateToF32
 
class  TestApplyFromRight
 
class  TestApplyToCombined
 
class  TestApplyToFloat32
 
class  TestApplyToFloat64
 
class  TestApplyToList
 
class  TestApplyToListF32
 
class  TestCircuitMisc
 
class  TestGateFusion
 
class  TestGeneralOperation
 
class  TestNestedCircuit
 
class  TestRectangularApplyRoutes
 

Functions

def _assert_state_close (a, b, rtol=1e-6)
 
def _assert_unitary_close (a, b, rtol=1e-6)
 
def _build_rx_rz_cnot_circuit (qbit_num)
 
def _identity (n, dtype=np.complex128)
 
def _params32 (n)
 
def _params64 (n)
 
def _random_state (n, dtype=np.complex128, seed=42)
 
def _random_unitary (dim, seed=123)
 
def _ref_matrix64 (circuit)
 

Variables

 QBIT_NUMS_ALL
 
 QBIT_NUMS_MEDIUM
 
 QBIT_NUMS_SMALL
 
 RECT_COLS_MAX
 

Detailed Description

Copyright 2020 Peter Rakyta, Ph.D.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Tests for qgd_Circuit: covers float32/float64 dispatch, state vector vs unitary,
apply_from_right, gate fusion (set_min_fusion), nested circuits, and boundary qubit
counts that stress AVX kernels (small kernel: qbit_num<14, TBB large kernel: qbit_num>=14).

Function Documentation

◆ _assert_state_close()

def tests.gates.test_circuit._assert_state_close (   a,
  b,
  rtol = 1e-6 
)
private
Assert two state vectors are the same up to a global phase.

Definition at line 83 of file test_circuit.py.

Here is the caller graph for this function:

◆ _assert_unitary_close()

def tests.gates.test_circuit._assert_unitary_close (   a,
  b,
  rtol = 1e-6 
)
private
Assert two unitaries are the same up to a global phase.

Definition at line 73 of file test_circuit.py.

Here is the caller graph for this function:

◆ _build_rx_rz_cnot_circuit()

def tests.gates.test_circuit._build_rx_rz_cnot_circuit (   qbit_num)
private
Build RX(0) → RZ(0) → CNOT(0,1) circuit if qbit_num >= 2, else RX → RZ.

Definition at line 56 of file test_circuit.py.

Here is the caller graph for this function:

◆ _identity()

def tests.gates.test_circuit._identity (   n,
  dtype = np.complex128 
)
private

Definition at line 30 of file test_circuit.py.

Here is the caller graph for this function:

◆ _params32()

def tests.gates.test_circuit._params32 (   n)
private
Float32 parameter array of length n.

Definition at line 49 of file test_circuit.py.

Here is the caller graph for this function:

◆ _params64()

def tests.gates.test_circuit._params64 (   n)
private
Float64 parameter array of length n.

Definition at line 42 of file test_circuit.py.

Here is the caller graph for this function:

◆ _random_state()

def tests.gates.test_circuit._random_state (   n,
  dtype = np.complex128,
  seed = 42 
)
private
Return a normalised random state vector of length n.

Definition at line 34 of file test_circuit.py.

Here is the caller graph for this function:

◆ _random_unitary()

def tests.gates.test_circuit._random_unitary (   dim,
  seed = 123 
)
private
Create a deterministic random unitary matrix using QR decomposition.

Definition at line 93 of file test_circuit.py.

Here is the caller graph for this function:

◆ _ref_matrix64()

def tests.gates.test_circuit._ref_matrix64 (   circuit)
private
Compute reference unitary via get_Matrix (float64).

Definition at line 67 of file test_circuit.py.

Here is the call graph for this function:

Variable Documentation

◆ QBIT_NUMS_ALL

tests.gates.test_circuit.QBIT_NUMS_ALL

Definition at line 112 of file test_circuit.py.

◆ QBIT_NUMS_MEDIUM

tests.gates.test_circuit.QBIT_NUMS_MEDIUM

Definition at line 111 of file test_circuit.py.

◆ QBIT_NUMS_SMALL

tests.gates.test_circuit.QBIT_NUMS_SMALL

Definition at line 110 of file test_circuit.py.

◆ RECT_COLS_MAX

tests.gates.test_circuit.RECT_COLS_MAX

Definition at line 113 of file test_circuit.py.