Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistency between f32 and f64 in convertability to RealField #54

Open
patowen opened this issue Feb 25, 2024 · 0 comments
Open

Inconsistency between f32 and f64 in convertability to RealField #54

patowen opened this issue Feb 25, 2024 · 0 comments

Comments

@patowen
Copy link

patowen commented Feb 25, 2024

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 9d95d6d)

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 a pull request may close this issue.

1 participant