|
Sequential Quantum Gate Decomposer
v1.9.6
Powerful decomposition of general unitarias into one- and two-qubit gates gates
|
Methods to calculate the cost function of the final optimization problem (supporting parallel computations). More...
#include "N_Qubit_Decomposition_Cost_Function.h"#include "QGDTypes.h"#include <vector>#include <algorithm>
Go to the source code of this file.
Classes | |
| struct | OSRTriplet< ComplexT > |
Macros | |
| #define | LAPACK_COL_MAJOR 102 |
| #define | LAPACK_ROW_MAJOR 101 |
| #define | USE_COL_MAJ |
| #define | USE_SDD |
Functions | |
| template<class MatrixT , class ComplexT > | |
| static void | accumulate_grad_for_cut (MatrixT &accum, const std::vector< double > &G, const std::vector< ComplexT > &Umat, const std::vector< ComplexT > &VTmat, int n, const std::vector< int > &A, int rank=-1) |
| double | avg_loss_for_rank (const std::vector< std::vector< double >> &cuts_S, int rank) |
| double | avg_tail_loss (const std::vector< std::vector< double >> &cuts_S, double rho=0.1) |
| template<class MatrixT , class ComplexT > | |
| static std::vector< ComplexT > | build_osr_matrix (const MatrixT &U, int n, const std::vector< int > &A, int &m_rows, int &m_cols) |
| static void | combinations_recursive (int n, int r, int start, std::vector< int > ¤t, std::vector< std::vector< int >> &out) |
| std::vector< std::vector< double > > | cuts_avg_rank_grad (const std::vector< std::vector< double >> &cuts_S, int rank, double Fnorm) |
| std::vector< std::vector< double > > | cuts_avg_tail_grad (const std::vector< std::vector< double >> &cuts_S, double Fnorm, double rho=0.1) |
| double | cuts_softmax_rank_cost (const std::vector< std::vector< double >> &cuts_S, int rank, double tau=1e-2) |
| std::vector< std::vector< double > > | cuts_softmax_rank_grad (const std::vector< std::vector< double >> &cuts_S, int rank, double Fnorm, double tau=1e-2) |
| double | cuts_softmax_tail_cost (const std::vector< std::vector< double >> &cuts_S, double rho=0.1, double tau=1e-2) |
| std::vector< std::vector< double > > | cuts_softmax_tail_grad (const std::vector< std::vector< double >> &cuts_S, double Fnorm, double rho=0.1, double tau=1e-2) |
| static int | extract_bits (int x, const std::vector< int > &pos) |
| double | get_cost_function (const Matrix &matrix, int trace_offset) |
| Call co calculate the cost function during the final optimization process. More... | |
| double | get_cost_function (const Matrix_float &matrix, int trace_offset) |
| double | get_cost_function_sum_of_squares (Matrix &matrix) |
| Matrix_real | get_cost_function_with_correction (const Matrix &matrix, int qbit_num, int trace_offset) |
| Call co calculate the cost function of the optimization process, and the first correction to the cost finction according to https://arxiv.org/pdf/2210.09191.pdf. More... | |
| Matrix_real_float | get_cost_function_with_correction (const Matrix_float &matrix, int qbit_num, int trace_offset) |
| Matrix_real | get_cost_function_with_correction2 (const Matrix &matrix, int qbit_num, int trace_offset) |
| Call co calculate the cost function of the optimization process, and the first correction to the cost finction according to https://arxiv.org/pdf/2210.09191.pdf. More... | |
| Matrix_real_float | get_cost_function_with_correction2 (const Matrix_float &matrix, int qbit_num, int trace_offset) |
| Matrix | get_deriv_osr_entanglement (Matrix &matrix, std::vector< std::vector< int >> &use_cuts, int rank, bool use_softmax) |
| Matrix_float | get_deriv_osr_entanglement (Matrix_float &matrix, std::vector< std::vector< int >> &use_cuts, int rank, bool use_softmax) |
| template<class MatrixT , class ComplexT , class RealT > | |
| static MatrixT | get_deriv_osr_entanglement_impl (MatrixT &matrix, std::vector< std::vector< int >> &use_cuts, int rank, bool use_softmax) |
| Matrix | get_deriv_sum_of_squares (Matrix &matrix) |
| double | get_hilbert_schmidt_test (Matrix &matrix) |
| Call co calculate the cost function of the optimization process according to https://arxiv.org/pdf/2210.09191.pdf. More... | |
| double | get_hilbert_schmidt_test (Matrix_float &matrix) |
| double | get_infidelity (Matrix &matrix) |
| Call to calculate infidelity. More... | |
| double | get_infidelity (Matrix_float &matrix) |
| double | get_osr_entanglement_test (Matrix &matrix, std::vector< std::vector< int >> &use_cuts, int rank, bool use_softmax) |
| double | get_osr_entanglement_test (Matrix_float &matrix, std::vector< std::vector< int >> &use_cuts, int rank, bool use_softmax) |
| template<class MatrixT , class ComplexT , class RealT > | |
| static double | get_osr_entanglement_test_impl (MatrixT &matrix, std::vector< std::vector< int >> &use_cuts, int rank, bool use_softmax) |
| QGD_Complex16 | get_trace (Matrix &matrix) |
| Call to calculate the real and imaginary parts of the trace. More... | |
| QGD_Complex16 | get_trace (Matrix_float &matrix) |
| Matrix | get_trace_with_correction (Matrix &matrix, int qbit_num) |
| Call co calculate the Hilbert Schmidt testof the optimization process, and the first correction to the cost finction according to https://arxiv.org/pdf/2210.09191.pdf. More... | |
| Matrix | get_trace_with_correction2 (Matrix &matrix, int qbit_num) |
| Call co calculate the Hilbert Schmidt testof the optimization process, and the first correction to the cost finction according to https://arxiv.org/pdf/2210.09191.pdf. More... | |
| static int | lapack_gesdd_dispatch (int lapack_layout, char jobz, int m, int n, QGD_Complex16 *a, int lda, double *s, QGD_Complex16 *u, int ldu, QGD_Complex16 *vt, int ldvt) |
| static int | lapack_gesdd_dispatch (int lapack_layout, char jobz, int m, int n, QGD_Complex8 *a, int lda, float *s, QGD_Complex8 *u, int ldu, QGD_Complex8 *vt, int ldvt) |
| int | LAPACKE_cgesdd (int matrix_order, char jobz, int m, int n, QGD_Complex8 *a, int lda, float *s, QGD_Complex8 *u, int ldu, QGD_Complex8 *vt, int ldvt) |
| int | LAPACKE_cgesvd (int matrix_order, char jobu, char jobvt, int m, int n, QGD_Complex8 *a, int lda, float *s, QGD_Complex8 *u, int ldu, QGD_Complex8 *vt, int ldvt, float *superb) |
| int | LAPACKE_zgesdd (int matrix_order, char jobz, int m, int n, QGD_Complex16 *a, int lda, double *s, QGD_Complex16 *u, int ldu, QGD_Complex16 *vt, int ldvt) |
| int | LAPACKE_zgesvd (int matrix_order, char jobu, char jobvt, int m, int n, QGD_Complex16 *a, int lda, double *s, QGD_Complex16 *u, int ldu, QGD_Complex16 *vt, int ldvt, double *superb) |
| static uint32_t | lg_down (uint32_t v) |
| static uint32_t | lg_up (uint32_t x) |
| double | logsumexp_smoothmax (const std::vector< double > &Lc, double tau=1e-2) |
| double | loss_for_rank (const std::vector< double > &S, int rank) |
| std::vector< double > | loss_for_rank_grad_diag (const std::vector< double > &S, int rank, double Fnorm) |
| static size_t | mat_idx (int row, int col, int nrows, int ncols) |
| static int | numerical_rank_osr (std::vector< double > S, double tol) |
| std::pair< int, double > | operator_schmidt_rank (const Matrix &U, int n, const std::vector< int > &A_qubits, double Fnorm, double tol) |
| std::pair< int, double > | operator_schmidt_rank (const Matrix_float &U, int n, const std::vector< int > &A_qubits, double Fnorm, double tol) |
| template<class ComplexT , class RealT > | |
| static std::vector< double > | osr (std::vector< ComplexT > &A, int m_rows, int m_cols, double Fnorm) |
| double | real_trace_conj_dot (Matrix &A, Matrix &B) |
| double | real_trace_conj_dot (Matrix_float &A, Matrix_float &B) |
| double | tail_loss (const std::vector< double > &S, int max_dyadic, double rho=0.1, double tol=1e-4) |
| std::vector< double > | tail_loss_grad_diag (const std::vector< double > &S, int max_dyadic, double Fnorm, double rho=0.1, double tol=1e-4) |
| template<class MatrixT , class ComplexT , class RealT > | |
| static OSRTriplet< ComplexT > | top_k_triplet_for_cut (const MatrixT &U, int q, const std::vector< int > &A, double Fnorm, int &m_rows, int &m_cols) |
| std::vector< std::vector< int > > | unique_cuts (int n) |
| double | weighted_loss_for_rank (const std::vector< double > &S, int rank, double rho=0.1, double tol=1e-4) |
Methods to calculate the cost function of the final optimization problem (supporting parallel computations).
Definition in file N_Qubit_Decomposition_Cost_Function.cpp.
| #define LAPACK_COL_MAJOR 102 |
Definition at line 30 of file N_Qubit_Decomposition_Cost_Function.cpp.
| #define LAPACK_ROW_MAJOR 101 |
Definition at line 29 of file N_Qubit_Decomposition_Cost_Function.cpp.
| #define USE_COL_MAJ |
Definition at line 59 of file N_Qubit_Decomposition_Cost_Function.cpp.
| #define USE_SDD |
Definition at line 58 of file N_Qubit_Decomposition_Cost_Function.cpp.
|
static |
Definition at line 810 of file N_Qubit_Decomposition_Cost_Function.cpp.

