Ask Your Question
0

backslash operator on RDF matrices

asked 2013-02-08 14:53:18 -0600

Greg Marks gravatar image

I've discovered that the backslash operator produces a weird type error when used on matrices with Real Double Field entries:

----------------------------------------------------------------------
| Sage Version 5.6, Release Date: 2013-01-21                         |
| Type "notebook()" for the browser-based notebook interface.        |
| Type "help()" for help.                                            |
----------------------------------------------------------------------
sage: A = matrix(QQ, 3, [1,2,4,2,3,1,0,1,2])
sage: B = matrix(QQ, 3, 2, [1,7,5,2,1,3])
sage: A\B
[  -1    1]
[13/5 -3/5]
[-4/5  9/5]
sage: A = matrix(RDF, 3, [1,2,4,2,3,1,0,1,2])
sage: B = matrix(RDF, 3, 2, [1,7,5,2,1,3])
sage: A\B
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/home/gtmarks/<ipython console> in <module>()

/usr/local/sage-5.6/local/lib/python2.7/site-packages/sage/misc/preparser.pyc in __mul__(self, right)
   1398             (0.0, 0.5, 1.0, 1.5, 2.0)
   1399         """
-> 1400         return self.left._backslash_(right)
   1401 
   1402 

/usr/local/sage-5.6/local/lib/python2.7/site-packages/sage/matrix/matrix2.so in sage.matrix.matrix2.Matrix._backslash_ (sage/matrix/matrix2.c:3658)()

/usr/local/sage-5.6/local/lib/python2.7/site-packages/sage/matrix/matrix_double_dense.so in sage.matrix.matrix_double_dense.Matrix_double_dense.solve_right (sage/matrix/matrix_double_dense.c:11636)()

TypeError: vector of constants over Real Double Field incompatible with matrix over Real Double Field

I don't understand the final "imcompatibility" message: both the vector and the matrix are RDF type, so how could they be incompatible? This is a small version of a problem I encountered in the context of an attempt to demonstrate to a linear algebra class the computation time of solving systems of linear equations via LU factorization versus via matrix inversion by naive methods; to make the case for LU, I have to avoid various optimized algorithms built into SAGE. (Perhaps I should be using a call to LAPACK or something for this demonstration?)

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2013-02-08 16:58:36 -0600

ppurka gravatar image

If you compare the documentation of the methods A.solve_right? when A is a matrix over QQ and when A is a matrix over RDF, you will find that the former allows B to be a matrix, but the latter does not. Only vectors are supported/implemented for RDF fields. As such it is not a bug, but I think this should raise a NotImplementedError when a matrix B is is used over RDF A.

edit flag offensive delete link more

Comments

I agree - open a ticket and be sure to cc rbeezer on it, who would be very interested in at least raising the error, if not even implementing it.

kcrisman gravatar imagekcrisman ( 2013-02-09 01:54:36 -0600 )edit

It's [#14087](http://trac.sagemath.org/sage_trac/ticket/14087).

ppurka gravatar imageppurka ( 2013-02-09 03:00:15 -0600 )edit

patch posted there...

Jason Grout gravatar imageJason Grout ( 2013-02-12 04:09:01 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-02-08 14:53:18 -0600

Seen: 194 times

Last updated: Feb 08 '13