Mantid
Loading...
Searching...
No Matches
MaxentSpaceReal.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
8#include <stdexcept>
9
10namespace Mantid::Algorithms {
11
17std::vector<double> MaxentSpaceReal::toComplex(const std::vector<double> &values) {
18
19 // The output has 2*N values
20 std::vector<double> result(values.size() * 2);
21
22 for (size_t i = 0; i < values.size(); i++)
23 result[2 * i] = values[i];
24
25 return result;
26}
27
33std::vector<double> MaxentSpaceReal::fromComplex(const std::vector<double> &values) {
34
35 if (values.size() % 2) {
36 throw std::invalid_argument("Cannot convert to real vector");
37 }
38
39 // The output has N/2 values
40 std::vector<double> result(values.size() / 2);
41
42 for (size_t i = 0; i < result.size(); i++) {
43 result[i] = values[2 * i];
44 }
45 return result;
46}
47
48} // namespace Mantid::Algorithms
std::vector< double > fromComplex(const std::vector< double > &values) override
Converts a vector of complex numbers to a vector of real numbers.
std::vector< double > toComplex(const std::vector< double > &values) override
Converts a vector of real values to a vector of complex numbers.