# RecursiveArrayTools.VectorOfArray weirdness

**URL:** <https://discourse.julialang.org/t/recursivearraytools-vectorofarray-weirdness/132726>\
**Category:** General Usage\
**Tags:** question\
**Created:** [September 28, 2025, 7:17am UTC](https://discourse.julialang.org/t/recursivearraytools-vectorofarray-weirdness/132726 "2025-09-28T07:17:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Post date:** [September 28, 2025, 7:17am UTC](https://discourse.julialang.org/t/recursivearraytools-vectorofarray-weirdness/132726/1 "2025-09-28T07:17:59Z")

</div>

Hi,

I stumbled onto the following weirdness, it seems `norm(a,2)` is computed in place of `norm(a,Inf)`.

```julia-auto
julia> using RecursiveArrayTools

julia> a = VectorOfArray([rand(10)])
VectorOfArray{Float64,2}:
1-element Vector{Vector{Float64}}:
 [0.9374610738552556, 0.294321363382817, 0.8097899894308892, 0.6862080401372058, 0.5797315120596563, 0.02451813324511276, 0.31231472187900955, 0.21977997754703116, 0.33771596470243326, 0.35617455891579763]

julia> norm(a, Inf) # What???? it should be <=1
1.677958732945566

julia> norm(a.u, Inf) # What???? it should be <=1
1.677958732945566

julia> norm(a.u[1], Inf) # finally!!
0.9374610738552556

```

---

<div class="post-metadata">

**Author:** ![WalterMadelim](https://avatars.discourse-cdn.com/v4/letter/w/3e96dc/32.png) [@WalterMadelim](https://discourse.julialang.org/u/WalterMadelim)\
**Post date:** [September 28, 2025, 8:01am UTC](https://discourse.julialang.org/t/recursivearraytools-vectorofarray-weirdness/132726/2 "2025-09-28T08:01:08Z")

</div>

I don’t know if it helps, but there may be some useful info here

> <https://github.com/JuliaLang/LinearAlgebra.jl/issues/1105>
>
> The function \`LinearAlgebra.norm\` should be calculated in a global way. e.g. the… 1-norm:
> 
> \`\`\`julia
> julia\> function norm1(x) return LinearAlgebra.norm(x, 1) end
> norm1 (generic function with 1 method)
> 
> julia\> t = (\[1 1; 0 0.\], \[0 0; 0 0.\])
> (\[1.0 1.0; 0.0 0.0\], \[0.0 0.0; 0.0 0.0\])
> 
> julia\> t\[1\]
> 2×2 Matrix{Float64}:
> 1.0 1.0
> 0.0 0.0
> 
> julia\> t\[2\]
> 2×2 Matrix{Float64}:
> 0.0 0.0
> 0.0 0.0
> 
> julia\> norm1(t) # this is strange because norm-2 feature is involved in a norm-1 function
> 1.4142135623730951
> \`\`\`
> I think in practice people should expect the last result being 2.0, because we are calculating 1-norm.

---

<div class="post-metadata">

**Author:** ![eldee](https://avatars.discourse-cdn.com/v4/letter/e/b5a626/32.png) [@eldee](https://discourse.julialang.org/u/eldee)\
**Post date:** [September 28, 2025, 8:13am UTC](https://discourse.julialang.org/t/recursivearraytools-vectorofarray-weirdness/132726/3 "2025-09-28T08:13:35Z")

</div>

Hi,

This seems to work fine on my system:

```julia-auto
julia> using RecursiveArrayTools, LinearAlgebra

julia> a = VectorOfArray([rand(3)])
VectorOfArray{Float64,2}:
1-element Vector{Vector{Float64}}:
 [0.3719972466024375, 0.6359087294343279, 0.5154365209406289]

julia> norm(a, Inf)
0.6359087294343279

julia> norm(a.u, Inf)
0.8991310642892699

julia> norm(a.u[1], Inf)
0.6359087294343279

```

The only weird thing here is `norm(a.u, Inf)`, but that’s probably related to the issue (/ design choice) `WalterMadelim` highlights:

```julia-auto
generic_normInf(x) = float(mapreduce(norm, max, x))

```

so that for `a.u::Vector{Vector{Float64}}` we get `maximum(norm.(a.u)) == norm(a.u[1])` using the 2-norm.

> **Versions**
>
> I’m using RecursiveArrayTools v3.37.1 and
> 
> ```julia-repl
> julia> versioninfo()
> Julia Version 1.11.5
> Commit 760b2e5b73 (2025-04-14 06:53 UTC)
> Build Info:
> Official https://julialang.org/ release
> Platform Info:
> OS: Windows (x86_64-w64-mingw32)
> CPU: 8 × Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz
> WORD_SIZE: 64
> LLVM: libLLVM-16.0.6 (ORCJIT, skylake)
> Threads: 8 default, 0 interactive, 4 GC (on 8 virtual cores)
> Environment:
> JULIA_NUM_THREADS = auto
> 
> ```

---

<div class="post-metadata">

**Author:** ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Post date:** [September 28, 2025, 8:56am UTC](https://discourse.julialang.org/t/recursivearraytools-vectorofarray-weirdness/132726/4 "2025-09-28T08:56:01Z")

</div>

I am on `RecursiveArrayTools v3.37.1` but julia `1.10.10`

---

<div class="post-metadata">

**Author:** ![eldee](https://avatars.discourse-cdn.com/v4/letter/e/b5a626/32.png) [@eldee](https://discourse.julialang.org/u/eldee)\
**Post date:** [September 28, 2025, 5:22pm UTC](https://discourse.julialang.org/t/recursivearraytools-vectorofarray-weirdness/132726/5 "2025-09-28T17:22:02Z")

</div>

I don’t see why you would get different results on a slightly older Julia version, and indeed, at least on my machine I still get `norm(a, Inf) == maximum(a)` on Julia 1.10.10.

Just to be safe, did you run your MWE above without any other imports (except for `LinearAlgebra`) or method definitions?

---

<div class="post-metadata">

**Author:** ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Post date:** [September 28, 2025, 5:35pm UTC](https://discourse.julialang.org/t/recursivearraytools-vectorofarray-weirdness/132726/6 "2025-09-28T17:35:43Z")

</div>

Yes that work but it does not work on GPU. That’s why I then invoke `norm(a.u, Inf)` but this one returns `norm(,2)`
