You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm running into problems with coercing to complexes or reals in
matrices:
sage: d = matrix([[3, 0],[0,sqrt(2)]])
sage: b = matrix([[1, -1], [2, 2]])
sage: e = b * d * b.inverse(); e
[ 1/sqrt(2) + 3/2 3/4 - 1/(2*sqrt(2))]
[ 3 - sqrt(2) 1/sqrt(2) + 3/2]
and when I try to run n() on the matrix e, I get:
sage: e.n() # or n(e)
[snip]
<type 'exceptions.TypeError'>: unable to coerce to a ComplexNumber
If you take a look at the source code for n(), you'll see that the first thing that it does is to try calling numerical_approx(prec) on the object, and then tries coercing to real or complex fields. So the solution is to write a method numerical_approx(prec) in the matrix base class that tries to numerically approximate the entries and make a new matrix out of them.
I'm running into problems with coercing to complexes or reals in
matrices:
and when I try to run n() on the matrix e, I get:
If you take a look at the source code for n(), you'll see that the first thing that it does is to try calling numerical_approx(prec) on the object, and then tries coercing to real or complex fields. So the solution is to write a method numerical_approx(prec) in the matrix base class that tries to numerically approximate the entries and make a new matrix out of them.
Component: linear algebra
Issue created by migration from https://trac.sagemath.org/ticket/2857
The text was updated successfully, but these errors were encountered: