Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linspace: try to "lift" linspace the float ranges are [close #9637] #9666

Merged
merged 13 commits into from
Apr 13, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
linspace: raise errors for cases that cannot be constructed.
E.g. linspace(realmin(), realmax(), maxintfloat())
  • Loading branch information
StefanKarpinski committed Apr 13, 2015
commit 7ce35bf029be022467352175839c597fc8b8c526
12 changes: 8 additions & 4 deletions base/range.jl
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,16 @@ function linspace{T<:FloatingPoint}(start::T, stop::T, len::T)
end
end
end
if isinf(n*start) || isinf(n*stop)
n, p = frexp(n)
a, c, s = start, stop, n
if isinf(a*n) || isinf(c*n)
s, p = frexp(s)
p = one(p) << p
start /= p; stop /= p
a /= p; c /= p
end
return LinSpace(start, stop, len, n)
if a*n/s == start && c*n/s == stop
return LinSpace(a, c, len, s)
end
error("linspace($start, $stop, $len): cannot be constructed")
end
function linspace{T<:FloatingPoint}(start::T, stop::T, len::Real)
T_len = convert(T, len)
Expand Down