Skip to content

Commit

Permalink
TL: remove default weight scaling in LagrangeApproximation
Browse files Browse the repository at this point in the history
  • Loading branch information
tlunet committed Jun 21, 2024
1 parent 271e25b commit 85a9b94
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions qmat/lagrange.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class LagrangeApproximation(object):
"Barycentric Lagrange interpolation." SIAM review, 46(3), 501-517.
"""

def __init__(self, points, weightComputation='AUTO', scaleRef='MAX', fValues=None):
def __init__(self, points, weightComputation='AUTO', scaleWeights=False, scaleRef='MAX', fValues=None):
points = np.asarray(points).ravel()
assert np.unique(points).size == points.size, "distinct interpolation points are required"

Expand Down Expand Up @@ -173,7 +173,8 @@ def chebfun(diffs):
raise NotImplementedError(
f'weightComputation={weightComputation}')
weights = invProd
weights /= np.max(np.abs(weights))
if scaleWeights:
weights /= np.max(np.abs(weights))

# Store attributes
self.points = points
Expand Down
2 changes: 1 addition & 1 deletion tests/test_2_lagrange.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def referenceWeights(pType, n):
def testWeights(pType, weightComputation):
for n in nNodeTests:
points, weights = referenceWeights(pType, n)
approx = LagrangeApproximation(points, weightComputation=weightComputation)
approx = LagrangeApproximation(points, weightComputation=weightComputation, scaleWeights=True)
assert np.allclose(approx.weights, weights), f"discrepancy with reference weights for n={n}"


Expand Down

0 comments on commit 85a9b94

Please sign in to comment.