paddle_quantum.qpp.laurent.rst 5.8 KB
Newer Older
Q
Quleaf 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228
paddle\_quantum.qpp.laurent
===============================

劳伦类的定义和它的函数

.. py:class:: Laurent

   基类: :py:class:`object`

   为劳伦多项式定义的类,定义为 :math:`P:\mathbb{C}[X, X^{-1}] \to \mathbb{C} :x \mapsto \sum_{j = -L}^{L} p_j X^j`

   :param coef: 劳伦多项式系数的列表,排列为 :math:`\{p_{-L}, ..., p_{-1}, p_0, p_1, ..., p_L\}`
   :type coef: np.ndarray

   .. py:property:: coef()

      以上升顺序给出多项式的系数序列
      
   .. py:property:: conj()

      给出多项式的共轭

   .. py:property:: roots()

      给出多项式根的列表
      
   .. py:property:: norm()

      给出多项式系数的绝对值平方之和

   .. py:property:: max_norm()

      给出多项式的系数的绝对值的最大值

   .. py:property:: parity()

      给出多项式的宇称

   .. py:method:: is_parity(p)

      检验劳伦多项式是否有确定宇称

      :param p: 宇称
      :type p: int

      :return:
        包含以下元素:

        -宇称是否是 ``p mod 2``
        -如果不是,返回破坏该宇称的绝对值最大的系数
        -如果不是,返回破坏该宇称的绝对值最小的系数
      :rtype: Tuple[bool, complex]

.. py:function:: revise_tol(t)

   回顾 ``TOL`` 的值

   :param t: TOL的值
   :type t: float

.. py:function:: ascending_coef(coef)

   通过 ``coef`` 从 ``P`` 和 ``Q`` 中计算角度

   :param coef: 排列成 :math:`\{ p_0, ..., p_L, p_{-L}, ..., p_{-1} \}` 的系数列表
   :type coef: np.ndarray

   :return: 排列成 :math:`\{ p_{-L}, ..., p_{-1}, p_0, p_1, ..., p_L \}` 的系数列表
   :rtype: np.ndarray

.. py:function:: remove_abs_error(data, tol)

   移除数据中的错误

   :param data: 数据数组
   :type data: np.ndarray
   :param tol: 容错率
   :type tol: Optional[float] = None

   :return: 除错后的数据
   :rtype: np.ndarray

.. py:function:: random_laurent_poly(deg, parity, is_real)

   随机生成一个劳伦多项式

   :param deg: 该多项式的度数
   :type deg: int
   :param parity: 该多项式的宇称,默认为 ``none``
   :type parity: Optional[int] = None
   :param is_real: 该多项式系数是否是实数,默认为 ``false``
   :type is_real: Optional[bool] = False

   :return: 一个模小于等于1的劳伦多项式
   :rtype: Laurent

.. py:function:: sqrt_generation(A)

   生成劳伦多项式 :math:`A` 的平方根

   :param A: 一个劳伦多项式
   :type A: Laurent

   :return: 一个模小于等于1的劳伦多项式
   :rtype: Laurent

.. py:function:: Q_generation(P)

   生成劳伦多项式 :math:`P` 的互补多项式

   :param P: 一个宇称为 :math:`deg` ,度数为 :math:`L` 的劳伦多项式
   :type P: Laurent

   :return: 一个宇称为 :math:`deg` ,度数为 :math:`L` 的劳伦多项式  :math:`Q` ,使得 :math:`PP^* + QQ^* = 1`
   :rtype: Laurent

.. py:function:: pair_generation(f)

   生成劳伦多项式 :math:`f` 的劳伦对

   :param f: 一个实的,偶次的,max_norm小于1的劳伦多项式
   :type f: Laurent

   :return: 劳伦多项式 :math:`P, Q` 使得  :math:`P = \sqrt{1 + f / 2}, Q = \sqrt{1 - f / 2}`
   :rtype: Laurent

.. py:function:: laurent_generator(fn, dx, deg, L)

   生成劳伦多项式 :math:`f` 的劳伦对

   :param fn: 要近似的函数
   :type fn: Callable[[np.ndarray], np.ndarray]
   :param dx: 数据点的采样频率
   :type dx: float
   :param deg: 劳伦多项式的度数
   :type deg: int
   :param L: 近似宽度的一半
   :type L: float

   :return: 一个度数为 ``deg`` 的,在区间 :math:`[-L, L]` 内近似`fn` 的劳伦多项式
   :rtype: Laurent

.. py:function:: deg_finder(fn, delta, l)

   找到一个度数,使得由 ``laurent_generator`` 生成的劳伦多项式具有小于1的max_norm

   :param fn: 要近似的函数
   :type fn: Callable[[np.ndarray], np.ndarray]
   :param delta: 数据点的采样频率,默认值为 :math:`0.00001 \pi`
   :type delta: Optional[float] = 0.00001 * np.pi
   :param l: 近似宽度的一半,默认值为 :math:`\pi`
   :type l: Optional[float] = np.pi

   :return: 该近似的度数
   :rtype: int

.. py:function:: step_laurent(deg)

   生成一个近似阶梯函数的劳伦多项式

   :param deg: 输出劳伦多项式的度数(为偶数)
   :type deg: int

   :return: 一个估计 :math:`f(x) = 0.5` if :math:`x <= 0` else :math:`0` 的劳伦多项式
   :rtype: Laurent

   .. note::
       在哈密顿量能量计算器中使用

.. py:function:: hamiltonian_laurent(t, deg)

   生成一个近似哈密顿量演化函数的劳伦多项式

   :param t: 演化常数(时间)
   :type t: float
   :param deg: 输出劳伦多项式的度数(为偶数)
   :type deg: int

   :return: 一个估计 :math:`e^{it \cos(x)}` 的劳伦多项式
   :rtype: Laurent

   .. note::
       -起源于Jacobi-Anger展开: :math:`y(x) = \sum_n i^n Bessel(n, x) e^{inx}`
       -在哈密顿量模拟中使用

.. py:function:: ln_laurent(deg, t)

   生成一个近似ln函数的劳伦多项式

   :param deg: 劳伦多项式的度数(是4的因子)
   :type deg: int
   :param t: 归一化常数
   :type t: float
   

   :return: 一个估计 :math:`ln(cos(x)^2) / t` 的劳伦多项式
   :rtype: Laurent

   .. note::
       在冯诺依曼熵的估计中使用。

.. py:function:: comb(n, k)

   计算nCr(n, k)

   :param n: 输入参数
   :type n: float
   :param k: 输入参数
   :type k: int
   

   :return: nCr(n, k)
   :rtype: float

.. py:function:: power_laurent(deg, alpha, t)

   生成近似幂函数的劳伦多项式

   :param deg: 劳伦多项式的度数(是4的因子)
   :type deg: int
   :param alpha: 幂函数的幂次
   :type alpha: int
   :param t: 归一化常数
   :type t: float
   

   :return: 一个估计 :math:`(cos(x)^2)^{\alpha / 2} / t` 的劳伦多项式
   :rtype: Laurent