<commit_before><commit_msg>Add r -> c -> r using r2c<commit_after>
extern crate fftw3;
extern crate num_traits;

use fftw3::*;
use num_traits::Zero;

#[test]
fn r2c2r() {
    let n = 128;
    let mut in_ = vec![0.0; n];
    let mut out = vec![c64::zero(); n / 2 + 1];
    let mut plan = Plan::r2c_1d(&mut in_, &mut out, FLAG::FFTW_ESTIMATE);
    for (i, val) in plan.field.iter_mut().enumerate() {
        *val = (i + 1) as f64;
    }
    plan.forward();
    plan.backward();
    for (i, val) in plan.field.iter().enumerate() {
        let ans = (i + 1) as f64;
        if (ans - *val).abs() / ans.abs() > 1e-7 {
            panic!("Not equal: ans={:?}/val={:?}", ans, val);
        }
    }
}

#[test]
fn c2r2c() {
    let n = 128;
    let mut in_ = vec![0.0; n];
    let mut out = vec![c64::zero(); n / 2 + 1];
    let mut plan = Plan::r2c_1d(&mut in_, &mut out, FLAG::FFTW_ESTIMATE);
    for (i, val) in plan.coef.iter_mut().enumerate() {
        *val = c64::new((i + 1) as f64, (i + 2) as f64);
    }
    plan.backward();
    plan.forward();
    for (i, val) in plan.coef.iter().enumerate() {
        let mut ans = c64::new((i + 1) as f64, (i + 2) as f64);
        if i == 0 || i == n / 2 {
            ans[1] = 0.0;
        }
        if (ans - *val).abs() / ans.abs() > 1e-7 {
            panic!("Not equal: i={}, ans={:?}/val={:?}", i, ans, val);
        }
    }
}
{'fraction_non_alphanumeric': 0.21183345507669832, 'fraction_numerical': 0.04382761139517896, 'mean_word_length': 2.106575963718821, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '5059648', 'n_tokens_mistral': 595, 'n_tokens_neox': 563, 'n_words': 153}