@@ -89,29 +89,6 @@ tensor(op::AbstractOperator) = op
8989tensor (operators:: AbstractOperator... ) = reduce (tensor, operators)
9090
9191
92-
93- """
94- check_indices(indices::Array)
95-
96- Determine whether a collection of indices, written as a list of (integers or lists of integers) is unique.
97- This assures that the embedded operators are in non-overlapping subspaces.
98- """
99- function check_indices (indices:: Array )
100- status = true
101- # Check that no sub-list contains duplicates.
102- for i in filter (x -> typeof (x) <: Array , indices)
103- status &= (length (Set (i)) == length (i))
104- end
105- # Check that there are no duplicates across `indices`
106- for (idx, i) in enumerate (indices[1 : end - 1 ])
107- for j in indices[idx+ 1 : end ]
108- status &= (length (intersect (i, j)) == 0 )
109- end
110- end
111- return status
112- end
113-
114-
11592"""
11693 embed(basis1[, basis2], indices::Vector, operators::Vector)
11794
@@ -120,7 +97,7 @@ Tensor product of operators where missing indices are filled up with identity op
12097function embed (basis_l:: CompositeBasis , basis_r:: CompositeBasis ,
12198 indices:: Vector , operators:: Vector{T} ) where T<: AbstractOperator
12299
123- @assert check_indices (indices)
100+ @assert sortedindices . check_embed_indices (indices)
124101
125102 N = length (basis_l. bases)
126103 @assert length (basis_r. bases) == N
@@ -132,15 +109,14 @@ function embed(basis_l::CompositeBasis, basis_r::CompositeBasis,
132109 ops_sb = [x[2 ] for x in idxop_sb]
133110
134111 for (idxsb, opsb) in zip (indices_sb, ops_sb)
135- @assert (opsb. basis_l == basis_l. bases[idxsb]) || throw (bases. IncompatibleBases ())
136- @assert (opsb. basis_r == basis_r. bases[idxsb]) || throw (bases. IncompatibleBases ())
112+ (opsb. basis_l == basis_l. bases[idxsb]) || throw (bases. IncompatibleBases ())
113+ (opsb. basis_r == basis_r. bases[idxsb]) || throw (bases. IncompatibleBases ())
137114 end
138115
139116 embed_op = tensor ([i ∈ indices_sb ? ops_sb[indexin (i, indices_sb)[1 ]] : identityoperator (T, basis_l. bases[i], basis_r. bases[i]) for i= 1 : N]. .. )
140117
141118 # Embed all joint-subspace operators.
142119 idxop_comp = [x for x in zip (indices, operators) if typeof (x[1 ]) <: Array ]
143-
144120 for (idxs, op) in idxop_comp
145121 embed_op *= embed (basis_l, basis_r, idxs, op)
146122 end
@@ -159,8 +135,8 @@ function embed(basis_l::CompositeBasis, basis_r::CompositeBasis,
159135 N = length (basis_l. bases)
160136 @assert length (basis_r. bases) == N
161137
162- @assert reduce (tensor, basis_l. bases[indices]) == op. basis_l || throw (bases. IncompatibleBases ())
163- @assert reduce (tensor, basis_r. bases[indices]) == op. basis_r || throw (bases. IncompatibleBases ())
138+ reduce (tensor, basis_l. bases[indices]) == op. basis_l || throw (bases. IncompatibleBases ())
139+ reduce (tensor, basis_r. bases[indices]) == op. basis_r || throw (bases. IncompatibleBases ())
164140
165141 index_order = [idx for idx in 1 : length (basis_l. bases) if idx ∉ indices]
166142 all_operators = AbstractOperator[identityoperator (T, basis_l. bases[i], basis_r. bases[i]) for i in index_order]
0 commit comments