Skip to content

Commit

Permalink
Add const I
Browse files Browse the repository at this point in the history
  • Loading branch information
cuviper committed May 7, 2024
1 parent 7ae5235 commit 2045f2d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ impl<T> Complex<T> {
}

impl<T: Clone + Num> Complex<T> {
/// Returns imaginary unit
/// Returns the imaginary unit.
///
/// See also [`Complex::I`].
#[inline]
pub fn i() -> Self {
Self::new(T::zero(), T::one())
Expand Down Expand Up @@ -1176,6 +1178,9 @@ impl<T: Clone + Num> Zero for Complex<T> {
impl<T: ConstOne + ConstZero> Complex<T> {
/// A constant `Complex` 1.
pub const ONE: Self = Self::new(T::ONE, T::ZERO);

/// A constant `Complex` _i_, the imaginary unit.
pub const I: Self = Self::new(T::ZERO, T::ONE);
}

impl<T: Clone + Num + ConstOne + ConstZero> ConstOne for Complex<T> {
Expand Down

0 comments on commit 2045f2d

Please sign in to comment.