Hi everyone,

FixedSizeArrays <https://github.com/SimonDanisch/FixedSizeArrays.jl>offers 
an abstract interface to turn arbitrary types into arrays of fixed size 
with most array functionality defined.
The types Point, Vec and Mat are already included per default.

Advantages are that they're stack allocated, often have less overhead than 
Julia arrays and you can dispatch on the dimension.
Disadvantages are, that they're still immutable (advantage?!), 0.4 only and 
I still have some problems with compilation times for first calls of the 
function even with precompilation.
Also the constructor code is pretty messy, as it is currently relatively 
hard to write constructors for abstract types.

In the future I want to move this into base, by simply inheriting from 
AbstractArray, which is currently not possible for immutable arrays. 
Major blocking issue for this is my restricted time and #11610 
<https://github.com/JuliaLang/julia/issues/11610>.
Also, we might use Ref{NTuples} for fixed size arrays in the future, which 
would resolve quite a few issues.
It's pretty fast but might get even faster as soon as NTuple gets 
translated into LLVM's vector type (currently array).

Here's a short code sample:

immutable RGB{T} <: FixedVectorNoTuple{T, 3}
r::T
g::T
b::Tendimmutable Vec{N, T} <: FixedVector{N, T} # defined in GeometryTypes.jl
    _::NTuple{N, T}end
Vec{3, Float32}(0) # constructor with 1 argument already definedrand(Vec{3, 
Int})+sin(Vec(0,2,2)) # a lot of array functions are already defined#There is 
also a matrix typeeye(Mat{3,3,Float32}) * rand(Vec{3, Float32}) # will also 
"just work"
a = Vec(1,2,3)[1:2] # returns (1,2)


Best,
Simon

Reply via email to