I have an array of vectors (of different lengths) and I want to perform a point wise operation on all values:
a= [[1 2 3 4], [1 2 3 4 5], [1 2 3]]
b = a .-1
This give me an error.
MethodError: no method matching -(::Array{Int64,2}, ::Int64)
Closest candidates are:
-(!Matched::Complex{Bool}, ::Real) at complex.jl:307
-(!Matched::Missing, ::Number) at missing.jl:115
-(!Matched::Base.CoreLogging.LogLevel, ::Integer) at logging.jl:108
…
Stacktrace:
[1] _broadcast_getindex_evalf at .\broadcast.jl:631 [inlined]
[2] _broadcast_getindex at .\broadcast.jl:604 [inlined]
[3] getindex at .\broadcast.jl:564 [inlined]
[4] copy at .\broadcast.jl:854 [inlined]
[5] materialize(::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1},Nothing,typeof(-),Tuple{Array{Array{Int64,2},1},Int64}}) at .\broadcast.jl:820
[6] top-level scope at In[95]:8
How do I perform this operation simply without a loop?
4 posts - 3 participants