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 post of
this thread.

The performance isn't a huge deal to me: I'm sorry if I left the
impression that this was a pressing issue. I will eventually be
implementing the FFT in Clojure (code to be posted if it's decent: I
think I might have a better time expressing that functionally than
this) and that speeds up convolution by orders of magnitude anyway.
I'll also, ideally, be parallelizing it. This was more of an exercise
for myself, and than it turned out to be so interesting that I thought
I'd pose it to the community, as my own solutions seemed lacking or
rather imperative.

I am impressed with the beauty of some of the functional solutions;
the issue is that the ones that work well are decidedly less
functional than would be ideal. Ideal only in that, well, it'd be nice
to have a functional solution that is speedy: I think it'd be neat.

The solutions here ranged from functional (slow), to procedural but
still in Clojure (could get rather fast) to basically Java (a little
faster than the latter).

I'm not unhappy with this: I learned a lot from the answers here, and
I got an idea of some limitation of purely functional Clojure (for
now: Stuart Sierra says this might get better soon?) I want to say
thank you to all of you who posted. I'll be posting more soon, about
the FFT, when the time comes: should be fun!

--individual responses--

@David Nolan:
Sent you a Twitter message–I am having trouble running your solution,
but that looks nicely Clojuresque and speedy. I was unaware of
`dotimes`.

@Michael Gardener:
You're right: it's idiomatic, though not functional. I misspoke there:
Clojure is, reluctantly it seems, multi-paradigm. And you're right, if
I just wanted raw, single-threaded, speed, I would go with C. But I'd
like to do this in Clojure!

@Carson:
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.

@j-g-faustus:
I agree with you completely: as I said above, it can be expressed in
the language, and can even be rather elegant. What you don't get is
speed, and not too much functional-style programming going on.

As for what's practical, yes, Clojure might not be it if all I want is
the raw speed. And translating imperative algorithms to functional
isn't always easy: but it's fun! And the other advantages that Clojure
has over C and its ilk make it really nice for the project(s) I'm
working on.

-----

Thank you all again!



On Jul 17, 9:13 pm, Frederick Polgardy <f...@polgardy.com> wrote:
> 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
>
> --
> Science answers questions; philosophy questions answers.
>
> On Jul 17, 2010, at 3:43 PM, Isaac Hodes wrote:
>
>
>
> > double convolve(double *xs, double *is, double *ys){
> >  int i,j;
> >  for(i=0; i<len(xs); i++){
> >    for(j=0; j<len(is); j++){
> >      ys[i+j] = ys[i+j] + (xs[i]*is[j]);
> >    }
> >  }
> >  return ys;
> > }

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to