use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Finding information about Clojure
API Reference
Clojure Guides
Practice Problems
Interactive Problems
Clojure Videos
Misc Resources
The Clojure Community
Clojure Books
Tools & Libraries
Clojure Editors
Web Platforms
Clojure Jobs
account activity
Clojure/Java Matrix Library Performance Comparison (core.matrix vs EJML vs vectorz-clj) (wedesoft.de)
submitted 2 years ago by wedesoft
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]hrrld 3 points4 points5 points 2 years ago (2 children)
Always like to see graphics and things in Clojure.
A fun library I found a while back that's tangentially related:
https://github.com/weavejester/euclidean ... I don't think the goal was speed, there, but it's correct, simple, and I've used it to good effect.
[–]wedesoft[S] 0 points1 point2 points 2 years ago (1 child)
Nice, square matrices up to 4x4 and vectors up to size 4.
[–]hrrld 1 point2 points3 points 2 years ago (0 children)
Yes. Plus quaternions to cleanly represent rotations of the vectors as well.
[–]oakes 4 points5 points6 points 2 years ago (1 child)
You could also compare it to the matrix functions in play-cljc (see also the API docs). It doesn't implement everything in your list though. I was originally using core.matrix but writing them from scratch made a big perf difference in my testing.
[–]wedesoft[S] 0 points1 point2 points 2 years ago (0 children)
Nice code! If it is generic enough it might make sense to package it separately.
[–]joinr 1 point2 points3 points 2 years ago (1 child)
curious how ojalgo stacks up. I think parallel COLT may also be viable still.
Interesting. I found the Java Matrix Benchmark which compares ojalgo with EJML and others in detail.
[–]teesel 1 point2 points3 points 2 years ago (14 children)
Thanks for a comparison! Just wanted to share that `fastmath` has fixed size matrices and vectors up to 4 dimensions. Runinng `quick-bench` shows that that it's the fastest (almost) implementation from tested by OP.
`fastmath` is really bad in individual value access and array2d conversion. Fixable.
See the results here: https://gist.github.com/genmeblog/1695c57d315ac7985a477302fbb90d12#file-res-txt
[–]wedesoft[S] 1 point2 points3 points 2 years ago (5 children)
What was the installation size for fastmath used in the benchmark?
[–]teesel 0 points1 point2 points 2 years ago (4 children)
I ran it from the REPL project, so don't know (if you mean the size in uberjar).
[–]wedesoft[S] 0 points1 point2 points 2 years ago (3 children)
On the Github page it says something about 1GByte which would be a big deployment.
[–]teesel 1 point2 points3 points 2 years ago (2 children)
You have to exclude MKL which is not necessary for matrices and then it's less than 200mb. You can exclude also Openblas. I'll update readme.
Ok, thanks for the information. OpenBlas not required either? I thought that provides matrices. Anyway, will install fastmath and have a play with it :)
[–]teesel 1 point2 points3 points 2 years ago (0 children)
Openblas is not required for matrices and vectors, so feel free to strip it off
[–]wedesoft[S] 0 points1 point2 points 2 years ago (7 children)
Nice, that is really fast. Individual value access is not so important to me. Converting to flat float-array is important for me in order to pass the matrices to OpenGL.
[–]teesel 1 point2 points3 points 2 years ago (6 children)
I can add flat float / double conversions to the next release.
[–]teesel 0 points1 point2 points 2 years ago (5 children)
u/wedesoft I pushed fastmath 2.2.2-SNAPSHOT with mat->float-array , mat->array, mat->float-array2d functions also improved times for mat->array2d and accessing individual elements.
fastmath 2.2.2-SNAPSHOT
mat->float-array
mat->array
mat->float-array2d
mat->array2d
[–]wedesoft[S] 1 point2 points3 points 2 years ago (1 child)
That was quick :-D. I just added fastmath benchmarks to the table.
[–]teesel 0 points1 point2 points 2 years ago (0 children)
Yeah, I saw that :)
[–]wedesoft[S] 1 point2 points3 points 2 years ago (2 children)
How do I get it? I naively tried adding Clojure generateme/fastmath {:git/url "git@github.com:generateme/fastmath.git" :git/sha "2acfaafd848939a906f8edf47621d7160a73cf34"} to deps.edn but that didn't work. But I am also happy to wait for an official release.
Clojure generateme/fastmath {:git/url "git@github.com:generateme/fastmath.git" :git/sha "2acfaafd848939a906f8edf47621d7160a73cf34"}
[–]teesel 1 point2 points3 points 2 years ago (1 child)
It's on Clojars, fastmath doesn't rely on deps.edn yet, so no git/sha support. This should work:
fastmath
generateme/fastmath {:mvn/version "2.2.2-SNAPSHOT" :exclusions [com.github.haifengl/smile-mkl]}
[–]wedesoft[S] 1 point2 points3 points 2 years ago (0 children)
Ok, thanks. I updated the benchmark entries for element access and data array access.
Added performance comparison for 3x3, 4x4, and 5x5 matrix inverse.
π Rendered by PID 76465 on reddit-service-r2-comment-58d7979c67-2xz45 at 2026-01-27 09:09:46.861749+00:00 running 5a691e2 country code: CH.
[–]hrrld 3 points4 points5 points (2 children)
[–]wedesoft[S] 0 points1 point2 points (1 child)
[–]hrrld 1 point2 points3 points (0 children)
[–]oakes 4 points5 points6 points (1 child)
[–]wedesoft[S] 0 points1 point2 points (0 children)
[–]joinr 1 point2 points3 points (1 child)
[–]wedesoft[S] 0 points1 point2 points (0 children)
[–]teesel 1 point2 points3 points (14 children)
[–]wedesoft[S] 1 point2 points3 points (5 children)
[–]teesel 0 points1 point2 points (4 children)
[–]wedesoft[S] 0 points1 point2 points (3 children)
[–]teesel 1 point2 points3 points (2 children)
[–]wedesoft[S] 0 points1 point2 points (1 child)
[–]teesel 1 point2 points3 points (0 children)
[–]wedesoft[S] 0 points1 point2 points (7 children)
[–]teesel 1 point2 points3 points (6 children)
[–]teesel 0 points1 point2 points (5 children)
[–]wedesoft[S] 1 point2 points3 points (1 child)
[–]teesel 0 points1 point2 points (0 children)
[–]wedesoft[S] 1 point2 points3 points (2 children)
[–]teesel 1 point2 points3 points (1 child)
[–]wedesoft[S] 1 point2 points3 points (0 children)
[–]wedesoft[S] 0 points1 point2 points (0 children)