Julia - Q & .
julia> VERSION
v"0.6.0-dev.2259"
Julia .
( ).
- (v0.6.0 2017-1-16) (, ?).
:
@wallnuss 4 , . :
function meanw{T <: Number}(x::Array{Vector{T}, 1}, w::Vector{T})
info("both are Vector for the same element-type: $T")
end
julia> meanw([[1],[2]], [1])
INFO: both are Vector for the same element-type: Int32
, AbstractVector :
julia> (typeof(spzeros(3)) |> supertype |> supertype) <: AbstractVector
, :
function meanw{T <: Number}(x::Array{Vector{T}, 1}, w::AbstractVector{T})
info("an Array of Vectors and an AbstractVector sub-type both with the same element-type: $T") #
end
:
julia> meanw([[1.],[2]], spzeros(3))
INFO: an Array of Vectors and an AbstractVector sub-type both with the same element-type: Float64
:
function meanw{T <: Number}(x::AbstractArray{Vector{T}, 1}, w::AbstractVector{T})
info("an AbstractVector subtype of Vectors and an AbstractVector sub-type both with the same element-type $T")
end
:
julia> meanw([spzeros(3) for i=1:3], spzeros(3))
julia> meanw([[1],[2]],[1.])
, , .
function meanw{T <: Number, V <: AbstractVector}(x::AbstractArray{V, 1}, w::AbstractVector{T})
info("an AbstractVector of AbstractVector sub-type with Any element and an AbstractVector sub-type of Number")
end
, , , , :
julia> meanw([[""],[2]],[1.])
INFO: an AbstractVector of AbstractVector sub-type with Any element and an AbstractVector sub-type of Number
:
function meanw{T <: Number, V <: AbstractVector{T}}(x::AbstractArray{V, 1}, w::AbstractVector{T})
info("an AbstractVector of AbstractVector sub-type and an AbstractVector subtype both for same sub-type of Number (triangular)")
end
:
julia> methods(meanw)
meanw{T<:Number}(x::Array{Array{T,1},1}, w::Array{T,1}) in Main at REPL[1]:2
meanw{T<:Number}(x::Array{Array{T,1},1}, w::AbstractArray{T,1}) in Main at REPL[22]:2
meanw{T<:Number}(x::AbstractArray{Array{T,1},1}, w::AbstractArray{T,1}) in Main at REPL[24]:2
meanw{T<:Number,V<:AbstractArray{T<:Number,1}}(x::AbstractArray{V,1}, w::AbstractArray{T,1}) in Main at REPL[41]:2
meanw{T<:Number,V<:(AbstractArray{T,1} where T)}(x::AbstractArray{V,1}, w::AbstractArray{T,1}) in Main at REPL[39]:2
4- , .
julia> meanw([spzeros(3) for i=1:3], spzeros(3))
INFO: an AbstractVector of AbstractVector sub-type and an AbstractVector subtype both for a same sub-type of Number (triangular)
meanw([[2],[2]],[1.]) - (5). :
function meanw{T <: Number, W <: Number, V <: AbstractVector{W}}(x::AbstractArray{V, 1}, w::AbstractVector{T})
info("an AbstractVector of AbstractVector sub-type and an AbstractVector sub-type both for Number (triangular)")
end
julia> meanw([[2],[2]],[1.])
INFO: an AbstractVector of AbstractVector sub-type and an AbstractVector sub-type both for Number (triangular)