Skip to content

Commit

Permalink
add log_weights to roots_chebys
Browse files Browse the repository at this point in the history
  • Loading branch information
itamarfaran committed Apr 5, 2021
1 parent 4c00691 commit 0baf9e2
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions scipy/special/orthogonal.py
Expand Up @@ -1772,7 +1772,7 @@ def chebyc(n, monic=False):
# Chebyshev of the second kind S_n(x)


def roots_chebys(n, mu=False):
def roots_chebys(n, mu=False, log_weights=False):
r"""Gauss-Chebyshev (second kind) quadrature.
Compute the sample points and weights for Gauss-Chebyshev
Expand All @@ -1789,15 +1789,17 @@ def roots_chebys(n, mu=False):
quadrature order
mu : bool, optional
If True, return the sum of the weights, optional.
log_weights : bool, optional
If true, return the log of the weights and mu0, optional.
Returns
-------
x : ndarray
Sample points
w : ndarray
Weights
Weights if log_weights=False (default), else the log of the weights
mu : float
Sum of the weights
Sum of the weights if log_weights=False (default), else the log of the Sum of the weights
See Also
--------
Expand All @@ -1811,10 +1813,14 @@ def roots_chebys(n, mu=False):
Graphs, and Mathematical Tables. New York: Dover, 1972.
"""
x, w, m = roots_chebyu(n, True)
x, w, m = roots_chebyu(n, True, log_weights)
x *= 2
w *= 2
m *= 2
if log_weights:
w += np.log(2)
m += np.log(2)
else:
w *= 2
m *= 2
if mu:
return x, w, m
else:
Expand Down

0 comments on commit 0baf9e2

Please sign in to comment.