Skip to content

Commit c9a3843

Browse files
committed
Enable the trait CoordXY for complex numbers
1 parent 46b2596 commit c9a3843

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ rust-version = "1.80"
1616
numpy = "0.23.0"
1717
ndarray = "0.16.1"
1818
curve-sampling = { version = "0.5", optional = true, git = "https://github.com/Chris00/rust-curve-sampling.git" }
19+
num-complex = { version = "0.4.6", optional = true }
1920

2021
[dependencies.pyo3]
2122
version = "0.23.3"

src/lib.rs

+8
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,14 @@ impl CoordXY for [f64; 2] {
810810
fn y(&self) -> f64 { self[1] }
811811
}
812812

813+
#[cfg(feature = "num-complex")]
814+
impl CoordXY for num_complex::Complex64 {
815+
#[inline]
816+
fn x(&self) -> f64 { self.re }
817+
#[inline]
818+
fn y(&self) -> f64 { self.im }
819+
}
820+
813821
impl<'a, I> XYFrom<'a, I>
814822
where I: IntoIterator,
815823
<I as IntoIterator>::Item: CoordXY {

0 commit comments

Comments
 (0)