Remove the Scalar::is method, which is unsound.
This commit is contained in:
parent
38ac9a2f9a
commit
6d57396a42
@ -22,6 +22,7 @@ use crate::base::dimension::{Dim, Dynamic, U1};
|
||||
use crate::base::storage::{RawStorage, RawStorageMut};
|
||||
use crate::base::uninit::{InitStatus, Initialized};
|
||||
use crate::base::{Matrix, Scalar, Vector};
|
||||
use std::any::TypeId;
|
||||
|
||||
// # Safety
|
||||
// The content of `y` must only contain values for which
|
||||
@ -265,7 +266,7 @@ pub unsafe fn gemm_uninit<
|
||||
return;
|
||||
}
|
||||
|
||||
if T::is::<f32>() {
|
||||
if TypeId::of::<T>() == TypeId::of::<f32>() {
|
||||
let (rsa, csa) = a.strides();
|
||||
let (rsb, csb) = b.strides();
|
||||
let (rsc, csc) = y.strides();
|
||||
@ -287,7 +288,7 @@ pub unsafe fn gemm_uninit<
|
||||
csc as isize,
|
||||
);
|
||||
return;
|
||||
} else if T::is::<f64>() {
|
||||
} else if TypeId::of::<T>() == TypeId::of::<f64>() {
|
||||
let (rsa, csa) = a.strides();
|
||||
let (rsb, csb) = b.strides();
|
||||
let (rsc, csc) = y.strides();
|
||||
|
@ -1,19 +1,10 @@
|
||||
use std::any::Any;
|
||||
use std::any::TypeId;
|
||||
use std::fmt::Debug;
|
||||
|
||||
/// The basic scalar type for all structures of `nalgebra`.
|
||||
///
|
||||
/// This does not make any assumption on the algebraic properties of `Self`.
|
||||
pub trait Scalar: Clone + PartialEq + Debug + Any {
|
||||
#[inline]
|
||||
/// Tests if `Self` the same as the type `T`
|
||||
///
|
||||
/// Typically used to test of `Self` is a f32 or a f64 with `T::is::<f32>()`.
|
||||
fn is<T: Scalar>() -> bool {
|
||||
TypeId::of::<Self>() == TypeId::of::<T>()
|
||||
}
|
||||
|
||||
pub trait Scalar: 'static + Clone + PartialEq + Debug {
|
||||
#[inline(always)]
|
||||
/// Performance hack: Clone doesn't get inlined for Copy types in debug mode, so make it inline anyway.
|
||||
fn inlined_clone(&self) -> Self {
|
||||
|
Loading…
Reference in New Issue
Block a user