Skip to content

Commit

Permalink
ENH: optimize: redundancy removal replace solve_triangular w/ dtrsv
Browse files Browse the repository at this point in the history
As reported in scipygh-10722, solve_triangular can be quite slow. Replacing
with direct call to dtrsv is faster.
  • Loading branch information
mdhaber authored and gwgundersen committed Jul 18, 2020
1 parent cb75707 commit 4bb42fc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions scipy/optimize/_remove_redundancy.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import numpy as np
from scipy.linalg import svd
import scipy
from scipy.linalg.blas import dtrsv


def _row_count(A):
Expand Down Expand Up @@ -95,8 +96,8 @@ def _remove_zero_rows(A, b):
def bg_update_dense(plu, perm_r, v, j):
LU, p = plu

u = scipy.linalg.solve_triangular(LU, v[perm_r], lower=True,
unit_diagonal=True)
vperm = v[perm_r]
u = dtrsv(LU, vperm, lower=1, diag=1)
LU[:j+1, j] = u[:j+1]
l = u[j+1:]
piv = LU[j, j]
Expand Down

0 comments on commit 4bb42fc

Please sign in to comment.