On 12/01/2012 09:34 AM, kcrisman wrote:
>
>
> On Friday, November 30, 2012 11:16:48 PM UTC-5, Michael Orlitzky wrote:
>
> On 11/30/2012 10:12 PM, Jason Grout wrote:
> >
> > Is there something better? I tried to get piecewise to work, but I
> > couldn't plot, integrate, etc., the function.
> >
>
> I've collected a lot of code over the years for working with piecewise
> functions, but most of it was written before I knew anything about sage
> development. I've made myself a note to clean some of it up and
> document/test it, after which I'll add it to my init.sage repo and
> others can reuse it.
>
>
> Unless it has documentation inappropriate for PG audiences, just post it
> NOW on a new ticket (perhaps linking other piecewise-fixing tickets
> listed at http://trac.sagemath.org/sage_trac/wiki/symbolics) and then
> it's available for others to work on. I know you were definitely
> interested in this before, so maybe we can find a couple people to write
> a new class that still has all the same (good) behavior as the current
> stuff, avoiding the Pynac piecewise class we would otherwise try to
> create and hook into.
There's no documentation for any of it, really (although most of it is
pretty obvious -- add, subtract, and so on).
The problem is it hooks into a bunch of other junk that I threw together
over the years to work around bugs that no longer exist, or
functionality that I didn't know existed in Sage at the time.
An example:
def multiply(p, multiplier):
"""
Multiply a piecewise function p by a multiplier on all domains
on which it's defined.
"""
l = medium_copy(p.list(), 1)
for piece in l:
piece[1] = piece[1] * multiplier
return piecewise(l)
1. The medium_copy() comes from someplace else, which imports someplace
else... And I think it's redundant now anyway, since pickling of
symbolic functions was fixed.
2. That same code is copy/pasted about ten times -- it should be
abstracted into do_piecewise(lambda f: ...).
3. (The hard part) If you wanted to add this to
PiecewisePolynomial.__mul__, you'd have to climb up the chain of
inheritance and make sure that every other object in the ring(?)
knows to call this function when it's multiplied by a piecewise
function.
I can fix (1) and (2) easily and post it to a ticket. I am still
interested in getting piecewise fixed properly, but I have less time
these days. This is still a good start:
http://wiki.sagemath.org/PiecewiseSymbolicSEP
I updated it yesterday with a pointer to the Mathematica Piecewise[]
documentation. If theirs is easy to use, it looks similar to what's in
the SEP, so that's encouraging.
--
You received this message because you are subscribed to the Google Groups
"sage-support" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
Visit this group at http://groups.google.com/group/sage-support?hl=en.