Finding matrices with the same l1 and l2 norm

Sorry, I just realized I assumed your matrix was symmetric/Hermitian (i.e., had a unitary eigendecomposition). More generally, you want to use the singular value decomposition:

julia> using LinearAlgebra

julia> x = rand(3); y = rand(3); A = x * y' # A is some random rank-1 matrix
3×3 Matrix{Float64}:
 0.206881  0.02146    0.00257651
 0.139733  0.0144947  0.00174024
 0.395132  0.0409876  0.004921

julia> opnorm(A, 1) ≈ opnorm(A, 2)
false

julia> (U, σ, V) = svd(A);

julia> σ[1] ≈ opnorm(A, 2)
true

julia> B = U' * A * V # B is rotation of A (U and V are unitary)
3×3 Matrix{Float64}:
  0.469935     1.04626e-17  -8.67362e-19
  2.86845e-17  7.47916e-18  -3.92335e-19
 -0.0          0.0           0.0

julia> opnorm(B, 1) ≈ opnorm(B, 2) ≈ opnorm(A, 2)
true

julia> C = U * B * V'; C ≈ A # Transformation is reversible
true
2 Likes