[decimal] Enhance power() function to accept a Decimal exponent
#37
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 several changes to the benchmarking and arithmetic functionalities in the
decimojoproject. The most significant updates include the improvements to the power function forDecimalvalues, the addition of new benchmark cases, and the introduction of new constants.Power Function Enhancements:
src/decimojo/exponential.mojo: Enhanced thepowerfunction to handle both integer and non-integer exponents using the identity ( x^y = e^{(y \cdot \ln(x))} ). Improved error handling and added support for common fractional exponents.Benchmarking Enhancements:
benches/bench.mojo: Added new benchmark cases forbench_lnandbench_powerfunctions.benches/bench_power.mojo: Introduced comprehensive benchmarks for theDecimalpower function, including various test cases and logging of results.mojoproject.toml: Added new test and benchmark entries fortest_powerandbench_power.Arithmetic Function Improvements:
src/decimojo/arithmetics.mojo: Commented out debug print statements in themultiplyfunction for cleaner output.src/decimojo/constants.mojo: Added new decimal constantsM0D5andM0D25to represent 0.5 and 0.25 asDecimalvalues.src/decimojo/decimal.mojo: Updated__pow__method to handle different types of exponents and added error handling.These changes collectively improve the functionality and performance of the
decimojolibrary, especially in handling complex arithmetic operations and benchmarking their performance.