-
-
Notifications
You must be signed in to change notification settings - Fork 0
Reworked Simplify to work better on Polynomials (with ripple effects) #27
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
Conversation
…ughout the symbolic math library
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #27 +/- ##
==========================================
- Coverage 87.46% 87.09% -0.38%
==========================================
Files 42 42
Lines 6432 6516 +84
==========================================
+ Hits 5626 5675 +49
- Misses 719 743 +24
- Partials 87 98 +11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR reworks the AsSimplifiedExpression method for Polynomial types and refactors arithmetic operations to avoid making assumptions about output types, particularly for Polynomial objects. The changes introduce template functions for vector operations and add a ToScalarExpressions() method to all VectorExpression types.
Key changes:
- Enhanced polynomial simplification that can return Constants, Variables, or Monomials when appropriate
- Refactored arithmetic operations to use templates and avoid type assumptions
- Added
ToScalarExpressions()method to vector expression types
Reviewed Changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| symbolic/polynomial.go | Enhanced AsSimplifiedExpression() and Simplify() methods, refactored arithmetic operations |
| symbolic/vector_expression.go | Added ToScalarExpressions() method and vector operation templates |
| symbolic/variable_vector.go | Refactored Plus() and Multiply() to use templates |
| symbolic/polynomial_vector.go | Updated arithmetic operations to use ConcretizeExpression() |
| symbolic/monomial.go | Added IsVariable(), ToVariable() methods and enhanced Plus() |
| testing/symbolic/*.go | Updated tests to expect simplified return types (Monomials, Variables, Constants) |
| examples/ | Added new example scripts demonstrating substitution and derivatives |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Adding extra checks to prevent panics in Monomial.ToVariable() method Co-authored-by: Copilot <[email protected]>
Summary
AsSimplifiedExpressionmethod forPolynomialto clean it up + remove extra polynomials OR return a Monomial, or Variable, or Constant, if it makes sense.Plus,Multiply, and more to not make assumptions (especially forPolynomialobjects) on output types.ToScalarExpressions()method for the allVectorExpressions.