125 const auto &
X = inWS->x(spec);
126 double dx = (
X.back() -
X.front()) /
static_cast<double>(
X.size() - 1);
127 auto ySize = inWS->y(spec).size();
131 if (transform ==
"Forward") {
133 auto const &yData = inWS->y(spec);
134 std::vector<double> data(yData.cbegin(), yData.cend());
142 std::vector<double> unpacked(2 * ySize, 0.0);
143 gsl_fft_halfcomplex_unpack(data.data(), unpacked.data(), 1, ySize);
150 auto yOutSize = ySize / 2 + 1;
151 auto xOutSize = inWS->isHistogramData() ? yOutSize + 1 : yOutSize;
154 auto tAxis = std::make_unique<API::TextAxis>(3);
155 tAxis->setLabel(0,
"Real");
156 tAxis->setLabel(1,
"Imag");
157 tAxis->setLabel(2,
"Modulus");
158 outWS->replaceAxis(1, std::move(tAxis));
161 auto &
x = outWS->mutableX(0);
162 double df = 1.0 / (dx *
static_cast<double>(ySize));
163 std::generate(
x.begin(),
x.end(), HistogramData::LinearGenerator(0, df));
164 outWS->setSharedX(1, outWS->sharedX(0));
165 outWS->setSharedX(2, outWS->sharedX(0));
168 auto &y1 = outWS->mutableY(0);
169 auto &y2 = outWS->mutableY(1);
170 auto &y3 = outWS->mutableY(2);
171 for (std::size_t i = 0; i < yOutSize; i++) {
172 std::size_t
const j = i * 2;
173 double re = unpacked[j];
174 double im = unpacked[j + 1];
177 y3[i] = dx * sqrt(re * re + im * im);
182 std::size_t yOutSize = (ySize - 1) * 2;
183 if (inWS->y(1).back() != 0.0) {
194 bool even = (yOutSize % 2 == 0);
195 std::size_t num_unique_complex = (even ? yOutSize / 2 : (yOutSize - 1) / 2);
196 std::vector<double> yhc(yOutSize);
198 auto const &yR = inWS->y(0);
199 auto const &yI = inWS->y(1);
208 for (std::size_t i = 1; i < num_unique_complex + (even ? 0UL : 1UL); i++) {
209 std::size_t
const j = 2 * i;
215 yhc[2 * num_unique_complex - 1] = yR[num_unique_complex];
221 gsl_fft_halfcomplex_inverse(yhc.data(), 1, yOutSize,
wavetable.get(),
workspace.get());
226 std::size_t xOutSize = inWS->isHistogramData() ? yOutSize + 1 : yOutSize;
227 double df = 1.0 / (dx *
static_cast<double>(yOutSize));
229 auto tAxis = std::make_unique<API::TextAxis>(1);
230 tAxis->setLabel(0,
"Real");
231 outWS->replaceAxis(1, std::move(tAxis));
234 auto &xData = outWS->mutableX(0);
235 std::generate(xData.begin(), xData.end(), HistogramData::LinearGenerator(0, df));
238 auto &yData = outWS->mutableY(0);
239 std::move(yhc.begin(), yhc.begin() + yOutSize, yData.begin());