Skip to content
This repository has been archived by the owner on Jul 7, 2024. It is now read-only.

Commit

Permalink
Fix LinearAlgebra.norm call
Browse files Browse the repository at this point in the history
  • Loading branch information
mofeing committed Jun 2, 2024
1 parent 2c4518e commit af59181
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Ansatz.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit af59181

Please sign in to comment.