Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small fix for is_symmetric for matrices over CDF #27831

Closed
mwageringel opened this issue May 14, 2019 · 9 comments
Closed

Small fix for is_symmetric for matrices over CDF #27831

mwageringel opened this issue May 14, 2019 · 9 comments

Comments

@mwageringel
Copy link

Calling is_symmetric on a matrix defined over CDF fails:

sage: a = matrix(CDF, [(21, 0.6 + 18.5*i), (0.6 - 18.5*i, 21)])
sage: a.is_symmetric()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-3-6d0498c2f774> in <module>()
----> 1 a.is_symmetric()

/Applications/SageMath/local/lib/python2.7/site-packages/sage/matrix/matrix_double_dense.pyx in sage.matrix.matrix_double_dense.Matrix_double_dense.is_symmetric (build/cythonized/sage/matrix/matrix_double_dense.c:15478)()
   2400         for i from 0 < i < self._nrows:
   2401             for j from 0 <= j < i:
-> 2402                 if math.fabs(self.get_unsafe(i,j) - self.get_unsafe(j,i)) > tol:
   2403                     b = False
   2404                     break

/Applications/SageMath/local/lib/python2.7/site-packages/sage/rings/complex_double.pyx in sage.rings.complex_double.ComplexDoubleElement.__float__ (build/cythonized/sage/rings/complex_double.c:10102)()
    968         """
    969         if self._complex.imag:
--> 970             raise TypeError(f"unable to convert {self} to float; use abs() or real_part() as desired")
    971         return self._complex.real
    972

TypeError: unable to convert -37.0*I to float; use abs() or real_part() as desired

The implementation calls math.fabs which unsuitable for complex numbers and should be replaced by abs (which is used in similar functions like is_hermitian).

Component: linear algebra

Keywords: numpy

Author: Markus Wageringel

Branch/Commit: 3b62253

Reviewer: Frédéric Chapoton

Issue created by migration from https://trac.sagemath.org/ticket/27831

@mwageringel
Copy link
Author

Commit: 3b62253

@mwageringel
Copy link
Author

Author: Markus Wageringel

@mwageringel
Copy link
Author

@mwageringel
Copy link
Author

New commits:

3b62253fix is_symmetric for matrices over CDF

@mwageringel
Copy link
Author

Changed keywords from none to numpy

@embray
Copy link
Contributor

embray commented Jul 3, 2019

comment:2

Moving tickets from the Sage 8.8 milestone that have been actively worked on in the last six months to the next release milestone (optimistically).

@embray embray modified the milestones: sage-8.8, sage-8.9 Jul 3, 2019
@fchapoton
Copy link
Contributor

Reviewer: Frédéric Chapoton

@fchapoton
Copy link
Contributor

comment:3

ok

@vbraun
Copy link
Member

vbraun commented Aug 26, 2019

Changed branch from u/gh-mwageringel/matrix_cdf_symmetric to 3b62253

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants