Computes t_n = exp(sqrt(-1) * pi * n^2 / line_len).
(length)
| 237 | expanded, _array_ops.concat([_array_ops.shape(t)[:-2], [1, 1]], 0)) |
| 238 | |
| 239 | def _mask_matrix(length): |
| 240 | """Computes t_n = exp(sqrt(-1) * pi * n^2 / line_len).""" |
| 241 | # TODO(rjryan): Speed up computation of twiddle factors using the |
| 242 | # following recurrence relation and cache them across invocations of RFFT. |
| 243 | # |
| 244 | # t_n = exp(sqrt(-1) * pi * n^2 / line_len) |
| 245 | # for n = 0, 1,..., line_len-1. |
| 246 | # For n > 2, use t_n = t_{n-1}^2 / t_{n-2} * t_1^2 |
| 247 | a = _array_ops.tile( |
| 248 | _array_ops.expand_dims(_math_ops.range(length), 0), (length, 1)) |
| 249 | b = _array_ops.transpose(a, [1, 0]) |
| 250 | return _math_ops.exp( |
| 251 | -2j * np.pi * _math_ops.cast(a * b, _dtypes.complex64) / |
| 252 | _math_ops.cast(length, _dtypes.complex64)) |
| 253 | |
| 254 | def _ymask(length): |
| 255 | """A sequence of [1+0j, -1+0j, 1+0j, -1+0j, ...] with length `length`.""" |