| double avg_loss_for_rank | ( | const std::vector< std::vector< double >> & | cuts_S, |
| int | rank | ||
| ) |
Definition at line 1037 of file N_Qubit_Decomposition_Cost_Function.cpp.


| double avg_tail_loss | ( | const std::vector< std::vector< double >> & | cuts_S, |
| double | rho = 0.1 |
||
| ) |
Definition at line 1155 of file N_Qubit_Decomposition_Cost_Function.cpp.


|
static |
Definition at line 773 of file N_Qubit_Decomposition_Cost_Function.cpp.

|
static |
Definition at line 959 of file N_Qubit_Decomposition_Cost_Function.cpp.

| std::vector<std::vector<double> > cuts_avg_rank_grad | ( | const std::vector< std::vector< double >> & | cuts_S, |
| int | rank, | ||
| double | Fnorm | ||
| ) |
Definition at line 1076 of file N_Qubit_Decomposition_Cost_Function.cpp.


| std::vector<std::vector<double> > cuts_avg_tail_grad | ( | const std::vector< std::vector< double >> & | cuts_S, |
| double | Fnorm, | ||
| double | rho = 0.1 |
||
| ) |
Definition at line 1201 of file N_Qubit_Decomposition_Cost_Function.cpp.


| double cuts_softmax_rank_cost | ( | const std::vector< std::vector< double >> & | cuts_S, |
| int | rank, | ||
| double | tau = 1e-2 |
||
| ) |
Definition at line 1047 of file N_Qubit_Decomposition_Cost_Function.cpp.


