Skip to content

Commit

Permalink
Handle single basis in embed
Browse files Browse the repository at this point in the history
This commit addresses the issue where the `embed` function fails when it receives a single basis instead of a composite basis as input.
  • Loading branch information
a-eghrari committed Jun 12, 2024
1 parent a3b09c2 commit ad5fd2e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/embed_permute.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@ embed(basis_l::CompositeBasis, basis_r::CompositeBasis, index::Integer, op::Abst
embed(basis::CompositeBasis, indices, operators::Vector{T}) where {T<:AbstractOperator} = embed(basis, basis, indices, operators)
embed(basis::CompositeBasis, indices, op::AbstractOperator) = embed(basis, basis, indices, op)

"""
embed(basis::Basis, indices, ops::AbstractOperator)
Special case of the `embed` to handle embedding an operator `ops` into a single
basis.
"""
function embed(basis::Basis, indices, ops::AbstractOperator)
if indices == 1 || indices == (1,) || indices == [1]
return ops
else
throw(ArgumentError("Invalid indices for single basis."))
end
end

"""
embed(basis1[, basis2], indices::Vector, operators::Vector)
Expand Down

0 comments on commit ad5fd2e

Please sign in to comment.