generateme / fastmath

Fast primitive based math library
MIT License
238 stars 12 forks source link

Clojars Project

fastmath

A Clojure math library.

Documentation

3.0.0-alpha1 (WIP)

Fastmath book

2.4.0

Codox documentation

Clerk notebooks

Index

Installation

[generateme/fastmath "2.4.0"]

Alpha

[generateme/fastmath "3.0.0-alpha1"]

Source code in the 3.x branch.

2.3.0 GPL warning

Important Note

Fastmath 2.3.0 depends on SMILE 3.0.x which is GPL. That means that Fastmath 2.3.0 also should be treated as GPL. Version 2.4.x fixes it and brings back SMILE LGPL 2.x dependency.

MKL

Important Note

Fastmath relies on SMILE 2.6.0 which relies on BLAS/LAPACK via MKL and/or OpenBlas. MKL (preferred) and OpenBlas are included as dependencies in fastmath. This leads to addional 1GB of jar files. I can't assure that all functionalities will work on OpenBlas (see: #15) but 99% should. If you need fastmath to be lighter, please exclude MKL from your path.

lein / project.clj

[generateme/fastmath "2.4.0" :exclusions [com.github.haifengl/smile-mkl]]

deps.edn

{:deps {generateme/fastmath {:mvn/version "2.4.0"
                             :exclusions [com.github.haifengl/smile-mkl]}}}

If you don't need certain interpolation or clustering methods you can exclude OpenBlas as well (be warned that other things can break):

:exclusions [com.github.haifengl/smile-mkl org.bytedeco/openblas]

MKL Exception

When MKL is not available fastmath (SMILE actually, here and here) will throw two exceptions with full stack traces about lack of MKL. You can safely ignore them.

[main] DEBUG smile.math.blas.LAPACK - Failed to create MKL instance:
java.lang.ClassNotFoundException: smile.math.blas.mkl.MKL
[...]

[main] DEBUG smile.math.blas.BLAS - Failed to create MKL instance:
java.lang.ClassNotFoundException: smile.math.blas.mkl.MKL
[...]

Contribution

NOTE Currently we work on the 3.x branch only. PRs to master branch will not be accepted.

We accept PRs!

Content

PrimitiveMath

Code adopted from Zach Tellmans' library.

[* + - / > < >= <= == rem quot mod bit-or bit-and bit-xor bit-not bit-shift-left bit-shift-right unsigned-bit-shift-right inc dec zero? neg? pos? min max even? odd? bool-and bool-or bool-xor bool-not << >> >>> not==]

Math functions

Most of them backed by Jafama FastMath 2.3.1 or Apache Commons Math 3.6.1

Vector operations protocol and implementations

Matrix operations protocol and implementations

With typical basic matrix operations

Complex and Quaternion number functions

Integration, differentiations and solvers

Random numbers

Distributions

Noise

Statistics

Bootstrap

Bootstrap functions and confidence intervals

Interpolations

1d, 2d interpolations

Easings

Several easing functions (in, out, in-out)

Transforms

Vector fields

Great collection (100+) of R^2->R^2 functions.

Gaussian Processes

Gaussian Processes

Clustering

Various clustering algorithms including K-Means++, DBSCAN, CLARANS, DENCLUE, MEC, Spectral, Deterministic Annealing

Optimization

L-BFGS-B, Gradient, Nelder-Mead, Simplex, Powell, BOBYQA, CMAES, BayesianOptimizer, Linear optimizer

Grids

Hexagonal, squared, triangular, rhomboidal grid functions

Kernels

Collection of various kernels (density, RBF, correlation)

Signal

EFloat

Floating point operations with error bounds

Other

Plenty of constant values

Almost all functions optimized to work with double and long primitives

Supporting libraries

Alternatives

Since this library is only JVM version, you can check following Clojure/ClojureScript libraries as replacement

Java

Java classes are compiled for java 1.8

How To Help

If you see place of improvement, I'm accepting PRs.

Licence

Copyright (c) 2024 generateme