# Best practices for handling arrays of points

**URL:** https://discourse.julialang.org/t/best-practices-for-handling-arrays-of-points/8533
**Category:** General Usage
**Created:** [January 22, 2018, 9:19pm UTC](https://discourse.julialang.org/t/best-practices-for-handling-arrays-of-points/8533 "2018-01-22T21:19:59Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![ajd](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ajd/32/46350_2.png) [@ajd](https://discourse.julialang.org/u/ajd)
#### Post date: [January 22, 2018, 9:19pm UTC](https://discourse.julialang.org/t/best-practices-for-handling-arrays-of-points/8533/1 "2018-01-22T21:19:59Z")

</div>

I’m working with arrays of d-dimensional StaticArrays (representing trajectories in d-space, for d a small integer). It seems that standard library functions are not set-up well to deal with this: as a simple example, I can’t find an efficient standard library function to convert this to an N x 3 array (given that zip(arr…) is very slow if arr is long). Is this a sign that in Julia this type of data should be represented in a different way?

---

<div class="post-metadata">

### Author: ![simonbyrne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simonbyrne/32/19_2.png) [@simonbyrne](https://discourse.julialang.org/u/simonbyrne)
#### Post date: [January 22, 2018, 9:24pm UTC](https://discourse.julialang.org/t/best-practices-for-handling-arrays-of-points/8533/2 "2018-01-22T21:24:07Z")

</div>

This is explained in the [StaticArrays docs](http://juliaarrays.github.io/StaticArrays.jl/stable/pages/api.html#Arrays-of-static-arrays-1):

```julia
julia> X = [@SArray randn(3) for i = 1:5]
5-element Array{SVector{3,Float64},1}:
 [1.7243, 1.74027, 0.152618]    
 [0.312562, -0.487502, 0.221353]
 [1.10307, -1.032, 0.898139]    
 [-0.158312, -0.230623, 1.10006]
 [-1.39961, 1.11121, -1.54268]  

julia> reinterpret(Float64, X, (3,5))
3×5 Array{Float64,2}:
 1.7243 0.312562 1.10307 -0.158312 -1.39961
 1.74027 -0.487502 -1.032 -0.230623 1.11121
 0.152618 0.221353 0.898139 1.10006 -1.54268

```

Note that Julia is column-major, so you will get a 3xN array.

---

<div class="post-metadata">

### Author: ![ajd](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ajd/32/46350_2.png) [@ajd](https://discourse.julialang.org/u/ajd)
#### Post date: [January 22, 2018, 9:55pm UTC](https://discourse.julialang.org/t/best-practices-for-handling-arrays-of-points/8533/3 "2018-01-22T21:55:49Z")

</div>

Aha, this is exactly what I needed. Thanks!

---

<div class="post-metadata">

### Author: ![Seif\_Shebl](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@Seif\_Shebl](https://discourse.julialang.org/u/Seif_Shebl)
#### Post date: [January 22, 2018, 10:04pm UTC](https://discourse.julialang.org/t/best-practices-for-handling-arrays-of-points/8533/4 "2018-01-22T22:04:24Z")

</div>

> [@simonbyrne](#):
>
> julia\> reinterpret(Float64, X, (3,5))  
> 3×5 Array{Float64,2}:

Note that the `typeof` the output in v0.7 is:

```
julia> reinterpret(Float64, X, (3,5))
3×5 reshape(reinterpret(Float64, ::Array{SVector{3,Float64},1}), 3, 5) with eltype Float64:

```

I know it can be dealt with the same as `3×5 Array{Float64,2}` but is a bit weird.
