Skip to content

[decimal] Optimize exp for BigDecimal#75

Merged
forfudan merged 2 commits intomainfrom
work
Apr 2, 2025
Merged

[decimal] Optimize exp for BigDecimal#75
forfudan merged 2 commits intomainfrom
work

Conversation

@forfudan
Copy link
Copy Markdown
Owner

@forfudan forfudan commented Apr 2, 2025

This pull request includes several updates to the BigDecimal library, focusing on improving the precision and performance of mathematical operations. The changes involve modifying benchmarks, adding new functions, and optimizing existing ones.

Benchmark Updates:

  • Updated benchmark cases in benches/bigdecimal/bench_bigdecimal_exp.mojo to use more realistic values for the exponential function tests. [1] [2] [3] [4]
  • Increased the number of iterations in the square root benchmark in benches/bigdecimal/bench_bigdecimal_sqrt.mojo to improve accuracy.

Function Enhancements:

  • Added a new true_divide_fast function in src/decimojo/bigdecimal/arithmetics.mojo for faster division with a specified minimum precision.
  • Integrated the true_divide_fast function into the BigDecimal struct and the sqrt function to enhance performance. [1] [2]

Code Optimization:

  • Improved the exponential function (exp) in src/decimojo/bigdecimal/exponential.mojo by using the true_divide_fast function and optimizing the range reduction process. [1] [2]
  • Refined the Taylor series implementation for the exponential function to reduce computational complexity and improve precision.

Documentation and Comments:

  • Enhanced documentation for the true_divide function to specify the precision parameter.
  • Added comments and TODOs for further improvements in the sqrt and exp functions. [1] [2]

These changes collectively aim to make the BigDecimal library more efficient and accurate for mathematical computations.

@forfudan forfudan merged commit 60980a8 into main Apr 2, 2025
1 check passed
@forfudan forfudan deleted the work branch April 2, 2025 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant