Logarithm of an array

Hello

A very basic question.

This used to work without fuss:

A=rand(10)
log(A)

But with Julia 1.1 it is not valid any more:

MethodError: no method matching log(::Array{Float64,1})
Closest candidates are:
log(!Matched::Float16) at math.jl:1018
log(!Matched::Complex{Float16}) at math.jl:1019
log(!Matched::Float64) at special/log.jl:254

Stacktrace:
[1] top-level scope at In[21]:100:

My question is, It is necessary to use a loop to do it?
Thanks

Use log.(A).

Also, please quote your code: PSA: how to quote code with backticks.

3 Likes

If you are upgrading old code, upgrade it to earlier Julia versions first so that you will see the deprecation messages. (log(array) was deprecated in Julia 0.6.)

(For example, if you have code that was written for Julia 0.5, first upgrade it to 0.6 and fix the deprecations, then upgrade it to 0.7 and fix the deprecations, then upgrade to 1.0 and 1.1. If you skip versions when upgrading, then you will get error messages instead of deprecation warnings … this is manageable, but requires more knowledge of how to fix things.)

3 Likes

Thank you all.

I also recommend this blog post for the rational between this change:

https://julialang.org/blog/2017/01/moredots

1 Like

5 posts were split to a new topic: Performance of log.(x)