Polynomials¶
qsp_proc.polynomials
¶
Polynomial types and approximations for QSP (Chebyshev, Laurent, Jacobi-Anger, etc.)
ChebyshevPoly
¶
Polynomial represented in first-kind Chebyshev basis.
For coefficients c_k this class represents
P(x) = sum_k c_k T_k(x).
Source code in src\qsp_proc\polynomials\chebyshev.py
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 | |
coeffs
property
¶
Return a copy of Chebyshev coefficients.
degree
property
¶
Return polynomial degree.
__init__(coeffs)
¶
Initialize the polynomial from coefficients or a Chebyshev object.
Source code in src\qsp_proc\polynomials\chebyshev.py
24 25 26 27 28 29 | |
__call__(x)
¶
Evaluate the polynomial at x.
Source code in src\qsp_proc\polynomials\chebyshev.py
41 42 43 44 45 46 | |
parity(tol=1e-14)
¶
Return parity by Chebyshev index support.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tol
|
float
|
Numerical zero threshold for coefficients. |
1e-14
|
Returns:
| Type | Description |
|---|---|
int
|
|
Source code in src\qsp_proc\polynomials\chebyshev.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
decompose_eq17()
¶
Decompose P according to Eq. (17) into four real components.
Eq. (17) in the paper writes
P(x) = f_R,E(x) + f_R,O(x) + i f_I,E(x) + i f_I,O(x).
Returns:
| Type | Description |
|---|---|
tuple[ChebyshevPoly, ChebyshevPoly, ChebyshevPoly, ChebyshevPoly]
|
Tuple |
Source code in src\qsp_proc\polynomials\chebyshev.py
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 | |
from_eq17_components(f_re_even, f_re_odd, f_im_even, f_im_odd)
classmethod
¶
Reconstruct P from Eq. (17) components.
Source code in src\qsp_proc\polynomials\chebyshev.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | |
linf_norm_on_unit_circle(n_samples=4096)
¶
Estimate ||P||_inf on U(1) using Eq. (16) coordinate map.
Eq. (16) uses z = exp(i*theta) and x = cos(theta), which here is
evaluated as x = (z + z^{-1}) / 2 for sampled unit-circle points.
Source code in src\qsp_proc\polynomials\chebyshev.py
120 121 122 123 124 125 126 127 128 129 | |
subnormalize(bound=0.5, n_samples=4096)
¶
Return a scaled polynomial with sampled norm at most bound.
Source code in src\qsp_proc\polynomials\chebyshev.py
131 132 133 134 135 136 137 138 | |
to_laurent()
¶
Convert first-kind Chebyshev series to Laurent form.
Uses Appendix A identities with x = (z + z^{-1})/2:
T_0(x)=1 and T_n(x)=(z^n + z^{-n})/2 for n>=1.
Source code in src\qsp_proc\polynomials\chebyshev.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
LaurentPoly
¶
Finite Laurent polynomial P(z)=sum_k a_k z^k with dense storage.
Source code in src\qsp_proc\polynomials\laurent.py
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 | |
coeffs
property
¶
Return dense coefficients as a copy.
coefficients
property
¶
Alias for :attr:coeffs.
min_degree
property
¶
Return the minimum represented exponent.
max_degree
property
¶
Return the maximum represented exponent.
degree
property
¶
Return half-width degree max(|min_degree|, |max_degree|).
__init__(coefficients, min_degree=None, *, trim_tol=0.0)
¶
Create a Laurent polynomial from dense or sparse coefficients.
Source code in src\qsp_proc\polynomials\laurent.py
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 | |
coefficient(exponent)
¶
Return coefficient of z**exponent (or 0 outside support).
Source code in src\qsp_proc\polynomials\laurent.py
73 74 75 76 77 | |
__call__(z)
¶
Evaluate the Laurent polynomial at scalar or array z.
Source code in src\qsp_proc\polynomials\laurent.py
79 80 81 82 83 84 85 86 | |
evaluate_on_unit_circle(theta)
¶
Evaluate on U(1) via z = exp(i*theta).
Source code in src\qsp_proc\polynomials\laurent.py
88 89 90 91 | |
linf_norm_on_unit_circle(num_samples=4096)
¶
Estimate sampled ||P||_inf on U(1).
Source code in src\qsp_proc\polynomials\laurent.py
93 94 95 | |
with_bounded_linf_on_unit_circle(bound, num_samples=4096)
¶
Return scaled polynomial with sampled unit-circle norm at most bound.
Source code in src\qsp_proc\polynomials\laurent.py
97 98 99 100 101 102 103 104 105 106 | |
is_reciprocal(tol=1e-12)
¶
Check Appendix A reciprocal condition F(z)=F(z^{-1}).
Source code in src\qsp_proc\polynomials\laurent.py
108 109 110 111 112 | |
is_anti_reciprocal(tol=1e-12)
¶
Check Appendix A anti-reciprocal condition F(z)=-F(z^{-1}).
Source code in src\qsp_proc\polynomials\laurent.py
114 115 116 117 118 | |
to_chebyshev(tol=1e-12)
¶
Convert reciprocal Laurent polynomial to first-kind Chebyshev series.
Source code in src\qsp_proc\polynomials\laurent.py
120 121 122 123 124 125 126 127 128 129 | |
to_appendix_a_components()
¶
Return Appendix A Chebyshev decomposition of a Laurent polynomial.
Any Laurent series can be written as
sum a_n T_n(x) + sqrt(1-x^2) * sum b_n U_n(x)
under x=(z+z^{-1})/2.
Returns:
| Type | Description |
|---|---|
ChebyshevPoly
|
A pair |
ndarray
|
|
tuple[ChebyshevPoly, ndarray]
|
|
Source code in src\qsp_proc\polynomials\laurent.py
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 | |
from_appendix_a_components(first_kind, second_kind_coeffs)
classmethod
¶
Build Laurent polynomial from Appendix A Chebyshev components.
The input represents
sum a_n T_n(x) + sqrt(1-x^2) * sum b_n U_n(x).
Source code in src\qsp_proc\polynomials\laurent.py
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 | |
from_chebyshev(poly)
classmethod
¶
Construct Laurent polynomial from a first-kind Chebyshev series.
Source code in src\qsp_proc\polynomials\laurent.py
184 185 186 187 | |
__mul__(other)
¶
Scalar multiplication P * c.
Source code in src\qsp_proc\polynomials\laurent.py
189 190 191 | |
__rmul__(other)
¶
Scalar multiplication c * P.
Source code in src\qsp_proc\polynomials\laurent.py
193 194 195 | |
__repr__()
¶
Return unambiguous string representation.
Source code in src\qsp_proc\polynomials\laurent.py
197 198 199 | |
hamiltonian_sim_degree_bound(tau, epsilon)
¶
Return the Appendix B.2 piecewise truncation bound r_tilde(tau, epsilon).
This implements Eq. (73) from the paper for tau >= 0 and 0 < epsilon < 1.
For negative tau, the bound is computed with |tau|.
Source code in src\qsp_proc\polynomials\approximations.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | |
jacobi_anger_laurent(tau, epsilon, *, max_degree=None, subnormalization=math.sqrt(0.5))
¶
Build truncated Jacobi-Anger Laurent target for Hamiltonian simulation.
The target corresponds to exp(i * tau * x) with x = cos(theta) and
z = exp(i * theta), truncated to degree r where r is either
max_degree or the Appendix B.2 Eq. (73) bound.
Coefficients are generated from the Fourier/Jacobi-Anger identity
exp(i * tau * cos(theta)) = sum_k i^k J_k(tau) z^k for k in [-r, r].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tau
|
float
|
Simulation time parameter. |
required |
epsilon
|
float
|
Approximation precision for selecting truncation degree. |
required |
max_degree
|
int | None
|
Explicit truncation degree override. |
None
|
subnormalization
|
float
|
Optional multiplicative scaling (paper uses |
sqrt(0.5)
|
Returns:
| Type | Description |
|---|---|
LaurentPoly
|
Truncated Laurent polynomial target. |
Source code in src\qsp_proc\polynomials\approximations.py
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 | |
random_complex_target_laurent(degree, *, nz=None, decay_rate=1.5, norm_bound=0.5, rng=None)
¶
Generate Appendix B.1 style sparse random complex target.
The target is sampled in theta-form:
P(theta) = sum_j a_j cos(j theta) + i sum_j b_j sin(j theta),
then converted to Laurent coefficients.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
degree
|
int
|
Maximum Fourier/Chebyshev order. |
required |
nz
|
int | None
|
Number of non-zero coefficients across |
None
|
decay_rate
|
float
|
Magnitude decay exponent for higher-order terms. |
1.5
|
norm_bound
|
float
|
Post-normalization bound for sampled |
0.5
|
rng
|
Generator | None
|
Optional NumPy random generator. |
None
|
Returns:
| Type | Description |
|---|---|
LaurentPoly
|
Sparse random Laurent polynomial with sampled norm at most |
Source code in src\qsp_proc\polynomials\approximations.py
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 | |
sampled_linf_on_unit_circle(evaluator, num_samples)
¶
Estimate ||f||_inf on U(1) via uniform sampling.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
evaluator
|
Callable[[ndarray], ndarray]
|
Vectorized callable that accepts sampled |
required |
num_samples
|
int
|
Number of points used for sampling. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Estimated sup norm on sampled points. |
Source code in src\qsp_proc\polynomials\utils.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
trim_dense_support(coeffs, min_degree, *, tol)
¶
Trim near-zero boundary entries in a dense Laurent support.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coeffs
|
ndarray
|
Dense coefficient array where |
required |
min_degree
|
int
|
Smallest exponent represented by |
required |
tol
|
float
|
Trimming tolerance. |
required |
Returns:
| Type | Description |
|---|---|
tuple[ndarray, int]
|
A pair |
Source code in src\qsp_proc\polynomials\utils.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
unit_circle_points(num_samples)
¶
Return uniformly sampled points on the unit circle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_samples
|
int
|
Number of points to sample on |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Complex array |
ndarray
|
spaced in |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src\qsp_proc\polynomials\utils.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | |
qsp_proc.polynomials.chebyshev
¶
Chebyshev polynomial utilities for QSP
ChebyshevPoly
¶
Polynomial represented in first-kind Chebyshev basis.
For coefficients c_k this class represents
P(x) = sum_k c_k T_k(x).
Source code in src\qsp_proc\polynomials\chebyshev.py
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 | |
coeffs
property
¶
Return a copy of Chebyshev coefficients.
degree
property
¶
Return polynomial degree.
__init__(coeffs)
¶
Initialize the polynomial from coefficients or a Chebyshev object.
Source code in src\qsp_proc\polynomials\chebyshev.py
24 25 26 27 28 29 | |
__call__(x)
¶
Evaluate the polynomial at x.
Source code in src\qsp_proc\polynomials\chebyshev.py
41 42 43 44 45 46 | |
parity(tol=1e-14)
¶
Return parity by Chebyshev index support.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tol
|
float
|
Numerical zero threshold for coefficients. |
1e-14
|
Returns:
| Type | Description |
|---|---|
int
|
|
Source code in src\qsp_proc\polynomials\chebyshev.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
decompose_eq17()
¶
Decompose P according to Eq. (17) into four real components.
Eq. (17) in the paper writes
P(x) = f_R,E(x) + f_R,O(x) + i f_I,E(x) + i f_I,O(x).
Returns:
| Type | Description |
|---|---|
tuple[ChebyshevPoly, ChebyshevPoly, ChebyshevPoly, ChebyshevPoly]
|
Tuple |
Source code in src\qsp_proc\polynomials\chebyshev.py
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 | |
from_eq17_components(f_re_even, f_re_odd, f_im_even, f_im_odd)
classmethod
¶
Reconstruct P from Eq. (17) components.
Source code in src\qsp_proc\polynomials\chebyshev.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | |
linf_norm_on_unit_circle(n_samples=4096)
¶
Estimate ||P||_inf on U(1) using Eq. (16) coordinate map.
Eq. (16) uses z = exp(i*theta) and x = cos(theta), which here is
evaluated as x = (z + z^{-1}) / 2 for sampled unit-circle points.
Source code in src\qsp_proc\polynomials\chebyshev.py
120 121 122 123 124 125 126 127 128 129 | |
subnormalize(bound=0.5, n_samples=4096)
¶
Return a scaled polynomial with sampled norm at most bound.
Source code in src\qsp_proc\polynomials\chebyshev.py
131 132 133 134 135 136 137 138 | |
to_laurent()
¶
Convert first-kind Chebyshev series to Laurent form.
Uses Appendix A identities with x = (z + z^{-1})/2:
T_0(x)=1 and T_n(x)=(z^n + z^{-n})/2 for n>=1.
Source code in src\qsp_proc\polynomials\chebyshev.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
qsp_proc.polynomials.laurent
¶
Laurent polynomial utilities.
LaurentPoly
¶
Finite Laurent polynomial P(z)=sum_k a_k z^k with dense storage.
Source code in src\qsp_proc\polynomials\laurent.py
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 | |
coeffs
property
¶
Return dense coefficients as a copy.
coefficients
property
¶
Alias for :attr:coeffs.
min_degree
property
¶
Return the minimum represented exponent.
max_degree
property
¶
Return the maximum represented exponent.
degree
property
¶
Return half-width degree max(|min_degree|, |max_degree|).
__init__(coefficients, min_degree=None, *, trim_tol=0.0)
¶
Create a Laurent polynomial from dense or sparse coefficients.
Source code in src\qsp_proc\polynomials\laurent.py
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 | |
coefficient(exponent)
¶
Return coefficient of z**exponent (or 0 outside support).
Source code in src\qsp_proc\polynomials\laurent.py
73 74 75 76 77 | |
__call__(z)
¶
Evaluate the Laurent polynomial at scalar or array z.
Source code in src\qsp_proc\polynomials\laurent.py
79 80 81 82 83 84 85 86 | |
evaluate_on_unit_circle(theta)
¶
Evaluate on U(1) via z = exp(i*theta).
Source code in src\qsp_proc\polynomials\laurent.py
88 89 90 91 | |
linf_norm_on_unit_circle(num_samples=4096)
¶
Estimate sampled ||P||_inf on U(1).
Source code in src\qsp_proc\polynomials\laurent.py
93 94 95 | |
with_bounded_linf_on_unit_circle(bound, num_samples=4096)
¶
Return scaled polynomial with sampled unit-circle norm at most bound.
Source code in src\qsp_proc\polynomials\laurent.py
97 98 99 100 101 102 103 104 105 106 | |
is_reciprocal(tol=1e-12)
¶
Check Appendix A reciprocal condition F(z)=F(z^{-1}).
Source code in src\qsp_proc\polynomials\laurent.py
108 109 110 111 112 | |
is_anti_reciprocal(tol=1e-12)
¶
Check Appendix A anti-reciprocal condition F(z)=-F(z^{-1}).
Source code in src\qsp_proc\polynomials\laurent.py
114 115 116 117 118 | |
to_chebyshev(tol=1e-12)
¶
Convert reciprocal Laurent polynomial to first-kind Chebyshev series.
Source code in src\qsp_proc\polynomials\laurent.py
120 121 122 123 124 125 126 127 128 129 | |
to_appendix_a_components()
¶
Return Appendix A Chebyshev decomposition of a Laurent polynomial.
Any Laurent series can be written as
sum a_n T_n(x) + sqrt(1-x^2) * sum b_n U_n(x)
under x=(z+z^{-1})/2.
Returns:
| Type | Description |
|---|---|
ChebyshevPoly
|
A pair |
ndarray
|
|
tuple[ChebyshevPoly, ndarray]
|
|
Source code in src\qsp_proc\polynomials\laurent.py
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 | |
from_appendix_a_components(first_kind, second_kind_coeffs)
classmethod
¶
Build Laurent polynomial from Appendix A Chebyshev components.
The input represents
sum a_n T_n(x) + sqrt(1-x^2) * sum b_n U_n(x).
Source code in src\qsp_proc\polynomials\laurent.py
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 | |
from_chebyshev(poly)
classmethod
¶
Construct Laurent polynomial from a first-kind Chebyshev series.
Source code in src\qsp_proc\polynomials\laurent.py
184 185 186 187 | |
__mul__(other)
¶
Scalar multiplication P * c.
Source code in src\qsp_proc\polynomials\laurent.py
189 190 191 | |
__rmul__(other)
¶
Scalar multiplication c * P.
Source code in src\qsp_proc\polynomials\laurent.py
193 194 195 | |
__repr__()
¶
Return unambiguous string representation.
Source code in src\qsp_proc\polynomials\laurent.py
197 198 199 | |
qsp_proc.polynomials.approximations
¶
Target polynomial constructors
hamiltonian_sim_degree_bound(tau, epsilon)
¶
Return the Appendix B.2 piecewise truncation bound r_tilde(tau, epsilon).
This implements Eq. (73) from the paper for tau >= 0 and 0 < epsilon < 1.
For negative tau, the bound is computed with |tau|.
Source code in src\qsp_proc\polynomials\approximations.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | |
jacobi_anger_laurent(tau, epsilon, *, max_degree=None, subnormalization=math.sqrt(0.5))
¶
Build truncated Jacobi-Anger Laurent target for Hamiltonian simulation.
The target corresponds to exp(i * tau * x) with x = cos(theta) and
z = exp(i * theta), truncated to degree r where r is either
max_degree or the Appendix B.2 Eq. (73) bound.
Coefficients are generated from the Fourier/Jacobi-Anger identity
exp(i * tau * cos(theta)) = sum_k i^k J_k(tau) z^k for k in [-r, r].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tau
|
float
|
Simulation time parameter. |
required |
epsilon
|
float
|
Approximation precision for selecting truncation degree. |
required |
max_degree
|
int | None
|
Explicit truncation degree override. |
None
|
subnormalization
|
float
|
Optional multiplicative scaling (paper uses |
sqrt(0.5)
|
Returns:
| Type | Description |
|---|---|
LaurentPoly
|
Truncated Laurent polynomial target. |
Source code in src\qsp_proc\polynomials\approximations.py
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 | |
random_complex_target_laurent(degree, *, nz=None, decay_rate=1.5, norm_bound=0.5, rng=None)
¶
Generate Appendix B.1 style sparse random complex target.
The target is sampled in theta-form:
P(theta) = sum_j a_j cos(j theta) + i sum_j b_j sin(j theta),
then converted to Laurent coefficients.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
degree
|
int
|
Maximum Fourier/Chebyshev order. |
required |
nz
|
int | None
|
Number of non-zero coefficients across |
None
|
decay_rate
|
float
|
Magnitude decay exponent for higher-order terms. |
1.5
|
norm_bound
|
float
|
Post-normalization bound for sampled |
0.5
|
rng
|
Generator | None
|
Optional NumPy random generator. |
None
|
Returns:
| Type | Description |
|---|---|
LaurentPoly
|
Sparse random Laurent polynomial with sampled norm at most |
Source code in src\qsp_proc\polynomials\approximations.py
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 | |
qsp_proc.polynomials.utils
¶
Shared helpers for polynomial operations
unit_circle_points(num_samples)
¶
Return uniformly sampled points on the unit circle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_samples
|
int
|
Number of points to sample on |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Complex array |
ndarray
|
spaced in |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src\qsp_proc\polynomials\utils.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | |
sampled_linf_on_unit_circle(evaluator, num_samples)
¶
Estimate ||f||_inf on U(1) via uniform sampling.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
evaluator
|
Callable[[ndarray], ndarray]
|
Vectorized callable that accepts sampled |
required |
num_samples
|
int
|
Number of points used for sampling. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Estimated sup norm on sampled points. |
Source code in src\qsp_proc\polynomials\utils.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
trim_dense_support(coeffs, min_degree, *, tol)
¶
Trim near-zero boundary entries in a dense Laurent support.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coeffs
|
ndarray
|
Dense coefficient array where |
required |
min_degree
|
int
|
Smallest exponent represented by |
required |
tol
|
float
|
Trimming tolerance. |
required |
Returns:
| Type | Description |
|---|---|
tuple[ndarray, int]
|
A pair |
Source code in src\qsp_proc\polynomials\utils.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |