# \#offsetarrays

**URL:** https://discourse.julialang.org/tag/offsetarrays/1083.md

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

---

## [OffsetArrays, transpose, no\_offset\_view](https://discourse.julialang.org/t/offsetarrays-transpose-no-offset-view/136690)

<div class="topic-metadata">

**Author:** [@ryofurue](https://discourse.julialang.org/u/ryofurue)\
**Replies:** 3\
**Last updated:** [April 13, 2026, 5:09pm UTC](https://discourse.julialang.org/t/offsetarrays-transpose-no-offset-view/136690 "2026-04-13T17:09:36Z")

</div>

Why doesn’t no\_offset\_view remove offsets from a transposed OffsetArray ? Edit: After I posted my initial message, @adienes kindly pointed out that the offsets are removed: -1:2 → 1:4, 0:4 → 1:5 . My actual problem is…

---

## [Type stability and OffsetArray components of a struct](https://discourse.julialang.org/t/type-stability-and-offsetarray-components-of-a-struct/131313)

<div class="topic-metadata">

**Author:** [@billmclean](https://discourse.julialang.org/u/billmclean)\
**Replies:** 5\
**Last updated:** [August 6, 2025, 2:03am UTC](https://discourse.julialang.org/t/type-stability-and-offsetarray-components-of-a-struct/131313 "2025-08-06T02:03:33Z")

</div>

I found that @code\_warntype indicated a type instability in a finite difference code. The same issue arises in the following simple example. using OffsetArrays abstract type AbstractGrid end struct Grid \<: AbstractGr…

---

## [A gotcha with OffsetArrays](https://discourse.julialang.org/t/a-gotcha-with-offsetarrays/130858)

<div class="topic-metadata">

**Author:** [@Joris\_Pinkse](https://discourse.julialang.org/u/Joris_Pinkse)\
**Replies:** 3\
**Last updated:** [July 18, 2025, 7:45pm UTC](https://discourse.julialang.org/t/a-gotcha-with-offsetarrays/130858 "2025-07-18T19:45:37Z")

</div>

With using OffsetArrays import Base: length, size, lastindex, firstindex, eachindex, getindex, setindex!, show, display struct Polly{T} \<: AbstractVector{ T } d :: Int a :: OffsetArray{ T, 1 } functio…

---

## [How can i make Julia array index to start from zero 0 and not from one 1?](https://discourse.julialang.org/t/how-can-i-make-julia-array-index-to-start-from-zero-0-and-not-from-one-1/129268)

<div class="topic-metadata">

**Author:** [@stefaniecg](https://discourse.julialang.org/u/stefaniecg)\
**Replies:** 31\
**Last updated:** [May 25, 2025, 12:27pm UTC](https://discourse.julialang.org/t/how-can-i-make-julia-array-index-to-start-from-zero-0-and-not-from-one-1/129268 "2025-05-25T12:27:31Z")

</div>

For a = \[0,1,2\] the index starts at a\[1\]=0 I want all my arrays to allways start at index zero a\[0\]=0. How can configure Julia to do this?

---

## [OffsetArray of size 1 from elementwise multiplication](https://discourse.julialang.org/t/offsetarray-of-size-1-from-elementwise-multiplication/119135)

<div class="topic-metadata">

**Author:** [@liamh](https://discourse.julialang.org/u/liamh)\
**Replies:** 3\
**Last updated:** [September 9, 2024, 2:57pm UTC](https://discourse.julialang.org/t/offsetarray-of-size-1-from-elementwise-multiplication/119135 "2024-09-09T14:57:53Z")

</div>

When I elementwise multiply an offset array by a regular array, I get the result I expect - the resulting array is offset properly - except when the size is 1. In this example, the input array dimension is 6:10, and the…

---

## [How to use OffsetArray with CUDA](https://discourse.julialang.org/t/how-to-use-offsetarray-with-cuda/118400)

<div class="topic-metadata">

**Author:** [@0samuraiE](https://discourse.julialang.org/u/0samuraiE)\
**Replies:** 8\
**Last updated:** [August 21, 2024, 11:58pm UTC](https://discourse.julialang.org/t/how-to-use-offsetarray-with-cuda/118400 "2024-08-21T23:58:41Z")

</div>

Hello all. In the following code, sum returns ERROR: Scalar indexing is disallowed. How should sum be dispatched or How should I do? A = OffsetArray(CUDA.rand(10), -4:5); a = @views A\[-1:2\]; sum(a)

---

## [Convenient creation of an OffsetArray?](https://discourse.julialang.org/t/convenient-creation-of-an-offsetarray/113047)

<div class="topic-metadata">

**Author:** [@ryofurue](https://discourse.julialang.org/u/ryofurue)\
**Replies:** 5\
**Last updated:** [April 19, 2024, 11:01am UTC](https://discourse.julialang.org/t/convenient-creation-of-an-offsetarray/113047 "2024-04-19T11:01:04Z")

</div>

I’ve been using OffsetArrays and is a bit frustrated with its cumbersome creation: # xax\[0:imax\], zax\[0:kmax\] are OffsetArrays. # I want to create an OffsetArray \[0:imax, 0:kmax\] oa = OffsetArray(Array{Float64,2}(undef,…

---

## [Create a matrix with given dimension](https://discourse.julialang.org/t/create-a-matrix-with-given-dimension/98066)

<div class="topic-metadata">

**Author:** [@angeloaliano1](https://discourse.julialang.org/u/angeloaliano1)\
**Replies:** 2\
**Last updated:** [April 29, 2023, 12:59am UTC](https://discourse.julialang.org/t/create-a-matrix-with-given-dimension/98066 "2023-04-29T00:59:07Z")

</div>

Dear all, I need to creeate a null three-dimensional matrix d = d\[s,l,t\] where s = \[2,3,4,5\], l=\[12,13,14,15,16\] and t=1:12, e.g, I don’t need for example of positions \[1,1,1\], \[1,2,1\], etc, but only in the ranges of th…

---

## [Using OffsetArrays within a struct causes AbstractVector type](https://discourse.julialang.org/t/using-offsetarrays-within-a-struct-causes-abstractvector-type/91366)

<div class="topic-metadata">

**Author:** [@markowkes](https://discourse.julialang.org/u/markowkes)\
**Replies:** 2\
**Last updated:** [December 7, 2022, 8:15pm UTC](https://discourse.julialang.org/t/using-offsetarrays-within-a-struct-causes-abstractvector-type/91366 "2022-12-07T20:15:02Z")

</div>

I’m putting offset arrays in a struct and it is causing a type warning and slow performance. Here is a MWE module test using Parameters using OffsetArrays # Define struct with standard vector and offset vector @wit…

---

## [Poll: Do you use convenience functions such as \`zeros\` to construct OffsetArrays?](https://discourse.julialang.org/t/poll-do-you-use-convenience-functions-such-as-zeros-to-construct-offsetarrays/84377)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 4\
**Last updated:** [July 18, 2022, 8:59am UTC](https://discourse.julialang.org/t/poll-do-you-use-convenience-functions-such-as-zeros-to-construct-offsetarrays/84377 "2022-07-18T08:59:34Z")

</div>

Recently, it has been pointed out that the type-piracy committed by OffsetArrays can lead to unexpected results. In particular, OffsetArrays provides the convenience method zeros(::Union{Integer, AbstractUnitRange}...) t…
