# \#matrix

**URL:** https://discourse.julialang.org/tag/matrix/1246.md

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

---

## [Creating looping matrixes (Torus-like) with type inheritance](https://discourse.julialang.org/t/creating-looping-matrixes-torus-like-with-type-inheritance/135475)

<div class="topic-metadata">

**Author:** [@Daeltam](https://discourse.julialang.org/u/Daeltam)\
**Replies:** 7\
**Last updated:** [February 18, 2026, 11:36pm UTC](https://discourse.julialang.org/t/creating-looping-matrixes-torus-like-with-type-inheritance/135475 "2026-02-18T23:36:13Z")

</div>

Context : I am trying to create a cellular automata and want its behaviour on edges to be looping (ex : neighbour of the cell at \[0,0\] are the cells at \[0,end\] and \[end, 0\] (as well as \[0,1\] and \[1,0\] ) Some kind of tor…

---

## [Resize!(matrix)](https://discourse.julialang.org/t/resize-matrix/2379)

<div class="topic-metadata">

**Author:** [@gdkrmr](https://discourse.julialang.org/u/gdkrmr)\
**Replies:** 51\
**Last updated:** [January 29, 2026, 12:59pm UTC](https://discourse.julialang.org/t/resize-matrix/2379 "2026-01-29T12:59:04Z")

</div>

is it possible to resize an Array with more than one dimension? For example: tmp1 = collect(1:6) @show pointer(tmp1) for i in 1:5 resize!(tmp1, length(tmp1) + 2) @show pointer(tmp1) tmp2 = reshape(tmp1, 2…

---

## [Matrix of type textbox?](https://discourse.julialang.org/t/matrix-of-type-textbox/135260)

<div class="topic-metadata">

**Author:** [@BananaMaster3](https://discourse.julialang.org/u/BananaMaster3)\
**Replies:** 6\
**Last updated:** [January 27, 2026, 7:53pm UTC](https://discourse.julialang.org/t/matrix-of-type-textbox/135260 "2026-01-27T19:53:18Z")

</div>

Hey, I want to store my instances of Makie.Textbox in a matrix of size m=(L,L) where L is an integer. The ideal situation would be: matrix = zeros(m, Makie.Textbox) for ... #assign different parts of the matrix to di…

---

## [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…

---

## [Multidimensional array comprehension](https://discourse.julialang.org/t/multidimensional-array-comprehension/134004)

<div class="topic-metadata">

**Author:** [@fps](https://discourse.julialang.org/u/fps)\
**Replies:** 13\
**Last updated:** [November 21, 2025, 8:31am UTC](https://discourse.julialang.org/t/multidimensional-array-comprehension/134004 "2025-11-21T08:31:59Z")

</div>

I wonder it is possible to get the following matrix with a single array comprehension that’s also efficient to evaluate: (1, 1, 1) (1, 2, 1) (1, 1, 2) (1, 2, 2) (1, 1, 3) (1, 2, 3).... (2, 1, 1) (2, 2, 1) (2, 1, 2) (2…

---

## [Numeric stability of Base.exp of static matrix of Float32](https://discourse.julialang.org/t/numeric-stability-of-base-exp-of-static-matrix-of-float32/133389)

<div class="topic-metadata">

**Author:** [@Xu\_Shan](https://discourse.julialang.org/u/Xu_Shan)\
**Replies:** 12\
**Last updated:** [October 26, 2025, 7:46pm UTC](https://discourse.julialang.org/t/numeric-stability-of-base-exp-of-static-matrix-of-float32/133389 "2025-10-26T19:46:53Z")

</div>

Guys, I want to use Base.exp in my model which uses Float32 with StaticArray and StaticVector. However, I found there is a numerical instability of Base.exp with the 3\*3 matrix…see the example above: using StaticArrays…

---

## [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.

---

## [How do I make a matrix of vectors?](https://discourse.julialang.org/t/how-do-i-make-a-matrix-of-vectors/132765)

<div class="topic-metadata">

**Author:** [@phma](https://discourse.julialang.org/u/phma)\
**Replies:** 6\
**Last updated:** [September 30, 2025, 5:44pm UTC](https://discourse.julialang.org/t/how-do-i-make-a-matrix-of-vectors/132765 "2025-09-30T17:44:08Z")

</div>

I’m cryptanalyzing a hash function I invented. I get a big amount of data which I want to return as a matrix normalize(cd0a) normalize(cd0b) normalize(cd1a) normalize(cd1b) where the two rows represent using the three …

---

## [Null initialisation for a loop that appends vectors](https://discourse.julialang.org/t/null-initialisation-for-a-loop-that-appends-vectors/131754)

<div class="topic-metadata">

**Author:** [@rcomm](https://discourse.julialang.org/u/rcomm)\
**Replies:** 14\
**Last updated:** [August 24, 2025, 5:35pm UTC](https://discourse.julialang.org/t/null-initialisation-for-a-loop-that-appends-vectors/131754 "2025-08-24T17:35:48Z")

</div>

In Matlab, it is common to initialise a loop like this: x = ; for i = 1:n; x = \[x; another numerical row vector (of fixed length L)\]; end This creates a matrix of size \[n,L\]. It works regardless of chosen length L. W…

---

## [Simplifying Iwasawa decomposition with Symbolics.jl](https://discourse.julialang.org/t/simplifying-iwasawa-decomposition-with-symbolics-jl/128842)

<div class="topic-metadata">

**Author:** [@potatoh8](https://discourse.julialang.org/u/potatoh8)\
**Replies:** 0\
**Last updated:** [May 8, 2025, 3:42pm UTC](https://discourse.julialang.org/t/simplifying-iwasawa-decomposition-with-symbolics-jl/128842 "2025-05-08T15:42:31Z")

</div>

I’m trying to verify the following matrix identity using Symbolics.jl: Here’s my attempt: using Symbolics function SL2CIwasawaDecomp(X) # given matrix X in SL2C, return tuple (z, r, α, β) such that # X = n(z…

---

## [Repeat and reshape vector into a matrix](https://discourse.julialang.org/t/repeat-and-reshape-vector-into-a-matrix/127451)

<div class="topic-metadata">

**Author:** [@Ju\_ska](https://discourse.julialang.org/u/Ju_ska)\
**Replies:** 9\
**Last updated:** [March 28, 2025, 9:13pm UTC](https://discourse.julialang.org/t/repeat-and-reshape-vector-into-a-matrix/127451 "2025-03-28T21:13:31Z")

</div>

Hi, this is a Python code I’m translating in Julia: import numpy as np val = \[1,2,3,4,5,6\] val\_length = len(val) rpt = 3 np.repeat(val, rpt).reshape((val\_length, rpt)) It gives: \>\>\> val = \[1,2,3,4,5,6\] \>\>\> val\_leng…

---

## [Is matrix multiplication not associative?](https://discourse.julialang.org/t/is-matrix-multiplication-not-associative/127231)

<div class="topic-metadata">

**Author:** [@Yeguarr](https://discourse.julialang.org/u/Yeguarr)\
**Replies:** 22\
**Last updated:** [March 23, 2025, 2:11am UTC](https://discourse.julialang.org/t/is-matrix-multiplication-not-associative/127231 "2025-03-23T02:11:43Z")

</div>

Hi! I have a very simple code snippet: let B = \[1;1\] K = \[1 2\] x = \[1;2\] (B\*K)\*x #Works fine B\*(K\*x) #MethodError: no method matching \*(::Vector{Int64}, ::Vector{Int64}) end It seems that Julia automatically conv…

---

## [Slicing a Vector into a Matrix using views](https://discourse.julialang.org/t/slicing-a-vector-into-a-matrix-using-views/126918)

<div class="topic-metadata">

**Author:** [@Ju\_ska](https://discourse.julialang.org/u/Ju_ska)\
**Replies:** 13\
**Last updated:** [March 16, 2025, 11:06am UTC](https://discourse.julialang.org/t/slicing-a-vector-into-a-matrix-using-views/126918 "2025-03-16T11:06:07Z")

</div>

Hi, I loaded data from a simple file input.txt: 1 2 3 4 5 6 7 8 9 into a vector with: data = CSV.File("input.txt", ntasks=1, header=false).Column1 So it’s equivalent to: julia\> data = \[1,2,3,4,5,6,7,8,9\] 9…

---

## [Matrix (linear map function) exponential multiplied with vector in ExponentialUtilities.jl](https://discourse.julialang.org/t/matrix-linear-map-function-exponential-multiplied-with-vector-in-exponentialutilities-jl/126957)

<div class="topic-metadata">

**Author:** [@eveningsilverfox](https://discourse.julialang.org/u/eveningsilverfox)\
**Replies:** 10\
**Last updated:** [March 15, 2025, 12:04am UTC](https://discourse.julialang.org/t/matrix-linear-map-function-exponential-multiplied-with-vector-in-exponentialutilities-jl/126957 "2025-03-15T00:04:07Z")

</div>

I am trying to multiply the exponential of a matrix (available as a function which linearly maps the input vector to an output vector), to a given vector, using expv from ExponentialUtilities.jl using MKL using LinearAl…

---

## [Question about singular matrix inversion](https://discourse.julialang.org/t/question-about-singular-matrix-inversion/126403)

<div class="topic-metadata">

**Author:** [@fdekerme](https://discourse.julialang.org/u/fdekerme)\
**Replies:** 2\
**Last updated:** [February 28, 2025, 12:59pm UTC](https://discourse.julialang.org/t/question-about-singular-matrix-inversion/126403 "2025-02-28T12:59:10Z")

</div>

Hello :grinning:, I was wondering why inversion works (when it shouldn’t) with floats, but returns an error with integers? Is it a rounding issue? julia\> inv(\[0.23 0.23; 0.3 0.3\]) 2×2 Matrix{Float64}: -3.3777e17 2.5…

---

## [What is the best way to get a running matrix-product over a large 3D array](https://discourse.julialang.org/t/what-is-the-best-way-to-get-a-running-matrix-product-over-a-large-3d-array/125452)

<div class="topic-metadata">

**Author:** [@SanAlphaTau](https://discourse.julialang.org/u/SanAlphaTau)\
**Replies:** 9\
**Last updated:** [February 2, 2025, 4:44pm UTC](https://discourse.julialang.org/t/what-is-the-best-way-to-get-a-running-matrix-product-over-a-large-3d-array/125452 "2025-02-02T16:44:16Z")

</div>

Heya, I am doing some markov process simulations which output NxN matrices these are stored (currently) in a 3D array X\[N, N, M) where M can be very large (1E6 or more). My code currently uses a reduce statement reduce…

---

## [Argmax over columns of a large matrix](https://discourse.julialang.org/t/argmax-over-columns-of-a-large-matrix/121924)

<div class="topic-metadata">

**Author:** [@miguelborrero](https://discourse.julialang.org/u/miguelborrero)\
**Replies:** 2\
**Last updated:** [October 29, 2024, 6:50pm UTC](https://discourse.julialang.org/t/argmax-over-columns-of-a-large-matrix/121924 "2024-10-29T18:50:52Z")

</div>

Hi there, I have a large matrix for e.g (7x10000) and I want to iterate over each of the columns and compute the index of the maximum element. There are naive ways I can think of but since this part of my code is perfor…

---

## [Which package is suitable for matrix-free partial SVD?](https://discourse.julialang.org/t/which-package-is-suitable-for-matrix-free-partial-svd/118419)

<div class="topic-metadata">

**Author:** [@MAChiyu](https://discourse.julialang.org/u/MAChiyu)\
**Replies:** 2\
**Last updated:** [August 20, 2024, 8:15pm UTC](https://discourse.julialang.org/t/which-package-is-suitable-for-matrix-free-partial-svd/118419 "2024-08-20T20:15:57Z")

</div>

Hi! I am new to Julia. I used to use MATLAB. Within MATLAB, I use lansvd in PROPACK to do partial SVD of some linear operator (needs Afunpar to input other parameters of the matrix free operator). I notice there is PROPA…

---

## [Finding \*all\* the eigenvalues of a sparse matrix?](https://discourse.julialang.org/t/finding-all-the-eigenvalues-of-a-sparse-matrix/116895)

<div class="topic-metadata">

**Author:** [@rafaelbailo](https://discourse.julialang.org/u/rafaelbailo)\
**Replies:** 24\
**Last updated:** [July 18, 2024, 9:22am UTC](https://discourse.julialang.org/t/finding-all-the-eigenvalues-of-a-sparse-matrix/116895 "2024-07-18T09:22:44Z")

</div>

Seems that LinearAlgebra.jl does not work with sparse matrices, and the libraries that do (e.g. Arpack.jl, ArnoldiMethod.jl, KrylovKit.jl) all use iterative methods, which are not efficient to find all the eigenvalues. S…

---

## [Indexing array with a matrix and scalar](https://discourse.julialang.org/t/indexing-array-with-a-matrix-and-scalar/116848)

<div class="topic-metadata">

**Author:** [@baptnz](https://discourse.julialang.org/u/baptnz)\
**Replies:** 9\
**Last updated:** [July 10, 2024, 7:33pm UTC](https://discourse.julialang.org/t/indexing-array-with-a-matrix-and-scalar/116848 "2024-07-10T19:33:45Z")

</div>

A bit rusty after a while away from julia… How would I fill a 3D array with N values at positions given as follows: 1st index given as a scalar (from a for loop) the other two indices are provided as vectors I’m u…

---

## [Simple CUDA kernel on matrix slower than running GPU](https://discourse.julialang.org/t/simple-cuda-kernel-on-matrix-slower-than-running-gpu/115018)

<div class="topic-metadata">

**Author:** [@jlbosse](https://discourse.julialang.org/u/jlbosse)\
**Replies:** 8\
**Last updated:** [June 3, 2024, 12:27pm UTC](https://discourse.julialang.org/t/simple-cuda-kernel-on-matrix-slower-than-running-gpu/115018 "2024-06-03T12:27:21Z")

</div>

I am trying to write a simple CUDA kernel that swaps pairs of columns in a square matrix and puts a sign on one of them: using CUDA, BenchmarkTools function swap\_and\_sign!(A::Matrix) n = size(A, 1) ÷ 2 for i in…

---

## [Jordan norm in julia](https://discourse.julialang.org/t/jordan-norm-in-julia/114500)

<div class="topic-metadata">

**Author:** [@swsw](https://discourse.julialang.org/u/swsw)\
**Replies:** 6\
**Last updated:** [May 23, 2024, 6:06am UTC](https://discourse.julialang.org/t/jordan-norm-in-julia/114500 "2024-05-23T06:06:22Z")

</div>

Is there a way to do jordan decomposition or find out the jordan norm of a n\*n matrix in julia? I see the following one but the function jordan\_form is not available in SymPy.jl. Any insight?

---

## [How to convert a thread-parallelized code into a core-parallelized code?](https://discourse.julialang.org/t/how-to-convert-a-thread-parallelized-code-into-a-core-parallelized-code/114406)

<div class="topic-metadata">

**Author:** [@Uranium238](https://discourse.julialang.org/u/Uranium238)\
**Replies:** 3\
**Last updated:** [May 19, 2024, 7:06am UTC](https://discourse.julialang.org/t/how-to-convert-a-thread-parallelized-code-into-a-core-parallelized-code/114406 "2024-05-19T07:06:44Z")

</div>

This post can be thought as a successor to an old series of posts that I had made where the motive was to improve the performance and eventually parallelize a code that consisted primarily of matrix operations, the end g…

---

## [Why does rand(Complex{Float64},N,N) always host a large eigenvalue?](https://discourse.julialang.org/t/why-does-rand-complex-float64-n-n-always-host-a-large-eigenvalue/114402)

<div class="topic-metadata">

**Author:** [@yosuga](https://discourse.julialang.org/u/yosuga)\
**Replies:** 5\
**Last updated:** [May 17, 2024, 5:17pm UTC](https://discourse.julialang.org/t/why-does-rand-complex-float64-n-n-always-host-a-large-eigenvalue/114402 "2024-05-17T17:17:36Z")

</div>

rand(Complex{Float64},N,N) has a single huge eigenvalue: 1000-element Vector{ComplexF64}: -12.783541578066096 + 0.3846555290226826im -12.640629292870221 + 0.3298358788214941im -12.532390460903775 - 0.46833512398154803im…

---

## [Matrix inside Matrix in Julia](https://discourse.julialang.org/t/matrix-inside-matrix-in-julia/113280)

<div class="topic-metadata">

**Author:** [@sati](https://discourse.julialang.org/u/sati)\
**Replies:** 10\
**Last updated:** [April 25, 2024, 5:09pm UTC](https://discourse.julialang.org/t/matrix-inside-matrix-in-julia/113280 "2024-04-25T17:09:53Z")

</div>

This is a matrix formula derived from algebra. My question is how to implement this in Julia? For the first row : I is an identity matrix with a size 3x3 , 0 is a zero matrix with a size 3x6, AG is a 3x10 matrix, and…

---

## [How to construct a matrix of gradients depending on nodal locations in gridap](https://discourse.julialang.org/t/how-to-construct-a-matrix-of-gradients-depending-on-nodal-locations-in-gridap/113255)

<div class="topic-metadata">

**Author:** [@mary](https://discourse.julialang.org/u/mary)\
**Replies:** 0\
**Last updated:** [April 19, 2024, 9:52pm UTC](https://discourse.julialang.org/t/how-to-construct-a-matrix-of-gradients-depending-on-nodal-locations-in-gridap/113255 "2024-04-19T21:52:55Z")

</div>

Hi, I want to calculate the gradients of residuals(displacement) with respect to another vector. based on mathematical calculations, as residuals are a vector this gradient should be a matrix. This matrix should has val…

---

## [How to extract the upper/lower triangular matrix values except the diagonal?](https://discourse.julialang.org/t/how-to-extract-the-upper-lower-triangular-matrix-values-except-the-diagonal/112974)

<div class="topic-metadata">

**Author:** [@Shayan](https://discourse.julialang.org/u/Shayan)\
**Replies:** 4\
**Last updated:** [April 15, 2024, 6:07pm UTC](https://discourse.julialang.org/t/how-to-extract-the-upper-lower-triangular-matrix-values-except-the-diagonal/112974 "2024-04-15T18:07:52Z")

</div>

Consider the following matrix: julia\> c = rand(2, 2) 2×2 Matrix{Float64}: 0.0443768 0.515352 0.531426 0.967584 Expected output: 1-element Vector{Float64}: 0.531426 I can do: julia\> using LinearAlgebra: LowerTri…

---

## [How to transpose Matrix{Any} that contains strings?](https://discourse.julialang.org/t/how-to-transpose-matrix-any-that-contains-strings/112514)

<div class="topic-metadata">

**Author:** [@homocomputeris](https://discourse.julialang.org/u/homocomputeris)\
**Replies:** 3\
**Last updated:** [April 4, 2024, 11:24am UTC](https://discourse.julialang.org/t/how-to-transpose-matrix-any-that-contains-strings/112514 "2024-04-04T11:24:16Z")

</div>

How to transpose Matrix{Any} that contains strings? The obvious way doesn’t work: transpose(\["aoeu", 2\]) 1×2 transpose(::Vector{Any}) with eltype Any: Error showing value of type LinearAlgebra.Transpose{Any, Vector{Any}…

---

## [Using Luxor.Table to visualize Julia 2D matrix results in transposed view](https://discourse.julialang.org/t/using-luxor-table-to-visualize-julia-2d-matrix-results-in-transposed-view/112484)

<div class="topic-metadata">

**Author:** [@Julia2001](https://discourse.julialang.org/u/Julia2001)\
**Replies:** 1\
**Last updated:** [April 4, 2024, 7:34am UTC](https://discourse.julialang.org/t/using-luxor-table-to-visualize-julia-2d-matrix-results-in-transposed-view/112484 "2024-04-04T07:34:55Z")

</div>

Hi, I’m stumbling across the fact that Luxor.Table looks row-major but Julia matrices are column-major. How can I “swap” dimension indices between source matrix read access and Luxor.Table write access? using Luxor wi…

---

## [How can I use NonlinearSolve.jl with matrix functions?](https://discourse.julialang.org/t/how-can-i-use-nonlinearsolve-jl-with-matrix-functions/112379)

<div class="topic-metadata">

**Author:** [@homocomputeris](https://discourse.julialang.org/u/homocomputeris)\
**Replies:** 8\
**Last updated:** [April 2, 2024, 11:06am UTC](https://discourse.julialang.org/t/how-can-i-use-nonlinearsolve-jl-with-matrix-functions/112379 "2024-04-02T11:06:52Z")

</div>

I want to use NonlinearSolve.jl with matrix functions, something like: using NonlinearSolve using LinearAlgebra dim = 2 function f(u, p) return exp(u) - Matrix{Float64}(I(dim)) end u0 = rand(dim, dim) \* 0.01 p = n…

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