@@ -479,28 +479,23 @@ end
479479
480480(A:: MPO )(ψ:: MPS ; kwargs... ) = apply (A, ψ; kwargs... )
481481
482- function contract (A:: MPO , ψ:: MPS ; kwargs... )
483- method = get (kwargs, :method , " densitymatrix" )
482+ function contract (A:: MPO , ψ:: MPS ; alg= " densitymatrix" , kwargs... )
483+ if haskey (kwargs, :method )
484+ # Backwards compatibility, use `method`.
485+ alg = get (kwargs, :method , " densitymatrix" )
486+ end
484487
485488 # Keyword argument deprecations
486- if method == " DensityMatrix"
489+ if alg == " DensityMatrix"
487490 @warn " In contract, method DensityMatrix is deprecated in favor of densitymatrix"
488- method = " densitymatrix"
491+ alg = " densitymatrix"
489492 end
490-
491- if method == " Naive"
492- @warn " In contract, method Naive is deprecated in favor of naive"
493- method = " naive"
493+ if alg == " Naive"
494+ @warn " In contract, `alg=\" Naive\" ` is deprecated in favor of `alg=\" naive\" `"
495+ alg = " naive"
494496 end
495497
496- if method == " densitymatrix"
497- Aψ = _contract_densitymatrix (A, ψ; kwargs... )
498- elseif method == " naive"
499- Aψ = _contract_naive (A, ψ; kwargs... )
500- else
501- throw (ArgumentError (" Method $method not supported" ))
502- end
503- return Aψ
498+ return contract (Algorithm (alg), A, ψ; kwargs... )
504499end
505500
506501contract_mpo_mps_doc = """
@@ -555,7 +550,7 @@ contract(ψ::MPS, A::MPO; kwargs...) = contract(A, ψ; kwargs...)
555550
556551# @doc (@doc contract(::MPO, ::MPS)) *(::MPO, ::MPS)
557552
558- function _contract_densitymatrix ( A:: MPO , ψ:: MPS ; kwargs... ):: MPS
553+ function contract ( :: Algorithm"densitymatrix" , A:: MPO , ψ:: MPS ; kwargs... ):: MPS
559554 n = length (A)
560555 n != length (ψ) &&
561556 throw (DimensionMismatch (" lengths of MPO ($n ) and MPS ($(length (ψ)) ) do not match" ))
@@ -636,7 +631,7 @@ function _contract_densitymatrix(A::MPO, ψ::MPS; kwargs...)::MPS
636631 return ψ_out
637632end
638633
639- function _contract_naive ( A:: MPO , ψ:: MPS ; kwargs... ):: MPS
634+ function contract ( :: Algorithm"naive" , A:: MPO , ψ:: MPS ; kwargs... ):: MPS
640635 truncate = get (kwargs, :truncate , true )
641636
642637 N = length (A)
0 commit comments