On 1/21/11 3:19 AM, ancienthart wrote:
A possible approach for my proposed (mega) simplify method is outlined
below.

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.

sage: a=matrix(2,2,[1,2,3,4])
sage: a.base_ring()
Integer Ring

(we don't assume that matrices are just over fields, they could be over rings as well, like above).


Jason

--
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

Reply via email to