Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Row-vectorisation for open systems #248

Draft
wants to merge 2 commits into
base: development
Choose a base branch
from
Draft
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
6 changes: 3 additions & 3 deletions src/quanguru/QuantumToolbox/evolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ def _preSO(operator: Matrix, identity: Matrix = None) -> Matrix:

if identity is None:
identity = sp.identity(operator.shape[0], format="csc")
pre = sp.kron(identity, operator, format='csc')
pre = sp.kron(operator, identity, format='csc')
return pre if sp.issparse(operator) else pre.A

def _postSO(operator: Matrix, identity: Matrix = None) -> Matrix:
Expand Down Expand Up @@ -338,7 +338,7 @@ def _postSO(operator: Matrix, identity: Matrix = None) -> Matrix:

if identity is None:
identity = sp.identity(operator.shape[0], format="csc")
pos = sp.kron(operator.transpose(), identity, format='csc')
pos = sp.kron(identity, operator.transpose(), format='csc')
return pos if sp.issparse(operator) else pos.A

def _prepostSO(operatorA: Matrix, operatorB: Optional[Matrix] = None) -> Matrix:
Expand Down Expand Up @@ -371,7 +371,7 @@ def _prepostSO(operatorA: Matrix, operatorB: Optional[Matrix] = None) -> Matrix:
"""
if operatorB is None:
operatorB = operatorA
prepost = sp.kron(operatorB.transpose(), operatorA, format='csc')
prepost = sp.kron(operatorA, operatorB.transpose(), format='csc')
return prepost if sp.issparse(operatorA) else prepost.A

def evolveOpen(initialState, totalTime, timeStep: float = 1.0, Hamiltonian: Optional[Matrix] = None,# pylint: disable=dangerous-default-value,unsubscriptable-object,too-many-arguments # noqa: E501
Expand Down
4 changes: 2 additions & 2 deletions src/quanguru/QuantumToolbox/states.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ def mat2Vec(denMat: Matrix) -> Matrix: # pylint: disable=invalid-name
[1]]
"""

return denMat.T.reshape(np.prod(np.shape(denMat)), 1)
return denMat.reshape(np.prod(np.shape(denMat)), 1)

def vec2Mat(vec: Matrix) -> Matrix: # pylint: disable=invalid-name
r"""
Expand Down Expand Up @@ -575,7 +575,7 @@ def vec2Mat(vec: Matrix) -> Matrix: # pylint: disable=invalid-name

a = vec.shape
n = int(np.sqrt(a[0]))
mat = vec.reshape((n, n)).T
mat = vec.reshape((n, n))
return mat

def BellStates(bs: str = 'Phi+', sparse: bool = True) -> Matrix:
Expand Down
Loading