I mistook third param for step, and got confusing error:
julia> linspace(1, 2, 1)
ERROR: linspace(1.0, 2.0, 1.0): endpoints differ
in linspace(::Float64, ::Float64, ::Float64) at ./range.jl:212
in linspace(::Float64, ::Float64, ::Int64) at ./range.jl:251
in linspace(::Int64, ::Int64, ::Int64) at ./range.jl:253
julia> linspace(1.0, 2.0, 1)
ERROR: linspace(1.0, 2.0, 1.0): endpoints differ
in linspace(::Float64, ::Float64, ::Float64) at ./range.jl:212
in linspace(::Float64, ::Float64, ::Int64) at ./range.jl:251
It may not matter too much to get this to work (or give helpful error); I
went to debug and found (should num/len be Integer? see inline comments):
immutable LinSpace{T<:AbstractFloat} <: Range{T}
start::T
stop::T
len::T # len::Integer, only countable..
divisor::T
end
function linspace{T<:AbstractFloat}(start::T, stop::T, len::T)
#long function omitted
function linspace{T<:AbstractFloat}(start::T, stop::T, len::Real) # change
to len::Integer, is this for type stability reasons, or to handle Rationals
somehow?
T_len = convert(T, len)
T_len == len || throw(InexactError())
linspace(start, stop, T_len)
end
linspace(start::Real, stop::Real, len::Real=50) = # change to
len::Integer=50
linspace(promote(AbstractFloat(start), AbstractFloat(stop))..., len)