Re: [julia-users] Re: How to define an array of floating point numbers?
Here, my point is the word "Abstract" On Tuesday, August 18, 2015 at 3:42:16 PM UTC+2, Kristoffer Carlsson wrote: > > They are the same. The vector is just a type alias for the array of size > 1. Personally I like vector because to me it is clearer to read. > > On Tuesday, August 18, 2015 at 12:09:23 PM UTC+2, Sisyphuss wrote: >> >> Is `function sum{T<:FloatingPoint}(x::AbstractArray{T,1}) ` or >> `function sum{T<:FloatingPoint}(x::AbstractVector{T}) ` better? >> >> >> On Tuesday, August 18, 2015 at 11:29:15 AM UTC+2, René Donner wrote: >>> >>> Hi, >>> >>> I think this does what you want: >>> >>> function sum{T<:FloatingPoint}(x::Array{T,1}) >>> println("hi") >>> end >>> >>> Cheers, >>> >>> Rene >>> >>> >>> >>> >>> >>> >>> Am 18.08.2015 um 11:22 schrieb Uwe Fechner : >>> >>> > Ok, the following definition works on Julia 0.4, but not with 0.3: >>> > >>> > FloatArray = Union{Array{Float32, 1}, Array{Float64, 1}} >>> > >>> > function sum(x::FloatArray). >>> > >>> > Any idea? >>> > >>> > Am Dienstag, 18. August 2015 11:07:16 UTC+2 schrieb Uwe Fechner: >>> > Hello, >>> > >>> > I want to write a function, that can operate on any one dimensional >>> array of floating point numbers. >>> > >>> > The following works, but only for Float64: >>> > >>> > function sum(x::Array{Float64,1}) >>> > >>> > The following does not work: >>> > >>> > function sum(x::Array{AbstractFloat,1}) >>> > >>> > Any idea? >>> > >>> > Uwe >>> >>>
Re: [julia-users] Re: How to define an array of floating point numbers?
They are the same. The vector is just a type alias for the array of size 1. Personally I like vector because to me it is clearer to read. On Tuesday, August 18, 2015 at 12:09:23 PM UTC+2, Sisyphuss wrote: > > Is `function sum{T<:FloatingPoint}(x::AbstractArray{T,1}) ` or > `function sum{T<:FloatingPoint}(x::AbstractVector{T}) ` better? > > > On Tuesday, August 18, 2015 at 11:29:15 AM UTC+2, René Donner wrote: >> >> Hi, >> >> I think this does what you want: >> >> function sum{T<:FloatingPoint}(x::Array{T,1}) >> println("hi") >> end >> >> Cheers, >> >> Rene >> >> >> >> >> >> >> Am 18.08.2015 um 11:22 schrieb Uwe Fechner : >> >> > Ok, the following definition works on Julia 0.4, but not with 0.3: >> > >> > FloatArray = Union{Array{Float32, 1}, Array{Float64, 1}} >> > >> > function sum(x::FloatArray). >> > >> > Any idea? >> > >> > Am Dienstag, 18. August 2015 11:07:16 UTC+2 schrieb Uwe Fechner: >> > Hello, >> > >> > I want to write a function, that can operate on any one dimensional >> array of floating point numbers. >> > >> > The following works, but only for Float64: >> > >> > function sum(x::Array{Float64,1}) >> > >> > The following does not work: >> > >> > function sum(x::Array{AbstractFloat,1}) >> > >> > Any idea? >> > >> > Uwe >> >>
Re: [julia-users] Re: How to define an array of floating point numbers?
Is `function sum{T<:FloatingPoint}(x::AbstractArray{T,1}) ` or `function sum{T<:FloatingPoint}(x::AbstractVector{T}) ` better? On Tuesday, August 18, 2015 at 11:29:15 AM UTC+2, René Donner wrote: > > Hi, > > I think this does what you want: > > function sum{T<:FloatingPoint}(x::Array{T,1}) > println("hi") > end > > Cheers, > > Rene > > > > > > > Am 18.08.2015 um 11:22 schrieb Uwe Fechner >: > > > Ok, the following definition works on Julia 0.4, but not with 0.3: > > > > FloatArray = Union{Array{Float32, 1}, Array{Float64, 1}} > > > > function sum(x::FloatArray). > > > > Any idea? > > > > Am Dienstag, 18. August 2015 11:07:16 UTC+2 schrieb Uwe Fechner: > > Hello, > > > > I want to write a function, that can operate on any one dimensional > array of floating point numbers. > > > > The following works, but only for Float64: > > > > function sum(x::Array{Float64,1}) > > > > The following does not work: > > > > function sum(x::Array{AbstractFloat,1}) > > > > Any idea? > > > > Uwe > >
Re: [julia-users] Re: How to define an array of floating point numbers?
Thank's a lot, that is cool. Am Dienstag, 18. August 2015 11:29:44 UTC+2 schrieb Pontus Stenetorp: > > On 18 August 2015 at 10:22, Uwe Fechner > wrote: > > > > Ok, the following definition works on Julia 0.4, but not with 0.3: > > > > FloatArray = Union{Array{Float32, 1}, Array{Float64, 1}} > > > > function sum(x::FloatArray). > > > > Any idea? > > I would simply go with: > > function mysum{T<:FloatingPoint}(x::Vector{T}) sum(x) end >
Re: [julia-users] Re: How to define an array of floating point numbers?
On 18 August 2015 at 10:22, Uwe Fechner wrote: > > Ok, the following definition works on Julia 0.4, but not with 0.3: > > FloatArray = Union{Array{Float32, 1}, Array{Float64, 1}} > > function sum(x::FloatArray). > > Any idea? I would simply go with: function mysum{T<:FloatingPoint}(x::Vector{T}) sum(x) end
Re: [julia-users] Re: How to define an array of floating point numbers?
Hi, I think this does what you want: function sum{T<:FloatingPoint}(x::Array{T,1}) println("hi") end Cheers, Rene Am 18.08.2015 um 11:22 schrieb Uwe Fechner : > Ok, the following definition works on Julia 0.4, but not with 0.3: > > FloatArray = Union{Array{Float32, 1}, Array{Float64, 1}} > > function sum(x::FloatArray). > > Any idea? > > Am Dienstag, 18. August 2015 11:07:16 UTC+2 schrieb Uwe Fechner: > Hello, > > I want to write a function, that can operate on any one dimensional array of > floating point numbers. > > The following works, but only for Float64: > > function sum(x::Array{Float64,1}) > > The following does not work: > > function sum(x::Array{AbstractFloat,1}) > > Any idea? > > Uwe
[julia-users] Re: How to define an array of floating point numbers?
Ok, the following works for 0.3 and 0.4: FloatArray = Union(Array{Float32, 1}, Array{Float64, 1}) Is this the best way to define an array of floating point numbers? Am Dienstag, 18. August 2015 11:22:50 UTC+2 schrieb Uwe Fechner: > > Ok, the following definition works on Julia 0.4, but not with 0.3: > > FloatArray = Union{Array{Float32, 1}, Array{Float64, 1}} > > function sum(x::FloatArray). > > Any idea? > > Am Dienstag, 18. August 2015 11:07:16 UTC+2 schrieb Uwe Fechner: >> >> Hello, >> >> I want to write a function, that can operate on any one dimensional array >> of floating point numbers. >> >> The following works, but only for Float64: >> >> function sum(x::Array{Float64,1}) >> >> The following does not work: >> >> function sum(x::Array{AbstractFloat,1}) >> >> Any idea? >> >> Uwe >> >
[julia-users] Re: How to define an array of floating point numbers?
Ok, the following definition works on Julia 0.4, but not with 0.3: FloatArray = Union{Array{Float32, 1}, Array{Float64, 1}} function sum(x::FloatArray). Any idea? Am Dienstag, 18. August 2015 11:07:16 UTC+2 schrieb Uwe Fechner: > > Hello, > > I want to write a function, that can operate on any one dimensional array > of floating point numbers. > > The following works, but only for Float64: > > function sum(x::Array{Float64,1}) > > The following does not work: > > function sum(x::Array{AbstractFloat,1}) > > Any idea? > > Uwe >