npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ml-fft

v1.3.5

Published

fft

Downloads

71,828

Readme

ml-fft

NPM version build status David deps npm download

fft library for the ml libraries.

The idea of this, another flavor of the FFT library, is to perform, Real and Complex matrix FFT and IFFT, by using only the 1D FFT algorithm. The 1D FFT and IFFT was taken and adapted from this project: [https://github.com/wellflat/javascript-labs/tree/master/cv/fft]

Installation

$ npm install ml-fft

Import in node

var lib = require("ml-fft");
var FFT = lib.FFT;
var FFTUtils = lib.FFTUtils

1D FFT and IFFT

var n = 16; 
var nCols = n; 
FFT.init(nCols);
var re = new Array(nCols);
var im = new Array(nCols);

for(var i=0;i<nCols;i++){
   re[i]=i;
   im[i]=nCols-i-1;
}

FFT.fft(re, im);
FFT.ifft(re, im);

2D FFT and 2D IFFT

data contains the matrix. The even rows contain the real part, the odd rows contain the imaginary part.

var n = 4;
var nRows = n;
var nCols = n;
var data = new Array(nRows*nCols);
for(var i=0;i<nRows;i++){
    for(var j=0;j<nCols;j++){
        data[i*nCols+j]=i+j;
    }
}
var ftData = FFTUtils.fft2DArray(data, nCols, nCols);
var ftRows = nRows * 2;
var ftCols = nCols / 2 + 1;
var iftData =  FFTUtils.ifft2DArray(ftData, ftRows, ftCols);

Matrix-Matrix convolution.

It performs the convolution in the Fourier space(multiplication) and then makes an inverse transformation of the result. The difference in performance can be tested in the BenchMark script.

var n=1024;
var data = new Uint32Array(n*n);
for(var i=0;i<n;i++){
    for(var j=0;j<n;j++){
        data[i*n+j]=i+j;
    }
}

var kn = 21;
var kernel = new Array(kn);
for(var i=0;i<kn;i++){
  kernel[i]=new Array(kn);
  for(var j=0;j<kn;j++){
      kernel[i][j]=i+j;
  }
}

var convolutedData = FFTUtils.convolute(data, kernel, n, n);

toRadix2

Convert the data matrix to a radix2 2D matrix. The input data is a a single vector containing all the values of the matrix

FFTUtils.toRadix2(data, nRows, nCols);

License

MIT