Skip to content

Commit 70564df

Browse files
committed
Add cis function
1 parent 3a89daa commit 70564df

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,14 @@ impl<T: Clone + Signed> Complex<T> {
161161

162162
#[cfg(any(feature = "std", feature = "libm"))]
163163
impl<T: Float> Complex<T> {
164+
/// Create a new Complex with a given phase -- `exp(i * phase)`
165+
///
166+
/// [cis (mathematics)]: https://en.wikipedia.org/wiki/Cis_(mathematics)
167+
#[inline]
168+
pub fn cis(phase: T) -> Self {
169+
(Self::i() * phase).exp()
170+
}
171+
164172
/// Calculate |self|
165173
#[inline]
166174
pub fn norm(self) -> T {

0 commit comments

Comments
 (0)