<commit_before>//-----------------------------------------------------------------------------
// Copyright 2012-2016 <NAME>. All Rights Reserved.
// Author: mmorise [at] yamanashi.ac.jp (<NAME>)
//
// This file represents the functions about FFT (Fast Fourier Transform)
// implemented by Mr. Ooura, and wrapper functions implemented by M. Morise.
// We can use these wrapper functions as well as the FFTW functions.
// Please see the FFTW web-page to show the usage of the wrapper functions.
// Ooura FFT:
//   (Japanese) http://www.kurims.kyoto-u.ac.jp/~ooura/index-j.html
//   (English) http://www.kurims.kyoto-u.ac.jp/~ooura/index.html
// FFTW:
//   (English) http://www.fftw.org/
// 2012/08/24 by <NAME>
//-----------------------------------------------------------------------------
#include "./fft.h"

#include <math.h>
#include <stdlib.h>

void cdft(int n, int isgn, double *a, int *ip, double *w);
void rdft(int n, int isgn, double *a, int *ip, double *w);

namespace {
void BackwardFFT(fft_plan p) {
  if (p.c_out == NULL) {  // c2r
    p.input[0] = p.c_in[0][0];
    p.input[1] = p.c_in[p.n / 2][0];
    for (int i = 1; i < p.n / 2; ++i) {
      p.input[i * 2]  = p.c_in[i][0];
      p.input[i * 2 + 1]  = p.c_in[i][1];
    }
    rdft(p.n, -1, p.input, p.ip, p.w);
    for (int i = 0; i < p.n; ++i) p.out[i] = p.input[i] * 2.0;
  } else {  // c2c
    for (int i = 0; i < p.n; ++i) {
      p.input[i * 2] = p.c_in[i][0];
      p.input[i * 2 + 1] = p.c_in[i][1];
    }
    cdft(p.n * 2, -1, p.input, p.ip, p.w);
    for (int i = 0; i < p.n; ++i) {
      p.c_out[i][0] = p.input[i * 2];
      p.c_out[i][1] = p.input[i * 2 + 1];
    }
  }
}

void ForwardFFT(fft_plan p) {
  if (p.c_in == NULL) {  // r2c
    for (int i = 0; i < p.n; ++i) p.input[i] = p.in[i];
    rdft(p.n, 1, p.input, p.ip, p.w);
    p.c_out[0][0] = p.input[0];
    p.c_out[0][1] = 0.0;
    for (int i = 1; i < p.n / 2; ++i) {
      p.c_out[i][0] = p.input[i * 2];
      p.c_out[i][1] = p.input[i * 2 + 1];
    }
    p.c_out[p.n / 2][0] = p.input[1];
    p.c_out[p.n / 2][1] = 0.0;
  } else {  // c2c
    for (int i = 0; i < p.n; ++i) {
      p.input[i * 2] = p.c_in[i][0];
      p.input[i * 2 + 1] = p.c_in[i][1];
    }
    cdft(p.n * 2, 1, p.input, p.ip, p.w);
    for (int i = 0; i < p.n; ++i) {
      p.c_out[i][0]   = p.input[i * 2];
      p.c_out[i][1]   = p.input[i * 2 + 1];
    }
  }
}

}  // namespace

fft_plan fft_plan_dft_1d(int n, fft_complex *in, fft_complex *out, int sign,
    unsigned int flags) {
  void makewt(int nw, int *ip, double *w);

  fft_plan output = {0};<commit_msg>Added static keyword to functions in anonymous namespace in fft.cpp.<commit_after>//-----------------------------------------------------------------------------
// Copyright 2012-2016 <NAME>. All Rights Reserved.
// Author: mmorise [at] yamanashi.ac.jp (<NAME>)
//
// This file represents the functions about FFT (Fast Fourier Transform)
// implemented by Mr. Ooura, and wrapper functions implemented by <NAME>.
// We can use these wrapper functions as well as the FFTW functions.
// Please see the FFTW web-page to show the usage of the wrapper functions.
// Ooura FFT:
//   (Japanese) http://www.kurims.kyoto-u.ac.jp/~ooura/index-j.html
//   (English) http://www.kurims.kyoto-u.ac.jp/~ooura/index.html
// FFTW:
//   (English) http://www.fftw.org/
// 2012/08/24 by <NAME>
//-----------------------------------------------------------------------------
#include "./fft.h"

#include <math.h>
#include <stdlib.h>

void cdft(int n, int isgn, double *a, int *ip, double *w);
void rdft(int n, int isgn, double *a, int *ip, double *w);

namespace {
static void BackwardFFT(fft_plan p) {
  if (p.c_out == NULL) {  // c2r
    p.input[0] = p.c_in[0][0];
    p.input[1] = p.c_in[p.n / 2][0];
    for (int i = 1; i < p.n / 2; ++i) {
      p.input[i * 2]  = p.c_in[i][0];
      p.input[i * 2 + 1]  = p.c_in[i][1];
    }
    rdft(p.n, -1, p.input, p.ip, p.w);
    for (int i = 0; i < p.n; ++i) p.out[i] = p.input[i] * 2.0;
  } else {  // c2c
    for (int i = 0; i < p.n; ++i) {
      p.input[i * 2] = p.c_in[i][0];
      p.input[i * 2 + 1] = p.c_in[i][1];
    }
    cdft(p.n * 2, -1, p.input, p.ip, p.w);
    for (int i = 0; i < p.n; ++i) {
      p.c_out[i][0] = p.input[i * 2];
      p.c_out[i][1] = p.input[i * 2 + 1];
    }
  }
}

static void ForwardFFT(fft_plan p) {
  if (p.c_in == NULL) {  // r2c
    for (int i = 0; i < p.n; ++i) p.input[i] = p.in[i];
    rdft(p.n, 1, p.input, p.ip, p.w);
    p.c_out[0][0] = p.input[0];
    p.c_out[0][1] = 0.0;
    for (int i = 1; i < p.n / 2; ++i) {
      p.c_out[i][0] = p.input[i * 2];
      p.c_out[i][1] = p.input[i * 2 + 1];
    }
    p.c_out[p.n / 2][0] = p.input[1];
    p.c_out[p.n / 2][1] = 0.0;
  } else {  // c2c
    for (int i = 0; i < p.n; ++i) {
      p.input[i * 2] = p.c_in[i][0];
      p.input[i * 2 + 1] = p.c_in[i][1];
    }
    cdft(p.n * 2, 1, p.input, p.ip, p.w);
    for (int i = 0; i < p.n; ++i) {
      p.c_out[i][0]   = p.input[i * 2];
      p.c_out[i][1]   = p.input[i * 2 + 1];
    }
  }
}

}  // namespace

fft_plan fft_plan_dft_1d(int n, fft_complex *in, fft_complex *out, int sign,
    unsigned int flags) {
  void makewt(int nw, int *ip, double *w);

  fft_plan output = {0};
{'fraction_non_alphanumeric': 0.2680353031465848, 'fraction_numerical': 0.03453568687643899, 'mean_word_length': 1.817837837837838, 'pattern_counts': {'":': 0, '<': 30, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, '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': '1112869', 'n_tokens_mistral': 2477, 'n_tokens_neox': 2338, 'n_words': 573}