use core::fmt;
use std::ops::{Add, AddAssign, Div, Mul, MulAssign, Neg, Sub, SubAssign};
pub trait Scalar:
Sized
+ Copy
+ Default
+ PartialEq
+ PartialOrd
+ PartialEq<f64>
+ PartialOrd<f64>
+ From<f64>
+ Send
+ Sync
+ fmt::Debug
+ fmt::Display
{
fn scalar(v: f64) -> Self;
fn value(&self) -> f64;
fn zero() -> Self;
fn one() -> Self;
#[must_use]
fn exp(self) -> Self;
#[must_use]
fn ln(self) -> Self;
#[must_use]
fn sqrt(self) -> Self;
#[must_use]
fn sin(self) -> Self;
#[must_use]
fn cos(self) -> Self;
#[must_use]
fn abs(self) -> Self;
#[must_use]
fn powf(self, p: f64) -> Self;
#[must_use]
fn pows(self, p: Self) -> Self;
#[must_use]
fn max_val(self, other: Self) -> Self;
#[must_use]
fn min_val(self, other: Self) -> Self;
#[must_use]
fn add_val(self, other: Self) -> Self;
#[must_use]
fn sub_val(self, other: Self) -> Self;
#[must_use]
fn mul_val(self, other: Self) -> Self;
#[must_use]
fn div_val(self, other: Self) -> Self;
#[must_use]
fn neg_val(self) -> Self;
}
pub trait IsReal: Scalar {}
impl<T: Scalar> IsReal for T {}
impl Scalar for f64 {
#[inline]
fn scalar(v: f64) -> Self {
v
}
#[inline]
fn value(&self) -> f64 {
*self
}
#[inline]
fn zero() -> Self {
0.0
}
#[inline]
fn one() -> Self {
1.0
}
#[inline]
fn exp(self) -> Self {
Self::exp(self)
}
#[inline]
fn ln(self) -> Self {
Self::ln(self)
}
#[inline]
fn sqrt(self) -> Self {
Self::sqrt(self)
}
#[inline]
fn sin(self) -> Self {
Self::sin(self)
}
#[inline]
fn cos(self) -> Self {
Self::cos(self)
}
#[inline]
fn abs(self) -> Self {
Self::abs(self)
}
#[inline]
fn powf(self, p: f64) -> Self {
Self::powf(self, p)
}
#[inline]
fn pows(self, p: Self) -> Self {
Self::powf(self, p)
}
#[inline]
fn max_val(self, o: Self) -> Self {
Self::max(self, o)
}
#[inline]
fn min_val(self, o: Self) -> Self {
Self::min(self, o)
}
#[inline]
fn add_val(self, other: Self) -> Self {
self + other
}
#[inline]
fn sub_val(self, other: Self) -> Self {
self - other
}
#[inline]
fn mul_val(self, other: Self) -> Self {
self * other
}
#[inline]
fn div_val(self, other: Self) -> Self {
self / other
}
#[inline]
fn neg_val(self) -> Self {
-self
}
}
pub trait InnerScalar:
Scalar
+ Add<Output = Self>
+ Sub<Output = Self>
+ Mul<Output = Self>
+ Div<Output = Self>
+ Neg<Output = Self>
+ AddAssign
+ SubAssign
+ MulAssign
+ Add<f64, Output = Self>
+ Sub<f64, Output = Self>
+ Mul<f64, Output = Self>
+ Div<f64, Output = Self>
{
}
impl InnerScalar for f64 {}