Skip to content

Commit c9e4923

Browse files
authored
Avoid an unnecessary allocation calling permutedims (#1931)
1 parent 9ac586b commit c9e4923

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

src/Matrix.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6731,11 +6731,11 @@ function matrix(arr::AbstractVector{T}) where {T<:NCRingElement}
67316731
end
67326732

67336733
function matrix(arr::Vector{Vector{T}}) where {T<:NCRingElement}
6734-
return matrix(permutedims(reduce(hcat, arr), (2, 1)))
6734+
return matrix(permutedims(reduce(hcat, arr)))
67356735
end
67366736

67376737
function matrix(R::NCRing, arr::Vector{<:Vector})
6738-
return matrix(R, permutedims(reduce(hcat, arr), (2, 1)))
6738+
return matrix(R, permutedims(reduce(hcat, arr)))
67396739
end
67406740

67416741
@doc raw"""

src/generic/MatRing.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ is_domain_type(::Type{MatRingElem{T}}) where T <: NCRingElement = false
3434
###############################################################################
3535

3636
function transpose(x::MatRingElem{T}) where T <: NCRingElement
37-
arr = permutedims(x.entries, [2, 1])
37+
arr = permutedims(x.entries)
3838
z = MatRingElem{T}(base_ring(x), arr)
3939
return z
4040
end

test/generic/MatRing-test.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ end
518518
S = matrix_ring(R, 3)
519519
arr = [t + 1 t R(1); t^2 t t; t+1 t^2 R(-1)]
520520
A = S(arr)
521-
B = S(permutedims(arr, [2, 1]))
521+
B = S(permutedims(arr))
522522
@test transpose(A) == B
523523

524524
# Tests over noncommutative ring

test/generic/Matrix-test.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1662,12 +1662,12 @@ end
16621662
R, t = polynomial_ring(QQ, "t")
16631663
arr = [t + 1 t R(1); t^2 t t]
16641664
A = matrix(R, arr)
1665-
B = matrix(R, permutedims(arr, [2, 1]))
1665+
B = matrix(R, permutedims(arr))
16661666
@test transpose(A) == B
16671667

16681668
arr = [t + 1 t; t^2 t]
16691669
A = matrix(R, arr)
1670-
B = matrix(R, permutedims(arr, [2, 1]))
1670+
B = matrix(R, permutedims(arr))
16711671
@test transpose(A) == B
16721672

16731673
# transpose input/output types are the same
@@ -2337,7 +2337,7 @@ end
23372337
U = matrix_space(S, 3, 1)
23382338

23392339
M = T([3y*a^2 + (y + 1)*a + 2y (5y+1)*a^2 + 2a + y - 1 a^2 + (-a) + 2y; (y + 1)*a^2 + 2y - 4 3y*a^2 + (2y - 1)*a + y (4y - 1)*a^2 + (y - 1)*a + 5; 2a + y + 1 (2y + 2)*a^2 + 3y*a + 3y a^2 + (-y-1)*a + (-y - 3)])
2340-
b = U(permutedims([4y*a^2 + 4y*a + 2y + 1 5y*a^2 + (2y + 1)*a + 6y + 1 (y + 1)*a^2 + 3y*a + 2y + 4], [2, 1]))
2340+
b = U(permutedims([4y*a^2 + 4y*a + 2y + 1 5y*a^2 + (2y + 1)*a + 6y + 1 (y + 1)*a^2 + 3y*a + 2y + 4]))
23412341

23422342
x, d = AbstractAlgebra._solve_rational(M, b)
23432343

0 commit comments

Comments
 (0)