elcritch

elcritch

MatrexNumerix - Numeric stats library ported to (fast) nif based matrix library Matrex for fast stats and data-science.

I ported the Numerix math and statistics library to use the Matrex library. A couple of convenience functions have been added to Matrex, primarily Matrex.from_list/1 which produces a “vector” (just 1 row matrex with function guards). These can then be properly dotted as vectors by using the Matrex.inner_dot/2 function. This enables most “vector” based numerical algorithms to be encoded without getting transposes mixed up.

On the Numerix side the port contains almost all of the features of the original library. The test framework has been switched to plain exunit.

A new feature that’s been added is a 1d fast Fourier transform (FFT) which produces results comparable to NumPy’s fft module. It supports complex numbers by using a 2xN matrix size (e.g. real and imaginary components are stored in separate rows side by side). It’d be possible to generalize it to 2d (or more) for image FFT’s, if anyone’s interested.

One last note is that a polynomial fitting function has been added to Matrex.Algorithms.fit_poly/3 which supports fitting polynomial coefficients for a given x and y vector using gradient descent. Sometimes this produces better results than least squares.

First 3 of 3 Posts Switch mode

dsd

dsd

Is Matrex the go to math and statistics library for Elixir? I could not find a way to use FFT as mentioned in this post. Any guidance on how to use FFT with Matrex?

elcritch

elcritch OP

Matrex is mostly for linear algebra and such. Numerix is probably the closest to a “math and statistics” Elixir has currently (that I know of). So I’d ported Numerix to Matrex, and added a few extras (like the FFT).

See matrex_numerix/test/fft_test.exs at master · elcritch/matrex_numerix · GitHub for how to use it. It should be back-portable to Numerix or Nx. Note it’s probably not fast.

Note, the to_freq_and_amplitude is important to put the data in a recognizable frequency power form.

MatrexNumerix currently uses a forked version of Matrex that supports vectors (aka rank 1 tensors).

The FFT in theory should be portable to Nx as well.

dsd

dsd

Much appreciate the response. That helps.

— All posts loaded —

Where Next? Top

Trending in Announcing Top

bluzky
You may know https://ui.shadcn.com/, a UI component library for React. I really love it’s design style and components. I’ve built some co...
387 15136 120
New
woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
restlessronin
The repo is at GitHub - cyberchitta/openai_ex: Community maintained Elixir library for OpenAI API · GitHub. Docs are at OpenaiEx User Gu...
152 11030 135
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
shahryarjb
The Chelekom project is a library of Phoenix and LiveView components generated via Mix tasks to fit developer needs seamlessly. One of i...
New
woylie
Phoenix components for pagination, sortable tables and filter forms with Flop and (optionally) Ecto. pagination cursor pagination sorta...
New
kip
Please say hi to a new lib, Astro that aims to deliver easy-to-consume astronomy calculations of practical use. For now it only calculat...
New

Other Trending Topics Top

akoutmos
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
alexslade
Fly’s CEO posted this recently - Turn And Face The Strange · The Fly Blog It says that Fly is going all-in on sprites, which is a worry ...
New
Herve37
We’re evaluating API mocking tools for OpenAPI-based projects and would love to hear what other teams are using. We’re particularly inte...
New
bartblast
Hey folks, I just published a post about Hologram’s funding and where the project goes next - the short version: Curiosum as Main Spons...
New
matt-savvy
Is there a word for the ~> symbol used in Version strings? Do you also just call it a Squiggle Arrow™ ?!
New

We're in Beta

About us Mission Statement