Skip to content

Commit

Permalink
Add (range, integer) indexing to UniformScaling
Browse files Browse the repository at this point in the history
  • Loading branch information
dalum committed May 30, 2020
1 parent d120f7b commit 8109aa2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions stdlib/LinearAlgebra/src/uniformscaling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,18 @@ ndims(J::UniformScaling) = 2
Base.has_offset_axes(::UniformScaling) = false
getindex(J::UniformScaling, i::Integer,j::Integer) = ifelse(i==j,J.λ,zero(J.λ))

getindex(x::UniformScaling, n::Integer, m::AbstractRange{<:Integer}) where T = getindex(x, m, n)
function getindex(x::UniformScaling{T}, n::AbstractRange{<:Integer}, m::Integer) where T
v = zeros(T, length(n))
@inbounds for (i,ii) in enumerate(n)
if ii == m
v[i] = x.λ
end
end
return v
end


function getindex(x::UniformScaling{T}, n::AbstractRange{<:Integer}, m::AbstractRange{<:Integer}) where T
A = zeros(T, length(n), length(m))
@inbounds for (j,jj) in enumerate(m), (i,ii) in enumerate(n)
Expand Down

0 comments on commit 8109aa2

Please sign in to comment.