[decimal] Implement root() function to calculate the n-th root of a Decimal value
#40
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 pull request introduces the
rootfunction to the DeciMojo library, which calculates the n-th root of a Decimal value using the Newton-Raphson method. The most important changes include adding therootfunction, updating theDecimalstruct to include therootmethod, and adding comprehensive tests for the new functionality.New Functionality:
src/decimojo/exponential.mojo: Added therootfunction to calculate the n-th root of a Decimal value. This function includes special cases for handling different values ofnandx, and uses the Newton-Raphson method for iteration.Updates to Existing Code:
src/decimojo/decimal.mojo: Updated theDecimalstruct to include therootmethod, which calls the newrootfunction.src/decimojo/__init__.mojo: Updated the import statements to include the newrootfunction from theexponentialmodule.Testing:
tests/test_root.mojo: Added comprehensive tests for therootfunction, covering basic root calculations, fractional inputs, edge cases, error conditions, precision, and mathematical identities.Configuration:
mojoproject.toml: Added commands for testing and benchmarking the newrootfunction.