Skip to content

Commit

Permalink
vectorize tensor contractions
Browse files Browse the repository at this point in the history
10x speedup. These took almost as long as a full function evaluation.
  • Loading branch information
richardsheridan committed May 19, 2022
1 parent 8c4b1d6 commit 067c8b0
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions magic_afm/_vendored_lstsq.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,18 +719,8 @@ def chisq_alpha_beta(
yfit = last_evaluation
deltay = y - yfit
help0 = weight * deltay
for i in range(n_free):
derivi = numpy.resize(deriv[i, :], (1, nr))
help1 = numpy.resize(numpy.sum((help0 * derivi), 1), (1, 1))
if i == 0:
beta = help1
else:
beta = numpy.concatenate((beta, help1), 1)
help1 = numpy.inner(deriv, weight * derivi)
if i == 0:
alpha = help1
else:
alpha = numpy.concatenate((alpha, help1), 1)
alpha = deriv @ (weight*deriv).T
beta = help0[numpy.newaxis, :] @ deriv.T
chisq = (help0 * deltay).sum()
if full_output:
ddict = {}
Expand Down

0 comments on commit 067c8b0

Please sign in to comment.