diff --git a/j/darray.j b/j/darray.j index d7622be3eda31..17944726b7667 100644 --- a/j/darray.j +++ b/j/darray.j @@ -750,10 +750,13 @@ function map_vectorized(f, A::SubOrDArray) T, size(A), distdim(A), procmap(A)) end -for f = (:ceil, :floor, :trunc, :round, :iround, :itrunc, - :sqrt, :cbrt, :sin, :cos, :tan, :sinh, :cosh, :tanh, - :asin, :acos, :atan, - :log, :log2, :exp, :expm1) +for f = (:ceil, :floor, :trunc, :round, + :iceil, :ifloor, :itrunc, :iround, + :sqrt, :cbrt, :log, :log2, :exp, :expm1, + :sin, :cos, :tan, :cot, :sec, :csc, + :sinh, :cosh, :tanh, :coth, :sech, :csch, + :asin, :acos, :atan, :acot, :asec, :acsc, + :acoth, :asech, :acsch, :sinc, :cosc, :atan2) @eval ($f)(A::SubOrDArray) = map_vectorized($f, A) end diff --git a/j/float.j b/j/float.j index 16db8dbdfc65f..45f1a3c07289a 100644 --- a/j/float.j +++ b/j/float.j @@ -1,10 +1,4 @@ -## floating point conversions ## - -iround(x::Float32) = boxsi32(fpiround32(unbox32(x))) -iround(x::Float64) = boxsi64(fpiround64(unbox64(x))) - -itrunc(x::Float32) = boxsi32(fptosi32(unbox32(x))) -itrunc(x::Float64) = boxsi64(fptosi64(unbox64(x))) +## conversions to floating-point ## convert(::Type{Float32}, x::Bool) = boxf32(sitofp32(unbox8(x))) convert(::Type{Float32}, x::Int8) = boxf32(sitofp32(unbox8(x))) @@ -45,6 +39,20 @@ float32(x) = convert(Float32, x) float64(x) = convert(Float64, x) float(x) = convert(Float, x) +## conversions from floating-point ## + +iround(x::Float32) = boxsi32(fpiround32(unbox32(x))) +iround(x::Float64) = boxsi64(fpiround64(unbox64(x))) +itrunc(x::Float32) = boxsi32(fptosi32(unbox32(x))) +itrunc(x::Float64) = boxsi64(fptosi64(unbox64(x))) + +iceil(x::Float) = int(ceil(x)) # TODO: fast primitive for iceil +ifloor(x::Float) = int(floor(x)) # TOOD: fast primitive for ifloor + +convert(::Type{Int}, x::Float) = iround(x) +convert(::Type{Int32}, x::Float) = float32(iround(x)) +convert(::Type{Int64}, x::Float) = float64(iround(x)) + ## floating point promotions ## promote_rule(::Type{Float64}, ::Type{Float32} ) = Float64 diff --git a/j/floatfuncs.j b/j/floatfuncs.j index 84fe3e48e6a91..6b3a6f1ed4ac3 100644 --- a/j/floatfuncs.j +++ b/j/floatfuncs.j @@ -55,4 +55,6 @@ end @vectorize_1arg Real iround @vectorize_1arg Real itrunc +@vectorize_1arg Real ifloor +@vectorize_1arg Real iceil @vectorize_1arg Number abs diff --git a/j/int.j b/j/int.j index 04bf22dfdb8fe..126d0a4c52f7b 100644 --- a/j/int.j +++ b/j/int.j @@ -126,11 +126,15 @@ signed(x::Uint16) = convert(Int16, x) signed(x::Uint32) = convert(Int32, x) signed(x::Uint64) = convert(Int64, x) -round(x::Int) = x +round(x::Int) = x +trunc(x::Int) = x +floor(x::Int) = x +ceil(x::Int) = x + iround(x::Int) = x -trunc(x::Int) = x -floor(x::Int) = x -ceil(x::Int) = x +itrunc(x::Int) = x +ifloor(x::Int) = x +iceil(x::Int) = x ## integer promotions ## diff --git a/j/version.j b/j/version.j index 97099ce097273..9476e8e40254e 100644 --- a/j/version.j +++ b/j/version.j @@ -103,24 +103,9 @@ $(jl)|__/$(tx) | \033[0m" -function color_available() - if run(`tput setaf 0`) - return true - end - if has(ENV, "TERM") - term = ENV["TERM"] - return term=="xterm" || term=="xterm-color" - end - false -end +color_available() = + run(`tput setaf 0`) || has(ENV, "TERM") && matches(r"^xterm", ENV["TERM"]) -function banner() - if color_available() - print(jl_banner_color) - else - print(jl_banner_plain) - end -end +banner() = print(color_available() ? jl_banner_color : jl_banner_plain) end # begin -