# Creating looping matrixes (Torus-like) with type inheritance

**URL:** <https://discourse.julialang.org/t/creating-looping-matrixes-torus-like-with-type-inheritance/135475>\
**Category:** General Usage\
**Tags:** type, inheritance, matrix\
**Created:** [February 5, 2026, 1:02pm UTC](https://discourse.julialang.org/t/creating-looping-matrixes-torus-like-with-type-inheritance/135475 "2026-02-05T13:02:32Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Daeltam](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/daeltam/32/220698_2.png) [@Daeltam](https://discourse.julialang.org/u/Daeltam)\
**Post date:** [February 17, 2026, 7:34pm UTC](https://discourse.julialang.org/t/creating-looping-matrixes-torus-like-with-type-inheritance/135475/4 "2026-02-17T19:34:37Z")

</div>

Sorry for the delay in the answer, I’ve been busy.

I can’t find out how to rewrite `getindex` (first one I’ve tried for now)

I’ve created my own struct :

```julia
struct LoopArray <: AbstractArray
 #what do I do here ?
end

```

And then I’ve looked at the code for get index in essentials.jl and in abstractarray.jl but they’re far too complicated to recode because they’re built first with an int index first and then generalized to vector indices.

So I’ve thought about saying something like

```julia-auto
Function getindex(LoopArray, index:: AbstractArray)
  index = index modulo array size
 getindex(LoopArray, index) # calling base function now that it's corrected

```

But won’t my second call just call the first one and loop ?  
I’ve searched similar implémentations but couldn’t find one with my needs

Edit : just found this : [Arrays with periodic boundaries - #3 by jonathanBieler](https://discourse.julialang.org/t/arrays-with-periodic-boundaries/4015/3) , I’ll try based on this for now, haven’t finished yet

---

_[View the full topic](https://discourse.julialang.org/t/creating-looping-matrixes-torus-like-with-type-inheritance/135475)._