| std::vector<std::vector<double> > cuts_softmax_rank_grad | ( | const std::vector< std::vector< double >> & | cuts_S, |
| int | rank, | ||
| double | Fnorm, | ||
| double | tau = 1e-2 |
||
| ) |
Definition at line 1097 of file N_Qubit_Decomposition_Cost_Function.cpp.


| double cuts_softmax_tail_cost | ( | const std::vector< std::vector< double >> & | cuts_S, |
| double | rho = 0.1, |
||
| double | tau = 1e-2 |
||
| ) |
Definition at line 1168 of file N_Qubit_Decomposition_Cost_Function.cpp.


| std::vector<std::vector<double> > cuts_softmax_tail_grad | ( | const std::vector< std::vector< double >> & | cuts_S, |
| double | Fnorm, | ||
| double | rho = 0.1, |
||
| double | tau = 1e-2 |
||
| ) |
Definition at line 1219 of file N_Qubit_Decomposition_Cost_Function.cpp.


Definition at line 751 of file N_Qubit_Decomposition_Cost_Function.cpp.

Call co calculate the cost function during the final optimization process.
| matrix | The square shaped complex matrix from which the cost function is calculated. |
| trace_offset | The offset in the first columns from which the "trace" is calculated. In this case Tr(A) = sum_(i-offset=j) A_{ij} |
Definition at line 73 of file N_Qubit_Decomposition_Cost_Function.cpp.

