Git Product home page Git Product logo

luafft's Introduction

Introduction

luafft is an easy to use Fast Fourier Transformation package in pure Lua. It is based on the FFT implementation of KissFFT by Mark Borgerding which is both easy to use and extremly fast. It also uses the complex number module from the Numeric Lua package.

Note: This is a very early version of the code. Although the algorithm has been thoroughly tested by Mark Borgerding, there may very well be bugs that have not been found yet. Please feel free to comment on any source code related problems.

Installation

LuaFFT is part of the LuaRocks repository where it can be easily installed by using:

luarocks install luafft

or simply use Git:

git clone git://github.com/vection/LuaFFT.git

Usage

LuaFFT is very easy to use. The following lines of code show, how to carry out a simple Fast Fourier Transformation. Keep in mind, that values have to be given as complex values, otherwise luafft returns an error.

luafft = require "luafft"

local list1 = {}
local size = 2048

--Populates a list with random real numbers in complex format
function populate(list)
  for i=1,size do
      list[i] = complex.new(math.random(), 0)
  end
end

--displays a comparison of two lists with complex numbers
function compare(one, two)
  for i=1,#one do print(string.format("1: %s\t2: %s\n",
 tostring(one[i]),tostring(two[i]))) end
end

--devide a list with a certain constant factor
function devide(list, factor)
  for i,v in ipairs(list) do list[i] = list[i] / factor end
end

--create a list with random real values
populate(list1)

--carry out fast fourier transformation and store result in "ret"
ret = fft(list1, false)

--now carry out inverse fast fourier transformation and store result in "ret2"
ret2 = fft(ret, true)

--After retransformation, we need to devide by the data size
devide(ret2, size)

--displays a comparison of the input and the output, the real part should be equal
--the imaginary part is non zero (but fairly close) due to several calculations
--that have been carried out in the FFT
compare(list2,ret)

Licence and Version

luafft is licensed under the same license as Lua -- the MIT license -- and so can be freely used for academic and commercial purposes.

luafft's People

Contributors

h4rm avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.