Skip to content

Commit ad5fd2e

Browse files
committed
Handle single basis in embed
This commit addresses the issue where the `embed` function fails when it receives a single basis instead of a composite basis as input.
1 parent a3b09c2 commit ad5fd2e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/embed_permute.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,19 @@ embed(basis_l::CompositeBasis, basis_r::CompositeBasis, index::Integer, op::Abst
4646
embed(basis::CompositeBasis, indices, operators::Vector{T}) where {T<:AbstractOperator} = embed(basis, basis, indices, operators)
4747
embed(basis::CompositeBasis, indices, op::AbstractOperator) = embed(basis, basis, indices, op)
4848

49+
"""
50+
embed(basis::Basis, indices, ops::AbstractOperator)
51+
52+
Special case of the `embed` to handle embedding an operator `ops` into a single
53+
basis.
54+
"""
55+
function embed(basis::Basis, indices, ops::AbstractOperator)
56+
if indices == 1 || indices == (1,) || indices == [1]
57+
return ops
58+
else
59+
throw(ArgumentError("Invalid indices for single basis."))
60+
end
61+
end
4962

5063
"""
5164
embed(basis1[, basis2], indices::Vector, operators::Vector)

0 commit comments

Comments
 (0)