Skip to content

Commit

Permalink
start migrating rotating_frame
Browse files Browse the repository at this point in the history
  • Loading branch information
to24toro committed Apr 13, 2023
1 parent 7ae2bfc commit 885d8c3
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 80 deletions.
22 changes: 22 additions & 0 deletions qiskit_dynamics/arraylias_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,36 @@

from typing import Union
from arraylias import numpy_alias
from scipy.sparse import csr_matrix
from .array import Array
try:
from jax.experimental.sparse import BCOO
except ImportError:
pass


DYNAMICS_ALIAS = numpy_alias()

# Set qiskit_dynamics.array.Array to be dispatched to numpy
DYNAMICS_ALIAS.register_type(Array, "numpy")

# register required custom versions of functions for csr type here
DYNAMICS_ALIAS.register_type(csr_matrix, lib="scipy_sparse")

# register required custom versions of functions for BCOO type here
DYNAMICS_ALIAS.register_type(BCOO, lib="jax_sparse")


@DYNAMICS_ALIAS.register_function(lib="scipy_sparse", path="asarray")
def _(csr: csr_matrix):
return csr.toarray()


@DYNAMICS_ALIAS.register_function(lib="jax_sparse", path="asarray")
def _(bcoo: BCOO):
return bcoo.todense()


DYNAMICS_NUMPY = DYNAMICS_ALIAS()

ArrayLike = Union[DYNAMICS_ALIAS.registered_types()]
Loading

0 comments on commit 885d8c3

Please sign in to comment.