use num_traits::{One, Zero};
use std::fmt::Debug;
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
mod private {
pub trait Sealed {}
impl Sealed for f32 {}
impl Sealed for f64 {}
impl Sealed for num_complex::Complex<f32> {}
impl Sealed for num_complex::Complex<f64> {}
}
pub trait LapackScalar:
private::Sealed
+ Copy
+ Debug
+ Zero
+ One
+ Send
+ Sync
+ 'static
+ Add<Output = Self>
+ Sub<Output = Self>
+ Mul<Output = Self>
+ Div<Output = Self>
+ Neg<Output = Self>
+ AddAssign
+ SubAssign
+ MulAssign
+ DivAssign
{
type Real: Copy + Debug + Zero + Send + Sync + 'static + Add<Output = Self::Real>;
fn conjugate(self) -> Self;
fn abs_squared(self) -> Self::Real;
}
impl LapackScalar for f32 {
type Real = f32;
fn conjugate(self) -> Self {
self
}
fn abs_squared(self) -> Self::Real {
self * self
}
}
impl LapackScalar for f64 {
type Real = f64;
fn conjugate(self) -> Self {
self
}
fn abs_squared(self) -> Self::Real {
self * self
}
}
impl LapackScalar for num_complex::Complex<f32> {
type Real = f32;
fn conjugate(self) -> Self {
self.conj()
}
fn abs_squared(self) -> Self::Real {
self.norm_sqr()
}
}
impl LapackScalar for num_complex::Complex<f64> {
type Real = f64;
fn conjugate(self) -> Self {
self.conj()
}
fn abs_squared(self) -> Self::Real {
self.norm_sqr()
}
}