On Mon, Apr 6 at 8:40 AM, Jaroslav Hajek wrote > On Mon, Apr 6, 2009 at 3:18 PM, Richardson, Anthony > <[email protected]> wrote: > > On Mon, Apr 6 at 3:50 AM, Jaroslav Hajek wrote > >> On Mon, Apr 6, 2009 at 5:12 AM, Tony Richardson > >> <[email protected]> wrote: > >> > I've attached three very simple polynomial functions that I'd like > >> > to contribute to octave-forge. g = polyscale(f,a) is equivalent > to > >> > g(x) = f(x*a). g = polytranslate(f,a) is equivalent to g(x) = > >> > f(x+a) and g = polytranscale(f, a, b) is equivalent to g(x) = > > f((x+a)*b). > >> > > >> > The functions are fairly simple, but I've found them to be > extremely > > > >> > useful. > >> > > >> > Tony Richardson > >> > > >> > >> I think these would be useful extensions to Octave's polynomial > >> manipulation capabilities. > >> I can assist you with including them, but I have several remarks: > >> 1. You need to add proper copyright header for GPL3. It's easiest to > >> copy it from other Octave's sources. > >> 2. The coding style needs some adjustments to fit Octave's coding > >> styke. In particular, there should be a space between a function > name > >> and parens, space after commas separating arguments, > > > > OK, I'll make the modifications. > > > >> 3. I see no need for polytranscale as a simple wrapper. It would > make > >> sense if it used a faster code. > > > > No problem. I can omit it. (There should be a polyscaletrans() for > > completeness anyway.) > > > >> 4. I don't understand why you use bsxfun. That would make sense only > >> if you left T as a vector. > > > > I'll have to look into generating the result using T as a vector. I > > don't see how to do it at first glance. > > Well I think something like bsxfun(@bincoeff, p, p') would work. But > my point was mainly that you can as well use bincoeff (T, T'), gievn > that bincoeff accepts vector arguments (which is a precondition for > bsxfun).
Yes it does work. I realized that not long after I sent my previous email. > >> 5. Maybe you could use "pascal" to form the pascal matrix? > > > > In my tests under Octave/Windows Vista: > > > > N=100;T = linspace(N-1,0,N)'*ones(1,N); ;bsxfun(@bincoeff,T,T') > > > > is about 4 times faster than > > > > N=100; pascal(N,1); > > > > for N=1000 it is about 10 times faster. This seems very odd. > > Am I missing something? > > > > Tony > > > > No, you're not; but remember that benchmarking is best done on > bleeding-edge version. I optimized the code of "pascal" today, so now > repeating your experiment with N = 2000 gives, on my computer, 1.21974 > seconds for bincoeff vs. 0.090153 for pascal. So I guess you can > safely use pascal. In fact, realizing that there is no way to make > pascal return a standard pascal triangle (without alternating signs), > I added this option under pascal (n, -1), so you can use that > expression instead of abs (pascal (n, 1)). OK. I've made the changes, but now "help polyscale" is not working. I assume this is due to adding the copyright header. I'll resubmit after I get this fixed. Thanks, Tony ------------------------------------------------------------------------------ _______________________________________________ Octave-dev mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/octave-dev
