mixed_num/traits/
complex_traits.rs

1// As this is a library intended for design reuse, the primary traits to be implemented are the ***Mixed*** traits.
2// With that said, as the complex structs are created in this library, they can have trais with sorter names, whih allow increased readability.
3
4use crate::*;
5
6pub trait ToCartesian<T> {
7    fn to_cartesian( &self ) -> Cartesian<T>;
8}
9
10pub trait ToPolar<T> {
11    fn to_polar( &self ) -> Polar<T>;
12}
13
14pub trait MixedComplexConversion<T> {
15    /// Type cast from real number T to Complex<T>.
16    fn mixed_to_complex( number:T ) -> Self;
17}
18
19pub trait NewFromCartesian<T> 
20    where Self: MixedComplex
21{
22    /// Create a complex number from cartesian coordinates.
23    fn new_from_cartesian( re:T, im:T ) -> Self;
24}
25
26pub trait NewFromPolar<T> 
27    where Self: MixedComplex
28{
29    /// Create a complex number from polar coordinates.
30    fn new_from_polar( mag:T, ang:T ) -> Self;
31}
32
33pub trait Mag<T>
34    where Self: MixedComplex
35{
36    /// Magnitude of the complex number.
37    fn mag( &self ) -> T;
38    /// Magnitude of the complex number.
39    fn abs( &self ) -> T;
40}
41
42pub trait Arg<T> 
43    where Self: MixedComplex
44{
45    /// Argument of the complex number.
46    fn arg( &self ) -> T;
47
48    /// Angle of the complex number.
49    fn ang( &self ) -> T;
50}
51
52pub trait Conj<T>
53    where Self: MixedComplex
54{
55    /// Complex Conjugate of T.
56    fn conj( &self ) -> T;
57}