Commit 387cf9bb authored by niklas.baumgarten's avatar niklas.baumgarten
Browse files

removing Mean an Variance, using RVector, CVector

parent 60eedc6e
#include <RVector.hpp>
#include <CVector.hpp>
#include "Utilities.hpp"
......@@ -41,7 +43,7 @@ void fft(int N, fftw_complex *in, fftw_complex *out) {
fftw_cleanup();
}
void fft(std::vector<std::complex<double>> &in, std::vector<std::complex<double>> &out) {
void fft(const CVector &in, CVector &out) {
int N = in.size();
fftw_complex in_arr[N], out_arr[N];
for (int i = 0; i < N; i++) {
......@@ -55,10 +57,10 @@ void fft(std::vector<std::complex<double>> &in, std::vector<std::complex<double>
}
}
void fft(const std::vector<double> &in, std::vector<double> &out) {
void fft(const RVector &in, RVector &out) {
int N = in.size();
std::vector<std::complex<double>> in_complex;
std::vector<std::complex<double>> out_complex;
CVector in_complex;
CVector out_complex;
in_complex.resize(N);
out_complex.resize(N);
for (int i = 0; i < N; i++) {
......
#ifndef TOOLS_HPP
#define TOOLS_HPP
#include "RVector.hpp"
#include "CVector.hpp"
#include "RMatrix.hpp"
#inlcude "CMatrix.hpp"
#include <vector>
#include <string>
#include <math.h>
#include <complex>
#include <fftw3.h>
template<typename T>
std::string vec2str(std::vector<T> vec);
template<typename T>
T Mean(const std::vector<T> &vec) {
T mean = 0.0;
for (auto const &value: vec)
mean += value;
return mean / T(vec.size());
}
template<typename T>
T Mean(const std::vector<std::vector<double>> &vec) {
T mean = 0.0;
for (auto const &value_vec: vec)
for (auto const &value: value_vec)
mean += value;
return mean / vec.size();
}
template<typename T>
T Variance(const std::vector<T> &vec) {
T sqrs = 0.0;
for (auto const &value: vec)
sqrs += std::pow(value, 2);
return sqrs / T(vec.size()) - std::pow(Mean(vec), 2);
}
template<typename T>
double Variance(const std::vector<std::vector<T>> &vec) {
double sqrs = 0.0;
for (auto const &value_vec: vec)
for (auto const &value: value_vec)
sqrs += std::pow(value, 2);
return sqrs / vec.size() - std::pow(Mean(vec), 2);
}
void fft(int N, fftw_complex *in, fftw_complex *out);
void fft(std::vector<std::complex<double>> &in,
std::vector<std::complex<double>> &out);
void fft(const CVector &in, CVector &out);
void fft(const std::vector<double> &in,
std::vector<double> &out);
void fft(const RVector &in, RVector &out);
void fft2(int N2, int N1, fftw_complex *in, fftw_complex *out);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment