-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
UniformScaling should be assignable in setindex!(::AbstractMatrix) #34130
Comments
With this proposed implementation, a modification of the example given by @StefanKarpinski here would work (at least algebraically; not avoiding the intermediate construction of julia> A=zeros(4,6); A[1:4,1:4] += I; A
4×6 Array{Float64,2}:
1.0 0.0 0.0 0.0 0.0 0.0
0.0 1.0 0.0 0.0 0.0 0.0
0.0 0.0 1.0 0.0 0.0 0.0
0.0 0.0 0.0 1.0 0.0 0.0 |
|
Wouldn't function Base.setindex!(A::AbstractMatrix, I::UniformScaling, is, js)
for i in eachindex(is), j in eachindex(js)
A[is[i], js[j]] = i == j ? I.λ : 0
end
end provide the expected results? |
Specializing |
I was surprised that assignment of a
UniformScaling
into a matrix does not work. For example:produces this error on Julia 1.3:
The issue here is distinct from #23197 in that broadcasting semantics are not relevant; the context
of the
setindex!
call defines precisely what the implicit dimensions ofUniformScaling
ought to be in the assignment operation.Here is a simple implementation that would work as intended in the original statement:
Some use cases that work:
The text was updated successfully, but these errors were encountered: