J(a language of the APL family) excels at this problem domain. It is
functional and very efficient.
conv =: +//@*/
It looks like line noise but that is the whole implementation
(1 1 ) conv (1 1)
=> 1 2 1
http://www.jsoftware.com/
--
You received this message because you are subscribed to
I have found Clojure to be consistently faster than Python, so I
thought it would be instructive to compare the Python code to the
closest Clojure equivalent.
Here's the originally posted Python code:
from itertools import repeat
def convolve(ns, ms):
y = [i for i in repeat(0, len(ns)+len(ms)
I should add, "oops, ignore what I wrote". :)
see:
https://groups.google.com/group/clojure/tree/browse_frm/thread/33366bccc6df7756/415072576d83b757?rnum=11&_done=%2Fgroup%2Fclojure%2Fbrowse_frm%2Fthread%2F33366bccc6df7756%3F#doc_0d0a3759a0a10328
Carson
On Jul 17, 3:58 pm, Carson wrote:
> Hi, T
Hi, Try this:
(defn stationary-convolve [n fs gs]
(let [window-size (count fs)
padding (repeat window-size 0)
padded-gs (concat padding gs padding)
new-center (+ n window-size)
window-of-gs (subvec (vec padded-gs)
(- (inc new-center) w
I thought this problem was interesting enough to merit better
treatment than I can give it here, hence a blog post was in order.
Brief version: I think I have a lazy, functional, and idiomatic
implementation with decent performance. Check it out here:
http://erl.nfshost.com/2010/07/17/discrete-co
On 17 July 2010 18:41, David Cabana wrote:
> I tried to run Jame's code, but the compiler (1.2 beta) squawked at me:
> Unable to resolve symbol: indexed in this context
> [Thrown class java.lang.Exception]
>
> What do I need to pull in to pick up the "indexed" function?
Sorry, I should have ment
It's in contrib.seq-utils
http://richhickey.github.com/clojure-contrib/seq-utils-api.html#clojure.contrib.seq-utils/indexed
On Jul 17, 2010, at 1:41 PM, David Cabana wrote:
> I tried to run Jame's code, but the compiler (1.2 beta) squawked at me:
> Unable to resolve symbol: indexed in this con
I tried to run Jame's code, but the compiler (1.2 beta) squawked at me:
Unable to resolve symbol: indexed in this context
[Thrown class java.lang.Exception]
What do I need to pull in to pick up the "indexed" function?
On Sat, Jul 17, 2010 at 5:08 AM, James Reeves wrote:
> Perhaps something lik
This statement is interesting. Part of what makes the Python implementation so
expressive is precisely the use of functional constructs like list
comprehensions, ranges, and all the awesome stuff in itertools. A purely
imperative implementation would probably be as clunky as the purely functiona
On Jul 16, 11:26 pm, Frederick Polgardy wrote:
> Where's the link? :)
>
> -Fred
Whew. Here it is; my bad!
http://stackoverflow.com/questions/3259825/trouble-with-lazy-convolution-fn-in-clojure
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To p
On 16 July 2010 20:57, Isaac Hodes wrote:
> I am trying to create a lazy/functional/efficient/Clojuresque function
> to carry out convolution on two lists/vectors of (ideally BigDecimals
> but that may be inefficient) doubles.
Perhaps something like this?
(defn convolve [ns ms]
(loop [nums (fo
I'm assuming the StackOverflow link you refer to is
http://stackoverflow.com/questions/3259825/trouble-with-lazy-convolution-fn-in-clojure.
I would think about the problem this way: to compute the value at index i in
the output list, you multiply together each pair of values in the input lists
Where's the link? :)
-Fred
--
Science answers questions; philosophy questions answers.
On Jul 16, 2010, at 2:57 PM, Isaac Hodes wrote:
> I posted this on StackOverflow yesterday, but to no avail: I don't
> think many people looked at it, or least I didn't get much feedback.
>
> I am trying to
I posted this on StackOverflow yesterday, but to no avail: I don't
think many people looked at it, or least I didn't get much feedback.
I am trying to create a lazy/functional/efficient/Clojuresque function
to carry out convolution on two lists/vectors of (ideally BigDecimals
but that may be ineff
14 matches
Mail list logo