diff --git a/docs/src/matrix.md b/docs/src/matrix.md index dde176eff0..ba6387e935 100644 --- a/docs/src/matrix.md +++ b/docs/src/matrix.md @@ -87,19 +87,19 @@ Matrix space of 3 rows and 3 columns over univariate polynomial ring in t over rationals julia> A = S() -[0 0 0] -[0 0 0] -[0 0 0] +[. . .] +[. . .] +[. . .] julia> B = S(12) -[12 0 0] -[ 0 12 0] -[ 0 0 12] +[12 . .] +[ . 12 .] +[ . . 12] julia> C = S(R(11)) -[11 0 0] -[ 0 11 0] -[ 0 0 11] +[11 . .] +[ . 11 .] +[ . . 11] ``` @@ -155,23 +155,23 @@ Matrix ring of degree 2 julia> M1 = S(Rational{BigInt}[2 3 1; 1 0 4]) [2//1 3//1 1//1] -[1//1 0//1 4//1] +[1//1 . 4//1] julia> M2 = S(BigInt[2 3 1; 1 0 4]) [2//1 3//1 1//1] -[1//1 0//1 4//1] +[1//1 . 4//1] julia> M3 = S(BigInt[2, 3, 1, 1, 0, 4]) [2//1 3//1 1//1] -[1//1 0//1 4//1] +[1//1 . 4//1] julia> N1 = T(Rational{BigInt}[2 3; 1 0]) [2//1 3//1] -[1//1 0//1] +[1//1 .] julia> N2 = T(BigInt[2 3; 1 0]) [2//1 3//1] -[1//1 0//1] +[1//1 .] julia> N3 = T(BigInt[2, 3, 1, 1]) [2//1 3//1] @@ -186,7 +186,7 @@ Matrix space of 3 rows and 3 columns julia> M = R[t + 1 1; t^2 0] [t + 1 1] -[ t^2 0] +[ t^2 .] julia> N = R[t + 1 2 t] # create a row vector [t + 1 2 t] @@ -228,25 +228,25 @@ Construct the $r\times c$ AbstractAlgebra.jl zero matrix over the ring `R`. ```jldoctest julia> M = matrix(ZZ, BigInt[3 1 2; 2 0 1]) [3 1 2] -[2 0 1] +[2 . 1] julia> N = matrix(ZZ, 3, 2, BigInt[3, 1, 2, 2, 0, 1]) [3 1] [2 2] -[0 1] +[. 1] julia> P = zero_matrix(ZZ, 3, 2) -[0 0] -[0 0] -[0 0] +[. .] +[. .] +[. .] julia> R = matrix_ring(ZZ, 2) Matrix ring of degree 2 over integers julia> M = R() -[0 0] -[0 0] +[. .] +[. .] ``` ## Block diagonal matrix constructors @@ -267,10 +267,10 @@ block_diagonal_matrix(::Ring, ::Vector{<:Matrix{T}}) where T <: RingElement ```jldoctest julia> block_diagonal_matrix(ZZ, [[1 2; 3 4], [4 5 6; 7 8 9]]) -[1 2 0 0 0] -[3 4 0 0 0] -[0 0 4 5 6] -[0 0 7 8 9] +[1 2 . . .] +[3 4 . . .] +[. . 4 5 6] +[. . 7 8 9] julia> M = matrix(ZZ, [1 2; 3 4]) [1 2] @@ -281,10 +281,10 @@ julia> N = matrix(ZZ, [4 5 6; 7 8 9]) [7 8 9] julia> block_diagonal_matrix([M, N]) -[1 2 0 0 0] -[3 4 0 0 0] -[0 0 4 5 6] -[0 0 7 8 9] +[1 2 . . .] +[3 4 . . .] +[. . 4 5 6] +[. . 7 8 9] ``` ## Conversion to Julia matrices, iteration and broacasting @@ -554,7 +554,7 @@ julia> Z = divexact(2*A, 2) [ -2 t + 2 t^2 + t + 1] julia> M = matrix(ZZ, BigInt[2 3 0; 1 1 1]) -[2 3 0] +[2 3 .] [1 1 1] julia> M[1, 2] = BigInt(4) @@ -685,22 +685,22 @@ julia> M = matrix(ZZ, BigInt[1 2 3; 2 3 4; 3 4 5]) [3 4 5] julia> N = matrix(ZZ, BigInt[1 0 1; 0 1 0; 1 0 1]) -[1 0 1] -[0 1 0] -[1 0 1] +[1 . 1] +[. 1 .] +[1 . 1] julia> P = hcat(M, N) -[1 2 3 1 0 1] -[2 3 4 0 1 0] -[3 4 5 1 0 1] +[1 2 3 1 . 1] +[2 3 4 . 1 .] +[3 4 5 1 . 1] julia> Q = vcat(M, N) [1 2 3] [2 3 4] [3 4 5] -[1 0 1] -[0 1 0] -[1 0 1] +[1 . 1] +[. 1 .] +[1 . 1] ``` @@ -740,7 +740,7 @@ Test whether the given matrix has a value associated with indices `i` and `j`. ```jldoctest julia> M = matrix(ZZ, BigInt[3 1 2; 2 0 1]) [3 1 2] -[2 0 1] +[2 . 1] julia> isassigned(M, 1, 2) true @@ -756,8 +756,8 @@ julia> isassigned(A, 1, 2) false julia> B = zero(M) -[0 0 0] -[0 0 0] +[. . .] +[. . .] julia> C = similar(M, 4, 5) [#undef #undef #undef #undef #undef] @@ -769,8 +769,8 @@ julia> base_ring(B) Integers julia> D = zero(M, QQ, 2, 2) -[0//1 0//1] -[0//1 0//1] +[. .] +[. .] julia> base_ring(D) Rationals @@ -839,7 +839,7 @@ Matrix space of 3 rows and 3 columns over residue field of univariate polynomial ring modulo x^3 + 3*x + 1 julia> A = S([K(0) 2a + 3 a^2 + 1; a^2 - 2 a - 1 2a; a^2 - 2 a - 1 2a]) -[ 0 2*x + 3 x^2 + 1] +[ . 2*x + 3 x^2 + 1] [x^2 - 2 x - 1 2*x] [x^2 - 2 x - 1 2*x] @@ -876,7 +876,7 @@ Matrix space of 3 rows and 3 columns over residue field of univariate polynomial ring modulo x^3 + 3*x + 1 julia> M = S([K(0) 2a + 3 a^2 + 1; a^2 - 2 a - 1 2a; a^2 + 3a + 1 2a K(1)]) -[ 0 2*x + 3 x^2 + 1] +[ . 2*x + 3 x^2 + 1] [ x^2 - 2 x - 1 2*x] [x^2 + 3*x + 1 2*x 1] @@ -894,7 +894,7 @@ Matrix space of 3 rows and 3 columns over univariate polynomial ring in x over integers julia> M = S([R(0) 2x + 3 x^2 + 1; x^2 - 2 x - 1 2x; x^2 + 3x + 1 2x R(1)]) -[ 0 2*x + 3 x^2 + 1] +[ . 2*x + 3 x^2 + 1] [ x^2 - 2 x - 1 2*x] [x^2 + 3*x + 1 2*x 1] @@ -949,10 +949,10 @@ julia> R, x = polynomial_ring(QQ, ["x$i" for i in 1:6]) (Multivariate polynomial ring in 6 variables over rationals, AbstractAlgebra.Generic.MPoly{Rational{BigInt}}[x1, x2, x3, x4, x5, x6]) julia> M = R[0 x[1] x[2] x[3]; -x[1] 0 x[4] x[5]; -x[2] -x[4] 0 x[6]; -x[3] -x[5] -x[6] 0] -[ 0 x1 x2 x3] -[-x1 0 x4 x5] -[-x2 -x4 0 x6] -[-x3 -x5 -x6 0] +[ . x1 x2 x3] +[-x1 . x4 x5] +[-x2 -x4 . x6] +[-x3 -x5 -x6 .] julia> pfaffian(M) x1*x6 - x2*x5 + x3*x4 @@ -999,7 +999,7 @@ Matrix space of 3 rows and 3 columns over residue field of univariate polynomial ring modulo x^3 + 3*x + 1 julia> A = S([K(0) 2a + 3 a^2 + 1; a^2 - 2 a - 1 2a; a^2 + 3a + 1 2a K(1)]) -[ 0 2*x + 3 x^2 + 1] +[ . 2*x + 3 x^2 + 1] [ x^2 - 2 x - 1 2*x] [x^2 + 3*x + 1 2*x 1] @@ -1022,7 +1022,7 @@ Matrix space of 3 rows and 3 columns over univariate polynomial ring in x over integers julia> A = S([R(0) 2x + 3 x^2 + 1; x^2 - 2 x - 1 2x; x^2 + 3x + 1 2x R(1)]) -[ 0 2*x + 3 x^2 + 1] +[ . 2*x + 3 x^2 + 1] [ x^2 - 2 x - 1 2*x] [x^2 + 3*x + 1 2*x 1] @@ -1059,15 +1059,15 @@ Matrix space of 4 rows and 4 columns julia> M = S([R(1) R(2) R(4) R(3); R(2) R(5) R(1) R(0); R(6) R(1) R(3) R(2); R(1) R(1) R(3) R(5)]) [1 2 4 3] -[2 5 1 0] +[2 5 1 .] [6 1 3 2] [1 1 3 5] julia> A = hessenberg(M) [1 5 5 3] -[2 1 1 0] -[0 1 3 2] -[0 0 2 2] +[2 1 1 .] +[. 1 3 2] +[. . 2 2] julia> is_hessenberg(A) true @@ -1112,9 +1112,9 @@ julia> A = matrix(ZZ, [2 3 -1; 3 5 7; 11 1 12]) [11 1 12] julia> H = hnf(A) -[1 0 255] -[0 1 17] -[0 0 281] +[1 . 255] +[. 1 17] +[. . 281] julia> is_hnf(H) true @@ -1123,9 +1123,9 @@ julia> H, U = hnf_with_transform(A) ([1 0 255; 0 1 17; 0 0 281], [-47 28 1; -3 2 0; -52 31 1]) julia> U*A -[1 0 255] -[0 1 17] -[0 0 281] +[1 . 255] +[. 1 17] +[. . 281] ``` ### Smith normal form @@ -1148,17 +1148,17 @@ julia> A = matrix(ZZ, [2 3 -1; 3 5 7; 11 1 12]) [11 1 12] julia> S = snf(A) -[1 0 0] -[0 1 0] -[0 0 281] +[1 . .] +[. 1 .] +[. . 281] julia> S, T, U = snf_with_transform(A) ([1 0 0; 0 1 0; 0 0 281], [1 0 0; 7 1 0; 229 31 1], [0 -3 26; 0 2 -17; -1 0 1]) julia> T*A*U -[1 0 0] -[0 1 0] -[0 0 281] +[1 . .] +[. 1 .] +[. . 281] ``` ### (Weak) Popov form @@ -1189,7 +1189,7 @@ julia> A = matrix(R, map(R, Any[1 2 3 x; x 2*x 3*x x^2; x x^2+1 x^3+x^2 x^4+x^2+ julia> P = weak_popov(A) [ 1 2 3 x] -[ 0 0 0 0] +[ . . . .] [-x^3 -2*x^3 + x^2 - 2*x + 1 -2*x^3 + x^2 - 3*x 1] julia> P, U = weak_popov_with_transform(A) @@ -1197,6 +1197,6 @@ julia> P, U = weak_popov_with_transform(A) julia> U*A [ 1 2 3 x] -[ 0 0 0 0] +[ . . . .] [-x^3 -2*x^3 + x^2 - 2*x + 1 -2*x^3 + x^2 - 3*x 1] ``` diff --git a/docs/src/matrix_algebras.md b/docs/src/matrix_algebras.md index b96f41270a..bc87615c06 100644 --- a/docs/src/matrix_algebras.md +++ b/docs/src/matrix_algebras.md @@ -80,19 +80,19 @@ Matrix ring of degree 3 over univariate polynomial ring in t over rationals julia> A = S() -[0 0 0] -[0 0 0] -[0 0 0] +[. . .] +[. . .] +[. . .] julia> B = S(12) -[12 0 0] -[ 0 12 0] -[ 0 0 12] +[12 . .] +[ . 12 .] +[ . . 12] julia> C = S(R(11)) -[11 0 0] -[ 0 11 0] -[ 0 0 11] +[11 . .] +[ . 11 .] +[ . . 11] ``` diff --git a/docs/src/polynomial.md b/docs/src/polynomial.md index 1bd662c7fe..ee57da2bbd 100644 --- a/docs/src/polynomial.md +++ b/docs/src/polynomial.md @@ -898,8 +898,8 @@ julia> g = 6(x + 1)*y + (x^3 + 2x + 2) julia> S = sylvester_matrix(f, g) [ 3*x x + 1 3] -[6*x + 6 x^3 + 2*x + 2 0] -[ 0 6*x + 6 x^3 + 2*x + 2] +[6*x + 6 x^3 + 2*x + 2 .] +[ . 6*x + 6 x^3 + 2*x + 2] julia> h = resultant(f, g) 3*x^7 + 6*x^5 - 6*x^3 + 96*x^2 + 192*x + 96 diff --git a/src/FreeAssociativeAlgebra.jl b/src/FreeAssociativeAlgebra.jl index 2e31cdae64..eba2450ef7 100644 --- a/src/FreeAssociativeAlgebra.jl +++ b/src/FreeAssociativeAlgebra.jl @@ -178,8 +178,8 @@ julia> m1 = S([1 2; 3 4]) [3 4] julia> m2 = S([0 1; 1 0]) -[0 1] -[1 0] +[. 1] +[1 .] julia> evaluate(f, [m1, m2]) [-1 -3] diff --git a/src/Matrix.jl b/src/Matrix.jl index c60217cfe9..2b717f7dcf 100644 --- a/src/Matrix.jl +++ b/src/Matrix.jl @@ -757,7 +757,8 @@ function Base.show(io::IO, ::MIME"text/plain", a::MatrixElem{T}) where T <: NCRi end # preprint each element to know the widths so as to align the columns - strings = String[sprint(print, isassigned(a, i, j) ? a[i, j] : Base.undef_ref_str, + # also replace zero entries by a dot + strings = String[sprint(print, isassigned(a, i, j) ? (iszero(a[i, j]) ? "." : a[i, j]) : Base.undef_ref_str, context = :compact => true) for i=1:r, j=1:c] maxs = maximum(length, strings, dims=1) @@ -2647,9 +2648,9 @@ diagonal, i.e., `transpose(M) == -M`, otherwise return `false`. # Examples ```jldoctest; setup = :(using AbstractAlgebra) julia> M = matrix(ZZ, [0 -1 -2; 1 0 -3; 2 3 0]) -[0 -1 -2] -[1 0 -3] -[2 3 0] +[. -1 -2] +[1 . -3] +[2 3 .] julia> is_skew_symmetric(M) true @@ -4173,7 +4174,7 @@ julia> T, y = polynomial_ring(R, :y) julia> M = S([R(1) R(2) R(4) R(3); R(2) R(5) R(1) R(0); R(6) R(1) R(3) R(2); R(1) R(1) R(3) R(5)]) [1 2 4 3] -[2 5 1 0] +[2 5 1 .] [6 1 3 2] [1 1 3 5] @@ -5974,7 +5975,7 @@ Matrix space of 4 rows and 4 columns julia> M = S([R(1) R(2) R(4) R(3); R(2) R(5) R(1) R(0); R(6) R(1) R(3) R(2); R(1) R(1) R(3) R(5)]) [1 2 4 3] -[2 5 1 0] +[2 5 1 .] [6 1 3 2] [1 1 3 5] @@ -6022,19 +6023,19 @@ row are swapped. # Examples ```jldoctest; setup = :(using AbstractAlgebra) julia> M = identity_matrix(ZZ, 3) -[1 0 0] -[0 1 0] -[0 0 1] +[1 . .] +[. 1 .] +[. . 1] julia> swap_rows(M, 1, 2) -[0 1 0] -[1 0 0] -[0 0 1] +[. 1 .] +[1 . .] +[. . 1] julia> M # was not modified -[1 0 0] -[0 1 0] -[0 0 1] +[1 . .] +[. 1 .] +[. . 1] ``` """ function swap_rows(a::MatrixElem{T}, i::Int, j::Int) where T <: NCRingElement @@ -6053,19 +6054,19 @@ matrix (since matrices are assumed to be mutable in AbstractAlgebra.jl). # Examples ```jldoctest; setup = :(using AbstractAlgebra) julia> M = identity_matrix(ZZ, 3) -[1 0 0] -[0 1 0] -[0 0 1] +[1 . .] +[. 1 .] +[. . 1] julia> swap_rows!(M, 1, 2) -[0 1 0] -[1 0 0] -[0 0 1] +[. 1 .] +[1 . .] +[. . 1] julia> M # was modified -[0 1 0] -[1 0 0] -[0 0 1] +[. 1 .] +[1 . .] +[. . 1] ``` """ function swap_rows!(a::MatrixElem{T}, i::Int, j::Int) where T <: NCRingElement @@ -6808,13 +6809,13 @@ zeroes elsewhere. If `n` is not specified, it defaults to `m`. # Examples ```jldoctest; setup = :(using AbstractAlgebra) julia> diagonal_matrix(ZZ(2), 2, 3) -[2 0 0] -[0 2 0] +[2 . .] +[. 2 .] julia> diagonal_matrix(QQ(-1), 3) -[-1//1 0//1 0//1] -[ 0//1 -1//1 0//1] -[ 0//1 0//1 -1//1] +[-1//1 . .] +[ . -1//1 .] +[ . . -1//1] ``` """ function diagonal_matrix(x::NCRingElement, m::Int, n::Int) @@ -6840,16 +6841,16 @@ matrix. Otherwise the parent is inferred from the vector $x$. ```jldoctest; setup = :(using AbstractAlgebra) julia> diagonal_matrix(ZZ(1), ZZ(2)) -[1 0] -[0 2] +[1 .] +[. 2] julia> diagonal_matrix([ZZ(3), ZZ(4)]) -[3 0] -[0 4] +[3 .] +[. 4] julia> diagonal_matrix(ZZ, [5, 6]) -[5 0] -[0 6] +[5 .] +[. 6] ``` """ function diagonal_matrix(R::NCRing, x::Vector{<:NCRingElement}) @@ -6908,7 +6909,7 @@ An exception is thrown if there is no integer $n$ with this property. # Examples ```jldoctest; setup = :(using AbstractAlgebra) julia> lower_triangular_matrix([1, 2, 3]) -[1 0] +[1 .] [2 3] ``` """ @@ -6948,7 +6949,7 @@ An exception is thrown if there is no integer $n$ with this property. ```jldoctest; setup = :(using AbstractAlgebra) julia> upper_triangular_matrix([1, 2, 3]) [1 2] -[0 3] +[. 3] ``` """ function upper_triangular_matrix(L::AbstractVector{T}) where {T <: NCRingElement} @@ -6986,9 +6987,9 @@ An exception is thrown if there is no integer $n$ with this property. # Examples ```jldoctest; setup = :(using AbstractAlgebra) julia> strictly_lower_triangular_matrix([1, 2, 3]) -[0 0 0] -[1 0 0] -[2 3 0] +[. . .] +[1 . .] +[2 3 .] ``` """ function strictly_lower_triangular_matrix(L::AbstractVector{T}) where {T <: NCRingElement} @@ -7026,9 +7027,9 @@ An exception is thrown if there is no integer $n$ with this property. # Examples ```jldoctest; setup = :(using AbstractAlgebra) julia> strictly_upper_triangular_matrix([1, 2, 3]) -[0 1 2] -[0 0 3] -[0 0 0] +[. 1 2] +[. . 3] +[. . .] ``` """ function strictly_upper_triangular_matrix(L::AbstractVector{T}) where {T <: NCRingElement} diff --git a/src/Solve.jl b/src/Solve.jl index 5bd26e0caf..7067f044ad 100644 --- a/src/Solve.jl +++ b/src/Solve.jl @@ -183,8 +183,8 @@ julia> A = QQ[1 2 3; 0 3 0; 5 0 0]; julia> C = solve_init(A) Linear solving context of matrix [1//1 2//1 3//1] - [0//1 3//1 0//1] - [5//1 0//1 0//1] + [ . 3//1 .] + [5//1 . .] julia> solve(C, [QQ(1), QQ(1), QQ(1)], side = :left) 3-element Vector{Rational{BigInt}}: diff --git a/src/fundamental_interface.jl b/src/fundamental_interface.jl index 8302391001..4ac5a84fff 100644 --- a/src/fundamental_interface.jl +++ b/src/fundamental_interface.jl @@ -149,8 +149,8 @@ Matrix space of 2 rows and 2 columns over integers julia> one(S) -[1 0] -[0 1] +[1 .] +[. 1] julia> R, x = puiseux_series_field(QQ, 4, :x) (Puiseux series field in x over rationals, x + O(x^5)) @@ -180,8 +180,8 @@ Matrix ring of degree 2 over rationals julia> zero(S) -[0//1 0//1] -[0//1 0//1] +[. .] +[. .] julia> R, x = polynomial_ring(ZZ, :x) (Univariate polynomial ring in x over integers, x) diff --git a/test/generic/Matrix-test.jl b/test/generic/Matrix-test.jl index 78cbaaafb9..2b49446606 100644 --- a/test/generic/Matrix-test.jl +++ b/test/generic/Matrix-test.jl @@ -4211,8 +4211,8 @@ end @testset "Generic.Mat.printing" begin # this is the REPL printing - @test sprint(show, "text/plain", matrix(ZZ, [3 1 2; 2 0 1])) == "[3 1 2]\n[2 0 1]" - @test sprint(show, "text/plain", matrix(ZZ, [3 1 2; 2 0 1])) == "[3 1 2]\n[2 0 1]" + @test sprint(show, "text/plain", matrix(ZZ, [3 1 2; 2 0 1])) == "[3 1 2]\n[2 . 1]" + @test sprint(show, "text/plain", matrix(ZZ, [3 1 2; 2 0 1])) == "[3 1 2]\n[2 . 1]" @test sprint(show, "text/plain", matrix(ZZ, 2, 0, [])) == "2 by 0 empty matrix" @test sprint(show, "text/plain", matrix(ZZ, 0, 3, [])) == "0 by 3 empty matrix" S = matrix_ring(QQ, 3)