Skip to content

Commit 33f8c98

Browse files
author
Matthias Koeppe
committed
Use more block tags, update # needs
1 parent ee025b0 commit 33f8c98

12 files changed

+646
-515
lines changed

src/sage/matrix/matrix1.pyx

Lines changed: 54 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -96,21 +96,22 @@ cdef class Matrix(Matrix0):
9696
9797
EXAMPLES::
9898
99+
sage: # needs sage.libs.gap
99100
sage: A = MatrixSpace(QQ,3,3)([0,1,2,3,4,5,6,7,8])
100-
sage: g = gap(A) # indirect doctest # needs sage.libs.gap
101-
sage: g # needs sage.libs.gap
101+
sage: g = gap(A) # indirect doctest
102+
sage: g
102103
[ [ 0, 1, 2 ], [ 3, 4, 5 ], [ 6, 7, 8 ] ]
103-
sage: g.CharacteristicPolynomial() # needs sage.libs.gap
104+
sage: g.CharacteristicPolynomial()
104105
x_1^3-12*x_1^2-18*x_1
105-
sage: A.characteristic_polynomial() # needs sage.libs.gap
106+
sage: A.characteristic_polynomial()
106107
x^3 - 12*x^2 - 18*x
107-
sage: matrix(QQ, g) == A # needs sage.libs.gap
108+
sage: matrix(QQ, g) == A
108109
True
109110
110111
Particularly difficult is the case of matrices over cyclotomic
111112
fields and general number fields. See :trac:`5618` and :trac:`8909`::
112113
113-
sage: # needs sage.rings.number_field
114+
sage: # needs sage.libs.gap sage.rings.number_field
114115
sage: K.<zeta> = CyclotomicField(8)
115116
sage: A = MatrixSpace(K, 2, 2)([0, 1+zeta, 2*zeta, 3])
116117
sage: g = gap(A); g
@@ -120,7 +121,7 @@ cdef class Matrix(Matrix0):
120121
sage: g.IsMatrix()
121122
true
122123
123-
sage: # needs sage.rings.number_field
124+
sage: # needs sage.libs.gap sage.rings.number_field
124125
sage: x = polygen(ZZ, 'x')
125126
sage: L.<tau> = NumberField(x^3 - 2)
126127
sage: A = MatrixSpace(L, 2, 2)([0, 1+tau, 2*tau, 3])
@@ -157,7 +158,7 @@ cdef class Matrix(Matrix0):
157158
158159
sage: libgap(identity_matrix(ZZ, 2)) # needs sage.libs.gap
159160
[ [ 1, 0 ], [ 0, 1 ] ]
160-
sage: libgap(matrix(GF(3), 2, 2, [4,5,6,7])) # needs sage.libs.gap sage.rings.finite_rings
161+
sage: libgap(matrix(GF(3), 2, 2, [4,5,6,7])) # needs sage.libs.gap
161162
[ [ Z(3)^0, Z(3) ], [ 0*Z(3), Z(3)^0 ] ]
162163
"""
163164
from sage.libs.gap.libgap import libgap
@@ -301,26 +302,28 @@ cdef class Matrix(Matrix0):
301302
302303
We first coerce a square matrix. ::
303304
305+
sage: # optional - magma
304306
sage: A = MatrixSpace(QQ,3)([1,2,3,4/3,5/3,6/4,7,8,9])
305-
sage: B = magma(A); B # (indirect doctest) optional - magma
307+
sage: B = magma(A); B # indirect doctest
306308
[ 1 2 3]
307309
[4/3 5/3 3/2]
308310
[ 7 8 9]
309-
sage: B.Type() # optional - magma
311+
sage: B.Type()
310312
AlgMatElt
311-
sage: B.Parent() # optional - magma
313+
sage: B.Parent()
312314
Full Matrix Algebra of degree 3 over Rational Field
313315
314316
We coerce a non-square matrix over
315317
`\ZZ/8\ZZ`. ::
316318
319+
sage: # optional - magma
317320
sage: A = MatrixSpace(Integers(8),2,3)([-1,2,3,4,4,-2])
318-
sage: B = magma(A); B # optional - magma
321+
sage: B = magma(A); B
319322
[7 2 3]
320323
[4 4 6]
321-
sage: B.Type() # optional - magma
324+
sage: B.Type()
322325
ModMatRngElt
323-
sage: B.Parent() # optional - magma
326+
sage: B.Parent()
324327
Full RMatrixSpace of 2 by 3 matrices over IntegerRing(8)
325328
326329
sage: R.<x,y> = QQ[]
@@ -338,17 +341,17 @@ cdef class Matrix(Matrix0):
338341
We coerce a matrix over a cyclotomic field, where the generator
339342
must be named during the coercion. ::
340343
341-
sage: K = CyclotomicField(9); z = K.0 # needs sage.rings.number_field
342-
sage: M = matrix(K, 3, 3, [0,1,3,z,z**4,z-1,z**17,1,0]) # needs sage.rings.number_field
343-
sage: M # needs sage.rings.number_field
344+
sage: # optional - magma, needs sage.rings.number_field
345+
sage: K = CyclotomicField(9); z = K.0
346+
sage: M = matrix(K, 3, 3, [0,1,3,z,z**4,z-1,z**17,1,0]); M
344347
[ 0 1 3]
345348
[ zeta9 zeta9^4 zeta9 - 1]
346349
[-zeta9^5 - zeta9^2 1 0]
347-
sage: magma(M) # optional - magma
350+
sage: magma(M)
348351
[ 0 1 3]
349352
[ zeta9 zeta9^4 zeta9 - 1]
350353
[-zeta9^5 - zeta9^2 1 0]
351-
sage: magma(M**2) == magma(M)**2 # optional - magma
354+
sage: magma(M**2) == magma(M)**2
352355
True
353356
354357
One sparse matrix::
@@ -438,15 +441,15 @@ cdef class Matrix(Matrix0):
438441
EXAMPLES::
439442
440443
sage: m = matrix(ZZ, [[1,2],[3,4]])
441-
sage: macaulay2(m) #optional - macaulay2 (indirect doctest)
444+
sage: macaulay2(m) # indirect doctest # optional - macaulay2
442445
| 1 2 |
443446
| 3 4 |
444447
445448
::
446449
447450
sage: R.<x,y> = QQ[]
448451
sage: m = matrix([[x,y],[1+x,1+y]])
449-
sage: macaulay2(m) #optional - macaulay2
452+
sage: macaulay2(m) # optional - macaulay2
450453
| x y |
451454
| x+1 y+1 |
452455
@@ -462,9 +465,9 @@ cdef class Matrix(Matrix0):
462465
Check that degenerate matrix dimensions are handled correctly
463466
(:trac:`28591`)::
464467
465-
sage: macaulay2(matrix(QQ, 2, 0)).numrows() # optional - macaulay2
468+
sage: macaulay2(matrix(QQ, 2, 0)).numrows() # optional - macaulay2
466469
2
467-
sage: macaulay2(matrix(QQ, 0, 2)).numcols() # optional - macaulay2
470+
sage: macaulay2(matrix(QQ, 0, 2)).numcols() # optional - macaulay2
468471
2
469472
"""
470473
if macaulay2 is None:
@@ -516,7 +519,7 @@ cdef class Matrix(Matrix0):
516519
[1 2 3]
517520
[4 5 6]
518521
[7 8 9]
519-
sage: b = scilab(a); b # optional - scilab (indirect doctest)
522+
sage: b = scilab(a); b # indirect doctest # optional - scilab
520523
1. 2. 3.
521524
4. 5. 6.
522525
7. 8. 9.
@@ -577,14 +580,15 @@ cdef class Matrix(Matrix0):
577580
578581
Symbolic matrices are supported::
579582
580-
sage: M = matrix([[sin(x), cos(x)], [-cos(x), sin(x)]]); M # needs sage.symbolic
583+
sage: # needs sympy sage.symbolic
584+
sage: M = matrix([[sin(x), cos(x)], [-cos(x), sin(x)]]); M
581585
[ sin(x) cos(x)]
582586
[-cos(x) sin(x)]
583-
sage: sM = M._sympy_(); sM # needs sympy sage.symbolic
587+
sage: sM = M._sympy_(); sM
584588
Matrix([
585589
[ sin(x), cos(x)],
586590
[-cos(x), sin(x)]])
587-
sage: sM.subs(x, pi/4) # needs sympy sage.symbolic
591+
sage: sM.subs(x, pi/4)
588592
Matrix([
589593
[ sqrt(2)/2, sqrt(2)/2],
590594
[-sqrt(2)/2, sqrt(2)/2]])
@@ -680,20 +684,21 @@ cdef class Matrix(Matrix0):
680684
681685
EXAMPLES::
682686
687+
sage: # needs numpy
683688
sage: a = matrix(3, range(12))
684-
sage: a.numpy() # needs numpy
689+
sage: a.numpy()
685690
array([[ 0, 1, 2, 3],
686691
[ 4, 5, 6, 7],
687692
[ 8, 9, 10, 11]])
688-
sage: a.numpy('f') # needs numpy
693+
sage: a.numpy('f')
689694
array([[ 0., 1., 2., 3.],
690695
[ 4., 5., 6., 7.],
691696
[ 8., 9., 10., 11.]], dtype=float32)
692-
sage: a.numpy('d') # needs numpy
697+
sage: a.numpy('d')
693698
array([[ 0., 1., 2., 3.],
694699
[ 4., 5., 6., 7.],
695700
[ 8., 9., 10., 11.]])
696-
sage: a.numpy('B') # needs numpy
701+
sage: a.numpy('B')
697702
array([[ 0, 1, 2, 3],
698703
[ 4, 5, 6, 7],
699704
[ 8, 9, 10, 11]], dtype=uint8)
@@ -712,15 +717,16 @@ cdef class Matrix(Matrix0):
712717
the magic :meth:`__array__` method) to convert Sage matrices
713718
to numpy arrays::
714719
715-
sage: import numpy # needs numpy
716-
sage: b = numpy.array(a); b # needs numpy
720+
sage: # needs numpy
721+
sage: import numpy
722+
sage: b = numpy.array(a); b
717723
array([[ 0, 1, 2, 3],
718724
[ 4, 5, 6, 7],
719725
[ 8, 9, 10, 11]])
720-
sage: b.dtype # needs numpy
726+
sage: b.dtype
721727
dtype('int32') # 32-bit
722728
dtype('int64') # 64-bit
723-
sage: b.shape # needs numpy
729+
sage: b.shape
724730
(3, 4)
725731
"""
726732
import numpy
@@ -762,7 +768,7 @@ cdef class Matrix(Matrix0):
762768
763769
EXAMPLES::
764770
765-
sage: M = Matrix(Integers(7), 2, 2, [5, 9, 13, 15]) ; M
771+
sage: M = Matrix(Integers(7), 2, 2, [5, 9, 13, 15]); M
766772
[5 2]
767773
[6 1]
768774
sage: M.lift()
@@ -806,7 +812,7 @@ cdef class Matrix(Matrix0):
806812
807813
EXAMPLES::
808814
809-
sage: M = Matrix(Integers(8), 2, 4, range(8)) ; M
815+
sage: M = Matrix(Integers(8), 2, 4, range(8)); M
810816
[0 1 2 3]
811817
[4 5 6 7]
812818
sage: L = M.lift_centered(); L
@@ -1106,7 +1112,8 @@ cdef class Matrix(Matrix0):
11061112
sage: c = a.dense_columns(); c
11071113
[(x, 2/3*x), (x^2, x^5 + 1)]
11081114
sage: parent(c[1])
1109-
Ambient free module of rank 2 over the principal ideal domain Univariate Polynomial Ring in x over Rational Field
1115+
Ambient free module of rank 2 over the principal ideal domain
1116+
Univariate Polynomial Ring in x over Rational Field
11101117
11111118
TESTS:
11121119
@@ -1640,7 +1647,8 @@ cdef class Matrix(Matrix0):
16401647
[ 1 2/3]
16411648
[ y y^2]
16421649
sage: C.parent()
1643-
Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in y over Rational Field
1650+
Full MatrixSpace of 2 by 2 dense matrices over
1651+
Univariate Polynomial Ring in y over Rational Field
16441652
16451653
Stacking a dense matrix atop a sparse one returns a sparse
16461654
matrix::
@@ -1911,7 +1919,8 @@ cdef class Matrix(Matrix0):
19111919
sage: C = B.augment(A); C
19121920
[ y y^2 1 2]
19131921
sage: C.parent()
1914-
Full MatrixSpace of 1 by 4 dense matrices over Univariate Polynomial Ring in y over Rational Field
1922+
Full MatrixSpace of 1 by 4 dense matrices over
1923+
Univariate Polynomial Ring in y over Rational Field
19151924
19161925
sage: D = A.augment(B)
19171926
Traceback (most recent call last):
@@ -1922,7 +1931,8 @@ cdef class Matrix(Matrix0):
19221931
sage: F = E.augment(B); F
19231932
[ 1 2 y y^2]
19241933
sage: F.parent()
1925-
Full MatrixSpace of 1 by 4 dense matrices over Univariate Polynomial Ring in y over Rational Field
1934+
Full MatrixSpace of 1 by 4 dense matrices over
1935+
Univariate Polynomial Ring in y over Rational Field
19261936
19271937
AUTHORS:
19281938
@@ -2098,8 +2108,8 @@ cdef class Matrix(Matrix0):
20982108
20992109
INPUT:
21002110
2101-
* ``drows`` - list of indices of rows to be deleted from self.
2102-
* ``check`` - checks whether any index in ``drows`` is out of range. Defaults to ``True``.
2111+
* ``drows`` -- list of indices of rows to be deleted from ``self``.
2112+
* ``check`` -- (boolean, default: ``True``); whether to check if any index in ``drows`` is out of range.
21032113
21042114
.. SEEALSO::
21052115
@@ -2161,7 +2171,7 @@ cdef class Matrix(Matrix0):
21612171

21622172
def matrix_from_rows_and_columns(self, rows, columns):
21632173
"""
2164-
Return the matrix constructed from self from the given rows and
2174+
Return the matrix constructed from ``self`` from the given rows and
21652175
columns.
21662176
21672177
EXAMPLES::

0 commit comments

Comments
 (0)