| double get_cost_function | ( | const Matrix_float & | matrix, |
| int | trace_offset | ||
| ) |
Definition at line 164 of file N_Qubit_Decomposition_Cost_Function.cpp.
| double get_cost_function_sum_of_squares | ( | Matrix & | matrix | ) |
Definition at line 443 of file N_Qubit_Decomposition_Cost_Function.cpp.

| Matrix_real get_cost_function_with_correction | ( | const Matrix & | matrix, |
| int | qbit_num, | ||
| int | trace_offset | ||
| ) |
Call co calculate the cost function of the optimization process, and the first correction to the cost finction according to https://arxiv.org/pdf/2210.09191.pdf.
| matrix | The square shaped complex matrix from which the cost function is calculated. |
| qbit_num | The number of qubits |
Definition at line 191 of file N_Qubit_Decomposition_Cost_Function.cpp.


| Matrix_real_float get_cost_function_with_correction | ( | const Matrix_float & | matrix, |
| int | qbit_num, | ||
| int | trace_offset | ||
| ) |
Definition at line 254 of file N_Qubit_Decomposition_Cost_Function.cpp.

| Matrix_real get_cost_function_with_correction2 | ( | const Matrix & | matrix, |
| int | qbit_num, | ||
| int | trace_offset | ||
| ) |
Call co calculate the cost function of the optimization process, and the first correction to the cost finction according to https://arxiv.org/pdf/2210.09191.pdf.
| matrix | The square shaped complex matrix from which the cost function is calculated. |
| qbit_num | The number of qubits |
Definition at line 295 of file N_Qubit_Decomposition_Cost_Function.cpp.


| Matrix_real_float get_cost_function_with_correction2 | ( | const Matrix_float & | matrix, |
| int | qbit_num, | ||
| int | trace_offset | ||
| ) |
Definition at line 406 of file N_Qubit_Decomposition_Cost_Function.cpp.

| Matrix get_deriv_osr_entanglement | ( | Matrix & | matrix, |
| std::vector< std::vector< int >> & | use_cuts, | ||
| int | rank, | ||
| bool | use_softmax | ||
| ) |
Definition at line 1441 of file N_Qubit_Decomposition_Cost_Function.cpp.

| Matrix_float get_deriv_osr_entanglement | ( | Matrix_float & | matrix, |
| std::vector< std::vector< int >> & | use_cuts, | ||
| int | rank, | ||
| bool | use_softmax | ||
| ) |
Definition at line 1445 of file N_Qubit_Decomposition_Cost_Function.cpp.
|
static |
Definition at line 1399 of file N_Qubit_Decomposition_Cost_Function.cpp.

Definition at line 459 of file N_Qubit_Decomposition_Cost_Function.cpp.

