Skip to content

problematic max and/or splatting #9439

@waTeim

Description

@waTeim
julia> help("max")
Base.max(x, y, ...)

   Return the maximum of the arguments. Operates elementwise over
   arrays.

Ok trying it....

julia> @time max(rand(30000))
ERROR: `max` has no method matching max(::Array{Float64,1})

Ok, maybe splatting?

julia> @time max(rand(30000)...)
elapsed time: 6.477102746 seconds (3602294488 bytes allocated, 27.43% gc time)
0.9999923243300144
                                        ^  LoLwut?

In comparison

julia> @time maxabs(rand(30000))
elapsed time: 0.001348913 seconds (240184 bytes allocated)
0.999986768847797

Also

julia> @time maxabs(rand(100)...)
ERROR: maxabs has no method matching maxabs(::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64)

The reason I pasted this is because it took a long time for this to return the first time but then was very fast the next time for a whole bunch of different values less than 100, so I think it's probably trying to compile for all possibilities up to 100.

julia> methods(maxabs)
#2 methods for generic function "maxabs":
maxabs(A::AbstractArray{T,N},region) at reducedim.jl:243
maxabs(a) at reduce.jl:317

julia> methods(max)
#10 methods for generic function "max":
max(x::Base.MPFR.BigFloat,y::Base.MPFR.BigFloat) at mpfr.jl:497
max{T<:FloatingPoint}(x::T<:FloatingPoint,y::T<:FloatingPoint) at math.jl:191
max{T<:Real}(x::T<:Real,y::T<:Real) at promotion.jl:201
max(x::Real,y::Real) at promotion.jl:181
max{T1<:Real,T2<:Real}(::T1<:Real,::AbstractArray{T2<:Real,N}) at operators.jl:370
max{T1<:Real,T2<:Real}(::AbstractArray{T1<:Real,N},::T2<:Real) at operators.jl:372
max{T1<:Real,T2<:Real}(::AbstractArray{T1<:Real,N},::AbstractArray{T2<:Real,N}) at operators.jl:376
max(x,y) at operators.jl:56
max(a,b,c) at operators.jl:83
max(a,b,c,xs...) at operators.jl:84

Pretty up-to-date

julia> versioninfo()
Julia Version 0.4.0-dev+2177
Commit a2ff1ea (2014-12-17 01:05 UTC)
Platform Info:
  System: Darwin (x86_64-apple-darwin13.4.0)
  CPU: Intel(R) Core(TM) i7-4850HQ CPU @ 2.30GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas
  LIBM: libopenlibm
  LLVM: libLLVM-3.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsThis change adds or pertains to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions