I have the following method:
function Q(penalties::Array{Float64, 1}, Q::Array{Float64, 2})
Q_ar = Array{Float64, 2}(undef, N+1, N+1)
for r in 1:N+1
Q_ar = Q_ar + penalties[r] * Q[r]
end
return Q_ar
end
That I'm calling, but I'm getting the following error:
(base.oneto(16), base.oneto(16))
error: loaderror: methoderror: no method matching +(::array{float64,2}, ::float64)
for element-wise addition, use broadcasting with dot syntax: array .+ scalar
closest candidates are:
+(::any, ::any, !matched::any, !matched::any...) at operators.jl:538
+(!matched::complex{bool}, ::real) at complex.jl:301
+(!matched::missing, ::number) at missing.jl:115
...
stacktrace:
[1] q(::array{float64,1}, ::array{float64,2}) at /users/prikshetsharma/documents/clotorch/src/clotorch/flight/trajectory.jl:42
[2] top-level scope at /users/prikshetsharma/documents/clotorch/src/clotorch/flight/trajectory.jl:50
[3] include(::function, ::module, ::string) at ./base.jl:380
[4] include(::module, ::string) at ./base.jl:368
[5] exec_options(::base.jloptions) at ./client.jl:296
[6] _start() at ./client.jl:506
in expression starting at /users/prikshetsharma/documents/clotorch/src/clotorch/flight/trajectory.jl:50
How to fix this error? The error is occurring at the line:
Q_ar = Q_ar + penalties[r] * Q[r]
My intention is to add all the
penalties[r] * Q[r]
together, and return the result with the array Q_ar. What am I doing wrong?