Hello, I am trying to find out the best way to deal with immutables (or
types) that contain fixed-size arrays, such as this:
# should have variable number of
# Uint64's
immutable Descriptor
a1::Uint64
a2::Uint64
a3::Uint64
a4::Uint64
end
# should work with variable-size Descriptor
function myDist(x1::Descriptor,x2::Descriptor) :inline
return count_ones(x1.a1 $ x2.a1) + count_ones(x1.a2 $ x2.a2) +
count_ones(x1.a3 $ x2.a3) + count_ones(x1.a4 $ x2.a4)
end
In this specific case, Descriptor is 32-bytes wide, but I would like to
make the code generic for different number of elements in the immutable.
If fixed-size arrays were available, this would be very easy, but which is
a neat way of doing this with the current julia v0.3?
btw, the code above runs amazingly fast, using popcount instructions when
available, almost c-speed ;)
This is good news for Julia indeed.
Thanks.