Thanks Simon!

I would like to highlight one reason for the importance of speedy small 
(and fixed) arrays.

Having done some work in MATLAB and knowing that vectorization is almost 
always the way to go in it, I got very happy when using Julia I could start 
programming in the same way I think.
However, since I work a lot with small vectors and matrices (robotics, 
image processing), I noticed that some algorithms were still much faster in 
vectorized MATLAB than using Julia loops.
It was usually when the body of the loop include small matrix and vector 
operations (e.g., the transformation of a point coordinates into another 
frame). 
This is due, I guess, allocation times of those small matrices.
The only solution was writing Julia code in the same vectorized style I 
used in MATLAB...  Bahhhh....  :-/

But then I tried using FixedSizeArrays. That has let me write code in the 
way I think again (in a very expressive way, although I hope we can someday 
write it in a way more close to Base.Arrays), while getting speeds not only 
comparable to the vectorized versions of MATLAB and Julia but in fact 
beating those versions.

Cheers,
Cristóvão

On Saturday, September 5, 2015 at 10:09:20 PM UTC+1, Simon Danisch wrote:
>
> 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