|
627 | 627 |
|
628 | 628 | roots(f::Fun{<:PointSpace}) = space(f).points[values(f) .== 0]
|
629 | 629 |
|
| 630 | +## Root finding for Chebyshev expansions |
| 631 | +# |
| 632 | +# Contains code that is based in part on Chebfun v5's chebfun/@chebteck/roots.m, |
| 633 | +# which is distributed with the following license: |
630 | 634 |
|
| 635 | +# Copyright (c) 2015, The Chancellor, Masters and Scholars of the University |
| 636 | +# of Oxford, and the Chebfun Developers. All rights reserved. |
| 637 | +# |
| 638 | +# Redistribution and use in source and binary forms, with or without |
| 639 | +# modification, are permitted provided that the following conditions are met: |
| 640 | +# * Redistributions of source code must retain the above copyright |
| 641 | +# notice, this list of conditions and the following disclaimer. |
| 642 | +# * Redistributions in binary form must reproduce the above copyright |
| 643 | +# notice, this list of conditions and the following disclaimer in the |
| 644 | +# documentation and/or other materials provided with the distribution. |
| 645 | +# * Neither the name of the University of Oxford nor the names of its |
| 646 | +# contributors may be used to endorse or promote products derived from |
| 647 | +# this software without specific prior written permission. |
| 648 | +# |
| 649 | +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 650 | +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 651 | +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 652 | +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
| 653 | +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 654 | +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 655 | +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 656 | +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 657 | +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 658 | +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 659 | + |
| 660 | + |
| 661 | +#function roots(f::Fun) |
| 662 | +# irts=map(real,filter!(x->abs(x)<=1.+10eps(),filter!#(isreal,complexroots(f.coefficients)))) |
| 663 | +# |
| 664 | +# map!(x->x>1. ? 1. : x,irts) |
| 665 | +# map!(x->x<-1. ? -1. : x,irts) |
| 666 | +# |
| 667 | +# if length(irts)==0 |
| 668 | +# Float64[] |
| 669 | +# else |
| 670 | +# fromcanonical(f,irts) |
| 671 | +# end |
| 672 | +#end |
| 673 | + |
| 674 | +function roots(f::Fun) |
| 675 | + f2=Fun(f,domain(f)) # default is to convert to Chebyshev/Fourier |
| 676 | + if space(f2)==space(f) |
| 677 | + error("roots not implemented for ", typeof(f)) |
| 678 | + else |
| 679 | + roots(f2) |
| 680 | + end |
| 681 | +end |
631 | 682 |
|
632 | 683 | #
|
633 | 684 | # These formulæ, appearing in Eq. (2.5) of:
|
|
0 commit comments