* @brief Encode Class * @ingroup quantum Algorithm */
| 86 | * @ingroup quantum Algorithm |
| 87 | */ |
| 88 | class Encode { |
| 89 | template <typename Scalar> |
| 90 | using dyn_col_vect = Eigen::Matrix<Scalar, Eigen::Dynamic, 1>; |
| 91 | |
| 92 | template <typename Scalar> |
| 93 | using dyn_mat = Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic>; |
| 94 | |
| 95 | //template <typename Scalar> |
| 96 | //using MatrixX = Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic>; |
| 97 | |
| 98 | public: |
| 99 | |
| 100 | Encode(); |
| 101 | /** |
| 102 | * @brief amplitude encode |
| 103 | * @ingroup quantum Algorithm. |
| 104 | * @param[in] QVec& Available qubits. |
| 105 | * @param[in] std::vector<double>& the target datas which will be encoded to the quantum state. |
| 106 | * @note The coding data must meet normalization conditions. |
| 107 | */ |
| 108 | void amplitude_encode(const QVec &q, const std::vector<double>& data); |
| 109 | |
| 110 | void amplitude_encode(const QVec &q, const std::vector<qcomplex_t>& data); |
| 111 | |
| 112 | void amplitude_encode_recursive(const QVec &q, const std::vector<double>& data); |
| 113 | |
| 114 | void amplitude_encode_recursive(const QVec &qubits, const QStat& full_cur_vec); |
| 115 | |
| 116 | /** |
| 117 | * @brief angle encode |
| 118 | * @ingroup quantum Algorithm. |
| 119 | * @param[in] QVec& Available qubits. |
| 120 | * @param[in] std::vector<double>& the target datas which will be encoded to the quantum state angle. |
| 121 | * @param[in] GateType gate_type gate types used in circuit. |
| 122 | * @note The coding data must meet [0,PI]. |
| 123 | * @note This concrete implementation is from https://arxiv.org/pdf/2003.01695.pdf. |
| 124 | */ |
| 125 | void angle_encode(const QVec &q, const std::vector<double>& data, const GateType& gate_type = GateType::RY_GATE); |
| 126 | |
| 127 | /** |
| 128 | * @brief dense angle encode |
| 129 | * @ingroup quantum Algorithm. |
| 130 | * @param[in] QVec& Available qubits. |
| 131 | * @param[in] std::vector<double>& the target datas which will be encoded to the quantum state angle and phase. |
| 132 | * @note The coding data must meet [0,PI]. |
| 133 | * @note The algorithm is implemented using U3 gates, and each gate is loaded with two data, theta, phi respectively. |
| 134 | * @note This concrete implementation is from https://arxiv.org/pdf/2003.01695.pdf. |
| 135 | */ |
| 136 | void dense_angle_encode(const QVec &q, const std::vector<double>& data); |
| 137 | |
| 138 | /** |
| 139 | * @brief divide conquer amplitude encode |
| 140 | * @ingroup quantum Algorithm. |
| 141 | * @param[in] QVec& Available qubits. |
| 142 | * @param[in] std::vector<double>& the target datas which will be encoded to the quantum state. |
| 143 | * @note The coding data must meet normalization conditions. |
| 144 | * @note The algorithm is implemented using CSWAP gates and data.size-1 qubits, effectively reducing the depth of quantum circuits. |
| 145 | * @note This concrete implementation is from https://arxiv.org/pdf/2008.01511.pdf. |
no outgoing calls