Skip to content

Commit 8ddf9df

Browse files
authored
[decimal] Implement root() function to calculate the n-th root of a Decimal value (#40)
This pull request introduces the `root` function 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 the `root` function, updating the `Decimal` struct to include the `root` method, and adding comprehensive tests for the new functionality. ### New Functionality: * `src/decimojo/exponential.mojo`: Added the `root` function to calculate the n-th root of a Decimal value. This function includes special cases for handling different values of `n` and `x`, and uses the Newton-Raphson method for iteration. ### Updates to Existing Code: * `src/decimojo/decimal.mojo`: Updated the `Decimal` struct to include the `root` method, which calls the new `root` function. * `src/decimojo/__init__.mojo`: Updated the import statements to include the new `root` function from the `exponential` module. ### Testing: * `tests/test_root.mojo`: Added comprehensive tests for the `root` function, covering basic root calculations, fractional inputs, edge cases, error conditions, precision, and mathematical identities. ### Configuration: * `mojoproject.toml`: Added commands for testing and benchmarking the new `root` function.
1 parent 15e28d5 commit 8ddf9df

File tree

6 files changed

+903
-35
lines changed

6 files changed

+903
-35
lines changed

0 commit comments

Comments
 (0)