complex
Complex Number Arithmetic
Functions
| Function | Description |
|---|---|
cx_new | Create complex number. |
cx_add | Add two complex numbers. |
cx_sub | Subtract: a - b. |
cx_mul | Multiply: (a+bi)(c+di) = (ac-bd) + (ad+bc)i. |
cx_scale | Scalar multiply. |
cx_abs_sq | Magnitude squared: |
cx_conjugate | Complex conjugate. |
cx_eq | Equality check. |
cx_re | Real part. |
cx_im | Imaginary part. |
cx_is_real | Check if purely real. |
_cx_write_int | Internal: write integer to buffer. Returns chars written. |
cx_to_str | Format as string: “a+bi” or “a-bi”. Returns length. |
Details
cx_new
fn cx_new(re: i64, im: i64) -> &i64Create complex number.
cx_add
fn cx_add(a: &i64, b: &i64) -> &i64Add two complex numbers.
cx_sub
fn cx_sub(a: &i64, b: &i64) -> &i64Subtract: a - b.
cx_mul
fn cx_mul(a: &i64, b: &i64) -> &i64Multiply: (a+bi)(c+di) = (ac-bd) + (ad+bc)i.
cx_scale
fn cx_scale(a: &i64, k: i64) -> &i64Scalar multiply.
cx_abs_sq
fn cx_abs_sq(a: &i64) -> i64Magnitude squared: |a|^2 = re^2 + im^2.
cx_conjugate
fn cx_conjugate(a: &i64) -> &i64Complex conjugate.
cx_eq
fn cx_eq(a: &i64, b: &i64) -> i64Equality check.
cx_re
fn cx_re(a: &i64) -> i64Real part.
cx_im
fn cx_im(a: &i64) -> i64Imaginary part.
cx_is_real
fn cx_is_real(a: &i64) -> i64Check if purely real.
_cx_write_int
fn _cx_write_int(val: i64, out: &i8, off: i64) -> i64Internal: write integer to buffer. Returns chars written.
cx_to_str
fn cx_to_str(a: &i64, out: &i8) -> i64Format as string: “a+bi” or “a-bi”. Returns length.