simba icon indicating copy to clipboard operation
simba copied to clipboard

Inconsistency between f32 and f64 in convertability to RealField

Open patowen opened this issue 1 year ago • 0 comments

The following function compiles:

fn my_convert<T: simba::scalar::RealField>(value: f64) -> T {
    T::from_subset(&value)
}

However, the following function does not compile (replacing f64 with f32):

fn my_convert<T: simba::scalar::RealField>(value: f32) -> T {
    T::from_subset(&value)
}

The non-compiling function results in error[E0308]: mismatched types with expected `&f64`, found `&f32` as the error message.

When looking for a root cause, I noticed that complex.rs's trait definition for ComplexField has SupersetOf<f64> as one of its trait bounds but not SupersetOf<f32>. If I modify this code myself, I am able to get the f32 version of my_convert to work.

I was able to reproduce this issue in the master branch as of 2024-02-24 (commit 9d95d6df788386d602b058938068a16ca866a0f1)

patowen avatar Feb 25 '24 04:02 patowen