[ccan] Mathematics Module
Rusty Russell
rusty at rustcorp.com.au
Wed Jan 28 21:03:20 EST 2009
On Monday 26 January 2009 02:02:13 Rupinder Singh wrote:
> Hello,
Hi Rupinder,
> You are correct, and I agree with that. But I think the more complex its
> made, the more application dependent it becomes. Not as basic as str, but I
> believe the modules should be such that the routines are frequently used but
> not many have ever cared to keep them typed. I'll redo it if you say so.
>
> Just a thought.
Well, gcd is optimal, but there are better methods of establishing primes and squares (your gcd example string is wrong, too BTW). For a start, I'd make them take unsigned long, rather than int. Then for squares I believe you can make a faster approximation using the most significant bit, but I'd have to do some math to figure out how. Google might have an even better algo.
For primes, there's surely a better way than this too. A classic sieve approach seems like it might fit here, but there are definitely papers on how to do this.
A simple benchmark should demonstrate these (*and* serve as a good testcase).
Oh, I also prefer is_prime, is_square and gcd over BumpyCaps, but that's just a personal thing.
> > Hmm, you had to create an err.h?
> >
>
> Done it : Can we change the Werror somehow ? So that it doesnt treat the
> warnings as errors
Hmm, it's proven useful in the past to have -Werr. But delete it for now from the Makefile.
We should really use our own on platforms that deprecate it: err/errx and warn/warnx are really sweet interfaces.
ccan/err?
Thanks!
Rusty.
More information about the ccan
mailing list