| double get_hilbert_schmidt_test | ( | Matrix & | matrix | ) |
Call co calculate the cost function of the optimization process according to https://arxiv.org/pdf/2210.09191.pdf.
| matrix | The square shaped complex matrix from which the cost function is calculated. |
| qbit_num | The number of qubits |
Definition at line 524 of file N_Qubit_Decomposition_Cost_Function.cpp.


| double get_hilbert_schmidt_test | ( | Matrix_float & | matrix | ) |
Definition at line 534 of file N_Qubit_Decomposition_Cost_Function.cpp.

| double get_infidelity | ( | Matrix & | matrix | ) |
Call to calculate infidelity.
| matrix | The square shaped complex matrix from which the cost function is calculated. |
| qbit_num | The number of qubits |
Definition at line 541 of file N_Qubit_Decomposition_Cost_Function.cpp.


| double get_infidelity | ( | Matrix_float & | matrix | ) |
Definition at line 551 of file N_Qubit_Decomposition_Cost_Function.cpp.

| double get_osr_entanglement_test | ( | Matrix & | matrix, |
| std::vector< std::vector< int >> & | use_cuts, | ||
| int | rank, | ||
| bool | use_softmax | ||
| ) |
Definition at line 1308 of file N_Qubit_Decomposition_Cost_Function.cpp.

| double get_osr_entanglement_test | ( | Matrix_float & | matrix, |
| std::vector< std::vector< int >> & | use_cuts, | ||
| int | rank, | ||
| bool | use_softmax | ||
| ) |
Definition at line 1312 of file N_Qubit_Decomposition_Cost_Function.cpp.
|
static |
Definition at line 1284 of file N_Qubit_Decomposition_Cost_Function.cpp.

| QGD_Complex16 get_trace | ( | Matrix & | matrix | ) |
Call to calculate the real and imaginary parts of the trace.
| matrix | The square shaped complex matrix from which the trace is calculated. |
Definition at line 482 of file N_Qubit_Decomposition_Cost_Function.cpp.

| QGD_Complex16 get_trace | ( | Matrix_float & | matrix | ) |
Definition at line 501 of file N_Qubit_Decomposition_Cost_Function.cpp.
Call co calculate the Hilbert Schmidt testof the optimization process, and the first correction to the cost finction according to https://arxiv.org/pdf/2210.09191.pdf.
| matrix | The square shaped complex matrix from which the cost function is calculated. |
| qbit_num | The number of qubits |
Definition at line 564 of file N_Qubit_Decomposition_Cost_Function.cpp.


Call co calculate the Hilbert Schmidt testof the optimization process, and the first correction to the cost finction according to https://arxiv.org/pdf/2210.09191.pdf.
| matrix | The square shaped complex matrix from which the cost function is calculated. |
| qbit_num | The number of qubits |
Definition at line 604 of file N_Qubit_Decomposition_Cost_Function.cpp.


|
static |
Definition at line 878 of file N_Qubit_Decomposition_Cost_Function.cpp.


|
static |
Definition at line 884 of file N_Qubit_Decomposition_Cost_Function.cpp.

| int LAPACKE_cgesdd | ( | int | matrix_order, |
| char | jobz, | ||
| int | m, | ||
| int | n, | ||
| QGD_Complex8 * | a, | ||
| int | lda, | ||
| float * | s, | ||
| QGD_Complex8 * | u, | ||
| int | ldu, | ||
| QGD_Complex8 * | vt, | ||
| int | ldvt | ||
| ) |

| int LAPACKE_cgesvd | ( | int | matrix_order, |
| char | jobu, | ||
| char | jobvt, | ||
| int | m, | ||
| int | n, | ||
| QGD_Complex8 * | a, | ||
| int | lda, | ||
| float * | s, | ||
| QGD_Complex8 * | u, | ||
| int | ldu, | ||
| QGD_Complex8 * | vt, | ||
| int | ldvt, | ||
| float * | superb | ||
| ) |

