A Matrix Library for Erlang in Erlang
This is an native Erlang linear algebra library (linalg).
The function signatures and results strive to match numpy and scipy linalg.
The are also erlang-linalg NIF libraries avalible that match in function
names, signature and results. This is the native version is slower than
those NIFs. This code was written to be readable and (maybe) teachable rather
than fast.
Erlang’s lists:nth indexes start at 1; and linalg’s Row, Col, Cell, ArgMax and ArgMin
function use this convention. This differs from python et al at start at 0.
Like the numpy and scipy, matrix input is alway expected to be Row Major.
In version 1.2 there is now support for complex numbers. And there is a svd power
function that uses qr Householder method.
Errors are now raised and return a string message rather than a error tuple.
Suggestions, enhancements and pull-requests welcomed.
There are no dependancies. In the top directory, compile using rebar/rebar3.
rebar3 compile
To include it as a rebar.config dependancy, add the line below.
{deps,[
{linalg, ".*", {git, "https://github.com/sklassen/erlang-linalg-native.git"}}
]}
Creation and Description
Matrix and Vector
Decomposition
Norms and others
Solves and inversion
Basic Scalar, Vector and Matrix Arithmetric
Reductions
Note: errors return as erlang:error(String).
Below are a few examples. See the tests directory for more examples.
Erlang R16B03 (erts-5.10.4) [source] [64-bit]
Eshell V5.10.4 (abort with ^G)
1> linalg:dot([1.0,2.0],[3.0,4.0]).
1> linalg:transpose([[1.0,2.0],[3.0,4.0]]).
1> linalg:matmul([[1.0,2.0],[3.0,4.0]],[[1.0,2.0,3.0],[4.0,5.0,6.0]]).
1> linalg:mul([1,2,3],[4,5,6]).
1> linalg:add(10,[[1,2,3],[4,5,6]]).
This project is licensed under the terms of the GNU General Public License v3.0