o
odinpkg.dev
packages / binding / OOURA_ODIN

OOURA_ODIN

c50eb66binding

Odin interface and bindings for the OOURA fft package by Dr. Takuya OOURA http://momonga.t.u-tokyo.ac.jp/~ooura/fft.html

BSD-3-Clause · updated 9 months ago

OOURA_ODIN

Odin interface and bindings for the OOURA fft package by Dr. Takuya OOURA

Documentations have been generated with the Odin doc generator:

Caution

Only the 1D FFT routines have been tested (on Windows). You may use it and report bugs if you come across any. The rest of the package is a WIP; use at your own risk.

What Is OOURA?

The Original Description for The Library

This is a package to calculate Discrete Fourier/Cosine/Sine Transforms of 1/2/3-dimensional sequences of length 2^N.

Additional Info

Usage

This shows an example of the usage of the odin wrapper provided here. For usage of the bindings themselves, consult the original documentation of the OOURA package. For convenience the original documentation has been copyied to this package, with explanations for each procedure provided above it, in the source files. (The documenting comments were copies as are. They will look ugly in the generated docs, view the in the source file instead.

Simple interface

n:= 16 // The size of the size of the signal needs to be a power of 2.

// We allocate a complex signal, since we are using the DFT transform. 
// check input type for other transforms.
x := make([]complex128, n) 
defer delete(x)

// Let's populate the signal with random values.
for i in 0..<n{
  x[i] = complex(rand.float64(), rand.float64())
}

// We can simply call the dft1d procedure to perform the transform.
f := ooura.dft1d(x)
defer delete(f)

// To inverse the transform we can simple set the inverse argument to false:
xf := ooura.dft1d(f, inverse=true)
defer delete(xf)

// That's all!!! :)

FFT Plan interface

n:= 16 // The size of the size of the signal needs to be a power of 2.

// We allocate a complex signal, since we are using the DFT transform. 
// check input type for other transforms.
x := make([]complex128, n) 
defer delete(x)

// Let's populate the signal with random values.
for i in 0..<n{
  x[i] = complex(rand.float64(), rand.float64())
}

// Then we create an 1D FFT plan with the type (FFT1D_Type.DFT).
plan := ooura.make_fft1d_plan(n, .DFT)
// Let's not forget to free the allocated memeory!
defer ooura.delete_fft1d_plan(plan)

// At any time we can execute the plan to perform the transform
f := ooura.execute_fft1d_plan(x, plan)
defer delete(f)
// We can do this as many times as we wish! However, the size of
// the input signals needs to be the same!
f2 := ooura.execute_fft1d_plan(x, plan)
defer delete(f2)

// To inverse the transform we can simple set the inverse argument to false:
xf := ooura.execute_fft1d_plan(f, plan, inverse=true)
defer delete(xf)

// That's all!!! :)

Original License for The OOURA Package

Copyright(C) 1996-2001 Takuya OOURA
email: ooura@mmm.t.u-tokyo.ac.jp
download: http://momonga.t.u-tokyo.ac.jp/~ooura/fft.html
You may use, copy, modify this code for any purpose and 
without fee. You may distribute this ORIGINAL package.