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

When printing matrices, replace zeros by dots #1459

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 72 additions & 72 deletions docs/src/matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]

```

Expand Down Expand Up @@ -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]
Expand All @@ -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]
Expand Down Expand Up @@ -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
Expand All @@ -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]
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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]

```

Expand Down Expand Up @@ -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
Expand All @@ -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]
Expand All @@ -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
Expand Down Expand Up @@ -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]

Expand Down Expand Up @@ -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]

Expand All @@ -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]

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]

Expand All @@ -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]

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -1189,14 +1189,14 @@ 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)
([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], [1 0 0; -x 1 0; -x^3-x 0 1])

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]
```
18 changes: 9 additions & 9 deletions docs/src/matrix_algebras.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]

```

Expand Down
4 changes: 2 additions & 2 deletions docs/src/polynomial.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/FreeAssociativeAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Loading
Loading