dimforge / alga

Abstract algebra for Rust.
194 stars 39 forks source link

Added is_finite method for Real #59

Closed AnneKitsune closed 5 years ago

AnneKitsune commented 5 years ago

<3

AnneKitsune commented 5 years ago

@sebcrozet can this be merged?

sebcrozet commented 5 years ago

@jojolepro Thanks! Sorry for the late answer. Could you provide an explanation about why this is needed? What is your specific use-case?

Also the Default super-trait should not be added without justification as well. Default makes very little sense for a real number which has two neutral elements (0 and 1).

This is a breaking change.

AnneKitsune commented 5 years ago

Ah true I didn't think much of the Default.

The reason for the addition of is_finite is to allow checking if a N is finite, without having to use feature gates to know if we should be checking for f32::is_nan and f64::is_nan. It will be used in the amethyst engine, inside of the Transform component. Usage example:

    /// Verifies that the global `Matrix4` doesn't contain any NaN values.
    pub fn is_finite(&self) -> bool {
        self.global_matrix.as_slice().iter().all(|f| f32::is_finite(*f))
    }
sebcrozet commented 5 years ago

@jojolepro Thank you for the clarification! Because this is a breaking change, this will be released under the version 0.9 (which will not happen immediatly).