Hello, > > If you are after numerical calculations for mxn matrices, then look at > `flomat` > which uses the same underlying C/Fortran library that NumPy uses. > > https://docs.racket-lang.org/manual-flomat/index.html > > If you need rrays with more dimensions than 2 use `math/array`. > > If you need simple computation of 1-dimensional data, you can use > standard Racket vectors (or flomats or arrays).
I didn't know about `flomat'. Thanks for (yet another) good hint. However, for my project I needed really fast matrix multiplication (and other basic linear algebra functions). It turned out that most of the available options are sub-optimal at best. To my surprise `flomat` is one of those. Mostly I am concerned with 3D and 4D matrices and vectors. During the past few months I hacked together a fairly optimized module[1] for performing these operations that defines algebras for given dimension during macro expansion stage and all the procedures are constructed in a way that helps Racket (mainly CS) perform all operations unboxed. In the repository, there is a benchmark script, which yields the following (self-explanatory) results: ==== Welcome to Racket v7.9.0.5 [cs]. # 1000000 iterations ## flalgebra mat3x3*mat3x3! cpu time: 13 real time: 13 gc time: 0 mat3x3*mat3x3 cpu time: 23 real time: 23 gc time: 4 ## math/matrix matrix*matrix cpu time: 55892 real time: 55911 gc time: 463 ## math/typed/matrix matrix*matrix cpu time: 6861 real time: 6862 gc time: 1045 ## flomat matrix*matrix! cpu time: 887 real time: 887 gc time: 4 matrix*matrix cpu time: 1825 real time: 1825 gc time: 7 ==== Welcome to Racket v7.9 [bc]. # 1000000 iterations ## flalgebra mat3x3*mat3x3! cpu time: 145 real time: 145 gc time: 7 mat3x3*mat3x3 cpu time: 163 real time: 163 gc time: 2 ## math/matrix matrix*matrix cpu time: 53817 real time: 53788 gc time: 733 ## math/typed/matrix matrix*matrix cpu time: 3852 real time: 3851 gc time: 730 ## flomat matrix*matrix! cpu time: 745 real time: 745 gc time: 1 matrix*matrix cpu time: 1621 real time: 1620 gc time: 1 What puzzles me the most: when I read `flomat' documentation, I thought it must beat my implementation by far margin - it's a native code for really basic number crunching. When using the `times!' variant of matrix multiplication, I would expect it to outperform anything implemented in in pure Racket. Is there something I miss or is it really the case, that carefully crafted Racket implementation is the fastest option right now? I actually wanted to write a similar email some time ago - in the spring - about the typed math/matrix variant. But I was almost certain I am doing something wrong and should figure it out. Now I am more and more convinced that the performance of all number crunching libraries - as they can be used in Racket - might be the real issue here. Cheers, Dominik [1] https://gitlab.com/racketeer/flalgebra -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/c94bf70d-1563-62d5-7632-bbaade7eb97f%40trustica.cz.