Using static arrays
The StaticArrays.jl
package provides an interface and tools for the creation and manipulation of statically-sized arrays in Julia. Compared to a normal Array
type, in a StaticArray
the array size is part of the data type definition. The StaticArrays.jl
package supports the creation of immutable as well as immutable arrays. The usage of statically-sized arrays in many scenarios leads to huge performance benefits since the array size is known to the compiler. This is particularly visible for small arrays (up to 100 elements). In this recipe, we show StaticArrays.jl
can be used to boost the performance of Julia code.
Getting ready
For this recipe, you need to install theStaticArrays.jl
package. In the Julia command line (REPL), press the] key to start the Julia package manager and run the command:
(v1.0) pkg> add StaticArrays
This will install theStaticArrays.jl
library and all its dependencies.
Additionally, to measure the performance of static arrays, we will use theBenchmarkTools...