# RollingFunctions.jl (first look at v1)

**URL:** <https://discourse.julialang.org/t/rollingfunctions-jl-first-look-at-v1/101570>\
**Category:** Package Announcements\
**Tags:** new-version\
**Created:** [July 13, 2023, 12:25pm UTC](https://discourse.julialang.org/t/rollingfunctions-jl-first-look-at-v1/101570 "2023-07-13T12:25:25Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Post date:** [July 13, 2023, 12:25pm UTC](https://discourse.julialang.org/t/rollingfunctions-jl-first-look-at-v1/101570/1 "2023-07-13T12:25:25Z")

</div>

Early access to RollingFunctions.jl v1 is given as [WindowedFunctions.jl](https://github.com/JeffreySarnoff/WindowedFunctions.jl).  
This version does more, has padding, and provides tiling. (see [the docs](https://jeffreysarnoff.github.io/WindowedFunctions.jl/dev/)).

```julia
# add the package
using Pkg
github_url = "JeffreySarnoff/WindowedFunctions.jl"
Pkg.add(url = "https://github.com/" * github_url)

```

This version is radically redesigned. The new approach offers the most requested capabilities, provides much flexibility, and performs well. All of the widely used call signatures will remain supported for many months following the official release of v1, identified as deprecated calls with detailed information about the revision.

It would be a great help if some users of RollingFunctions would take this prerelease for a walk. Post issues, suggestions [here](https://github.com/JeffreySarnoff/WindowedFunctions.jl/issues).

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [July 14, 2023, 12:37am UTC](https://discourse.julialang.org/t/rollingfunctions-jl-first-look-at-v1/101570/2 "2023-07-14T00:37:21Z")

</div>

Does the rolling only occur over one dimension or is multidimensional rolling supported?

---

<div class="post-metadata">

**Author:** ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Post date:** [July 14, 2023, 1:05am UTC](https://discourse.julialang.org/t/rollingfunctions-jl-first-look-at-v1/101570/3 "2023-07-14T01:05:15Z")

</div>

Please give me a short example of how you want multidimensional rolling to work.

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [July 14, 2023, 1:21am UTC](https://discourse.julialang.org/t/rollingfunctions-jl-first-look-at-v1/101570/4 "2023-07-14T01:21:14Z")

</div>

Given an N dimension array, I would want to run a function over N-dimensional subarrays created by taking an N-dimension sliding window over the space.

The sliding window would move over the space according to a Morton Z-order curve:

> **[Z-order curve](https://en.wikipedia.org/wiki/Z-order_curve)**
>
> In mathematical analysis and computer science, functions which are Z-order, Lebesgue curve, Morton space-filling curve, Morton order or Morton code map multidimensional data to one dimension while preserving locality of the data points. It is named in France after Henri Lebesgue, who studied it in 1904, and named in the United States after Guy Macdonald Morton, who first applied the order to file sequencing in 1966. The z-value of a point in multidimensions is simply calculated by interl The figu...

For example given a 4x4 matrix and a 3x3 window, I would want to iterate over the space as follows.

```julia
julia> A = reshape(1:16, 4, 4)
4×4 reshape(::UnitRange{Int64}, 4, 4) with eltype Int64:
 1 5 9 13
 2 6 10 14
 3 7 11 15
 4 8 12 16

julia> f = identity
identity (generic function with 1 method)

julia> f(@view(A[(1:3) .+ 0, (1:3) .+ 0]))
3×3 view(reshape(::UnitRange{Int64}, 4, 4), 1:3, 1:3) with eltype Int64:
 1 5 9
 2 6 10
 3 7 11

julia> f(@view(A[(1:3) .+ 1, (1:3) .+ 0]))
3×3 view(reshape(::UnitRange{Int64}, 4, 4), 2:4, 1:3) with eltype Int64:
 2 6 10
 3 7 11
 4 8 12

julia> f(@view(A[(1:3) .+ 0, (1:3) .+ 1]))
3×3 view(reshape(::UnitRange{Int64}, 4, 4), 1:3, 2:4) with eltype Int64:
 5 9 13
 6 10 14
 7 11 15

julia> f(@view(A[(1:3) .+ 1, (1:3) .+ 1]))
3×3 view(reshape(::UnitRange{Int64}, 4, 4), 2:4, 2:4) with eltype Int64:
 6 10 14
 7 11 15
 8 12 16

```

Here are some packages that partially address this.

- [GitHub - JuliaArrays/TiledIteration.jl: Julia package to facilitate writing mulithreaded, multidimensional, cache-efficient code](https://github.com/JuliaArrays/TiledIteration.jl)
- [GitHub - bionanoimaging/TiledViews.jl: Allows an AbstractArray, to look like an AbstractArray with one more dimension and the tiles are represented along this dimension.](https://github.com/bionanoimaging/TiledViews.jl)
- [GitHub - JaneliaSciComp/Morton.jl: convert between Z-order, Cartesian, and quadtree/octree coordinates](https://github.com/JaneliaSciComp/Morton.jl)

---

<div class="post-metadata">

**Author:** ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Post date:** [July 14, 2023, 1:27am UTC](https://discourse.julialang.org/t/rollingfunctions-jl-first-look-at-v1/101570/5 "2023-07-14T01:27:16Z")

</div>

Is the class of functions that would be appropriate to run over e.g. 3x3 subarrays or over 3x3x3 subarrays of a 4x4x4 data source some union of linear algebra (maximal eignenvalue) and basic agglomerative functions (min, sum, mean) or are there other function groups that may come into play?

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [July 14, 2023, 1:33am UTC](https://discourse.julialang.org/t/rollingfunctions-jl-first-look-at-v1/101570/6 "2023-07-14T01:33:53Z")

</div>

If the output of the function were scalar, then a common application would some of the classic morphological image processing algorithms. For example,

[https://homepages.inf.ed.ac.uk/rbf/HIPR2/hitmiss.htm](https://homepages.inf.ed.ac.uk/rbf/HIPR2/hitmiss.htm)

---

<div class="post-metadata">

**Author:** ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Post date:** [July 14, 2023, 1:49am UTC](https://discourse.julialang.org/t/rollingfunctions-jl-first-look-at-v1/101570/7 "2023-07-14T01:49:53Z")

</div>

perhaps … thank you for bringing this to my attention … worth considering

---

<div class="post-metadata">

**Author:** ![jar1](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jar1](https://discourse.julialang.org/u/jar1)\
**Post date:** [July 14, 2023, 2:51am UTC](https://discourse.julialang.org/t/rollingfunctions-jl-first-look-at-v1/101570/8 "2023-07-14T02:51:21Z")

</div>

I would put the examples of each function on the function’s page rather than having a separate examples page.

---

<div class="post-metadata">

**Author:** ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Post date:** [July 14, 2023, 3:16am UTC](https://discourse.julialang.org/t/rollingfunctions-jl-first-look-at-v1/101570/9 "2023-07-14T03:16:45Z")

</div>

Do you think it important to limit the length of any one doc page?  
I do see how there needs to be an immediate connection …  
so providing a direct and large link from each “approach page”  
to the corresponding “using page” and vice-versa.

---

<div class="post-metadata">

**Author:** ![jar1](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jar1](https://discourse.julialang.org/u/jar1)\
**Post date:** [July 14, 2023, 3:47am UTC](https://discourse.julialang.org/t/rollingfunctions-jl-first-look-at-v1/101570/10 "2023-07-14T03:47:34Z")

</div>

I would have 1-3 examples of a usage on the same page.

---

<div class="post-metadata">

**Author:** ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Post date:** [July 14, 2023, 3:54am UTC](https://discourse.julialang.org/t/rollingfunctions-jl-first-look-at-v1/101570/11 "2023-07-14T03:54:00Z")

</div>

I had been keeping the inline docs roughly matching the website docs.  
Letting inline doc entries scroll far away is somewhat annoying.  
How would you feel about separating the examples from the concepts with the inline docs – or do you prefer they too go long and one scrolls back to read it?

---

<div class="post-metadata">

**Author:** ![jar1](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jar1](https://discourse.julialang.org/u/jar1)\
**Post date:** [July 14, 2023, 4:09am UTC](https://discourse.julialang.org/t/rollingfunctions-jl-first-look-at-v1/101570/12 "2023-07-14T04:09:39Z")

</div>

I don’t mind a long page. I like for example [Functions · DataFrames.jl](https://dataframes.juliadata.org/stable/lib/functions/#DataFrames.rename)
