我正在使用 Boost.Rational 1.46。据其documentation ,
The final fundamental operation is normalizing a rational. This operation is performed whenever a rational is constructed (and assigned in place). All other operations are careful to maintain rationals in a normalized state. Normalization costs the equivalent of one gcd and two divisions.
对于密集使用相对较小的有理值(因此较小的整数)的应用程序,标准化的成本太高,无法始终进行。有没有办法避免这种情况,或者只是在某些时刻强制?
最佳答案
boost 有理数的不变性是它们总是标准化的(请参阅问题中引用的引用文献)。因此,如果您想使用非标准化有理数,则不能使用 boost 实现。
关于c++ - 如何避免boost中的有理数标准化?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9908064/