-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Properly define the in-place vs not-in-place interface
We support both mutating and non-mutating propagators. Mutation is better for large Hilbert spaces. Non-mutation is better for small Hilbert spaces (`StaticArrays`!) or when trying to use automatic differentiation. There are some subtleties in finding the correct abstraction. It is not as simple as using the built-in `ismutable` for states or operators and making decisions based on that: Anytime we use custom structs, unless that struct is explicitly defined as `mutable`, it is considered immutable. However, we can still use in-place propagation, mutating the mutable *components* of that struct. Instead of overloading `ismutable`, we define the in-place or not-in-place interface explicitly via the required behavior guaranteed by the `check_state`, `check_generator`, and `check_operator` functions. A new `QuantumPropagators.Interfaces.supports_inplace` function is available to check whether a given `state` or `operator` type is suitable for in-place operations.
- Loading branch information
Showing
18 changed files
with
504 additions
and
335 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module QuantumPropagatorsStaticArraysExt | ||
|
||
import QuantumPropagators.Interfaces: supports_inplace | ||
using StaticArrays: SArray, MArray | ||
|
||
supports_inplace(::SArray) = false | ||
supports_inplace(::MArray) = true | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.