Re: Response

2010-07-18 Thread Jeffrey Schwab
On 7/17/10 4:43 PM, Isaac Hodes wrote: Apologies in advance if this is somewhat OT in a Clojure group. double convolve(double *xs, double *is, double *ys){ int i,j; for(i=0; i How are you getting the size of the collections from the pointers, and why are you checking the lengths on ever

Re: Response

2010-07-18 Thread Michael Gardner
On Jul 17, 2010, at 9:46 PM, Isaac Hodes wrote: > I did check out your response: it's rather fast on my machine. it's > not really functional, though, as you use the `let` macro as a way of > procedurally executing a lot of functions. This isn't bad at all, but > you're not composing functions. '

Re: Response

2010-07-18 Thread Isaac Hodes
First: sorry for splitting the conversation. That was my fault: don't know how it happened. For those following along: the thread this started with is here: http://groups.google.com/group/clojure/browse_thread/thread/ee4169bc292ab572 Second, I don't think I expressed myself well in the original p

Re: Response

2010-07-17 Thread Carson
Hi Per, woh, take it easy. I don't claim to be an expert. Thanks for showing me that though. It certainly didn't seem right at first, but I had trouble figuring out the laziness in clojure, me being new to it. Anyway, have a good weekend! Carson On Jul 17, 10:02 pm, Per Vognsen wrote: > How a

Re: Response

2010-07-17 Thread Per Vognsen
On Sun, Jul 18, 2010 at 11:32 AM, Carson wrote: > I guess different people see things differently.  I actually didn't > understand the intent of the imperative version, even though it takes > less lines I guess.  There's quite a few things called convolution. > My naive implementation was function

Re: Response

2010-07-17 Thread Carson
Thanks David. On Jul 17, 4:58 pm, David Nolen wrote: > I tried this, it runs in about the same amount of time as it did for you. > > On Sat, Jul 17, 2010 at 7:17 PM, Carson wrote: > > Hi David, > > Would appreciate if you could try out my attempt at this [1] on your > > machine.  My machine ain'

Re: Response

2010-07-17 Thread Carson
I guess different people see things differently. I actually didn't understand the intent of the imperative version, even though it takes less lines I guess. There's quite a few things called convolution. My naive implementation was functional and pretty fast. Turns out it can be even faster with

Re: Response

2010-07-17 Thread Frederick Polgardy
I think it really doesn't get any clearer than this in terms of intent. While I was adept at calculus-level math 20 years ago, I've forgotten the little I knew of matrices. This is the first algorithm that has communicated by visual inspection (to me) exactly what a convolution is. -Fred -- Sc

Re: Response

2010-07-17 Thread Carson
Have you taken a look at my attempt at a solution (on the other/ original thread)? https://groups.google.com/group/clojure/tree/browse_frm/thread/ee4169bc292ab572/6d03461efde166ad?rnum=11&_done=%2Fgroup%2Fclojure%2Fbrowse_frm%2Fthread%2Fee4169bc292ab572%3F#doc_6d03461efde166ad I don't know if it

Re: Response

2010-07-17 Thread Frederick Polgardy
This example is beside the point of the original question. It uses mutable arrays. It's very much dropping to the Java level. Am I missing something? -Fred -- Science answers questions; philosophy questions answers. On Jul 17, 2010, at 6:04 PM, David Nolen wrote: > (defn ^{:static true} convol

Re: Response

2010-07-17 Thread j-g-faustus
On 17 Jul, 22:43, Isaac Hodes wrote: > It's just a shame, it seems to me, that there is such a nice way to > represent the procedure in Python or even C, yet Clojure (or any Lisp > really) struggles to idiomatically answer this question of > convolution. I'll have to disagree with the conclusion.

Re: Response

2010-07-17 Thread David Nolen
I tried this, it runs in about the same amount of time as it did for you. On Sat, Jul 17, 2010 at 7:17 PM, Carson wrote: > Hi David, > Would appreciate if you could try out my attempt at this [1] on your > machine. My machine ain't as fast as yours apparently... > > [1] > > https://groups.googl

Re: Response

2010-07-17 Thread Carson
Hi David, Would appreciate if you could try out my attempt at this [1] on your machine. My machine ain't as fast as yours apparently... [1] https://groups.google.com/group/clojure/tree/browse_frm/thread/ee4169bc292ab572/6d03461efde166ad?rnum=11&_done=%2Fgroup%2Fclojure%2Fbrowse_frm%2Fthread%2Fee4

Re: Response

2010-07-17 Thread Michael Gardner
On Jul 17, 2010, at 3:43 PM, Isaac Hodes wrote: > It's just a shame, it seems to me, that there is such a nice way to > represent the procedure in Python or even C, yet Clojure (or any Lisp > really) struggles to idiomatically answer this question of > convolution. No, it's pretty easy to do conv

Re: Response

2010-07-17 Thread David Nolen
(defn ^{:static true} convolve ^doubles [^doubles xs ^doubles is] (let [xlen (count xs) ilen (count is) ys (double-array (dec (+ xlen ilen)))] (dotimes [p xlen] (dotimes [q ilen] (let [n (+ p q), x (aget xs p), i (aget is q), y (aget ys n)] (aset ys n