2828
2929# Singular value decomposition
3030# ----------------------------
31- const T_USVᴴ = Tuple{<: AbstractTensorMap ,<: AbstractTensorMap ,<: AbstractTensorMap }
31+ const _T_USVᴴ = Tuple{<: AbstractTensorMap ,<: AbstractTensorMap ,<: AbstractTensorMap }
32+ const _T_USVᴴ_diag = Tuple{<: AbstractTensorMap ,<: DiagonalTensorMap ,<: AbstractTensorMap }
3233
3334function MatrixAlgebraKit. check_input (:: typeof (svd_full!), t:: AbstractTensorMap ,
34- (U, S, Vᴴ):: T_USV ᴴ )
35+ (U, S, Vᴴ):: _T_USV ᴴ )
3536 # scalartype checks
3637 @check_eltype U t
3738 @check_eltype S t real
@@ -51,7 +52,7 @@ function MatrixAlgebraKit.check_input(::typeof(svd_full!), t::AbstractTensorMap,
5152end
5253
5354function MatrixAlgebraKit. check_input (:: typeof (svd_compact!), t:: AbstractTensorMap ,
54- (U, S, Vᴴ):: T_USV ᴴ )
55+ (U, S, Vᴴ):: _T_USV ᴴ_diag )
5556 # scalartype checks
5657 @check_eltype U t
5758 @check_eltype S t real
@@ -137,40 +138,41 @@ end
137138
138139# Eigenvalue decomposition
139140# ------------------------
140- function MatrixAlgebraKit. check_input (:: typeof (eigh_full!), t:: AbstractTensorMap , (D, V))
141+ const _T_DV = Tuple{<: DiagonalTensorMap ,<: AbstractTensorMap }
142+ function MatrixAlgebraKit. check_input (:: typeof (eigh_full!), t:: AbstractTensorMap ,
143+ (D, V):: _T_DV )
141144 domain (t) == codomain (t) ||
142145 throw (ArgumentError (" Eigenvalue decomposition requires square input tensor" ))
143146
144- V_D = fuse (domain (t))
145-
146- (D isa DiagonalTensorMap &&
147- scalartype (D) == real (scalartype (t)) &&
148- V_D == space (D, 1 )) ||
149- throw (ArgumentError (" `eigh_full!` requires diagonal tensor D with isomorphic domain and real `scalartype`" ))
147+ # scalartype checks
148+ @check_eltype D t real
149+ @check_eltype V t
150150
151- V isa AbstractTensorMap &&
152- scalartype (V) == scalartype (t) &&
153- space (V) == (codomain (t) ← V_D) ||
154- throw (ArgumentError (" `eigh_full!` requires square tensor V with isomorphic domain and equal `scalartype`" ))
151+ # space checks
152+ V_D = fuse (domain (t))
153+ V_D == space (D, 1 ) ||
154+ throw (SpaceMismatch (" `eigh_full!(t, (D, V))` requires diagonal `D` with `domain(D) == fuse(domain(t))`" ))
155+ space (V) == (codomain (t) ← V_D) ||
156+ throw (SpaceMismatch (" `eigh_full!(t, (D, V))` requires `space(V) == (codomain(t) ← fuse(domain(t)))`" ))
155157
156158 return nothing
157159end
158160
159- function MatrixAlgebraKit. check_input (:: typeof (eig_full!), t:: AbstractTensorMap , (D, V))
161+ function MatrixAlgebraKit. check_input (:: typeof (eig_full!), t:: AbstractTensorMap ,
162+ (D, V):: _T_DV )
160163 domain (t) == codomain (t) ||
161164 throw (ArgumentError (" Eigenvalue decomposition requires square input tensor" ))
162- Tc = complex (scalartype (t))
163- V_D = fuse (domain (t))
164165
165- (D isa DiagonalTensorMap &&
166- scalartype (D) == Tc &&
167- V_D == space (D, 1 )) ||
168- throw (ArgumentError (" `eig_full!` requires diagonal tensor D with isomorphic domain and complex `scalartype`" ))
166+ # scalartype checks
167+ @check_eltype D t complex
168+ @check_eltype V t complex
169169
170- V isa AbstractTensorMap &&
171- scalartype (V) == Tc &&
172- space (V) == (codomain (t) ← V_D) ||
173- throw (ArgumentError (" `eig_full!` requires square tensor V with isomorphic domain and complex `scalartype`" ))
170+ # space checks
171+ V_D = fuse (domain (t))
172+ V_D == space (D, 1 ) ||
173+ throw (SpaceMismatch (" `eig_full!(t, (D, V))` requires diagonal `D` with `domain(D) == fuse(domain(t))`" ))
174+ space (V) == (codomain (t) ← V_D) ||
175+ throw (SpaceMismatch (" `eig_full!(t, (D, V))` requires `space(V) == (codomain(t) ← fuse(domain(t)))`" ))
174176
175177 return nothing
176178end
0 commit comments