On Monday, 25 February 2013 18:17:50 UTC+8, Mikera wrote:

> Hi All,
>
> Pleased to announce the latest release of vectorz-clj, a high performance 
> vector and matrix math implementation for Clojure.
>
> GitHub site: https://github.com/mikera/vectorz-clj
> Clojars: https://clojars.org/net.mikera/vectorz-clj
>
> Key features:
>
> a) 100% pure JVM code (no native libraries required)
> b) Supports a clean, functional, idiomatic style of vector and matrix 
> maths in Clojure
> c) Currently the most complete implementation of the "core.matrix" API for 
> Clojure numerics
> d) Very fast - designed for games, simulations, machine learning 
> applications etc.
>
> For an idea of performance, it is worth comparing with regular Clojure 
> vectors:
>
>   (let [a [1 2 3 4 5 6 7 8 9 10]
>         b [1 2 3 4 5 6 7 8 9 10]]
>     (c/quick-bench (dotimes [i 1000] (vec (map clojure.core/+ a b)))))  
>   ;; => Execution time mean per addition : 1221 ns
>
> Using vectorz-clj to do the same additions is about 15-20x faster:
>
>   (let [a (matrix :vectorz [1 2 3 4 5 6 7 8 9 10])
>         b (matrix :vectorz [1 2 3 4 5 6 7 8 9 10])]
>     (c/quick-bench (dotimes [i 1000] (+ a b))))
>   ;; => Execution time mean per addition: 68 ns
>
> If you are willing to abandon immutability and use mutable vectors, you 
> can go faster still:
>
>   (let [a (matrix :vectorz [1 2 3 4 5 6 7 8 9 10])
>         b (matrix :vectorz [1 2 3 4 5 6 7 8 9 10])]
>     (c/quick-bench (dotimes [i 1000] (add! a b))))
>   ;; => Execution time mean per addition: 31 ns
>
>
Incidentally, I found that if you call Vectorz methods directly using Java 
interop, you can go even faster again. I think the difference is mainly in 
the overhead of making a polymorphic call via a dynamically extended 
Clojure protocol, but I need to investigate a bit further to figure out 
what is really happening here:

  (let [a (Vectorz/create [1 2 3 4 5 6 7 8 9 10])
        b (Vectorz/create [1 2 3 4 5 6 7 8 9 10])]
    (c/quick-bench (dotimes [i 1000] (.add a b))))
  ;; => Execution time mean per addition: 11 ns
 

> This is all still very much in early development, so feedback / ideas / 
> code contributions all very welcome!
>
>   Mike.
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to