Skip to content

Commit

Permalink
Merge pull request #3 from rust-math/num-complex-0.3.0
Browse files Browse the repository at this point in the history
Upgrade to num-complex 0.3
  • Loading branch information
termoshtt committed Jun 20, 2020
2 parents e4e94a2 + 3d66f34 commit 873e27b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 48 deletions.
13 changes: 4 additions & 9 deletions Cargo.toml
Expand Up @@ -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"
78 changes: 39 additions & 39 deletions src/lib.rs
Expand Up @@ -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;
Expand All @@ -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)
Expand All @@ -132,16 +132,16 @@ pub trait Scalar:
macro_rules! impl_float {
($name:ident) => {
#[inline]
fn $name(&self) -> Self {
Float::$name(*self)
fn $name(self) -> Self {
Float::$name(self)
}
};
}

macro_rules! impl_complex {
($name:ident) => {
#[inline]
fn $name(&self) -> Self {
fn $name(self) -> Self {
Complex::$name(self)
}
};
Expand Down Expand Up @@ -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)
}

Expand All @@ -218,7 +218,7 @@ macro_rules! impl_scalar {
*self
}
#[inline]
fn square(&self) -> Self::Real {
fn square(self) -> Self::Real {
self * self
}

Expand Down Expand Up @@ -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)
}

Expand All @@ -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)
}

Expand Down

0 comments on commit 873e27b

Please sign in to comment.