oxilean_std/complex/complex_roots_of_unity_group.rs
1//! # Complex - roots_of_unity_group Methods
2//!
3//! This module contains method implementations for `Complex`.
4//!
5//! 🤖 Generated with [SplitRS](https://github.com/cool-japan/splitrs)
6
7use std::f64::consts::PI;
8
9use super::complex_type::Complex;
10
11impl Complex {
12 /// n-th roots of unity: e^(2πi·k/n) for k = 0..n-1.
13 pub fn roots_of_unity(n: u32) -> Vec<Self> {
14 if n == 0 {
15 return vec![];
16 }
17 (0..n)
18 .map(|k| Self::from_polar(1.0, 2.0 * PI * k as f64 / n as f64))
19 .collect()
20 }
21}