Parallel Calculations

Now, it's time to refactor the CalcTotalOrder function using parallel algorithms.

Arithmetic Operations in Parallel Algorithms

Another place where we can us parallel algorithms is CalcTotalOrder().

Instead of std::accumulate we can use std::transform_reduce.

As mentioned in the Parallel Algorithms chapter, the floating point sum operation is not associative. However, in our case, the results should be stable enough to give 2 decimal places of precision. If you need better accuracy and numerical stability, please consider using a different method.

Get hands-on with 1200+ tech skills courses.