|
@@ -32,6 +32,23 @@ pub struct Complex<T: Float + Numeric + Primitive> {
|
|
pub imag: T,
|
|
pub imag: T,
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/// A macro for easier creation of `Complex` numbers.
|
|
|
|
+///
|
|
|
|
+/// # Example
|
|
|
|
+///
|
|
|
|
+/// ```rust
|
|
|
|
+/// # use lineal::{Complex, complex};
|
|
|
|
+/// // just a real number
|
|
|
|
+/// let a = complex!(25.0);
|
|
|
|
+/// // first real, second imaginary
|
|
|
|
+/// let b = complex!(1.0, -1.0);
|
|
|
|
+/// // with named arguments
|
|
|
|
+/// let c = complex!(real = -1.0,);
|
|
|
|
+/// let d = complex!(imag = 1.0,);
|
|
|
|
+/// let e = complex!(real = 1.1, imag = 0.0,);
|
|
|
|
+/// // even reverse order
|
|
|
|
+/// let f = complex!(imag = 42.0, real = 23.0,);
|
|
|
|
+/// ```
|
|
#[macro_export]
|
|
#[macro_export]
|
|
macro_rules! complex {
|
|
macro_rules! complex {
|
|
($real:expr, $imag:expr) => {
|
|
($real:expr, $imag:expr) => {
|