Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
//! ```

use num_complex::Complex;
use num_traits::{Float, FromPrimitive, NumAssign, NumCast, NumOps, ToPrimitive, Zero};
use num_traits::{Float, FromPrimitive, NumAssign, NumCast, NumOps, One, ToPrimitive, Zero};
use rand::{distributions::Standard, prelude::*};
use serde::{Deserialize, Serialize};
use std::fmt::{Debug, Display, LowerExp, UpperExp};
Expand All @@ -52,6 +52,8 @@ pub trait Scalar:
NumAssign
+ FromPrimitive
+ NumCast
+ One
+ Zero
+ Neg<Output = Self>
+ Copy
+ Clone
Expand All @@ -72,6 +74,14 @@ pub trait Scalar:
+ NumOps<Self::Real, Self::Complex>
+ NumOps<Self::Complex, Self::Complex>;

fn zero() -> Self {
Zero::zero()
}

fn one() -> Self {
One::one()
}

/// Create a new real number
fn real<T: ToPrimitive>(re: T) -> Self::Real;
/// Create a new complex number
Expand Down