Closed
Description
openedon Jan 19, 2018
It appears that there is no method for scalar division by an Array{}
. Here is a quick example:
julia> x = 1.0:4.0
1.0:1.0:4.0
julia> y = [1.0, 2.0, 3.0, 4.0]
4-element Array{Float64,1}:
1.0
2.0
3.0
4.0
julia> 1+x
2.0:1.0:5.0
julia> 1+y
4-element Array{Float64,1}:
2.0
3.0
4.0
5.0
julia> 1-x
0.0:-1.0:-3.0
julia> 1-y
4-element Array{Float64,1}:
0.0
-1.0
-2.0
-3.0
julia> 1*x
1.0:1.0:4.0
julia> 1*y
4-element Array{Float64,1}:
1.0
2.0
3.0
4.0
julia> 1/x
4-element Array{Float64,1}:
1.0
0.5
0.333333
0.25
julia> 1/y
ERROR: MethodError: no method matching /(::Int64, ::Array{Float64,1})
Closest candidates are:
/(::Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8}, ::Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8}) at int.jl:38
/(::Union{Int16, Int32, Int64, Int8, UInt16, UInt32, UInt64, UInt8}, ::BigInt) at gmp.jl:381
/(::T<:Integer, ::T<:Integer) where T<:Integer at int.jl:36
As you can see, /
works when using StepRangeLen{}
, but not for Array{}
. It might be worth noting that 1./y
works as expected.
I observed this behavior on:
Julia Version 0.6.2
Commit d386e40c17 (2017-12-13 18:08 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Core(TM) i5-4288U CPU @ 2.60GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
I'd be surprised if I'm the first person to notice this, so my apologies if this is a known issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Metadata
Assignees
Labels
No labels