I've been struggling with this for a while, and haven't found a way to do 
it that I'm happy with. I'm sure there is one though. Basically, I want to 
declare a function that works on an array of floats. Doesn't matter what 
kind of float. Doesn't matter if there are 2 different kinds of float 
arrays.

For example, if `a` is an array of Float64, and `b` is an array of Float32, 
the function foobar(a, b) should work, just as well as f(a, a) or f(b, b). 
I've gotten a couple ways to work, but am not sure what's the most Julian, 
and have to believe there is a better way:

1.) Parametric definition. This gets really long if there are multiple 
different Matrices in the call.
function foobar{T<:FloatingPoint, S<:FloatingPoint}(a::Matrix{T}, b::Matrix{
S})

2.) Type union definition. Not sure if this is optimal or not. It also will 
only work with the initial defined floats, so anything that subtypes 
FloatingPoint later on will not be valid
FloatArrays = Union(Matrix{Float16}, Matrix{Float32}, Matrix{Float64})

function foobar(a::FloatArrays, b::FloatArrays)

Am I making this problem more complicated than it needs to be? What is the 
correct way to do this?

Reply via email to