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

Improve copy & deepcopy for MatSpaceElem #1898

Merged
merged 2 commits into from
Nov 12, 2024
Merged
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
4 changes: 4 additions & 0 deletions src/generic/GenericTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,10 @@
end
end

function MatSpaceElem{T}(R::NCRing, ::UndefInitializer, r::Int, c::Int) where T <: NCRingElement
return MatSpaceElem{T}(R, Matrix{T}(undef, r, c))

Check warning on line 1072 in src/generic/GenericTypes.jl

View check run for this annotation

Codecov / codecov/patch

src/generic/GenericTypes.jl#L1071-L1072

Added lines #L1071 - L1072 were not covered by tests
end

function MatSpaceElem{T}(R::NCRing, A::AbstractMatrix{T}) where T <: NCRingElement
return MatSpaceElem{T}(R, Matrix(A))
end
Expand Down
16 changes: 2 additions & 14 deletions src/generic/Matrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,11 @@ Base.isassigned(a::Union{Mat,MatRingElem}, i, j) = isassigned(a.entries, i, j)
################################################################################

function copy(d::MatSpaceElem{T}) where T <: NCRingElement
z = similar(d)
for i = 1:nrows(d)
for j = 1:ncols(d)
z[i, j] = d[i, j]
end
end
return z
return MatSpaceElem{T}(base_ring(d), copy(d.entries))
end

function deepcopy_internal(d::MatSpaceElem{T}, dict::IdDict) where T <: NCRingElement
z = similar(d)
for i = 1:nrows(d)
for j = 1:ncols(d)
z[i, j] = deepcopy_internal(d[i, j], dict)
end
end
return z
return MatSpaceElem{T}(base_ring(d), deepcopy_internal(d.entries, dict))
end

function deepcopy_internal(d::MatSpaceView{T}, dict::IdDict) where T <: NCRingElement
Expand Down
Loading