Common code used by 1D implementations, which copies data from the input to the contiguous buffer. Returns true if all copied values are zero.
| 806 | // Common code used by 1D implementations, which copies data from the input to |
| 807 | // the contiguous buffer. Returns true if all copied values are zero. |
| 808 | bool GatherToBuffer(absl::Span<complex128> data, int64 length, int64 start, |
| 809 | int64 stride, bool expand_input, |
| 810 | absl::Span<complex128> buffer) { |
| 811 | CHECK_GE(buffer.size(), length); |
| 812 | bool input_is_zero = true; |
| 813 | const int64 ub = expand_input ? length / 2 + 1 : length; |
| 814 | CHECK_GE(data.size(), start + (ub - 1) * stride); |
| 815 | for (int64 k = 0; k < ub; k++) { |
| 816 | complex128 value = data[start + k * stride]; |
| 817 | input_is_zero &= value == complex128(0.0, 0.0); |
| 818 | buffer[k] = value; |
| 819 | if (expand_input) { |
| 820 | // Use conjugates of the values at indices [1 ... (ub - 2)] when the |
| 821 | // length is even and at indices [1 ... (ub - 1)] when the length is odd |
| 822 | // to calculate missing values at indices [(length - 1) ... ub]. |
| 823 | if (k > 0 && k < (length - ub + 1)) { |
| 824 | buffer[length - k] = std::conj(value); |
| 825 | } |
| 826 | } |
| 827 | } |
| 828 | return input_is_zero; |
| 829 | } |
| 830 | |
| 831 | // Returns (conjugated, if 'inverse' is true) k-th twiddle for the given length. |
| 832 | inline complex128 Twiddle(int64 k, int64 length, bool inverse) { |
no test coverage detected