num-complex icon indicating copy to clipboard operation
num-complex copied to clipboard

Try to avoid cloning

Open konsumlamm opened this issue 3 years ago • 0 comments

Some operations (most notably multiplication and division) use clone. However, this is inefficient for types with non-trivial Clone impls, such as BigInt or BigDecimal (from the bigdecimal crate). To be fair, most of the time, people will use Complex<f32> or Complex<f64>, so this isn't a major problem, but sometimes people may want to use Complex<BigInt> (for Gaussian integers) or Complex<BigDecimal> (for arbitrary precision arithmetic).

See also https://github.com/rust-num/num-rational/issues/110. This has the same problems and solutions (e.g. using arithmetic on references).

konsumlamm avatar Sep 15 '22 14:09 konsumlamm