Since several objects have these defined as methods, would the following
approach work?
sage: D
[-(e^3 + 2)/(e^3 - 1) + (2*e^3 + 1)/(e^3 - 1) 1]
[ 2 0]
I then defined the following function:
def mysimplify(obj):
try:
return obj.simplify_full()
except AttributeError:
try:
return obj.simplify_trig()
except AttributeError:
try:
return obj.simplify_rational()
except AttributeError:
return obj.simplify()
The last function call isn't try/except wrapped to ensure that if the object
doesn't have any simplify methods at all, an exception is still returned.
The full list of simplify_ functions isn't included here. What would be the
best order of functions to apply people?
The result from my incomplete function is:
sage: mysimplify(D)
[1 1]
[2 0]
robertwb's method below also works very nicely, except that I can't seem to
locate any method to return the field that the matrix was defined over.
If it's not just a result of me missing something in the documentation
AGAIN, it'd be nice if matrices had an extra method called:
<matrix>.field() that returned the field of the matrix.
Then robertwb's method could be rewritten as the almost automatic:
D.apply_map(D.field().simplify_field)
A final possibility would be to define matrices in such a way that method
calls are handled as follows?
If the method is a matrix method, return the matrix method result.
If not:
See if the method is part of the base field. If it is, return the result
of apply_map(method)
If not a method of the base field, raise an Attribute_Error.
Can anyone see any problems?
Joal Heagney
--
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
URL: http://www.sagemath.org