Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@ QuantumControl = "8a270532-f23f-47a8-83a9-b33d10cad486"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[weakdeps]
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"

[extensions]
QuantumGradientGeneratorsArrayInterfaceExt = "ArrayInterface"

[compat]
ArrayInterface = "7.0"
LinearAlgebra = "1"
QuantumControl = ">=0.11.0"
Random = "1"
Expand Down
20 changes: 20 additions & 0 deletions ext/QuantumGradientGeneratorsArrayInterfaceExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module QuantumGradientGeneratorsArrayInterfaceExt

import ArrayInterface
import QuantumGradientGenerators: GradVector
import QuantumControl.QuantumPropagators.Interfaces: supports_vector_interface

# The following methods are necessary for `check_state`, because `similar`
# can return a `GradVector`, and the results of `similar` must be a mutable
# array.

ArrayInterface.ismutable(::Type{GradVector{N,T}}) where {N,T} =
ArrayInterface.ismutable(T) && supports_vector_interface(T)


# Direct access to the elements of a `GradVector` is possible, but should be
# discouraged

ArrayInterface.fast_scalar_indexing(::Type{<:GradVector}) = false

end