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<len(xs); i++){
for(j=0; j<len(is); j++){
How are you getting the size of the collections from the pointers, and
why are you checking the lengths on every loop pass (rather than once, a
priori)?
ys[i+j] = ys[i+j] + (xs[i]*is[j]);
The following would be more idiomatic:
ys[i + j] += xs[i] * is[j];
Less repetition, less line noise, and in C++, it may avoid some
unnecessary temporaries if you ever abstract from raw ints and doubles
to something less likely to be elided by the compiler (e.g.
Clojure-style, overflow-detecting types).
}
}
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