@@ -349,9 +349,11 @@ cdef class Matrix(Matrix1):
349
349
True
350
350
sage: X
351
351
(-1, 2, 0, 0)
352
+
353
+ sage: # needs sage.libs.pari
352
354
sage: A = Matrix(Zmod(128), 2, 3, [5, 29, 33, 64, 0, 7])
353
355
sage: B = vector(Zmod(128), [31,39,56])
354
- sage: X = A.solve_left(B); X # needs sage.libs.pari
356
+ sage: X = A.solve_left(B); X
355
357
(19, 83)
356
358
sage: X * A == B
357
359
True
@@ -393,9 +395,10 @@ cdef class Matrix(Matrix1):
393
395
The vector of constants needs to be compatible with
394
396
the base ring of the coefficient matrix::
395
397
396
- sage: F.<a> = FiniteField(27) # needs sage.rings.finite_rings
397
- sage: b = vector(F, [a,a,a,a,a]) # needs sage.rings.finite_rings
398
- sage: A.solve_left(b) # needs sage.rings.finite_rings
398
+ sage: # needs sage.rings.finite_rings
399
+ sage: F.<a> = FiniteField(27)
400
+ sage: b = vector(F, [a,a,a,a,a])
401
+ sage: A.solve_left(b)
399
402
Traceback (most recent call last):
400
403
...
401
404
TypeError: no common canonical parent for objects with parents: ...
@@ -4126,12 +4129,12 @@ cdef class Matrix(Matrix1):
4126
4129
We check that number fields are handled by the right routine as part of
4127
4130
typical right kernel computation. ::
4128
4131
4129
- sage" # needs sage.rings.number_field
4130
- sage: Q = QuadraticField(-7) # needs sage.rings.number_field
4131
- sage: a = Q.gen(0) # needs sage.rings.number_field
4132
- sage: A = matrix(Q, [[2, 5-a, 15-a, 16+4*a], [2+a, a, -7 + 5*a, -3+3*a]]) # needs sage.rings.number_field
4132
+ sage: # needs sage.rings.number_field
4133
+ sage: Q = QuadraticField(-7)
4134
+ sage: a = Q.gen(0)
4135
+ sage: A = matrix(Q, [[2, 5-a, 15-a, 16+4*a], [2+a, a, -7 + 5*a, -3+3*a]])
4133
4136
sage: set_verbose(1)
4134
- sage: A.right_kernel(algorithm='default') # needs sage.rings.number_field
4137
+ sage: A.right_kernel(algorithm='default')
4135
4138
verbose ...
4136
4139
verbose 1 (<module>) computing right kernel matrix over a number field for 2x4 matrix
4137
4140
verbose 1 (<module>) done computing right kernel matrix over a number field for 2x4 matrix
@@ -5686,33 +5689,38 @@ cdef class Matrix(Matrix1):
5686
5689
5687
5690
EXAMPLES::
5688
5691
5689
- i sage: # needs sage.libs.pari
5692
+ sage: # needs sage.libs.pari
5690
5693
sage: t = matrix(QQ, 3, [3, 0, -2, 0, -2, 0, 0, 0, 0]); t
5691
5694
[ 3 0 -2]
5692
5695
[ 0 -2 0]
5693
5696
[ 0 0 0]
5694
- sage: t.fcp('X') # factored charpoly # needs sage.libs.pari
5697
+ sage: t.fcp('X') # factored charpoly
5695
5698
(X - 3) * X * (X + 2)
5696
- sage: v = kernel(t*(t+2)); v # an invariant subspace
5699
+ sage: v = kernel(t*(t+2)); v # an invariant subspace
5697
5700
Vector space of degree 3 and dimension 2 over Rational Field
5698
5701
Basis matrix:
5699
5702
[0 1 0]
5700
5703
[0 0 1]
5701
- sage: D = t.decomposition_of_subspace(v); D # needs sage.libs.pari
5704
+ sage: D = t.decomposition_of_subspace(v); D
5702
5705
[ (Vector space of degree 3 and dimension 1 over Rational Field
5703
5706
Basis matrix: [0 0 1],
5704
5707
True),
5705
5708
(Vector space of degree 3 and dimension 1 over Rational Field
5706
5709
Basis matrix: [0 1 0],
5707
5710
True) ]
5708
- sage: t.restrict(D[0][0]) # needs sage.libs.pari
5711
+ sage: t.restrict(D[0][0])
5709
5712
[0]
5710
- sage: t.restrict(D[1][0]) # needs sage.libs.pari
5713
+ sage: t.restrict(D[1][0])
5711
5714
[-2]
5712
5715
5713
5716
We do a decomposition over ZZ::
5714
5717
5715
- sage: a = matrix(ZZ, 6, [0, 0, -2, 0, 2, 0, 2, -4, -2, 0, 2, 0, 0, 0, -2, -2, 0, 0, 2, 0, -2, -4, 2, -2, 0, 2, 0, -2, -2, 0, 0, 2, 0, -2, 0, 0])
5718
+ sage: a = matrix(ZZ, 6, [0, 0, -2, 0, 2, 0,
5719
+ ....: 2, -4, -2, 0, 2, 0,
5720
+ ....: 0, 0, -2, -2, 0, 0,
5721
+ ....: 2, 0, -2, -4, 2, -2,
5722
+ ....: 0, 2, 0, -2, -2, 0,
5723
+ ....: 0, 2, 0, -2, 0, 0])
5716
5724
sage: a.decomposition_of_subspace(ZZ^6) # needs sage.libs.pari
5717
5725
[ (Free module of degree 6 and rank 2 over Integer Ring
5718
5726
Echelon basis matrix:
@@ -5730,7 +5738,7 @@ i sage: # needs sage.libs.pari
5730
5738
TESTS::
5731
5739
5732
5740
sage: t = matrix(QQ, 3, [3, 0, -2, 0, -2, 0, 0, 0, 0])
5733
- sage: t.decomposition_of_subspace(v, check_restrict = False) == t.decomposition_of_subspace(v) # needs sage.libs.pari
5741
+ sage: t.decomposition_of_subspace(v, check_restrict= False) == t.decomposition_of_subspace(v) # needs sage.libs.pari
5734
5742
True
5735
5743
"""
5736
5744
if not sage.modules.free_module.is_FreeModule(M):
@@ -6041,14 +6049,14 @@ i sage: # needs sage.libs.pari
6041
6049
6042
6050
INPUT:
6043
6051
6044
- - ``format`` - ``None``, ``'all'`` or ``'galois'``
6052
+ - ``format`` -- ``None``, ``'all'`` or ``'galois'``
6045
6053
6046
6054
OUTPUT:
6047
6055
6048
6056
Any format except ``None`` is just passed through. When the
6049
- format is ``None`` a choice is made about the style of the output.
6057
+ format is ``None``, a choice is made about the style of the output.
6050
6058
If there is an algebraically closed field that will contain the
6051
- possible eigenvalues, then 'all" of the eigenspaces are given.
6059
+ possible eigenvalues, then `` 'all'`` of the eigenspaces are given.
6052
6060
6053
6061
However if this is not the case, then only one eigenspace is output
6054
6062
for each irreducible factor of the characteristic polynomial.
@@ -6100,48 +6108,48 @@ i sage: # needs sage.libs.pari
6100
6108
r"""
6101
6109
Compute the left eigenspaces of a matrix.
6102
6110
6103
- Note that `` eigenspaces_left()`` and `` left_eigenspaces()` `
6111
+ Note that :meth:` eigenspaces_left` and :meth:` left_eigenspaces`
6104
6112
are identical methods. Here "left" refers to the eigenvectors
6105
6113
being placed to the left of the matrix.
6106
6114
6107
6115
INPUT:
6108
6116
6109
- - ``self`` - a square matrix over an exact field. For inexact
6117
+ - ``self`` -- a square matrix over an exact field. For inexact
6110
6118
matrices consult the numerical or symbolic matrix classes.
6111
6119
6112
- - ``format`` - default: ``None``
6120
+ - ``format`` -- one of:
6113
6121
6114
- - ``'all'`` - attempts to create every eigenspace. This will
6122
+ - ``'all'`` -- Attempts to create every eigenspace. This will
6115
6123
always be possible for matrices with rational entries.
6116
- - ``'galois'`` - for each irreducible factor of the characteristic
6124
+ - ``'galois'`` -- For each irreducible factor of the characteristic
6117
6125
polynomial, a single eigenspace will be output for a
6118
6126
single root/eigenvalue for the irreducible factor.
6119
- - ``None`` - Uses the 'all' format if the base ring is contained
6127
+ - ``None`` (default) -- Uses the `` 'all'`` format if the base ring is contained
6120
6128
in an algebraically closed field which is implemented.
6121
- Otherwise, uses the 'galois' format.
6129
+ Otherwise, uses the `` 'galois'`` format.
6122
6130
6123
- - ``var`` - default: 'a' - variable name used to
6131
+ - ``var`` -- string ( default: `` 'a'``); variable name used to
6124
6132
represent elements of the root field of each
6125
6133
irreducible factor of the characteristic polynomial.
6126
- If var='a', then the root fields will be in terms of
6127
- a0, a1, a2, .... , where the numbering runs across all
6134
+ If `` var='a'`` , then the root fields will be in terms of
6135
+ `` a0, a1, a2, ...`` , where the numbering runs across all
6128
6136
the irreducible factors of the characteristic polynomial,
6129
6137
even for linear factors.
6130
6138
6131
- - ``algebraic_multiplicity`` - default: False - whether or
6132
- not to include the algebraic multiplicity of each eigenvalue
6139
+ - ``algebraic_multiplicity`` -- (boolean, default: `` False``);
6140
+ whether to include the algebraic multiplicity of each eigenvalue
6133
6141
in the output. See the discussion below.
6134
6142
6135
6143
OUTPUT:
6136
6144
6137
- If algebraic_multiplicity=False, return a list of pairs (e, V)
6138
- where e is an eigenvalue of the matrix, and V is the corresponding
6145
+ If `` algebraic_multiplicity=False`` , return a list of pairs ` (e, V)`
6146
+ where `e` is an eigenvalue of the matrix, and `V` is the corresponding
6139
6147
left eigenspace. For Galois conjugates of eigenvalues, there
6140
6148
may be just one representative eigenspace, depending on the
6141
6149
``format`` keyword.
6142
6150
6143
- If algebraic_multiplicity=True, return a list of triples (e, V, n)
6144
- where e and V are as above and n is the algebraic multiplicity of
6151
+ If `` algebraic_multiplicity=True`` , return a list of triples ` (e, V, n)`
6152
+ where `e` and `V` are as above and `n` is the algebraic multiplicity of
6145
6153
the eigenvalue.
6146
6154
6147
6155
.. warning::
@@ -6153,10 +6161,10 @@ i sage: # needs sage.libs.pari
6153
6161
EXAMPLES:
6154
6162
6155
6163
We compute the left eigenspaces of a `3\times 3`
6156
- rational matrix. First, we request `all` of the eigenvalues,
6157
- so the results are in the field of algebraic numbers, `QQbar`.
6164
+ rational matrix. First, we request ``' all'` ` of the eigenvalues,
6165
+ so the results are in the field of algebraic numbers, `` QQbar` `.
6158
6166
Then we request just one eigenspace per irreducible factor of
6159
- the characteristic polynomial with the ` galois` keyword . ::
6167
+ the characteristic polynomial with ``format=' galois'`` . ::
6160
6168
6161
6169
sage: A = matrix(QQ, 3, 3, range(9)); A
6162
6170
[0 1 2]
@@ -6349,15 +6357,15 @@ i sage: # needs sage.libs.pari
6349
6357
possible, will raise an error. Using the ``'galois'``
6350
6358
format option is more likely to be successful. ::
6351
6359
6352
- sage: F.<b> = FiniteField(11^2) # needs sage.rings.finite_rings
6353
- sage: A = matrix(F, [[b + 1, b + 1], [10*b + 4, 5*b + 4]]) # needs sage.rings.finite_rings
6354
- sage: A.eigenspaces_left(format='all') # needs sage.rings.finite_rings
6360
+ sage: # needs sage.rings.finite_rings
6361
+ sage: F.<b> = FiniteField(11^2)
6362
+ sage: A = matrix(F, [[b + 1, b + 1], [10*b + 4, 5*b + 4]])
6363
+ sage: A.eigenspaces_left(format='all')
6355
6364
Traceback (most recent call last):
6356
6365
...
6357
6366
NotImplementedError: unable to construct eigenspaces for eigenvalues outside the base field,
6358
6367
try the keyword option: format='galois'
6359
-
6360
- sage: A.eigenspaces_left(format='galois') # needs sage.rings.finite_rings
6368
+ sage: A.eigenspaces_left(format='galois')
6361
6369
[ (a0,
6362
6370
Vector space of degree 2 and dimension 1 over
6363
6371
Univariate Quotient Polynomial Ring in a0 over
@@ -6526,11 +6534,12 @@ i sage: # needs sage.libs.pari
6526
6534
6527
6535
We compute the right eigenspaces of a `3\times 3` rational matrix. ::
6528
6536
6537
+ sage: # needs sage.rings.number_field
6529
6538
sage: A = matrix(QQ, 3, 3, range(9)); A
6530
6539
[0 1 2]
6531
6540
[3 4 5]
6532
6541
[6 7 8]
6533
- sage: A.eigenspaces_right() # needs sage.rings.number_field
6542
+ sage: A.eigenspaces_right()
6534
6543
[ (0,
6535
6544
Vector space of degree 3 and dimension 1 over Rational Field
6536
6545
User basis matrix:
@@ -6543,7 +6552,7 @@ i sage: # needs sage.libs.pari
6543
6552
Vector space of degree 3 and dimension 1 over Algebraic Field
6544
6553
User basis matrix:
6545
6554
[ 1 3.069693845669907? 5.139387691339814?]) ]
6546
- sage: es = A.eigenspaces_right(format='galois'); es # needs sage.rings.number_field
6555
+ sage: es = A.eigenspaces_right(format='galois'); es
6547
6556
[ (0,
6548
6557
Vector space of degree 3 and dimension 1 over Rational Field
6549
6558
User basis matrix:
@@ -6553,7 +6562,7 @@ i sage: # needs sage.libs.pari
6553
6562
Number Field in a1 with defining polynomial x^2 - 12*x - 18
6554
6563
User basis matrix:
6555
6564
[ 1 1/5*a1 + 2/5 2/5*a1 - 1/5]) ]
6556
- sage: es = A.eigenspaces_right(format='galois', # needs sage.rings.number_field
6565
+ sage: es = A.eigenspaces_right(format='galois',
6557
6566
....: algebraic_multiplicity=True); es
6558
6567
[ (0,
6559
6568
Vector space of degree 3 and dimension 1 over Rational Field
@@ -6566,9 +6575,9 @@ i sage: # needs sage.libs.pari
6566
6575
User basis matrix:
6567
6576
[ 1 1/5*a1 + 2/5 2/5*a1 - 1/5],
6568
6577
1) ]
6569
- sage: e, v, n = es[0]; v = v.basis()[0] # needs sage.rings.number_field
6570
- sage: delta = v*e - A*v # needs sage.rings.number_field
6571
- sage: abs(abs(delta)) < 1e-10 # needs sage.rings.number_field
6578
+ sage: e, v, n = es[0]; v = v.basis()[0]
6579
+ sage: delta = v*e - A*v
6580
+ sage: abs(abs(delta)) < 1e-10
6572
6581
True
6573
6582
6574
6583
The same computation, but with implicit base change to a field::
@@ -6600,11 +6609,12 @@ i sage: # needs sage.libs.pari
6600
6609
sage: B.eigenspaces_right()
6601
6610
Traceback (most recent call last):
6602
6611
...
6603
- NotImplementedError: eigenspaces cannot be computed reliably for inexact rings such as Real Field with 53 bits of precision,
6612
+ NotImplementedError: eigenspaces cannot be computed reliably
6613
+ for inexact rings such as Real Field with 53 bits of precision,
6604
6614
consult numerical or symbolic matrix classes for other options
6605
6615
6606
6616
sage: em = B.change_ring(RDF).eigenmatrix_right()
6607
- sage: eigenvalues = em[0]; eigenvalues.dense_matrix() # abs tol 1e-13
6617
+ sage: eigenvalues = em[0]; eigenvalues.dense_matrix() # abs tol 1e-13
6608
6618
[13.348469228349522 0.0 0.0]
6609
6619
[ 0.0 -1.348469228349534 0.0]
6610
6620
[ 0.0 0.0 0.0]
@@ -6681,7 +6691,7 @@ i sage: # needs sage.libs.pari
6681
6691
then ``QQbar`` elements are returned that represent each separate
6682
6692
root.
6683
6693
6684
- If the option extend is set to False, only eigenvalues in the base
6694
+ If the option `` extend`` is set to `` False`` , only eigenvalues in the base
6685
6695
ring are considered.
6686
6696
6687
6697
EXAMPLES::
@@ -6734,12 +6744,12 @@ i sage: # needs sage.libs.pari
6734
6744
6735
6745
sage: e.as_number_field_element() # needs sage.rings.number_field
6736
6746
(Number Field in a
6737
- with defining polynomial y^4 - 2*y^3 - 507*y^2 - 3972*y - 4264,
6738
- a + 7,
6739
- Ring morphism:
6740
- From: Number Field in a with defining polynomial y^4 - 2*y^3 - 507*y^2 - 3972*y - 4264
6741
- To: Algebraic Real Field
6742
- Defn: a |--> -15.35066086057957?)
6747
+ with defining polynomial y^4 - 2*y^3 - 507*y^2 - 3972*y - 4264,
6748
+ a + 7,
6749
+ Ring morphism:
6750
+ From: Number Field in a with defining polynomial y^4 - 2*y^3 - 507*y^2 - 3972*y - 4264
6751
+ To: Algebraic Real Field
6752
+ Defn: a |--> -15.35066086057957?)
6743
6753
6744
6754
Notice the effect of the ``extend`` option.
6745
6755
@@ -6863,9 +6873,7 @@ i sage: # needs sage.libs.pari
6863
6873
(-1*I, [(1, -1*I, 0)], 1),
6864
6874
(1*I, [(1, 1*I, 0)], 1)]
6865
6875
sage: M.eigenvectors_left(extend=False) # needs sage.rings.number_field
6866
- [(2, [
6867
- (0, 0, 1)
6868
- ], 1)]
6876
+ [(2, [ (0, 0, 1) ], 1)]
6869
6877
6870
6878
TESTS::
6871
6879
@@ -6983,9 +6991,7 @@ i sage: # needs sage.libs.pari
6983
6991
(-1.348469228349535?, [(1, 0.1303061543300932?, -0.7393876913398137?)], 1),
6984
6992
(13.34846922834954?, [(1, 3.069693845669907?, 5.139387691339814?)], 1)]
6985
6993
sage: A.eigenvectors_right(extend=False)
6986
- [(0, [
6987
- (1, -2, 1)
6988
- ], 1)]
6994
+ [(0, [ (1, -2, 1) ], 1)]
6989
6995
sage: eval, [evec], mult = es[0]
6990
6996
sage: delta = eval*evec - A*evec
6991
6997
sage: abs(abs(delta)) < 1e-10
@@ -7137,7 +7143,7 @@ i sage: # needs sage.libs.pari
7137
7143
7138
7144
sage: A = matrix(QQ, 3, 3, range(9))
7139
7145
sage: em = A.change_ring(RDF).eigenmatrix_left()
7140
- sage: evalues = em[0]; evalues.dense_matrix() # abs tol 1e-13
7146
+ sage: evalues = em[0]; evalues.dense_matrix() # abs tol 1e-13
7141
7147
[13.348469228349522 0.0 0.0]
7142
7148
[ 0.0 -1.348469228349534 0.0]
7143
7149
[ 0.0 0.0 0.0]
@@ -7409,8 +7415,8 @@ i sage: # needs sage.libs.pari
7409
7415
sage: M.eigenvalue_multiplicity(1)
7410
7416
0
7411
7417
7412
- sage: M = posets.DiamondPoset(5).coxeter_transformation() # needs sage.combinat
7413
- sage: [M.eigenvalue_multiplicity(x) for x in [-1, 1]] # needs sage.combinat
7418
+ sage: M = posets.DiamondPoset(5).coxeter_transformation() # needs sage.graphs
7419
+ sage: [M.eigenvalue_multiplicity(x) for x in [-1, 1]] # needs sage.graphs
7414
7420
[3, 2]
7415
7421
7416
7422
TESTS::
@@ -7517,7 +7523,8 @@ i sage: # needs sage.libs.pari
7517
7523
sage: C.echelon_form()
7518
7524
Traceback (most recent call last):
7519
7525
...
7520
- NotImplementedError: Ideal Ideal (2, x + 1) of Univariate Polynomial Ring in x over Integer Ring not principal
7526
+ NotImplementedError: Ideal Ideal (2, x + 1) of Univariate
7527
+ Polynomial Ring in x over Integer Ring not principal
7521
7528
Echelon form not implemented over 'Univariate Polynomial Ring in x over Integer Ring'.
7522
7529
sage: C = matrix(3,[2,x,x^2,x+1,3-x,-1,3,2,1/2])
7523
7530
sage: C.echelon_form()
@@ -7776,8 +7783,8 @@ i sage: # needs sage.libs.pari
7776
7783
7777
7784
Check that :trac:`34724` is fixed (indirect doctest)::
7778
7785
7779
- sage: a= 6.12323399573677e-17
7780
- sage: m= matrix(RR,[[-a, -1.72508242466029], [ 0.579682446302195, a]])
7786
+ sage: a = 6.12323399573677e-17
7787
+ sage: m = matrix(RR,[[-a, -1.72508242466029], [ 0.579682446302195, a]])
7781
7788
sage: (~m*m).norm()
7782
7789
1.0
7783
7790
"""
@@ -18014,7 +18021,7 @@ def _generic_clear_column(m):
18014
18021
sage: OL = L.ring_of_integers(); w = OL(w)
18015
18022
sage: m = matrix(OL, 8, 4, [2*w - 2, 2*w + 1, -2, w, 2, -2, -2*w - 2, -2*w + 2, -w + 2, 2*w + 1, -w + 2, -w - 2, -2*w,
18016
18023
....: 2*w, -w+ 2, w - 1, -2*w + 2, 2*w + 2, 2*w - 1, -w, 2*w + 2, -w + 2, 2, 2*w -1, w - 4, -2*w - 2, 2*w - 1, 0, 6, 7, 2*w + 1, 14])
18017
- sage: s,t = m.echelon_form(transformation=True); t*m == s # indirect doctest
18024
+ sage: s,t = m.echelon_form(transformation=True); t*m == s # indirect doctest
18018
18025
True
18019
18026
sage: s[0]
18020
18027
(w, 0, 0, 0)
0 commit comments