I have a matrix of zeros A which has dimension (m x n). I have another matrix of some integer values b. b has length n. I want to have A be set to the identity wherever b has values greater than 5. So basically, for every row of A where b has value greater than 5, set it to the identity.
I tried to do this, but it's not working. Does anyone have an idea of how to do this in Julia?
using LinearAlgebra
usable_values = filter((x) -> x > 5, b)
# A[:, usable_values] = I
A[:, b .> 5] = I
A[:, b .> 5] .= I? Note the dot before equal sign. - 张实唯findallinstead offilter, which returns the indexes of those meet the condition. - 张实唯MethodError: no method matching length(::UniformScaling{Bool})- hockeybro