cas_compute/funcs/
complex.rs1use cas_attrs::builtin;
4use rug::{Complex, Float};
5
6#[derive(Debug)]
8pub struct Re;
9
10#[cfg_attr(feature = "numerical", builtin)]
11impl Re {
12 pub fn eval_static(n: Complex) -> Float {
13 n.into_real_imag().0
14 }
15}
16
17#[derive(Debug)]
19pub struct Im;
20
21#[cfg_attr(feature = "numerical", builtin)]
22impl Im {
23 pub fn eval_static(n: Complex) -> Float {
24 n.into_real_imag().1
25 }
26}
27
28#[derive(Debug)]
30pub struct Arg;
31
32#[cfg_attr(feature = "numerical", builtin(radian = output))]
33impl Arg {
34 pub fn eval_static(n: Complex) -> Float {
35 n.arg().into_real_imag().0 }
37}
38
39#[derive(Debug)]
41pub struct Conj;
42
43#[cfg_attr(feature = "numerical", builtin)]
44impl Conj {
45 pub fn eval_static(n: Complex) -> Complex {
46 n.conj()
47 }
48}