> I'm doing numerical minimization on it right now and the only reason I
> want/need it to be a sage function is so I can .subs() real values for
> my parameters. To get around that, I'm just going to use global
> variables for my parameters. It's kind of ugly, but it will work. It
> would be nice to be able to get symbolic derivatives too, but I don't
> need these either.
>
Something like that ?
class PieceOfFunction(object):
def __init__(f,interval)
self.f = f
self.interval = interval
def diff():
return PieceOfFunction(self.diff(),self.interval)
class PiecewiseFunction(object):
def __init__(listOfPieces):
self.listOfPieces = listOfPieces
def diff():
newList = []
for f in self.listOfPieces :
newList.append(f.diff(),f.interval)
retuen PiecewiseFunction(newList)
I define a piece of function as a pair of a function and an interval,
and then a piecewise function as a list of pieces of functions.
I'm far from being sure that it is an optimal way, but as far as I
understand your problem, I would do like that.
Have a good day
Laurent
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---