11# TODO : Define this properly.
22dag (i:: Index ) = i
3+ # TODO : Define this properly.
4+ dag (a:: ITensor ) = a
35# TODO : Deprecate.
46dim (i:: Index ) = dename (length (i))
7+ # TODO : Deprecate.
8+ dim (a:: AbstractITensor ) = unname (length (a))
59# TODO : Define this properly.
610hasqns (i:: Index ) = false
11+ # TODO : Define this properly.
12+ hasqns (i:: AbstractITensor ) = false
713# TODO : Deprecate.
814itensor (parent:: AbstractArray , nameddimsindices) = ITensor (parent, nameddimsindices)
915function itensor (parent:: AbstractArray , i1:: Index , i_rest:: Index... )
1016 return ITensor (parent, (i1, i_rest... ))
1117end
18+ # TODO : Deprecate.
19+ order (a:: AbstractArray ) = ndims (a)
1220
1321# This seems to be needed to get broadcasting working.
1422# TODO : Investigate this and see if we can get rid of it.
@@ -23,9 +31,24 @@ function onehot(iv::Pair{<:Index,<:Int})
2331 return a
2432end
2533
26- using LinearAlgebra: svd
34+ using LinearAlgebra: qr, svd
2735# TODO : Define this in `MatrixAlgebra.jl`/`TensorAlgebra.jl`.
28- function factorize (a:: AbstractITensor , args... ; kwargs... )
29- U, S, V = svd (a, args... ; kwargs... )
30- return U, S * V
36+ function factorize (a:: AbstractITensor , args... ; maxdim= nothing , cutoff= nothing , kwargs... )
37+ if isnothing (maxdim) && isnothing (cutoff)
38+ Q, R = qr (a, args... )
39+ return Q, R
40+ else
41+ error (" Truncation in `factorize` not implemented yet." )
42+ U, S, V = svd (a, args... ; kwargs... )
43+ return U, S * V
44+ end
3145end
46+
47+ # TODO : Used in `ITensorMPS.jl`, decide where or if to define it.
48+ # Ideally this would just be a zero-dimensional `ITensor` wrapping
49+ # a special type, like `Zeros{UnspecifiedZero()}()`.
50+ struct OneITensor <: AbstractITensor end
51+ Base. size (:: OneITensor ) = ()
52+ Base.:* (:: OneITensor , :: OneITensor ) = OneITensor ()
53+ Base.:* (:: OneITensor , a:: ITensor ) = a
54+ Base.:* (a:: ITensor , :: OneITensor ) = a
0 commit comments