1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
use Fixed;
/// Rase integer to an integer-valued power.
/// base^power.
/// Rase float number to an integer-valued power.
/// - `base^power`.
/// Rase fixed number to an integer-valued power.
/// - `base^power`.
/// Numerical square root of a fixed point scalar.
/// Slow but acurate method.
///
/// ## Argument
/// * `error` - The gratest allowed error in the result.
///
/// # Example
///
/// ```
/// use fixed::{types::extra::U20, FixedI32};
/// use integer_array::utility as util;
/// let x = util::sqrt( FixedI32::<U20>::from_num(110), FixedI32::<U20>::from_num(0.025) );
/// assert_eq!{ x.to_num::<f32>(), 10.488159f32 };
/// ```
/// Calculate atan(y/x) using a polynomial approximation.
/// Utilizes the following polynomial to estimate the angle θ \[radians\].
///
/// `atan(y,x) = ((y,x)+0.372003(y,x)^3) / (1+0.703384(y/x)^2 + 0.043562(y/x)^4)`
///
/// The method is accurat within 0.003 degrees when |θ|<=π/4.
///
/// \[1\] R. G. Lyons, Streamlining Digital Signal Processing, Second Etition, IEEE Press, 2012.
///
/// # Arguments
///
/// * `y` - Is the argument along the y or imaginary axis.
/// * `x` - Is the argument along the x or real axis.
///
/// # Example
///
/// ```
/// use integer_array::utility as util;
/// let arg = util::atan2_precise_float( 0.6f32, 0.4f32 );
/// assert_eq!{ arg, 0.98300606 };
/// ```
/// Calculate atan(y/x) using a polynomial approximation.
/// Utilizes the following polynomial to estimate the angle θ \[radians\].
///
/// `atan(y,x) = ((y,x)+0.372003(y,x)^3) / (1+0.703384(y/x)^2 + 0.043562(y/x)^4)`
///
/// The method is accurat within 0.003 degrees when |θ|<=π/4.
///
/// \[1\] R. G. Lyons, Streamlining Digital Signal Processing, Second Etition, IEEE Press, 2012.
///
/// # Arguments
///
/// * `y` - Is the argument along the y or imaginary axis.
/// * `x` - Is the argument along the x or real axis.
///
/// # Example
///
/// ```
/// use fixed::{types::extra::U28, FixedI32};
/// use integer_array::utility as util;
/// let arg = util::atan2_precise_fixed( FixedI32::<U28>::from_num(0.6), FixedI32::<U28>::from_num(0.4) );
/// assert_eq!{ arg.to_num::<f32>(), 0.983006064 };
/// ```
/// Calculate atan(x) using a polynomial approximation.
/// Utilizes the following polynomial to estimate the angle θ \[radians\].
///
/// `atan(x) = ((x)+0.372003(x)^3) / (1+0.703384(x)^2 + 0.043562(x)^4)`
///
/// The method is accurat within 0.003 degrees when |θ|<=π/4.
///
/// \[1\] R. G. Lyons, Streamlining Digital Signal Processing, Second Etition, IEEE Press, 2012.
///
/// # Arguments
///
/// * `y` - Is the argument along the y or imaginary axis.
/// * `x` - Is the argument along the x or real axis.
///
/// # Example
///
/// ```
/// use fixed::{types::extra::U28, FixedI32};
/// use integer_array::utility as util;
/// let arg = util::atan_precise_fixed( FixedI32::<U28>::from_num(0.6)/FixedI32::<U28>::from_num(0.4) );
/// assert_eq!{ arg.to_num::<f32>(), 0.983006064 };
/// ```
/*
pub fn test_complex<T>( y: T, x: T ) -> num::complex::Complex<T>
where T: Fixed
{
return num::complex::Complex::new(x, y);
}
*/