File smath.hpp

This file contains mathemical routines.

Author

Benjamin Lindner ben@benlabs.net

Version

See VERSION in CMakeLists.txt

Copyright

GNU General Public License

namespace smath

Functions

inline double sine(double &x)

Computes the sine within the first oscillation. Trades off speed vs. accuracy.

template<class T>
void multiply_elements(const T &factor, std::vector<std::complex<T>> &data)

Element-wise multiplication of an array

template<class T>
void square_elements(std::vector<std::complex<T>> &data)

Element-wise squaring of an array

template<class T>
void add_elements(std::vector<std::complex<T>> &target, const std::vector<std::complex<T>> &source)

Element-wise addition of two arrays

template<class T>
void auto_correlate_fftw(std::vector<std::complex<T>> &data, fftw_plan p1, fftw_plan p2)

Replaces the data within the array with its auto-correlated value using FFT (scales with N)

template<class T>
void auto_correlate_direct(std::vector<std::complex<T>> &data)

Replaces the data within the array with its auto-correlated value using the direct (scales with N*N)

template<class T>
std::complex<T> reduce(const std::vector<std::complex<T>> &data)

Computes the sum of an array

void auto_correlate_fftw(std::vector<std::complex<double>> &data, fftw_plan p1, fftw_plan p2, fftw_complex *fftw_planspace)

Replaces the data within the array with its auto-correlated value using FFT (scales with N)

template<class T>
void add_elements(std::vector<std::complex<T>> &target, const fftw_complex *source, size_t N)

Element-wise addition of two arrays