How to do `logspace()` in Julia v. 1.0.x?

Silly question, I guess… So: linspace() has been replaced by range(). But what about logspace()?

I tried to do it manually as, e.g., 10.^(range(-2,stop=2,length=50)), but that doesn’t work.

  • Is there a built-in new function for logspace(), or
  • What is the way to use dot-notation and raise a scalar to an array?

I can do it as:

v = range(-2,stop=2,length=50)
[10^i for i in v]

but that seems kind of clumsy??

1 Like

In Julia 0.7,

logspace(1,10)
Warning: `logspace(start, stop)` is deprecated, use `exp10.(range(start, stop=stop, length=50))` instead.
6 Likes

What you wrote is fine, too, you just need a space between the 10 and the .^ since otherwise it’s ambiguous if you mean 10. ^ x or 10 .^ x.

7 Likes

Thanks!

Ah… of course… Thanks!

2 posts were split to a new topic: Lazy logspace object