|
@@ -28,7 +28,9 @@ use crate::{Float, Numeric, Primitive};
|
|
/// ```
|
|
/// ```
|
|
#[derive(Debug, Copy, Clone)]
|
|
#[derive(Debug, Copy, Clone)]
|
|
pub struct Complex<T: Float + Numeric + Primitive> {
|
|
pub struct Complex<T: Float + Numeric + Primitive> {
|
|
|
|
+ /// The real component of the complex number.
|
|
pub real: T,
|
|
pub real: T,
|
|
|
|
+ /// The imaginary component of the complex number.
|
|
pub imag: T,
|
|
pub imag: T,
|
|
}
|
|
}
|
|
|
|
|
|
@@ -72,6 +74,7 @@ impl<T: Float + Numeric + Primitive> Default for Complex<T> {
|
|
}
|
|
}
|
|
|
|
|
|
impl<T: Float + Numeric + Primitive> Complex<T> {
|
|
impl<T: Float + Numeric + Primitive> Complex<T> {
|
|
|
|
+ /// Create a complex number with its imaginary component being zero.
|
|
pub fn real(value: T) -> Self {
|
|
pub fn real(value: T) -> Self {
|
|
Self {
|
|
Self {
|
|
real: value,
|
|
real: value,
|
|
@@ -79,6 +82,7 @@ impl<T: Float + Numeric + Primitive> Complex<T> {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// Create a complex number with its real component being zero.
|
|
pub fn imag(value: T) -> Self {
|
|
pub fn imag(value: T) -> Self {
|
|
Self {
|
|
Self {
|
|
real: unsafe { T::whole(0) },
|
|
real: unsafe { T::whole(0) },
|