Opened 10 years ago

Last modified 7 years ago

#12733 needs_work defect

norm of symbolic matrices gives an error

Reported by: jason Owned by: jason, was
Priority: major Milestone: sage-6.4
Component: linear algebra Keywords: matrix, symbolic
Cc: rbeezer, mmasdeu Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues: incorrect tests
Branch: Commit:
Dependencies: Stopgaps:

Status badges


This was reported on

Here is an example

sage: matrix(SR,[[x]]).norm()

TypeError                                 Traceback (most recent call last)

/Users/grout/<ipython console> in <module>()

/Users/grout/sage-trees/sage-5.0.beta6/local/lib/python2.7/site-packages/sage/matrix/ in sage.matrix.matrix2.Matrix.norm (sage/matrix/matrix2.c:47759)()

/Users/grout/sage-trees/sage-5.0.beta6/local/lib/python2.7/site-packages/sage/matrix/ in sage.matrix.matrix0.Matrix.change_ring (sage/matrix/matrix0.c:8151)()

/Users/grout/sage-trees/sage-5.0.beta6/local/lib/python2.7/site-packages/sage/matrix/matrix_space.pyc in __call__(self, entries, coerce, copy, rows)
    554             return self(entries.matrix(), copy=False)
--> 556         return self.matrix(entries, copy=copy, coerce=coerce, rows=rows)
    558     def change_ring(self, R):

/Users/grout/sage-trees/sage-5.0.beta6/local/lib/python2.7/site-packages/sage/matrix/matrix_space.pyc in matrix(self, x, coerce, copy, rows)
   1403                     x = new_x
   1404                     copy = False
-> 1405         return self.__matrix_class(self, entries=x, copy=copy, coerce=coerce) 
   1407     def matrix_space(self, nrows=None, ncols=None, sparse=False):

/Users/grout/sage-trees/sage-5.0.beta6/local/lib/python2.7/site-packages/sage/matrix/ in sage.matrix.matrix_double_dense.Matrix_double_dense.__init__ (sage/matrix/matrix_double_dense.c:3215)()

/Users/grout/sage-trees/sage-5.0.beta6/local/lib/python2.7/site-packages/sage/symbolic/ in sage.symbolic.expression.Expression.__complex__ (sage/symbolic/expression.cpp:5926)()

TypeError: unable to simplify to complex approximation

The problem appears to be an automatic coercion to RDF or CDF. Maybe symbolic matrices should override the method.

Attachments (1)

trac_12733_symbolic_matrix_norm.patch (2.1 KB) - added by abrochard 10 years ago.

Download all attachments as: .zip

Change History (11)

Changed 10 years ago by abrochard

comment:1 Changed 10 years ago by abrochard

Patch submitted. I also added an example to be sure, and corrected a little mistake in a test in sage/misc/

comment:2 Changed 10 years ago by chapoton

  • Status changed from new to needs_review

comment:3 Changed 10 years ago by abrochard

  • Cc mmasdeu added

comment:4 Changed 10 years ago by chapoton

This ticket (and the added tests in particular) does not make much sense, unless there exists a symbolic max function. In my opinion, it would be better to return a NotImplementedError? than to return nonsense results.

comment:5 Changed 10 years ago by jason

Use max_symbolic then:

sage: max_symbolic(a,b)
max(a, b)

comment:6 Changed 10 years ago by chapoton

  • Keywords matrix symbolic added
  • Status changed from needs_review to needs_work
  • Work issues set to incorrect tests

comment:7 Changed 8 years ago by jdemeyer

  • Milestone changed from sage-5.11 to sage-5.12

comment:8 Changed 8 years ago by vbraun_spam

  • Milestone changed from sage-6.1 to sage-6.2

comment:9 Changed 8 years ago by vbraun_spam

  • Milestone changed from sage-6.2 to sage-6.3

comment:10 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4
Note: See TracTickets for help on using tickets.