2008/11/5 Charles R Harris <charlesr.harris@gmail.com>:
Hi All,
I'm thinking of adding some new ufuncs. Some possibilities are
expadd(a,b) = exp(a) + exp(b) -- For numbers stored as logs:
Surely this should be log(exp(a)+exp(b))? That would be extremely useful, yes.
absdiff(a,b) = abs(a - b) -- Useful for forming norms absmax(a,b) = max(abs(a), abs(b)) absadd(a,b) = abs(a) + abs(b) -- Useful for L_1 norm and inequalities?
These I find less exciting, since they can be written easily in terms of existing ufuncs. (The expadd can't without an if statement unless you want range errors.) There is some small gain in having fewer temporaries, but as it stands now each ufunc lives in a byzantine nest of code and is hard to scrutinize.
I would really like a powadd = abs(a)**p + abs(b)**p, but I can't think of an easy way to pass a variable p that is compatible with the way ufuncs work without going to three variables, something that might not work with the reduce functions. Along these lines I also think it is time to review generalized ufuncs to see what we can do with them. Thoughts?
It's worth checking what reduce does on ternary ufuncs. It's not clear what it *should* do. Anne