<commit_before>package fftw

// #include <fftw3.h>
import "C"

import "unsafe"

type Plan struct {
  plan C.fftw_plan
}

func Alloc(n int) []complex128 {
  size := (C.size_t)(n * 16)
  return *(*[]complex128)((unsafe.Pointer)(C.fftw_malloc(size)))
}<commit_msg>Added a few more methods - working on release.2010-12-08<commit_after>package fftw

// #include <fftw3.h>
import "C"

import "unsafe"

// TODO: Need to handle garbage collecting plans
type Plan struct {
  plan C.fftw_plan
}
func (p *Plan) Execute() {
  C.fftw_execute(p.plan)
}


type Direction int
var Forward  Direction = C.FFTW_FORWARD
var Backward Direction = C.FFTW_BACKWARD

func Alloc1d(n int) []complex128 {
  return make([]complex128, n)
}
func Alloc2d(n0,n1 int) [][]complex128 {
  a := make([]complex128, n0*n1)
  r := make([][]complex128, n0)
  for i := range r {
    r[i] = a[i*n1 : (i+1)*n1]
  }
  return r
}


func PlanDft1d(in,out []complex128, dir Direction) *Plan {
  // TODO: check that len(in) == len(out)
  fftw_in := (*C.fftw_complex)((unsafe.Pointer)(&in[0]))
  fftw_out := (*C.fftw_complex)((unsafe.Pointer)(&out[0]))
  p := C.fftw_plan_dft_1d((C.int)(len(in)), fftw_in, fftw_out, C.int(dir), C.FFTW_ESTIMATE)
  return &Plan{p}
}

func PlanDft2d(in,out [][]complex128, dir Direction) *Plan {
  // TODO: check that in and out have the same dimensions
  fftw_in := (*C.fftw_complex)((unsafe.Pointer)(&in[0][0]))
  fftw_out := (*C.fftw_complex)((unsafe.Pointer)(&out[0][0]))
  p := C.fftw_plan_dft_2d((C.int)(len(in)), (C.int)(len(in[0])), fftw_in, fftw_out, C.int(dir), C.FFTW_ESTIMATE)
  return &Plan{p}
}

{'fraction_non_alphanumeric': 0.18364779874213835, 'fraction_numerical': 0.03773584905660377, 'mean_word_length': 4.582456140350877, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1381177', 'n_tokens_mistral': 713, 'n_tokens_neox': 670, 'n_words': 143}