diff --git a/Cargo.toml b/Cargo.toml index 7775822..ff4da39 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,12 +12,7 @@ categories = ["algorithms"] license = "MIT" [dependencies] -num-traits = "0.2" -serde = "1" -rand = "0.7" - -[dependencies.num-complex] -git = "http://github.com/rust-num/num-complex" -rev = "7fb4f1c0f0f0d293c18df8d5b2b03362605b3862" -version = "0.3.0-pre" -features = ["serde", "rand"] +num-complex = { version = "0.3.0", features = ["serde", "rand"] } +num-traits = "0.2.12" +rand = "0.7.3" +serde = "1.0.113" diff --git a/src/lib.rs b/src/lib.rs index fd11639..dc8a64f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -89,10 +89,10 @@ pub trait Scalar: fn mul_complex(self, im: Self::Complex) -> Self::Complex; fn div_complex(self, im: Self::Complex) -> Self::Complex; - fn pow(&self, n: Self) -> Self; - fn powi(&self, n: i32) -> Self; - fn powf(&self, n: Self::Real) -> Self; - fn powc(&self, n: Self::Complex) -> Self::Complex; + fn pow(self, n: Self) -> Self; + fn powi(self, n: i32) -> Self; + fn powf(self, n: Self::Real) -> Self; + fn powc(self, n: Self::Complex) -> Self::Complex; /// Real part fn re(&self) -> Self::Real; @@ -104,25 +104,25 @@ pub trait Scalar: fn conj(&self) -> Self; /// Absolute value - fn abs(&self) -> Self::Real; + fn abs(self) -> Self::Real; /// Sqaure of absolute value - fn square(&self) -> Self::Real; - - fn sqrt(&self) -> Self; - fn exp(&self) -> Self; - fn ln(&self) -> Self; - fn sin(&self) -> Self; - fn cos(&self) -> Self; - fn tan(&self) -> Self; - fn asin(&self) -> Self; - fn acos(&self) -> Self; - fn atan(&self) -> Self; - fn sinh(&self) -> Self; - fn cosh(&self) -> Self; - fn tanh(&self) -> Self; - fn asinh(&self) -> Self; - fn acosh(&self) -> Self; - fn atanh(&self) -> Self; + fn square(self) -> Self::Real; + + fn sqrt(self) -> Self; + fn exp(self) -> Self; + fn ln(self) -> Self; + fn sin(self) -> Self; + fn cos(self) -> Self; + fn tan(self) -> Self; + fn asin(self) -> Self; + fn acos(self) -> Self; + fn atan(self) -> Self; + fn sinh(self) -> Self; + fn cosh(self) -> Self; + fn tanh(self) -> Self; + fn asinh(self) -> Self; + fn acosh(self) -> Self; + fn atanh(self) -> Self; /// Generate an random number from /// [rand::distributions::Standard](https://docs.rs/rand/0.7.2/rand/distributions/struct.Standard.html) @@ -132,8 +132,8 @@ pub trait Scalar: macro_rules! impl_float { ($name:ident) => { #[inline] - fn $name(&self) -> Self { - Float::$name(*self) + fn $name(self) -> Self { + Float::$name(self) } }; } @@ -141,7 +141,7 @@ macro_rules! impl_float { macro_rules! impl_complex { ($name:ident) => { #[inline] - fn $name(&self) -> Self { + fn $name(self) -> Self { Complex::$name(self) } }; @@ -185,16 +185,16 @@ macro_rules! impl_scalar { re } - fn pow(&self, n: Self) -> Self { + fn pow(self, n: Self) -> Self { self.powf(n) } - fn powi(&self, n: i32) -> Self { - Float::powi(*self, n) + fn powi(self, n: i32) -> Self { + Float::powi(self, n) } - fn powf(&self, n: Self::Real) -> Self { - Float::powf(*self, n) + fn powf(self, n: Self::Real) -> Self { + Float::powf(self, n) } - fn powc(&self, n: Self::Complex) -> Self::Complex { + fn powc(self, n: Self::Complex) -> Self::Complex { self.as_c().powc(n) } @@ -218,7 +218,7 @@ macro_rules! impl_scalar { *self } #[inline] - fn square(&self) -> Self::Real { + fn square(self) -> Self::Real { self * self } @@ -271,16 +271,16 @@ macro_rules! impl_scalar { Self::new(re, Zero::zero()) } - fn pow(&self, n: Self) -> Self { + fn pow(self, n: Self) -> Self { self.powc(n) } - fn powi(&self, n: i32) -> Self { + fn powi(self, n: i32) -> Self { self.powf(n as Self::Real) } - fn powf(&self, n: Self::Real) -> Self { + fn powf(self, n: Self::Real) -> Self { self.powf(n) } - fn powc(&self, n: Self::Complex) -> Self::Complex { + fn powc(self, n: Self::Complex) -> Self::Complex { self.powc(n) } @@ -304,11 +304,11 @@ macro_rules! impl_scalar { Complex::conj(self) } #[inline] - fn square(&self) -> Self::Real { - Complex::norm_sqr(self) + fn square(self) -> Self::Real { + Complex::norm_sqr(&self) } #[inline] - fn abs(&self) -> Self::Real { + fn abs(self) -> Self::Real { Complex::norm(self) }