2018-09-20 20:23:31 +08:00
|
|
|
use approx::AbsDiffEq;
|
2018-10-22 04:11:27 +08:00
|
|
|
use num::{Bounded, FromPrimitive, Signed};
|
2018-09-20 16:50:34 +08:00
|
|
|
|
|
|
|
use na::allocator::Allocator;
|
2018-10-22 04:11:27 +08:00
|
|
|
use na::{DimMin, DimName, Scalar, U1};
|
2020-04-05 23:13:34 +08:00
|
|
|
use simba::scalar::{ClosedAdd, ClosedMul, ClosedSub};
|
|
|
|
use std::cmp::PartialOrd;
|
2018-09-20 16:50:34 +08:00
|
|
|
|
2018-09-22 19:18:59 +08:00
|
|
|
/// A type-level number representing a vector, matrix row, or matrix column, dimension.
|
2018-09-20 20:23:31 +08:00
|
|
|
pub trait Dimension: DimName + DimMin<Self, Output = Self> {}
|
|
|
|
impl<D: DimName + DimMin<D, Output = Self>> Dimension for D {}
|
2018-09-20 16:50:34 +08:00
|
|
|
|
2018-09-22 19:18:59 +08:00
|
|
|
/// A number that can either be an integer or a float.
|
2018-10-22 04:11:27 +08:00
|
|
|
pub trait Number:
|
2020-04-05 23:13:34 +08:00
|
|
|
Scalar
|
|
|
|
+ Copy
|
|
|
|
+ PartialOrd
|
|
|
|
+ ClosedAdd
|
|
|
|
+ ClosedSub
|
|
|
|
+ ClosedMul
|
|
|
|
+ AbsDiffEq<Epsilon = Self>
|
|
|
|
+ Signed
|
|
|
|
+ FromPrimitive
|
|
|
|
+ Bounded
|
2018-10-22 04:11:27 +08:00
|
|
|
{
|
2018-09-20 16:50:34 +08:00
|
|
|
}
|
|
|
|
|
2020-03-21 19:16:46 +08:00
|
|
|
impl<
|
|
|
|
T: Scalar
|
|
|
|
+ Copy
|
2020-04-05 23:13:34 +08:00
|
|
|
+ PartialOrd
|
|
|
|
+ ClosedAdd
|
|
|
|
+ ClosedSub
|
|
|
|
+ ClosedMul
|
2020-03-21 19:16:46 +08:00
|
|
|
+ AbsDiffEq<Epsilon = Self>
|
|
|
|
+ Signed
|
|
|
|
+ FromPrimitive
|
|
|
|
+ Bounded,
|
|
|
|
> Number for T
|
|
|
|
{
|
|
|
|
}
|
2018-09-20 16:50:34 +08:00
|
|
|
|
|
|
|
#[doc(hidden)]
|
2019-12-17 07:09:14 +08:00
|
|
|
pub trait Alloc<N: Scalar, R: Dimension, C: Dimension = U1>:
|
2018-10-22 04:11:27 +08:00
|
|
|
Allocator<N, R>
|
|
|
|
+ Allocator<N, C>
|
|
|
|
+ Allocator<N, U1, R>
|
|
|
|
+ Allocator<N, U1, C>
|
|
|
|
+ Allocator<N, R, C>
|
|
|
|
+ Allocator<N, C, R>
|
|
|
|
+ Allocator<N, R, R>
|
|
|
|
+ Allocator<N, C, C>
|
|
|
|
+ Allocator<bool, R>
|
|
|
|
+ Allocator<bool, C>
|
|
|
|
+ Allocator<f32, R>
|
|
|
|
+ Allocator<f32, C>
|
|
|
|
+ Allocator<u32, R>
|
|
|
|
+ Allocator<u32, C>
|
|
|
|
+ Allocator<i32, R>
|
|
|
|
+ Allocator<i32, C>
|
|
|
|
+ Allocator<f64, R>
|
|
|
|
+ Allocator<f64, C>
|
|
|
|
+ Allocator<u64, R>
|
|
|
|
+ Allocator<u64, C>
|
|
|
|
+ Allocator<i64, R>
|
|
|
|
+ Allocator<i64, C>
|
|
|
|
+ Allocator<i16, R>
|
|
|
|
+ Allocator<i16, C>
|
|
|
|
+ Allocator<(usize, usize), R>
|
|
|
|
+ Allocator<(usize, usize), C>
|
2018-09-20 16:50:34 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-12-17 07:09:14 +08:00
|
|
|
impl<N: Scalar, R: Dimension, C: Dimension, T> Alloc<N, R, C> for T where T: Allocator<N, R>
|
2018-10-22 04:11:27 +08:00
|
|
|
+ Allocator<N, C>
|
|
|
|
+ Allocator<N, U1, R>
|
|
|
|
+ Allocator<N, U1, C>
|
|
|
|
+ Allocator<N, R, C>
|
|
|
|
+ Allocator<N, C, R>
|
|
|
|
+ Allocator<N, R, R>
|
|
|
|
+ Allocator<N, C, C>
|
|
|
|
+ Allocator<bool, R>
|
|
|
|
+ Allocator<bool, C>
|
|
|
|
+ Allocator<f32, R>
|
|
|
|
+ Allocator<f32, C>
|
|
|
|
+ Allocator<u32, R>
|
|
|
|
+ Allocator<u32, C>
|
|
|
|
+ Allocator<i32, R>
|
|
|
|
+ Allocator<i32, C>
|
|
|
|
+ Allocator<f64, R>
|
|
|
|
+ Allocator<f64, C>
|
|
|
|
+ Allocator<u64, R>
|
|
|
|
+ Allocator<u64, C>
|
|
|
|
+ Allocator<i64, R>
|
|
|
|
+ Allocator<i64, C>
|
|
|
|
+ Allocator<i16, R>
|
|
|
|
+ Allocator<i16, C>
|
|
|
|
+ Allocator<(usize, usize), R>
|
|
|
|
+ Allocator<(usize, usize), C>
|
2020-03-21 19:16:46 +08:00
|
|
|
{
|
|
|
|
}
|