<commit_before>/* Copyright (c) 2016, the Cap authors.
 *
 * This file is subject to the Modified BSD License and may not be distributed
 * without copyright and license information. Please refer to the file LICENSE
 * for the text and further information on this license. 
 */

#define BOOST_TEST_MODULE TestDiscreteFourierTransform
#define BOOST_TEST_MAIN
#include <cap/energy_storage_device.h>
#include <cap/electrochemical_impedance_spectroscopy.h>
#include <boost/format.hpp>
#include <boost/foreach.hpp>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp>
#include <boost/test/unit_test.hpp>
#include <iostream>
#include <fstream>
#include <complex>

BOOST_AUTO_TEST_CASE( test_discrete_fourier_transform )
{
    size_t const n = 32;
    size_t const k = 3;
    std::vector<double> x(n);
    for (size_t i = 0; i < n; ++i)
        x[i] = static_cast<double>(i)/(n-1);
    double const pi = acos(-1.0);
    std::vector<double> y(n);
    for (size_t i = 0; i < n; ++i)
        y[i] = 1.0 + std::sin(2*pi*k*x[i]);
    auto fft_data = cap::compute_fft(&(y[0]), n);
    auto fft_freq = cap::compute_fft_frequencies(n, 1.0/n);
    for (size_t i = 0; i < fft_data.size(); ++i)
        std::cout<<i<<"  "<<fft_freq[i]<<"  "<<fft_data[i]<<"\n";
// import numpy
// n=32
// k=3
// x=numpy.linspace(0,1,n)
// y=1+numpy.sin(k*2*numpy.pi*x)
// fft_data=numpy.fft.rfft(y)
// fft_freq=numpy.fft.rfftfreq(n)
// #for i in range(len(fft_data)):
// #    print i,fft_freq[i],fft_data[i]
// print numpy.real(fft_data)<commit_msg>cleaned test discrete fourier transform<commit_after>/* Copyright (c) 2016, the Cap authors.
 *
 * This file is subject to the Modified BSD License and may not be distributed
 * without copyright and license information. Please refer to the file LICENSE
 * for the text and further information on this license. 
 */

#define BOOST_TEST_MODULE TestDiscreteFourierTransform
#define BOOST_TEST_MAIN
#include <cap/electrochemical_impedance_spectroscopy.h>
#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_CASE( test_discrete_fourier_transform )
{
    size_t const n = 32;
    size_t const k = 3;
    std::vector<double> x(n);
    for (size_t i = 0; i < n; ++i)
        x[i] = static_cast<double>(i)/(n-1);
    double const pi = acos(-1.0);
    std::vector<double> y(n);
    for (size_t i = 0; i < n; ++i)
        y[i] = 1.0 + std::sin(2*pi*k*x[i]);
    auto fft_data = cap::compute_fft(&(y[0]), n);
    auto fft_freq = cap::compute_fft_frequencies(n, 1.0/n);
// import numpy
// n=32
// k=3
// x=numpy.linspace(0,1,n)
// y=1+numpy.sin(k*2*numpy.pi*x)
// fft_data=numpy.fft.rfft(y)
// fft_freq=numpy.fft.rfftfreq(n)
// #for i in range(len(fft_data)):
// #    print i,fft_freq[i],fft_data[i]
// print numpy.real(fft_data)
{'fraction_non_alphanumeric': 0.1594360086767896, 'fraction_numerical': 0.01843817787418655, 'mean_word_length': 3.9676840215439855, 'pattern_counts': {'":': 0, '<': 38, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 1}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6602943', 'n_tokens_mistral': 1133, 'n_tokens_neox': 1088, 'n_words': 251}