Re: Adding up numbers, quickly

2014-10-17 Thread Jony Hudson
Thanks all again for the advice. For the record, I ended up writing the loop in Java - being constrained on the type of the data (it ultimately comes from Java code), and not wanting to pay the (newly reduced!) price of converting to vectorz for just this operation, this seemed like the best

Re: Adding up numbers, quickly

2014-10-17 Thread bernardH
On Friday, October 17, 2014 1:21:55 PM UTC+2, Jony Hudson wrote: Thanks all again for the advice. For the record, I ended up writing the loop in Java - being constrained on the type of the data (it ultimately comes from Java code), and not wanting to pay the (newly reduced!) price of

Re: Adding up numbers, quickly

2014-10-16 Thread Mikera
This is a case where I would definitely recommend using core.matrix / vectorz-clj (let [a (array :vectorz (range 1000)) b (array :vectorz (range 1000 2000))] (criterium/quick-bench (esum (sub a b = Execution time mean : 2.266914 µs Or it's even faster if you notice that you

Re: Adding up numbers, quickly

2014-10-16 Thread Jony Hudson
Thanks @Mikera. I had a look at using core.matrix, but what I couldn't figure out is how to quickly get the data into core.matrix form. For instance, if I take my PersistentList of Doubles from the example then getting it into a vectors array takes: (criterium/quick-bench (array :vectorz a))

Re: Adding up numbers, quickly

2014-10-16 Thread Mikera
On Thursday, 16 October 2014 18:04:39 UTC+8, Jony Hudson wrote: Thanks @Mikera. I had a look at using core.matrix, but what I couldn't figure out is how to quickly get the data into core.matrix form. For instance, if I take my PersistentList of Doubles from the example then getting it into

Adding up numbers, quickly

2014-10-15 Thread Jony Hudson
Hi all, another performance question ... this time about arithmetic on vectors :-) Let's say I have two vectors of numbers (specifically, things with type clojure.lang.PersistentVector, containing things of type java.lang.Double). And let's say I want to sum the differences [1] between

Re: Adding up numbers, quickly

2014-10-15 Thread Jozef Wagner
Slowdowns wrt math are caused mainly by boxing and range check, see this thread [1] [1] https://groups.google.com/d/msg/clojure/kcx5eKdMxcs/Wy4_IHrSEaMJ Jozef On Wednesday, October 15, 2014 9:53:40 PM UTC+2, Jony Hudson wrote: Hi all, another performance question ... this time about

Re: Adding up numbers, quickly

2014-10-15 Thread Jony Hudson
Thanks, that's really useful! Jony On Wednesday, 15 October 2014 20:53:40 UTC+1, Jony Hudson wrote: Hi all, another performance question ... this time about arithmetic on vectors :-) Let's say I have two vectors of numbers (specifically, things with type clojure.lang.PersistentVector,

Re: Adding up numbers, quickly

2014-10-15 Thread Linus Ericsson
There are primitive vectors. Extraordinary clever. http://clojuredocs.org/clojure.core/vector-of /Linus Den 16 okt 2014 00:02 skrev Jony Hudson jonyepsi...@gmail.com: Thanks, that's really useful! Jony On Wednesday, 15 October 2014 20:53:40 UTC+1, Jony Hudson wrote: Hi all, another