From 11c17eee0c549ca1f44b9af0d23cbdfd3b32a4bf Mon Sep 17 00:00:00 2001 From: Abhishek Bhatt Date: Tue, 19 Sep 2023 10:52:28 -0400 Subject: [PATCH 1/5] moved `nsubsystems` --- src/embed_permute.jl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/embed_permute.jl b/src/embed_permute.jl index bafdf5e..323bd12 100644 --- a/src/embed_permute.jl +++ b/src/embed_permute.jl @@ -84,3 +84,11 @@ function embed(basis_l::CompositeBasis, basis_r::CompositeBasis, end permutesystems(a::AbstractOperator, perm) = arithmetic_unary_error("Permutations of subsystems", a) + +nsubsystems(s::Ket) = nsubsystems(s.basis) +function nsubsystems(s::Operator) + s.basis_l == s.basis_r || throw(ArgumentError("`nsubsystem(::Operator)` is well defined only if the left and right bases are the same")) + nsubsystems(s.basis_l) +end +nsubsystems(b::CompositeBasis) = length(b.bases) +nsubsystems(b::Basis) = 1 From 42ccbbd7f0ebe481710c485453b2d2fae955a0ef Mon Sep 17 00:00:00 2001 From: Abhishek Bhatt Date: Tue, 19 Sep 2023 11:02:53 -0400 Subject: [PATCH 2/5] Some corrections --- src/embed_permute.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/embed_permute.jl b/src/embed_permute.jl index 323bd12..3052dc8 100644 --- a/src/embed_permute.jl +++ b/src/embed_permute.jl @@ -85,9 +85,9 @@ end permutesystems(a::AbstractOperator, perm) = arithmetic_unary_error("Permutations of subsystems", a) -nsubsystems(s::Ket) = nsubsystems(s.basis) -function nsubsystems(s::Operator) - s.basis_l == s.basis_r || throw(ArgumentError("`nsubsystem(::Operator)` is well defined only if the left and right bases are the same")) +nsubsystems(s::AbstractKet) = nsubsystems(s.basis) +function nsubsystems(s::AbstractOperator) + s.basis_l == s.basis_r || throw(ArgumentError("`nsubsystem(::AbstractOperator)` is well defined only if the left and right bases are the same")) nsubsystems(s.basis_l) end nsubsystems(b::CompositeBasis) = length(b.bases) From 58a217c2c13caa35c6754dbbf1ba76cc0bb841f5 Mon Sep 17 00:00:00 2001 From: Abhishek Bhatt Date: Wed, 20 Sep 2023 14:42:25 -0400 Subject: [PATCH 3/5] correction in dispatch for `AbstractKet` and bump patch --- Project.toml | 2 +- src/embed_permute.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 97fd9f2..2251023 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "QuantumInterface" uuid = "5717a53b-5d69-4fa3-b976-0bf2f97ca1e5" authors = ["QuantumInterface.jl contributors"] -version = "0.3.2" +version = "0.3.3" [deps] LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" diff --git a/src/embed_permute.jl b/src/embed_permute.jl index 3052dc8..f1d33fa 100644 --- a/src/embed_permute.jl +++ b/src/embed_permute.jl @@ -85,7 +85,7 @@ end permutesystems(a::AbstractOperator, perm) = arithmetic_unary_error("Permutations of subsystems", a) -nsubsystems(s::AbstractKet) = nsubsystems(s.basis) +nsubsystems(s::AbstractKet) = nsubsystems(basis(s)) function nsubsystems(s::AbstractOperator) s.basis_l == s.basis_r || throw(ArgumentError("`nsubsystem(::AbstractOperator)` is well defined only if the left and right bases are the same")) nsubsystems(s.basis_l) From e7ca7f2a233fd062da90b1276b8ebd2da908eda0 Mon Sep 17 00:00:00 2001 From: Abhishek Bhatt Date: Wed, 20 Sep 2023 14:46:03 -0400 Subject: [PATCH 4/5] update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 14180ef..2c5b04e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # News +## v0.3.3 + +- Add `nsubsystems` for computing the number of subsystems in a state. + ## v0.3.2 - Cleanup - removing forgotten debug print statements. From e98af67d1b213c83e568b9d658810302555e68f9 Mon Sep 17 00:00:00 2001 From: Abhishek Bhatt Date: Thu, 21 Sep 2023 10:44:19 -0400 Subject: [PATCH 5/5] updated embed_permute.jl --- src/embed_permute.jl | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/embed_permute.jl b/src/embed_permute.jl index f1d33fa..3f29ad3 100644 --- a/src/embed_permute.jl +++ b/src/embed_permute.jl @@ -86,9 +86,6 @@ end permutesystems(a::AbstractOperator, perm) = arithmetic_unary_error("Permutations of subsystems", a) nsubsystems(s::AbstractKet) = nsubsystems(basis(s)) -function nsubsystems(s::AbstractOperator) - s.basis_l == s.basis_r || throw(ArgumentError("`nsubsystem(::AbstractOperator)` is well defined only if the left and right bases are the same")) - nsubsystems(s.basis_l) -end +nsubsystems(s::AbstractOperator) = nsubsystems(basis(s)) nsubsystems(b::CompositeBasis) = length(b.bases) -nsubsystems(b::Basis) = 1 +nsubsystems(b::Basis) = 1 \ No newline at end of file