From af59181cc97b1e1b75fb7ea39acc4bf0cca960f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?= Date: Sun, 2 Jun 2024 12:28:32 +0200 Subject: [PATCH] Fix `LinearAlgebra.norm` call --- src/Ansatz.jl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Ansatz.jl b/src/Ansatz.jl index 7739752..270f11e 100644 --- a/src/Ansatz.jl +++ b/src/Ansatz.jl @@ -98,6 +98,12 @@ function Base.showerror(io::IO, e::MissingSchmidtCoefficientsException) print(io, "Can't access the spectrum on bond $(e.bond)") end +function LinearAlgebra.norm(ψ::Ansatz, p::Real = 2; kwargs...) + p == 2 || throw(ArgumentError("only L2-norm is implemented yet")) + + return LinearAlgebra.norm2(ψ; kwargs...) +end + function LinearAlgebra.norm2(ψ::Ansatz; kwargs...) return contract(TensorNetwork(merge(Quantum(ψ), Quantum(ψ'))); kwargs...) |> only |> sqrt |> abs end