# \#arrays

**URL:** https://discourse.julialang.org/tag/arrays/248.md

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

---

## [Auto-convert Vector{Type} to special container type](https://discourse.julialang.org/t/auto-convert-vector-type-to-special-container-type/139045)

<div class="topic-metadata">

**Author:** [@pekuntzpuglia](https://discourse.julialang.org/u/pekuntzpuglia)\
**Replies:** 6\
**Last updated:** [September 1, 2026, 12:36pm UTC](https://discourse.julialang.org/t/auto-convert-vector-type-to-special-container-type/139045 "2026-09-01T12:36:07Z")

</div>

I’m trying to use this unofficial CasADi interface in Julia since the official interface seems to be a long way from working (couldn’t get it installed in Julia 1.10, as stated in Project.toml). I’m having a hard time ha…

---

## [Performance overhead of an indirection to basic array function](https://discourse.julialang.org/t/performance-overhead-of-an-indirection-to-basic-array-function/137663)

<div class="topic-metadata">

**Author:** [@Tortar](https://discourse.julialang.org/u/Tortar)\
**Replies:** 0\
**Last updated:** [June 16, 2026, 11:38pm UTC](https://discourse.julialang.org/t/performance-overhead-of-an-indirection-to-basic-array-function/137663 "2026-06-16T23:38:19Z")

</div>

I have a macro which creates these function indirections for very basic collection functions, i.e. it substitutes all Base.getindex instances with \_unchecked\_getindex: Base.@propagate\_inbounds @inline function \_unchecke…

---

## [Accessing a column from a vector of vectors](https://discourse.julialang.org/t/accessing-a-column-from-a-vector-of-vectors/136722)

<div class="topic-metadata">

**Author:** [@Ju\_ska](https://discourse.julialang.org/u/Ju_ska)\
**Replies:** 9\
**Last updated:** [June 2, 2026, 10:45am UTC](https://discourse.julialang.org/t/accessing-a-column-from-a-vector-of-vectors/136722 "2026-06-02T10:45:25Z")

</div>

Hi, I have something like: a = \[\["a", "1" ,"11"\], \["b", "2" ,"22"\], \["c", "3" ,"33"\]\] 3-element Vector{Vector{String}}: \["a", "1", "11"\] \["b", "2", "22"\] \["c", "3", "33"\] And I would like to get e.g. th…

---

## [Is there any advantage of directly using \`Memory{T}\` over a traditional Array?](https://discourse.julialang.org/t/is-there-any-advantage-of-directly-using-memory-t-over-a-traditional-array/136062)

<div class="topic-metadata">

**Author:** [@pmc4](https://discourse.julialang.org/u/pmc4)\
**Replies:** 13\
**Last updated:** [March 7, 2026, 8:46am UTC](https://discourse.julialang.org/t/is-there-any-advantage-of-directly-using-memory-t-over-a-traditional-array/136062 "2026-03-07T08:46:23Z")

</div>

Hi, everyone. Correct me if I’m wrong, please: I understand that an Array is implemented via a MemoryRef which contains a Memory object, with supertype DenseArray. When an array is created, some memory is allocated. Me…

---

## [\[ANN\] FixedSizeArrays.jl: What Array probably should have been](https://discourse.julialang.org/t/ann-fixedsizearrays-jl-what-array-probably-should-have-been/129724)

<div class="topic-metadata">

**Author:** [@giordano](https://discourse.julialang.org/u/giordano)\
**Replies:** 79\
**Last updated:** [February 16, 2026, 12:04am UTC](https://discourse.julialang.org/t/ann-fixedsizearrays-jl-what-array-probably-should-have-been/129724 "2026-02-16T00:04:58Z")

</div>

This has been one year in the making, but the first release of FixedSizeArrays.jl is finally out and you can install it in your environment with import Pkg Pkg.add("FixedSizeArrays") This package can be installed in Ju…

---

## [Find n smallest values in an n dims array](https://discourse.julialang.org/t/find-n-smallest-values-in-an-n-dims-array/81092)

<div class="topic-metadata">

**Author:** [@marianoarnaiz](https://discourse.julialang.org/u/marianoarnaiz)\
**Replies:** 22\
**Last updated:** [February 13, 2026, 2:07pm UTC](https://discourse.julialang.org/t/find-n-smallest-values-in-an-n-dims-array/81092 "2026-02-13T14:07:33Z")

</div>

Hi Every one! I have the bad tendency of working with N dims arrays. Right now I have a 10x20x6 arrays and I need to find the index of the 5 smallest values. I have tried PartialQuickSort and argmin but I can’t get the…

---

## [How To Create a 2D Array of Arrays?](https://discourse.julialang.org/t/how-to-create-a-2d-array-of-arrays/135178)

<div class="topic-metadata">

**Author:** [@Grass](https://discourse.julialang.org/u/Grass)\
**Replies:** 5\
**Last updated:** [January 21, 2026, 9:50am UTC](https://discourse.julialang.org/t/how-to-create-a-2d-array-of-arrays/135178 "2026-01-21T09:50:52Z")

</div>

Is it possible to create a 2D array of (2D) arrays in Julia? If so, how can I do it? I scoured the internet but I did not manage to find out whether this is possible or not. I only managed to find information on creatin…

---

## [Multi-dimensional indices are incompatible with \`end\` index](https://discourse.julialang.org/t/multi-dimensional-indices-are-incompatible-with-end-index/134886)

<div class="topic-metadata">

**Author:** [@aryavorskiy](https://discourse.julialang.org/u/aryavorskiy)\
**Replies:** 1\
**Last updated:** [January 5, 2026, 2:14pm UTC](https://discourse.julialang.org/t/multi-dimensional-indices-are-incompatible-with-end-index/134886 "2026-01-05T14:14:41Z")

</div>

Julia allows to access the last index in the axis of an array using the end keyword by lowering it to lastindex in a rather predictable way: A = rand(5, 5, 2) A\[1:end - 1, end ÷ 2, :\] # lowers to A\[1:lastindex(A, 1) - 1…

---

## [Very best way to concatenate an array of arrays](https://discourse.julialang.org/t/very-best-way-to-concatenate-an-array-of-arrays/8672)

<div class="topic-metadata">

**Author:** [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)\
**Replies:** 49\
**Last updated:** [November 20, 2025, 11:39pm UTC](https://discourse.julialang.org/t/very-best-way-to-concatenate-an-array-of-arrays/8672 "2025-11-20T23:39:00Z")

</div>

I’ve been wondering about this for a while. Suppose I want to concatenate arrays of arrays. Currently the only way I know of doing that is vcat(A...) (or could be hcat, whatever). My understanding is that this is doub…

---

## [InvalidIRError when running AcceleratedKernels.sum on a GPU SubArray (CuArray view)](https://discourse.julialang.org/t/invalidirerror-when-running-acceleratedkernels-sum-on-a-gpu-subarray-cuarray-view/133994)

<div class="topic-metadata">

**Author:** [@0samuraiE](https://discourse.julialang.org/u/0samuraiE)\
**Replies:** 2\
**Last updated:** [November 20, 2025, 9:20am UTC](https://discourse.julialang.org/t/invalidirerror-when-running-acceleratedkernels-sum-on-a-gpu-subarray-cuarray-view/133994 "2025-11-20T09:20:41Z")

</div>

I’m running into an issue when trying to use AcceleratedKernels.sum on a GPU SubArray (a view into a CuArray). Calling AK.sum on the full array works fine, but calling it on the view throws an InvalidIRError. Question …

---

## [Is there a package for block-sparse matrix processing?](https://discourse.julialang.org/t/is-there-a-package-for-block-sparse-matrix-processing/133067)

<div class="topic-metadata">

**Author:** [@photor](https://discourse.julialang.org/u/photor)\
**Replies:** 5\
**Last updated:** [October 12, 2025, 7:46pm UTC](https://discourse.julialang.org/t/is-there-a-package-for-block-sparse-matrix-processing/133067 "2025-10-12T19:46:11Z")

</div>

As in the title, I mean every block is dense, but there are only a small percentage of non-vanishing blocks.

---

## [Assigning to a view of an array](https://discourse.julialang.org/t/assigning-to-a-view-of-an-array/132869)

<div class="topic-metadata">

**Author:** [@DanimirD](https://discourse.julialang.org/u/DanimirD)\
**Replies:** 37\
**Last updated:** [October 6, 2025, 11:55am UTC](https://discourse.julialang.org/t/assigning-to-a-view-of-an-array/132869 "2025-10-06T11:55:24Z")

</div>

The purpose of creating a view from an array is to avoid a copy. However, a view cannot be assigned to. julia\> X = rand(3,3) 3×3 Matrix{Float64}: 0.135318 0.958828 0.0860895 0.715183 0.136236 0.542946 0.513489 0.9…

---

## [Mapping over multidimensional array with eachslice](https://discourse.julialang.org/t/mapping-over-multidimensional-array-with-eachslice/131880)

<div class="topic-metadata">

**Author:** [@Geegee](https://discourse.julialang.org/u/Geegee)\
**Replies:** 5\
**Last updated:** [August 27, 2025, 4:55pm UTC](https://discourse.julialang.org/t/mapping-over-multidimensional-array-with-eachslice/131880 "2025-08-27T16:55:10Z")

</div>

I have a data opject Array{Float64, 3} where I want to map 2nd and 3rd dimension a function that accepts some static arguments and takes a Vector{Float64} from the data object. I tried to do this with eachslice(data, …

---

## [\[ANN\] Einops.jl: Concise, declarative tensor operations](https://discourse.julialang.org/t/ann-einops-jl-concise-declarative-tensor-operations/130792)

<div class="topic-metadata">

**Author:** [@AntonOresten](https://discourse.julialang.org/u/AntonOresten)\
**Replies:** 4\
**Last updated:** [July 17, 2025, 7:40am UTC](https://discourse.julialang.org/t/ann-einops-jl-concise-declarative-tensor-operations/130792 "2025-07-17T07:40:16Z")

</div>

I’m excited to share that I’ve been working on Einops.jl, bringing the popular einops tensor manipulation syntax to Julia. While Julia’s array interface is already excellent thanks to multiple dispatch, there’s still val…

---

## [Syntax for extracting keys from vector of pairs?](https://discourse.julialang.org/t/syntax-for-extracting-keys-from-vector-of-pairs/130063)

<div class="topic-metadata">

**Author:** [@g2g](https://discourse.julialang.org/u/g2g)\
**Replies:** 4\
**Last updated:** [June 20, 2025, 10:59pm UTC](https://discourse.julialang.org/t/syntax-for-extracting-keys-from-vector-of-pairs/130063 "2025-06-20T22:59:14Z")

</div>

julia\> X 3-element Vector{Pair{String, Any}}: "water" =\> \[1 2\] "coffee" =\> \[3 4 5\] "tea" =\> \[6 7 8 9\] To extract the keys from X, the current syntax is first.(X). However, given that the syntax for extracting a c…

---

## [How to stop array slice being flattened](https://discourse.julialang.org/t/how-to-stop-array-slice-being-flattened/130494)

<div class="topic-metadata">

**Author:** [@user664303](https://discourse.julialang.org/u/user664303)\
**Replies:** 2\
**Last updated:** [July 5, 2025, 4:03pm UTC](https://discourse.julialang.org/t/how-to-stop-array-slice-being-flattened/130494 "2025-07-05T16:03:51Z")

</div>

Julia is removing singular dimensions when I slice an array: A = reshape(\[2 2 2 2\], 2, 1, 2) A\[1,1,:\] 2-element Vector{Int64}: 2 2 If I want A to remain a 1x1x2 array, is there anything I can do other than reshape it…

---

## [Add elements to tuples or arrays](https://discourse.julialang.org/t/add-elements-to-tuples-or-arrays/75885)

<div class="topic-metadata">

**Author:** [@Leticia-maria](https://discourse.julialang.org/u/Leticia-maria)\
**Replies:** 32\
**Last updated:** [June 24, 2025, 9:39pm UTC](https://discourse.julialang.org/t/add-elements-to-tuples-or-arrays/75885 "2025-06-24T21:39:03Z")

</div>

Hi everyone, do you know a way to have this working on Julia REPL? \>\>\> a = \[1,2,3\] \>\>\> a + \[4\] \[1, 2, 3, 4\]

---

## [How to properly do thread-safe element-wise mutation on atomic fields?](https://discourse.julialang.org/t/how-to-properly-do-thread-safe-element-wise-mutation-on-atomic-fields/130138)

<div class="topic-metadata">

**Author:** [@frankwswang](https://discourse.julialang.org/u/frankwswang)\
**Replies:** 4\
**Last updated:** [June 23, 2025, 7:57pm UTC](https://discourse.julialang.org/t/how-to-properly-do-thread-safe-element-wise-mutation-on-atomic-fields/130138 "2025-06-23T19:57:52Z")

</div>

MWE: julia\> mutable struct Atomic{T} @atomic a::T end julia\> obj1 = Atomic(collect(1:4)) Atomic{Vector{Int64}}(\[1, 2, 3, 4\]) julia\> obj1.a .= 2 4-element Vector{Int64}: 2 2 2 2 Unlike directly c…

---

## [FixedSizeVectors with cache-aligned memory?](https://discourse.julialang.org/t/fixedsizevectors-with-cache-aligned-memory/129884)

<div class="topic-metadata">

**Author:** [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Replies:** 18\
**Last updated:** [June 19, 2025, 7:33pm UTC](https://discourse.julialang.org/t/fixedsizevectors-with-cache-aligned-memory/129884 "2025-06-19T19:33:33Z")

</div>

FixedSizeVectors offer a first, more performant and cleaner approach to working with (generally, numeric) vectors where, once formed, the size of the vector does not change. AlignedAllocs provides cache-aligned memory a…

---

## [Indexing by names, current favorites in the package space](https://discourse.julialang.org/t/indexing-by-names-current-favorites-in-the-package-space/123097)

<div class="topic-metadata">

**Author:** [@cdawg](https://discourse.julialang.org/u/cdawg)\
**Replies:** 7\
**Last updated:** [June 6, 2025, 8:40pm UTC](https://discourse.julialang.org/t/indexing-by-names-current-favorites-in-the-package-space/123097 "2025-06-06T20:40:18Z")

</div>

I loved AxisArrays.jl. However AxisArrays is old (designed pre1.0). It still works…ok, but I miss broadcasting and Not-.indexing. I did not learn about its newer counterparts until I had written a few weeks of analysis a…

---

## [Memory Comprehensions](https://discourse.julialang.org/t/memory-comprehensions/129033)

<div class="topic-metadata">

**Author:** [@PatrickHaecker](https://discourse.julialang.org/u/PatrickHaecker)\
**Replies:** 7\
**Last updated:** [May 25, 2025, 10:51am UTC](https://discourse.julialang.org/t/memory-comprehensions/129033 "2025-05-25T10:51:04Z")

</div>

Is there a Memory comprehension in Julia, which I missed so far? We have Array comprehensions, but when you don’t need the multiple dimensions and resizing properties of an Array and a Memory is enough, it would be nice…

---

## [Get the transpose of Vector{Vector{Float64}}](https://discourse.julialang.org/t/get-the-transpose-of-vector-vector-float64/128141)

<div class="topic-metadata">

**Author:** [@15et7dtwq](https://discourse.julialang.org/u/15et7dtwq)\
**Replies:** 9\
**Last updated:** [April 17, 2025, 8:36pm UTC](https://discourse.julialang.org/t/get-the-transpose-of-vector-vector-float64/128141 "2025-04-17T20:36:50Z")

</div>

I am coming from numpy, trying tosee if Julia can be faster. Right now I am dealing with a function that generates for me what I thought had to be a matrix, but no, it’s a vector of vector. Fine. How do I make it’s trans…

---

## [Find indexes of a String in Multi -Type Matrix](https://discourse.julialang.org/t/find-indexes-of-a-string-in-multi-type-matrix/128072)

<div class="topic-metadata">

**Author:** [@Vasilis\_Dim](https://discourse.julialang.org/u/Vasilis_Dim)\
**Replies:** 2\
**Last updated:** [April 14, 2025, 7:20pm UTC](https://discourse.julialang.org/t/find-indexes-of-a-string-in-multi-type-matrix/128072 "2025-04-14T19:20:36Z")

</div>

Hello There! I have created a matrix such as: T=Union{String, Int} June=Matrix{T}(undef,10,30) Later in the code some entries of A might change to a string (let’s say “Bill”). I tried to locate the indexes where that’…

---

## [\[ANN\] UnitfulTensors.jl: Efficient arrays with units](https://discourse.julialang.org/t/ann-unitfultensors-jl-efficient-arrays-with-units/114028)

<div class="topic-metadata">

**Author:** [@anonymous\_shrew](https://discourse.julialang.org/u/anonymous_shrew)\
**Replies:** 17\
**Last updated:** [March 26, 2025, 7:17pm UTC](https://discourse.julialang.org/t/ann-unitfultensors-jl-efficient-arrays-with-units/114028 "2025-03-26T19:17:25Z")

</div>

Hello everyone! I wrote a package UnitfulTensors.jl for working efficiently with arrays of physical quantities. It implements most of the LinearAlgebra functionality, but with physical units (including arrays with mixe…

---

## [How to select elements of a three-dimensional array fast](https://discourse.julialang.org/t/how-to-select-elements-of-a-three-dimensional-array-fast/127185)

<div class="topic-metadata">

**Author:** [@Joris\_Pinkse](https://discourse.julialang.org/u/Joris_Pinkse)\
**Replies:** 4\
**Last updated:** [March 20, 2025, 10:28pm UTC](https://discourse.julialang.org/t/how-to-select-elements-of-a-three-dimensional-array-fast/127185 "2025-03-20T22:28:50Z")

</div>

I have large three-dimensional arrays A that have different values, but from which I always wish to select the same set of entries. So A is a different matrix each time, but it has the same size and I need to collect th…

---

## [Memory \`isbits\` Union Optimization](https://discourse.julialang.org/t/memory-isbits-union-optimization/126175)

<div class="topic-metadata">

**Author:** [@PatrickHaecker](https://discourse.julialang.org/u/PatrickHaecker)\
**Replies:** 5\
**Last updated:** [February 23, 2025, 8:23am UTC](https://discourse.julialang.org/t/memory-isbits-union-optimization/126175 "2025-02-23T08:23:03Z")

</div>

Citing from isbits union memory optimization (emphasis mine) The optimization is accomplished by storing an extra “type tag memory” of bytes, one byte per element, alongside the bytes of the actual data. However, I s…

---

## [\[ANN\] Introducing AlternateVectors.jl - A Library for Peculiar One-Dimensional Array Patterns](https://discourse.julialang.org/t/ann-introducing-alternatevectors-jl-a-library-for-peculiar-one-dimensional-array-patterns/125686)

<div class="topic-metadata">

**Author:** [@rcalxrc08](https://discourse.julialang.org/u/rcalxrc08)\
**Replies:** 0\
**Last updated:** [February 8, 2025, 11:54am UTC](https://discourse.julialang.org/t/ann-introducing-alternatevectors-jl-a-library-for-peculiar-one-dimensional-array-patterns/125686 "2025-02-08T11:54:29Z")

</div>

Hello Julia Developers, I’m excited to introduce you to AlternateVectors.jl, a new Julia library designed to provide useful array representations for peculiar one-dimensional array patterns. What is AlternateVectors.jl?…

---

## [Keep array elements that are NOT in a list of indexes](https://discourse.julialang.org/t/keep-array-elements-that-are-not-in-a-list-of-indexes/125555)

<div class="topic-metadata">

**Author:** [@JM\_Beckers](https://discourse.julialang.org/u/JM_Beckers)\
**Replies:** 8\
**Last updated:** [February 5, 2025, 12:40pm UTC](https://discourse.julialang.org/t/keep-array-elements-that-are-not-in-a-list-of-indexes/125555 "2025-02-05T12:40:55Z")

</div>

Suppose I have a list of indexes mylist, is there an equivalent of setdiff(myarray, myarray\[mylist\]) but using directly the fact that I know which elements are to the eliminated (through mylist) in order to be more ef…

---

## [Elegant way of exclusive indexing](https://discourse.julialang.org/t/elegant-way-of-exclusive-indexing/76894)

<div class="topic-metadata">

**Author:** [@TheLateKronos](https://discourse.julialang.org/u/TheLateKronos)\
**Replies:** 41\
**Last updated:** [February 26, 2022, 4:34pm UTC](https://discourse.julialang.org/t/elegant-way-of-exclusive-indexing/76894 "2022-02-26T16:34:17Z")

</div>

In R, you can index all elements except for the second, by negative indexing: myvector\[-2\]. This is especially usefull if you want to make two complete subsets of a vector: set1 = myvector\[inds\] set2 = myvector\[-inds\] W…

---

## [Custom array type that defaults to views when sliced?](https://discourse.julialang.org/t/custom-array-type-that-defaults-to-views-when-sliced/125158)

<div class="topic-metadata">

**Author:** [@johnomotani](https://discourse.julialang.org/u/johnomotani)\
**Replies:** 6\
**Last updated:** [January 24, 2025, 7:31pm UTC](https://discourse.julialang.org/t/custom-array-type-that-defaults-to-views-when-sliced/125158 "2025-01-24T19:31:38Z")

</div>

I’m thinking about making a custom array type that defaults to creating a view when sliced. Is this a bad idea? Would it break things (if so, what things)? For clarity, this question is definitely not to resurrect the d…

[Next page](https://discourse.julialang.org/tag/arrays/248.md?match_all_tags=true&page=1&tags%5B%5D=arrays)
