@@ -1204,7 +1204,7 @@ cdef class Matrix_double_dense(Matrix_dense):
1204
1204
self .cache(' PLU_factors' , PLU)
1205
1205
return PLU
1206
1206
1207
- def eigenvalues (self , other = None , algorithm = ' default' , tol = None ,
1207
+ def eigenvalues (self , other = None , algorithm = ' default' , tol = None , *,
1208
1208
homogeneous = False ):
1209
1209
r """
1210
1210
Return a list of ordinary or generalized eigenvalues.
@@ -1380,6 +1380,10 @@ cdef class Matrix_double_dense(Matrix_dense):
1380
1380
Traceback ( most recent call last) :
1381
1381
...
1382
1382
ValueError: matrix must be square, not 2 x 3
1383
+ sage: matrix. identity( CDF, 2) . eigenvalues( A)
1384
+ Traceback ( most recent call last) :
1385
+ ...
1386
+ ValueError: other matrix must be square, not 2 x 3
1383
1387
1384
1388
sage: A = matrix( CDF, 2, [1, 2, 3, 4*I ])
1385
1389
sage: A. eigenvalues( algorithm='symmetric')
@@ -1411,21 +1415,52 @@ cdef class Matrix_double_dense(Matrix_dense):
1411
1415
sage: B = matrix( CDF, [[2, 1+I ], [1-I, 3 ]])
1412
1416
sage: A. eigenvalues( B, algorithm='hermitian', homogeneous=True) # tol 1e-14
1413
1417
[(0.25, 1.0), (1.0, 1.0) ]
1418
+
1419
+ Test the deprecation::
1420
+
1421
+ sage: A = graphs. PetersenGraph( ) . adjacency_matrix( ) . change_ring( RDF)
1422
+ sage: ev = A. eigenvalues( 'symmetric', 1e-13)
1423
+ doctest:... : DeprecationWarning: "extend" and "tol" should be used
1424
+ as keyword argument only
1425
+ See https://trac. sagemath. org/29243 for details.
1426
+ sage: ev # tol 1e-13
1427
+ [(-2.0, 4), (1.0, 5), (3.0, 1) ]
1428
+ sage: A. eigenvalues( 'symmetric', 1e-13, tol=1e-12)
1429
+ Traceback ( most recent call last) :
1430
+ ...
1431
+ TypeError: eigenvalues( ) got multiple values for keyword argument 'tol'
1432
+ sage: A. eigenvalues( 'symmetric', algorithm='hermitian')
1433
+ Traceback ( most recent call last) :
1434
+ ...
1435
+ TypeError: eigenvalues( ) got multiple values for keyword argument 'algorithm'
1414
1436
"""
1415
1437
from sage.rings.real_double import RDF
1416
1438
from sage.rings.complex_double import CDF
1417
1439
if isinstance (other, str ):
1418
1440
# for backward compatibilty, allow algorithm to be passed as first
1419
- # positional argument
1441
+ # positional argument and tol as second positional argument
1442
+ from sage.misc.superseded import deprecation
1443
+ deprecation(29243 , ' "extend" and "tol" should be used as '
1444
+ ' keyword argument only' )
1445
+ if algorithm != ' default' :
1446
+ if isinstance (algorithm, str ):
1447
+ raise TypeError (" eigenvalues() got multiple values for "
1448
+ " keyword argument 'algorithm'" )
1449
+ if tol is not None :
1450
+ raise TypeError (" eigenvalues() got multiple values for "
1451
+ " keyword argument 'tol'" )
1452
+ tol = algorithm
1420
1453
algorithm = other
1421
1454
other = None
1422
1455
if not algorithm in [' default' , ' symmetric' , ' hermitian' ]:
1423
1456
msg = " algorithm must be 'default', 'symmetric', or 'hermitian', not {0}"
1424
1457
raise ValueError (msg.format(algorithm))
1425
- if not self .is_square() or other is not None and not other.is_square():
1426
- msg = ' matrix must be square, not {0} x {1}'
1427
- m = self if not self .is_square() else other
1428
- raise ValueError (msg.format(m.nrows(), m.ncols()))
1458
+ if not self .is_square():
1459
+ raise ValueError (' matrix must be square, not %s x %s '
1460
+ % (self .nrows(), self .ncols()))
1461
+ if other is not None and not other.is_square():
1462
+ raise ValueError (' other matrix must be square, not %s x %s '
1463
+ % (other.nrows(), other.ncols()))
1429
1464
if algorithm == ' symmetric' :
1430
1465
if self .base_ring() != RDF:
1431
1466
try :
@@ -1503,7 +1538,7 @@ cdef class Matrix_double_dense(Matrix_dense):
1503
1538
ev_group[location][2 ] = ev_group[location][0 ]/ ev_group[location][1 ]
1504
1539
return [(return_class(avg), m) for _, m, avg in ev_group]
1505
1540
1506
- def left_eigenvectors (self , other = None , homogeneous = False ):
1541
+ def left_eigenvectors (self , other = None , *, homogeneous = False ):
1507
1542
r """
1508
1543
Compute the ordinary or generalized left eigenvectors of a matrix of
1509
1544
double precision real or complex numbers ( i. e. ``RDF`` or ``CDF``) .
@@ -1661,7 +1696,7 @@ cdef class Matrix_double_dense(Matrix_dense):
1661
1696
1662
1697
eigenvectors_left = left_eigenvectors
1663
1698
1664
- def right_eigenvectors (self , other = None , homogeneous = False ):
1699
+ def right_eigenvectors (self , other = None , *, homogeneous = False ):
1665
1700
r """
1666
1701
Compute the ordinary or generalized right eigenvectors of a matrix of
1667
1702
double precision real or complex numbers ( i. e. ``RDF`` or ``CDF``) .
0 commit comments