Matrex - A blazing fast matrix library for Elixir/Erlang with C implementation using CBLAS (Machine Learning)

Michal,

I considered using NIF resource, but decided to stay with explicit binary for 3 reasons:

  1. I don’t want to add unnecessary NIFs, when Elixir gives the same speed or operation is not time-critical.
  2. Pattern matching for simple operations, like getting the size of the matirx.
  3. There is an idea to implement Elixir versions of all the NIFs, so they would
    work as fallback functions that work everywhere. E.g., when NIFs would fail to compile for some reasons. I don’t know if it’s worth the effort, but don’t want to cut off such possibilities.

And NIF resource leaves us only with , AFAIK?

%Matrex{} struct now works mostly for the purpose of implementing protocols and behaviours (Inspect, Enum and Access). It gives the opportunity to add more fields later, to distinguish matrices with
different element types and sizes, different matrix shapes and so on.

So, I believe, the current setup gives greater flexibility in future development.
But I did not dig deep into NIF resources, so, maybe I am missing something.

4 Likes