Skip to content

Commit

Permalink
scipy.sparse.kron doesn't support kronecker product of three matrices
Browse files Browse the repository at this point in the history
  • Loading branch information
tjstavenger-pnnl committed Nov 13, 2024
1 parent dbc9240 commit d2c966a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions c2qa/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,16 @@ def get_a2(self, cutoff_a: int, cutoff_b: int):
return scipy.sparse.kron(self.get_eye(cutoff_a), self.get_a(cutoff_b)).tocsc()

def get_b1(self, cutoff_a: int, cutoff_b: int, cutoff_c: int):
return scipy.sparse.kron(self.get_a(cutoff_a), self.get_eye(cutoff_b), self.get_eye(cutoff_c)).tocsc()
kron_ab = scipy.sparse.kron(self.get_a(cutoff_a), self.get_eye(cutoff_b))
return scipy.sparse.kron(kron_ab, self.get_eye(cutoff_c)).tocsc()

def get_b2(self, cutoff_a: int, cutoff_b: int, cutoff_c: int):
return scipy.sparse.kron(self.get_eye(cutoff_a), self.get_a(cutoff_b), self.get_eye(cutoff_c)).tocsc()
kron_ab = scipy.sparse.kron(self.get_eye(cutoff_a), self.get_a(cutoff_b))
return scipy.sparse.kron(kron_ab, self.get_eye(cutoff_c)).tocsc()

def get_b3(self, cutoff_a: int, cutoff_b: int, cutoff_c: int):
return scipy.sparse.kron(self.get_eye(cutoff_a), self.get_eye(cutoff_b), self.get_a(cutoff_c)).tocsc()
kron_ab = scipy.sparse.kron(self.get_eye(cutoff_a), self.get_eye(cutoff_b))
return scipy.sparse.kron(kron_ab, self.get_a(cutoff_c)).tocsc()

def get_a12(self, cutoff_a: int, cutoff_b: int):
return self.get_a1(cutoff_a, cutoff_b) * self.get_a2(cutoff_a, cutoff_b)
Expand Down

0 comments on commit d2c966a

Please sign in to comment.