-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rational function #335
Merged
Merged
Rational function #335
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov Report
@@ Coverage Diff @@
## master #335 +/- ##
==========================================
- Coverage 91.54% 82.85% -8.70%
==========================================
Files 16 21 +5
Lines 1963 2420 +457
==========================================
+ Hits 1797 2005 +208
- Misses 166 415 +249
Continue to review full report at Codecov.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds an
AbstractRationalFunction
type for holding rational functions. In #308 it was suggested that this could be useful. Construction of the primaryRationalFunction
type borrows the//
syntax from theRational
type of Base. Other subtypes are possible.The https://github.com/andreasvarga/DescriptorSystems.jl/blob/main/src/types/RationalFunction.jl implementation is mostly realized as a subtype of
AbstractRationalFunction
as an example (for now it isn't included when the package is loaded).The https://github.com/aytekinar/RationalFunctions.jl package was a guide, but the main
RationalFunction
implementation does not include information about conjugated variables.The
conj
method has not (yet) been defined.The new exports are
poles
andresidues
. The "zeros" are found byroots
. As well, the functionlowest_terms
is exported to cancel common factors. (The namecancel
is used in SymPy and Mathematica, but wasn't used for this as it seemed like a useful generic elsewhere, though it is tempting.)There is a simple implementation for fitting rational functions using least squares,
fit(RationalFunction, xs, ys, m, n)
. (There are more accurate and robust fitting implementations elsewhere in the package ecosystem, such asBaryRational
.) As for fitting, this provides a natural home for thePade
function that is still available viaPolyCompat
, and now re-implemented byfit(RationalFunction, p::Polynomial, m,n)
.The
plot
recipe seems to do an okay job of plotting basic rational functions, though perhaps it could be tweaked in places.