| int LAPACKE_zgesdd | ( | int | matrix_order, |
| char | jobz, | ||
| int | m, | ||
| int | n, | ||
| QGD_Complex16 * | a, | ||
| int | lda, | ||
| double * | s, | ||
| QGD_Complex16 * | u, | ||
| int | ldu, | ||
| QGD_Complex16 * | vt, | ||
| int | ldvt | ||
| ) |

| int LAPACKE_zgesvd | ( | int | matrix_order, |
| char | jobu, | ||
| char | jobvt, | ||
| int | m, | ||
| int | n, | ||
| QGD_Complex16 * | a, | ||
| int | lda, | ||
| double * | s, | ||
| QGD_Complex16 * | u, | ||
| int | ldu, | ||
| QGD_Complex16 * | vt, | ||
| int | ldvt, | ||
| double * | superb | ||
| ) |

|
inlinestatic |
Definition at line 733 of file N_Qubit_Decomposition_Cost_Function.cpp.

|
inlinestatic |
Definition at line 746 of file N_Qubit_Decomposition_Cost_Function.cpp.


|
inline |
Definition at line 1002 of file N_Qubit_Decomposition_Cost_Function.cpp.

| double loss_for_rank | ( | const std::vector< double > & | S, |
| int | rank | ||
| ) |
Definition at line 1026 of file N_Qubit_Decomposition_Cost_Function.cpp.

| std::vector<double> loss_for_rank_grad_diag | ( | const std::vector< double > & | S, |
| int | rank, | ||
| double | Fnorm | ||
| ) |
Definition at line 1062 of file N_Qubit_Decomposition_Cost_Function.cpp.

Definition at line 758 of file N_Qubit_Decomposition_Cost_Function.cpp.

|
static |
Definition at line 951 of file N_Qubit_Decomposition_Cost_Function.cpp.


| std::pair<int, double> operator_schmidt_rank | ( | const Matrix & | U, |
| int | n, | ||
| const std::vector< int > & | A_qubits, | ||
| double | Fnorm, | ||
| double | tol | ||
| ) |
Definition at line 1254 of file N_Qubit_Decomposition_Cost_Function.cpp.


| std::pair<int, double> operator_schmidt_rank | ( | const Matrix_float & | U, |
| int | n, | ||
| const std::vector< int > & | A_qubits, | ||
| double | Fnorm, | ||
| double | tol | ||
| ) |
Definition at line 1269 of file N_Qubit_Decomposition_Cost_Function.cpp.

|
static |
Definition at line 905 of file N_Qubit_Decomposition_Cost_Function.cpp.

Definition at line 1451 of file N_Qubit_Decomposition_Cost_Function.cpp.

| double real_trace_conj_dot | ( | Matrix_float & | A, |
| Matrix_float & | B | ||
| ) |
Definition at line 1463 of file N_Qubit_Decomposition_Cost_Function.cpp.
| double tail_loss | ( | const std::vector< double > & | S, |
| int | max_dyadic, | ||
| double | rho = 0.1, |
||
| double | tol = 1e-4 |
||
| ) |
Definition at line 1141 of file N_Qubit_Decomposition_Cost_Function.cpp.


| std::vector<double> tail_loss_grad_diag | ( | const std::vector< double > & | S, |
| int | max_dyadic, | ||
| double | Fnorm, | ||
| double | rho = 0.1, |
||
| double | tol = 1e-4 |
||
| ) |
Definition at line 1184 of file N_Qubit_Decomposition_Cost_Function.cpp.


|
static |
Definition at line 1334 of file N_Qubit_Decomposition_Cost_Function.cpp.

Definition at line 975 of file N_Qubit_Decomposition_Cost_Function.cpp.


| double weighted_loss_for_rank | ( | const std::vector< double > & | S, |
| int | rank, | ||
| double | rho = 0.1, |
||
| double | tol = 1e-4 |
||
| ) |
Definition at line 1010 of file N_Qubit_Decomposition_Cost_Function.cpp.

1.8.13