Skip to content

Commit

Permalink
Bugfix: Do float64 conversion for 'N', 'T', 'H'
Browse files Browse the repository at this point in the history
Signed-off-by: aatmdelissen <2767694+aatmdelissen@users.noreply.github.com>
  • Loading branch information
aatmdelissen committed Jan 7, 2025
1 parent a9df579 commit 2993c46
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pymoto/solvers/sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,16 @@ def solve(self, b, x0=None, trans='N'):
Returns:
Solution of the system of linear equations, same shape as input b
"""
if b.dtype != np.float64: # Only float64 is supported --> this is also done in _check_b, but fails for int8
warnings.warn(f"Array b's data type was converted from {b.dtype} to float64")
b = b.astype(np.float64)
if trans == 'N':
return self._pardiso_solver.solve(self.A, b)
elif trans == 'T' or trans == 'H':
# T and H are the same, because only real matrix is supported
# Cannot use _pardiso_solver.solve because it changes flag 12 internally
iparm_prev = self._pardiso_solver.get_iparm(12)
self._pardiso_solver.set_iparm(12, int(not iparm_prev)) # Adjoint solver (transpose)
if b.dtype != np.float64: # Only float64 is supported --> this is also done in _check_b, but fails for int8
warnings.warn(f"Array b's data type was converted from {b.dtype} to float64")
b = b.astype(np.float64)
b = self._pardiso_solver._check_b(self.A, b)
x = self._pardiso_solver._call_pardiso(self.A, b)
self._pardiso_solver.set_iparm(12, iparm_prev) # Revert back to normal solver
Expand Down

0 comments on commit 2993c46

Please sign in to comment.