Skip to main content

mathlab/functions/vec/
mod.rs

1use super::{
2    num::{
3        abs, acos, acos_deg, acosh, acosh_deg, acot, acot_deg, acoth, acoth_deg, acsc, acsc_deg,
4        acsch, acsch_deg, asec, asec_deg, asech, asech_deg, asin, asin_deg, asinh, asinh_deg, atan,
5        atan_deg, atanh, atanh_deg, cbrt, ceil, cos, cos_deg, cosh, cosh_deg, cot, cot_deg, coth,
6        coth_deg, csc, csc_deg, csch, csch_deg, cube, deg_to_rad, exp, f64_to_f32, fact, fix64,
7        floor, fround, gamma, i64_to_f64, inv, ln, ln1p, log10, log2, rad_to_deg, round, sec,
8        sec_deg, sech, sech_deg, sign, sin, sin_deg, sinh, sinh_deg, sqr, sqrt, tan, tan_deg, tanh,
9        tanh_deg, trunc, u64_to_f64,
10    },
11    rand, string_to_u64,
12};
13/// ### abs_vec(x)
14///
15/// Native Function
16///
17/// The `abs_vec` function takes a single parameter, a slice of floating-point numbers (`&[f64]`),
18/// and returns a vector (`Vec<f64>`) containing the absolute values of each element in the input slice.
19/// The function iterates over each element in the slice,
20/// computes its absolute value, and collects the results into a new vector.
21///
22/// The `abs_vec` function can be written in two ways:
23///
24/// ```rust
25/// use mathlab::math::abs;
26/// let my_x_f64_array = [0.0, -1.0, 3.33, -3.33];
27/// // with a reference (&)
28/// pub fn abs_vec(x: &[f64]) -> Vec<f64> {
29///     x.iter().map(|&x| x.abs()).collect()
30/// }
31///
32/// assert_eq!(abs_vec(&my_x_f64_array), [0.0, 1.0, 3.33, 3.33]);
33/// ```
34///
35/// or directly without a reference `&`
36///
37/// ```rust
38/// use mathlab::math::abs;
39/// let my_x_f64_array = [0.0, -1.0, 3.33, -3.33];
40/// pub fn abs_vec<const N: usize>(x: [f64; N]) -> Vec<f64> {
41///     x.iter().map(|&x| x.abs()).collect()
42/// }
43///
44/// assert_eq!(abs_vec(my_x_f64_array), vec![0.0, 1.0, 3.33, 3.33]);
45/// ```
46///
47/// For most cases, using a slice (`&[f64]`) is more efficient and flexible,
48/// especially for larger arrays or when the function needs to handle variable-length input.
49/// It avoids the overhead of copying the entire array and allows the function
50/// to work with any contiguous memory block.
51///
52/// ### Examples
53/// ```rust
54/// use mathlab::math::{abs, abs_vec};
55/// let my_x_f64_array = [0.0, -1.0, 3.33, -3.33];
56/// assert_eq!(abs(-1.0), 1.0);
57/// assert_eq!(abs_vec(&my_x_f64_array), [0.0, 1.0, 3.33, 3.33]);
58/// ```
59/// <small>End Fun Doc</small>
60pub fn abs_vec(x: &[f64]) -> Vec<f64> {
61    x.iter().map(|&x| abs(x)).collect()
62}
63
64/// ### sign_vec(x)
65///
66/// Native Function
67///
68/// The `sign_vec` function takes a slice of floating-point numbers (`&[f64]`)
69/// and returns a vector (`Vec<f64>`) containing the sign of each element in the input slice.
70/// It iterates over each element, applies the sign function, and collects the results into a new vector.
71///
72/// ### Examples
73/// ```rust
74/// use mathlab::math::{sign, sign_vec};
75/// let my_x_f64_array = [-9.0, 9.0, --9.5, 6.0 - 15.0, 0.0, 0.0 / 0.0];
76/// assert_eq!(sign(-9.0), -1.0);
77/// assert_eq!(sign_vec(&my_x_f64_array), [-1.0, 1.0, 1.0, -1.0, 0.0, 0.0]);
78/// ```
79/// <small>End Fun Doc</small>
80pub fn sign_vec(x: &[f64]) -> Vec<f64> {
81    x.iter().map(|&x| sign(x)).collect()
82}
83
84/// ### fact_vec(x)
85///
86/// Native Function
87///
88/// The `fact_vec` function takes a slice of `unsigned` `64-bit` integers
89/// and returns a vector containing the factorial of each element in the input slice.
90/// It iterates over the input slice, computes the factorial of each element using the fact function,
91/// and collects the results into a vector.
92///
93/// ### Examples
94/// ```rust
95/// use mathlab::math::{fact, fact_vec, u64_to_f64_vec};
96/// let my_x_u64_array = [0, 1, 2, 3, 16, 18];
97/// assert_eq!(fact(3), 6);
98/// assert_eq!(fact(3) as f64, 6.0);
99/// assert_eq!(fact_vec(&my_x_u64_array), [1, 1, 2, 6, 20922789888000, 6402373705728000]);
100/// assert_eq!(fact_vec(&my_x_u64_array).iter().map(|&x| x as f64).collect::<Vec<f64>>(), vec![1.0, 1.0, 2.0, 6.0, 20922789888000.0, 6402373705728000.0]);
101/// assert_eq!(u64_to_f64_vec(&fact_vec(&my_x_u64_array)), [1.0, 1.0, 2.0, 6.0, 20922789888000.0, 6402373705728000.0]);
102/// ```
103/// <small>End Fun Doc</small>
104pub fn fact_vec(x: &[u64]) -> Vec<u64> {
105    x.iter().map(|&x| fact(x)).collect()
106}
107
108/// ### gamma_vec(x)
109///
110/// Extended Factorial Function
111///
112/// The `gamma_vec` function takes a slice of `64-bit unsigned` integers (`&[u64]`)
113/// and returns a vector of `64-bit unsigned` integers (`Vec<u64]`).
114/// It applies the gamma function to each element in the input slice and collects the results into a new vector.
115///
116/// ### Examples
117/// ```rust
118/// use mathlab::math::{gamma, gamma_vec, u64_to_f64_vec};
119/// let my_x_u64_array = [1, 2, 3, 4, 17, 19];
120/// assert_eq!(gamma(3), 2);
121/// assert_eq!(gamma(3) as f64, 2.0);
122/// assert_eq!(gamma_vec(&my_x_u64_array), [1, 1, 2, 6, 20922789888000, 6402373705728000]);
123/// assert_eq!(gamma_vec(&my_x_u64_array).iter().map(|&x| x as f64).collect::<Vec<f64>>(), vec![1.0, 1.0, 2.0, 6.0, 20922789888000.0, 6402373705728000.0]);
124/// assert_eq!(u64_to_f64_vec(&gamma_vec(&my_x_u64_array)), [1.0, 1.0, 2.0, 6.0, 20922789888000.0, 6402373705728000.0]);
125/// ```
126/// <small>End Fun Doc</small>
127pub fn gamma_vec(x: &[u64]) -> Vec<u64> {
128    x.iter().map(|&x| gamma(x)).collect()
129}
130
131/// ### inv_vec(x)
132///
133/// Native Function
134///
135/// The `inv_vec` function takes a slice of floating-point numbers `x` and
136/// returns a new vector containing the inverses of each element in `x`
137///
138/// ### Examples
139/// ```rust
140/// use mathlab::math::{inv, inv_vec, INF_F64, INF_F32, fround_vec};
141/// assert_eq!(inv(0.0), INF_F64);
142/// assert_eq!(inv(0.1), 10.0);
143/// assert_eq!(inv_vec(&[0.0, 0.1, 0.2, 0.3]), [INF_F64, 10.0, 5.0, 3.3333333333333335]);
144/// assert_eq!(fround_vec(&inv_vec(&[0.0, 0.1, 0.2, 0.3])), [INF_F32, 10.0, 5.0, 3.3333333]);
145/// assert_eq!(fround_vec(&inv_vec(&[0.0, 0.1, 0.2, 0.3])), [INF_F32, 10.0, 5.0, 3.3333333333333335]);
146/// ```
147/// <small>End Fun Doc</small>
148pub fn inv_vec(x: &[f64]) -> Vec<f64> {
149    x.iter().map(|&x| inv(x)).collect()
150}
151
152/// ### floor_vec(x)
153///
154/// Rounding Function
155///
156/// The `floor_vec` function takes a slice of `f64` values as input and returns
157/// a `Vec<f64>` where each element is the floor value of the corresponding input element.
158/// The floor value of a number is the largest integer less than or equal to that number.
159///
160/// ### Examples
161/// ```rust
162/// use mathlab::math::{floor, floor_vec};
163/// let my_x_f64_array = [0.0, 0.99, 1.01, 1.99, -0.99, -1.01, -1.99];
164/// assert_eq!(floor(1.99), 1.0);
165/// assert_eq!(floor_vec(&my_x_f64_array), [0.0, 0.0, 1.0, 1.0, -1.0, -2.0, -2.0]);
166/// ```
167/// <small>End Fun Doc</small>
168pub fn floor_vec(x: &[f64]) -> Vec<f64> {
169    x.iter().map(|&x| floor(x)).collect()
170}
171
172/// ### ceil_vec(x)
173///
174/// Rounding Function
175///
176/// The `ceil_vec` function takes a slice of `f64` values as input and returns
177/// a `Vec<f64>` where each element is the ceiling value of the corresponding input element.
178/// The ceiling value of a number is the smallest integer greater than or equal to that number.
179///
180/// ### Examples
181/// ```rust
182/// use mathlab::math::{ceil, ceil_vec};
183/// let my_x_f64_array = [0.0, 0.99, 1.01, 1.99, -0.99, -1.01, -1.99];
184/// assert_eq!(ceil(1.99), 2.0);
185/// assert_eq!(ceil_vec(&my_x_f64_array), [0.0, 1.0, 2.0, 2.0, 0.0, -1.0, -1.0]);
186/// ```
187/// <small>End Fun Doc</small>
188pub fn ceil_vec(x: &[f64]) -> Vec<f64> {
189    x.iter().map(|&x| ceil(x)).collect()
190}
191
192/// ### round_vec(x)
193///
194/// Rounding Function
195///
196/// The `round_vec` function takes a slice of `f64` values as input and returns
197/// a `Vec<f64>` where each element is the rounded value of the corresponding input element.
198/// The `round` function aligns a number to the closest integer,
199/// adjusting fractions of `0.5` or greater up, and less than `0.5` down.
200///
201/// ### Examples
202/// ```rust
203/// use mathlab::math::{round, round_vec};
204/// let my_x_f64_array = [0.0, 0.5, 1.01, 1.49, 1.99, -0.5, -1.01, -1.49, -1.99];
205/// assert_eq!(round(1.49), 1.0);
206/// assert_eq!(round(1.5), 2.0);
207/// assert_eq!(round_vec(&my_x_f64_array), [0.0, 1.0, 1.0, 1.0, 2.0, -1.0, -1.0, -1.0, -2.0]);
208/// ```
209/// <small>End Fun Doc</small>
210pub fn round_vec(x: &[f64]) -> Vec<f64> {
211    x.iter().map(|&x| round(x)).collect()
212}
213
214/// ### fround_vec(x)
215///
216/// Rounding Function
217///
218/// The `fround_vec` function takes a slice of `f64` values as input and returns
219/// a `Vec<f32>` where each element is the `f32` representation of the corresponding input element.
220/// The `fround` function converts a `f64` value to a `f32` value.
221///
222/// The `fround_vec` function performs the same operation as the `f64_to_f32_vec` function.
223///
224/// ### Examples
225/// ```rust
226/// use mathlab::math::{fround, fround_vec};
227/// let my_x_f64_array = [0.6666666666666666, 0.30000000000000004, 0.020000000000000004, 0.09999999999999998];
228/// assert_eq!(fround(0.30000000000000004), 0.3);
229/// assert_eq!(fround(0.09999999999999998), 0.1);
230/// assert_eq!(fround_vec(&my_x_f64_array), [0.6666667, 0.3, 0.02, 0.1]);
231/// ```
232/// <small>End Fun Doc</small>
233pub fn fround_vec(x: &[f64]) -> Vec<f32> {
234    x.iter().map(|&x| fround(x)).collect()
235}
236
237/// ### f64_to_f32_vec(x)
238///
239/// Conversion Function
240///
241/// The `f64_to_f32_vec` function takes a slice of `f64` values as input and returns
242/// a `Vec<f32>` where each element is the `f32` representation of the corresponding input element.
243/// The `f64_to_f32` function converts a `f64` value to a `f32` value.
244///
245/// The `f64_to_f32_vec` function performs the same operation as the `fround_vec` function.
246///
247/// ### Examples
248/// ```rust
249/// use mathlab::math::{f64_to_f32, f64_to_f32_vec};
250/// let my_x_f64_array = [0.6666666666666666, 0.30000000000000004, 0.020000000000000004, 0.09999999999999998];
251/// assert_eq!(f64_to_f32(0.30000000000000004), 0.3);
252/// assert_eq!(f64_to_f32(0.09999999999999998), 0.1);
253/// assert_eq!(f64_to_f32_vec(&my_x_f64_array), [0.6666667, 0.3, 0.02, 0.1]);
254/// ```
255/// <small>End Fun Doc</small>
256pub fn f64_to_f32_vec(x: &[f64]) -> Vec<f32> {
257    x.iter().map(|&x| f64_to_f32(x)).collect()
258}
259
260/// ### u64_to_f64_vec(x)
261///
262/// Conversion Function
263///
264/// The `u64_to_f64_vec` function takes a slice of `u64` values as input
265/// and returns a `Vec<f64>` where each element is the `f64`
266/// representation of the corresponding input element using the `u64_to_f64` function.
267///
268/// ### Examples
269/// ```rust
270/// use mathlab::math::{u64_to_f64, u64_to_f64_vec};
271/// let my_x_f64_array = [0, 1, 2, 3];
272/// assert_eq!(u64_to_f64(0), 0.0);
273/// assert_eq!(u64_to_f64_vec(&my_x_f64_array), [0.0, 1.0, 2.0, 3.0]);
274/// ```
275/// <small>End Fun Doc</small>
276pub fn u64_to_f64_vec(x: &[u64]) -> Vec<f64> {
277    x.iter().map(|&x| u64_to_f64(x)).collect()
278}
279
280/// ### i64_to_f64_vec(x)
281///
282/// Conversion Function
283///
284/// The `i64_to_f64_vec` function takes a slice of `i64` values as input
285/// and returns a `Vec<f64>` where each element is the `f64`
286/// representation of the corresponding input element using the `i64_to_f64` function.
287///
288/// ### Examples
289/// ```rust
290/// use mathlab::math::{i64_to_f64, i64_to_f64_vec};
291/// let my_x_f64_array = [-1, -2, 0, 1, 2];
292/// assert_eq!(i64_to_f64(0), 0.0);
293/// assert_eq!(i64_to_f64_vec(&my_x_f64_array), [-1.0, -2.0, 0.0, 1.0, 2.0]);
294/// ```
295/// <small>End Fun Doc</small>
296pub fn i64_to_f64_vec(x: &[i64]) -> Vec<f64> {
297    x.iter().map(|&x| i64_to_f64(x)).collect()
298}
299
300/// ### deg_to_rad_vec(x)
301///
302/// Conversion Function
303///
304/// The `deg_to_rad_vec` function takes a slice of `f64` values
305/// representing `angles` in `degrees` and returns a `Vec<f64>`
306/// containing the corresponding `angles` in `radians`.
307/// It uses the `deg_to_rad` function to convert each `angle` from `degrees` to `radians`.
308///
309/// ### Examples
310/// ```rust
311/// use mathlab::math::{deg_to_rad, deg_to_rad_vec};
312/// let my_x_f64_array = [0.0, 1.0, 30.0, 45.0, 60.0, 90.0, 180.0, 360.0, -360.0];
313/// assert_eq!(deg_to_rad(30.0), 0.5235987756);
314/// assert_eq!(deg_to_rad_vec(&my_x_f64_array), [0.0, 0.0174532925, 0.5235987756, 0.7853981634, 1.0471975512, 1.5707963268, 3.1415926536, 6.2831853072, -6.2831853072]);
315/// ```
316/// <small>End Fun Doc</small>
317pub fn deg_to_rad_vec(x: &[f64]) -> Vec<f64> {
318    x.iter().map(|&x| deg_to_rad(x)).collect()
319}
320
321/// ### rad_to_deg_vec(x)
322///
323/// Conversion Function
324///
325/// The `rad_to_deg_vec` function takes a slice of `f64` values
326/// representing `angles` in `radians` and returns a `Vec<f64>`
327/// containing the corresponding `angles` in `degrees`.
328/// It uses the `rad_to_deg` function to convert each `angle` from `radians` to `degrees`.
329///
330/// ### Examples
331/// ```rust
332/// use mathlab::math::{rad_to_deg, rad_to_deg_vec};
333/// let my_x_f64_array = [0.0, 0.0174532925, 0.5235987756, 0.7853981634, 1.0471975512, 1.5707963268, 3.1415926536, 6.2831853072, -6.2831853072];
334/// assert_eq!(rad_to_deg(0.5235987756), 30.0);
335/// assert_eq!(rad_to_deg_vec(&my_x_f64_array), [0.0, 1.0, 30.0, 45.0, 60.0, 90.0, 180.0, 360.0, -360.0]);
336/// ```
337/// <small>End Fun Doc</small>
338pub fn rad_to_deg_vec(x: &[f64]) -> Vec<f64> {
339    x.iter().map(|&x| rad_to_deg(x)).collect()
340}
341
342/// ### sqr_vec(x)
343///
344/// Native Function
345///
346/// The `sqr_vec` function applies the `sqr` operation to every element of a provided slice of floats,
347/// collecting their squares into a new vector.
348///
349/// ### Examples
350/// ```rust
351/// use mathlab::math::{sqr, sqr_vec, INF_F64, INF_F32, fround_vec};
352/// assert_eq!(sqr(0.1), 0.010000000000000002);
353/// assert_eq!(sqr(0.1) as f32, 0.01);
354/// assert_eq!(sqr_vec(&[0.0, 0.1, 1.0, 2.0, 10.0, INF_F64]), [0.0, 0.010000000000000002, 1.0, 4.0, 100.0, INF_F64]);
355/// assert_eq!(fround_vec(&sqr_vec(&[0.0, 0.1, 1.0, 2.0, 10.0, INF_F64])), [0.0, 0.01, 1.0, 4.0, 100.0, INF_F32]);
356/// ```
357/// <small>End Fun Doc</small>
358pub fn sqr_vec(x: &[f64]) -> Vec<f64> {
359    x.iter().map(|&x| sqr(x)).collect()
360}
361
362/// ### sqrt_vec(x)
363///
364/// Native Function
365///
366/// The `sqrt_vec` function takes a slice of floating-point numbers as input and applies the square root operation
367/// to each element in the slice, returning a new vector containing the squared roots of the original elements.
368///
369/// ### Examples
370/// ```rust
371/// use mathlab::math::{sqrt, sqrt_vec, INF_F64 as inf};
372/// assert_eq!(sqrt(0.01), 0.1);
373/// assert_eq!(sqrt_vec(&[0.0, 0.01, 1.0, 4.0, 9.0, 100.0, inf]), [0.0, 0.1, 1.0, 2.0, 3.0, 10.0, inf]);
374/// ```
375/// <small>End Fun Doc</small>
376pub fn sqrt_vec(x: &[f64]) -> Vec<f64> {
377    x.iter().map(|&x| sqrt(x)).collect()
378}
379
380/// ### exp_vec(x)
381///
382/// Operation Function
383///
384/// The `exp_vec` function applies the exponential function `exp(x)` to each element
385/// of a provided slice of floats, collects their results into a new vector.
386///
387/// ### Examples
388/// ```rust
389/// use mathlab::math::{exp, exp_vec, E};
390/// assert_eq!(exp(0.0), 1.0);
391/// assert_eq!(exp(-1.0) as f32, 0.36787945);
392/// assert_eq!(exp_vec(&[-1.0, 0.0, 1.0]), &[0.36787944117144233, 1.0, E]);
393/// ```
394/// <small>End Fun Doc</small>
395pub fn exp_vec(x: &[f64]) -> Vec<f64> {
396    x.iter().map(|&x| exp(x)).collect()
397}
398
399/// ### ln_vec(x)
400///
401/// Logarithm Function
402///
403/// The `ln_vec` function applies the natural logarithm `ln` to each element of a given slice of floats,
404/// producing a new vector containing the resultant values.
405///
406/// ### Examples
407/// ```rust
408/// use mathlab::math::{ln, ln_vec, is_nan_f64, E, INF_F64 as inf, LN10};
409/// assert!(is_nan_f64(ln(-inf)));
410/// assert_eq!(ln(10.0), 2.302585092994046);
411/// assert_eq!(ln_vec(&[0.0, 1.0, E, 10.0, 1.5]), &[-inf, 0.0, 1.0, LN10, 0.4054651081081644]);
412/// ```
413/// <small>End Fun Doc</small>
414pub fn ln_vec(x: &[f64]) -> Vec<f64> {
415    x.iter().map(|&x| ln(x)).collect()
416}
417
418/// ### ln1p_vec(x)
419///
420/// Logarithm Function
421///
422/// The `ln1p_vec` function computes the natural logarithm (base e) of all elements in a slice,
423/// accounting for numerically stable evaluation near zero through the use of the "Lambert W" function,
424/// returns the results as a new vector.
425///
426/// ### Examples
427/// ```rust
428/// use mathlab::math::{ln1p, ln1p_vec, is_nan_f64, E, INF_F64 as inf, LN10};
429/// assert!(is_nan_f64(ln1p(-inf)));
430/// assert_eq!(ln1p(0.0), 0.0);
431/// assert_eq!(ln1p(1.0), 0.6931471805599453);
432/// assert_eq!(ln1p_vec(&[0.0, 1.0, E, 10.0]), &[0.0, 0.6931471805599453, 1.3132616875182228, 2.3978952727983707]);
433/// ```
434/// <small>End Fun Doc</small>
435pub fn ln1p_vec(x: &[f64]) -> Vec<f64> {
436    x.iter().map(|&x| ln1p(x)).collect()
437}
438
439/// ### log2_vec(x)
440///
441/// Logarithm Function
442///
443/// The `log2_vec` function applies the base-2 logarithm to each element of `x`,
444/// returning a new vector containing the results of these computations.
445///
446/// ### Examples
447/// ```rust
448/// use mathlab::math::{log2, log2_vec, is_nan_f64, E, INF_F64 as inf, LN10};
449/// assert!(is_nan_f64(log2(-inf)));
450/// assert_eq!(log2(0.0), -inf);
451/// assert_eq!(log2(1.0), 0.0);
452/// assert_eq!(log2(E), 1.4426950408889634);
453/// assert_eq!(log2_vec(&[0.0, 1.0, E, LN10]), &[-inf, 0.0, 1.4426950408889634, 1.2032544726997219]);
454/// ```
455/// <small>End Fun Doc</small>
456pub fn log2_vec(x: &[f64]) -> Vec<f64> {
457    x.iter().map(|&x| log2(x)).collect()
458}
459
460/// ### log10_vec(x)
461///
462/// Logarithm Function
463///
464/// The `log10_vec` function applies the base-10 logarithm to each element of `x`,
465/// returning a new vector containing the results of these computations.
466///
467/// ### Examples
468/// ```rust
469/// use mathlab::math::{log10, log10_vec, is_nan_f64, E, INF_F64 as inf,};
470/// assert!(is_nan_f64(log10(-inf)));
471/// assert_eq!(log10(E), 0.4342944819032518);
472/// assert_eq!(log10_vec(&[0.0, 1.5, 10.0]), &[-inf, 0.17609125905568124, 1.0]);
473/// ```
474/// <small>End Fun Doc</small>
475pub fn log10_vec(x: &[f64]) -> Vec<f64> {
476    x.iter().map(|&x| log10(x)).collect()
477}
478
479/// ### fix64_vec(x)
480///
481/// Fixation Function
482///
483/// The `fix64_vec` function converts a slice of `double precision floats` to their equivalent
484/// `fixed-point values` with `the same bit width`, returning them as a new vector.
485///
486/// ### Examples
487/// ```rust
488/// use mathlab::math::{fix64, fix64_vec};
489/// // assert_eq!(fix64("abc"), 0.3); // error: expected `f64`, found `&str`
490/// // assert_eq!(fix64("0.1"), 0.3); // error: expected `f64`, found `&str`
491/// // assert_eq!(fix64(1), 0.3); // error: expected `f64`, found integer
492/// assert_eq!(fix64(0.1 + 0.2), 0.3);
493/// assert_eq!(fix64(0.30000000000000004), 0.3);
494/// assert_eq!(fix64_vec(&[0.3, 0.30000000000000004, 0.1 + 0.2]), [0.3, 0.3, 0.3]);
495/// ```
496/// <small>End Fun Doc</small>
497pub fn fix64_vec(x: &[f64]) -> Vec<f64> {
498    x.iter().map(|&x| fix64(x)).collect()
499}
500
501/// ### cube_vec(x)
502///
503/// Native Function
504///
505/// The `cube_vec` function applies the cube operation elementwise to each
506/// number in input vector x, returning a new vector containing the results.
507///
508/// ### Examples
509/// ```rust
510/// use mathlab::math::{cube_vec, fix64_vec};
511/// assert_eq!(cube_vec(&[0.0, 0.1, 0.2]), [0.0, 0.0010000000000000002, 0.008000000000000002]);
512/// assert_eq!(fix64_vec(&cube_vec(&[0.0, 0.1, 0.2])), [0.0, 0.001, 0.008]);
513/// ```
514/// <small>End Fun Doc</small>
515pub fn cube_vec(x: &[f64]) -> Vec<f64> {
516    x.iter().map(|&x| cube(x)).collect()
517}
518
519/// ### cbrt_vec(x)
520///
521/// Native Function
522///
523/// The `cbrt_vec` function maps the cbrt function over each element in the provided float slice,
524/// collecting the resulting values into a new vector.
525///
526/// ### Examples
527/// ```rust
528/// use mathlab::math::{cbrt_vec, fix64_vec};
529/// assert_eq!(cbrt_vec(&[0.0, 0.001, 0.008]), [0.0, 0.1, 0.2]);
530/// assert_eq!(cbrt_vec(&[8.0, 27.0]), [2.0, 3.0]);
531/// assert_eq!(fix64_vec(&cbrt_vec(&[8.0, 27.0])), [2.0, 3.0]);
532/// ```
533/// <small>End Fun Doc</small>
534pub fn cbrt_vec(x: &[f64]) -> Vec<f64> {
535    x.iter().map(|&x| cbrt(x)).collect()
536}
537
538/// ### trunc_vec(x)
539///
540/// Rounding Function
541///
542/// The `trunc_vec` function performs rounding downwards (i.e. Truncation) on every single-precision
543/// floating-point number in the input slice, gathering the outcomes into a new vector.
544///
545/// ### Examples
546/// ```rust
547/// use mathlab::math::trunc_vec;
548/// assert_eq!(trunc_vec(&[-0.37, 0.37, -3.7, 3.7]), [0.0, 0.0, -3.0, 3.0]);
549/// ```
550/// <small>End Fun Doc</small>
551pub fn trunc_vec(x: &[f64]) -> Vec<f64> {
552    x.iter().map(|&x| trunc(x)).collect()
553}
554
555/// ### sin_vec(x)
556///
557/// Trigonometric Function
558///
559/// The `sin_vec` function calculates the sine value of each angle represented as a radian in the input iterator,
560/// constructing a new vector from these results.
561///
562/// ### Examples
563/// ```rust
564/// use mathlab::math::sin_vec;
565/// assert_eq!(sin_vec(&[0.0, 1e-10, 0.5235987756]), [0.0, 1e-10, 0.5]);
566/// ```
567/// <small>End Fun Doc</small>
568pub fn sin_vec(x: &[f64]) -> Vec<f64> {
569    x.iter().map(|&x| sin(x)).collect()
570}
571
572/// ### sin_deg_vec(x)
573///
574/// Trigonometric Function
575///
576/// The `sin_deg_vec` function calculates the sine value of each angle represented in degrees in the input iterator,
577/// constructing a new vector from these results.
578///
579/// ### Examples
580/// ```rust
581/// use mathlab::math::sin_deg_vec;
582/// assert_eq!(sin_deg_vec(&[0.0, 30.0, 45.0, 60.0, 90.0]), [0.0, 0.5, 0.7071067812, 0.8660254038, 1.0]);
583/// ```
584/// <small>End Fun Doc</small>
585pub fn sin_deg_vec(x: &[f64]) -> Vec<f64> {
586    x.iter().map(|&x| sin_deg(x)).collect()
587}
588
589/// ### asin_vec(x)
590///
591/// Inverse Trigonometric Function
592///
593/// The `asin_vec` function computes the inverse sine of each number in the input slice, returning a new vector of angles whose sine is equal to the corresponding input value, in radians.
594///
595/// ### Examples
596/// ```rust
597/// use mathlab::math::asin_vec;
598/// assert_eq!(asin_vec(&[0.0, 0.5, 0.7071067812, 0.8660254038, 1.0]), [0.0, 0.5235987756, 0.7853981634, 1.0471975512, 1.5707963268]);
599/// ```
600/// <small>End Fun Doc</small>
601pub fn asin_vec(x: &[f64]) -> Vec<f64> {
602    x.iter().map(|&x| asin(x)).collect()
603}
604
605/// ### asin_deg_vec(x)
606///
607/// Inverse Trigonometric Function
608///
609/// The `asin_deg_vec` function computes the inverse sine of each number in the input slice, returning a new vector of angles whose sine is equal to the corresponding input value, in degrees.
610///
611/// ### Examples
612/// ```rust
613/// use mathlab::math::asin_deg_vec;
614/// assert_eq!(asin_deg_vec(&[0.0, 0.5, 0.7071067812, 0.8660254038, 1.0]), [0.0, 30.0, 45.0, 60.0, 90.0]);
615/// ```
616/// <small>End Fun Doc</small>
617pub fn asin_deg_vec(x: &[f64]) -> Vec<f64> {
618    x.iter().map(|&x| asin_deg(x)).collect()
619}
620
621/// ### cos_vec(x)
622///
623/// Trigonometric Function
624///
625/// The `cos_vec` function calculates the cosine value of each angle represented as a radian in the input iterator,
626/// constructing a new vector from these results.
627///
628/// ### Examples
629/// ```rust
630/// use mathlab::math::{cos_vec, deg_to_rad_vec};
631/// assert_eq!(cos_vec(&[0.0, 1e-10, 1.0471975512]), [1.0, 1.0, 0.5]);
632/// ```
633/// <small>End Fun Doc</small>
634pub fn cos_vec(x: &[f64]) -> Vec<f64> {
635    x.iter().map(|&x| cos(x)).collect()
636}
637
638/// ### cos_deg_vec(x)
639///
640/// Trigonometric Function
641///
642/// The `cos_deg_vec` function calculates the cosine value of each angle represented in degrees in the input iterator,
643/// constructing a new vector from these results.
644///
645/// ### Examples
646/// ```rust
647/// use mathlab::math::cos_deg_vec;
648/// assert_eq!(cos_deg_vec(&[0.0, 30.0, 45.0, 60.0, 90.0]), [1.0, 0.8660254038, 0.7071067812, 0.5, 0.0]);
649/// ```
650/// <small>End Fun Doc</small>
651pub fn cos_deg_vec(x: &[f64]) -> Vec<f64> {
652    x.iter().map(|&x| cos_deg(x)).collect()
653}
654
655/// ### acos_vec(x)
656///
657/// Inverse Trigonometric Function
658///
659/// The `acos_vec` function computes the inverse cosine of each number in the input slice, returning a new vector of angles whose cosine is equal to the corresponding input value, in radians.
660///
661/// ### Examples
662/// ```rust
663/// use mathlab::math::acos_vec;
664/// assert_eq!(acos_vec(&[0.0, 0.5, 0.7071067812, 0.8660254038, 1.0]), [1.5707963268, 1.0471975512, 0.7853981634, 0.5235987756, 0.0]);
665/// ```
666/// <small>End Fun Doc</small>
667pub fn acos_vec(x: &[f64]) -> Vec<f64> {
668    x.iter().map(|&x| acos(x)).collect()
669}
670
671/// ### acos_deg_vec(x)
672///
673/// Inverse Trigonometric Function
674///
675/// The `acos_deg_vec` function computes the inverse cosine of each number in the input slice, returning a new vector of angles whose cosine is equal to the corresponding input value, in degrees.
676///
677/// ### Examples
678/// ```rust
679/// use mathlab::math::acos_deg_vec;
680/// assert_eq!(acos_deg_vec(&[0.0, 0.5, 0.7071067812, 0.8660254038, 1.0]), [90.0, 60.0, 45.0, 30.0, 0.0]);
681/// ```
682/// <small>End Fun Doc</small>
683pub fn acos_deg_vec(x: &[f64]) -> Vec<f64> {
684    x.iter().map(|&x| acos_deg(x)).collect()
685}
686
687/// ### tan_vec(x)
688///
689/// Trigonometric Function
690///
691/// The `tan_vec` function calculates the tangent value of each angle represented as a radian in the input iterator,
692/// constructing a new vector from these results.
693///
694/// ### Examples
695/// ```rust
696/// use mathlab::math::{tan_vec, deg_to_rad_vec};
697/// assert_eq!(tan_vec(&[0.0, 1e-10, 0.7853981634]), [0.0, 1e-10, 1.0]);
698/// ```
699/// <small>End Fun Doc</small>
700pub fn tan_vec(x: &[f64]) -> Vec<f64> {
701    x.iter().map(|&x| tan(x)).collect()
702}
703
704/// ### tan_deg_vec(x)
705///
706/// Trigonometric Function
707///
708/// The `tan_deg_vec` function calculates the tangent value of each angle represented in degrees in the input iterator,
709/// constructing a new vector from these results.
710///
711/// ### Examples
712/// ```rust
713/// use mathlab::math::{tan_deg_vec, INF_F64 as inf};
714/// assert_eq!(tan_deg_vec(&[0.0, 30.0, 45.0, 60.0, 90.0]), [0.0, 0.5773502692, 1.0, 1.7320508076, -inf]);
715/// ```
716/// <small>End Fun Doc</small>
717pub fn tan_deg_vec(x: &[f64]) -> Vec<f64> {
718    x.iter().map(|&x| tan_deg(x)).collect()
719}
720
721/// ### atan_vec(x)
722///
723/// Inverse Trigonometric Function
724///
725/// The `atan_vec` function computes the inverse tangent of each number in the input slice, returning a new vector of angles whose tangent is equal to the corresponding input value, in radians.
726///
727/// ### Examples
728/// ```rust
729/// use mathlab::math::{atan_vec, INF_F64 as inf};
730/// assert_eq!(atan_vec(&[0.0, 0.5773502692, 1.0, 1.7320508076, inf]), [0.0, 0.5235987756, 0.7853981634, 1.0471975512, 1.5707963268]);
731/// ```
732/// <small>End Fun Doc</small>
733pub fn atan_vec(x: &[f64]) -> Vec<f64> {
734    x.iter().map(|&x| atan(x)).collect()
735}
736
737/// ### atan_deg_vec(x)
738///
739/// Inverse Trigonometric Function
740///
741/// The `atan_deg_vec` function computes the inverse tangent of each number in the input slice, returning a new vector of angles whose tangent is equal to the corresponding input value, in degrees.
742///
743/// ### Examples
744/// ```rust
745/// use mathlab::math::{atan_deg_vec, INF_F64 as inf};
746/// assert_eq!(atan_deg_vec(&[0.0, 0.5773502692, 1.0, 1.7320508076, inf]), [0.0, 30.0, 45.0, 60.0, 90.0]);
747/// ```
748/// <small>End Fun Doc</small>
749pub fn atan_deg_vec(x: &[f64]) -> Vec<f64> {
750    x.iter().map(|&x| atan_deg(x)).collect()
751}
752
753/// ### csc_vec(x)
754///
755/// Trigonometric Function
756///
757/// The `csc_vec` function calculates the cosecant value of each angle represented as a radian in the input iterator,
758/// constructing a new vector from these results.
759///
760/// ### Examples
761/// ```rust
762/// use mathlab::math::{csc_vec, INF_F64 as inf};
763/// assert_eq!(csc_vec(&[0.0, 1e-10, 0.5235987756]), [inf, 10000000000.0, 2.0]);
764/// ```
765/// <small>End Fun Doc</small>
766pub fn csc_vec(x: &[f64]) -> Vec<f64> {
767    x.iter().map(|&x| csc(x)).collect()
768}
769
770/// ### csc_deg_vec(x)
771///
772/// Trigonometric Function
773///
774/// The `csc_deg_vec` function calculates the cosecant value of each angle represented in degrees in the input iterator,
775/// constructing a new vector from these results.
776///
777/// ### Examples
778/// ```rust
779/// use mathlab::math::{csc_deg_vec, INF_F64 as inf};
780/// assert_eq!(csc_deg_vec(&[0.0, 30.0, 45.0, 60.0, 90.0]), [inf, 2.0, 1.4142135623, 1.1547005384, 1.0]);
781/// ```
782/// <small>End Fun Doc</small>
783pub fn csc_deg_vec(x: &[f64]) -> Vec<f64> {
784    x.iter().map(|&x| csc_deg(x)).collect()
785}
786
787/// ### acsc_vec(x)
788///
789/// Inverse Trigonometric Function
790///
791/// The `acsc_vec` function computes the inverse cosecant of each number in the input slice, returning a new vector of angles whose cosecant is equal to the corresponding input value, in radians.
792///
793/// ### Examples
794/// ```rust
795/// use mathlab::math::{acsc_vec, INF_F64 as inf};
796/// assert_eq!(acsc_vec(&[inf, 10000000000.0, 2.0, 1.4142135623, 1.1547005384, 1.0]), [0.0, 1e-10, 0.5235987756, 0.7853981634, 1.0471975512, 1.5707963268]);
797/// ```
798/// <small>End Fun Doc</small>
799pub fn acsc_vec(x: &[f64]) -> Vec<f64> {
800    x.iter().map(|&x| acsc(x)).collect()
801}
802
803/// ### acsc_deg_vec(x)
804///
805/// Inverse Trigonometric Function
806///
807/// The `acsc_deg_vec` function computes the inverse cosecant of each number in the input slice, returning a new vector of angles whose cosecant is equal to the corresponding input value, in degrees.
808///
809/// ### Examples
810/// ```rust
811/// use mathlab::math::{acsc_deg_vec, INF_F64 as inf};
812/// assert_eq!(acsc_deg_vec(&[inf, 10000000000.0, 2.0, 1.4142135623, 1.1547005384, 1.0]), [0.0, 5.729578e-9, 30.0, 45.0, 60.0, 90.0]);
813/// ```
814/// <small>End Fun Doc</small>
815pub fn acsc_deg_vec(x: &[f64]) -> Vec<f64> {
816    x.iter().map(|&x| acsc_deg(x)).collect()
817}
818
819/// ### sec_vec(x)
820///
821/// Trigonometric Function
822///
823/// The `sec_vec` function calculates the secant value of each angle represented as a radian in the input iterator,
824/// constructing a new vector from these results.
825///
826/// ### Examples
827/// ```rust
828/// use mathlab::math::{sec_vec, INF_F64 as inf};
829/// assert_eq!(sec_vec(&[0.0, 1e-10, 1.0471975512]), [1.0, 1.0, 2.0]);
830/// ```
831/// <small>End Fun Doc</small>
832pub fn sec_vec(x: &[f64]) -> Vec<f64> {
833    x.iter().map(|&x| sec(x)).collect()
834}
835
836/// ### sec_deg_vec(x)
837///
838/// Trigonometric Function
839///
840/// The `sec_deg_vec` function calculates the secant value of each angle represented in degrees in the input iterator,
841/// constructing a new vector from these results.
842///
843/// ### Examples
844/// ```rust
845/// use mathlab::math::{sec_deg_vec, INF_F64 as inf};
846/// assert_eq!(sec_deg_vec(&[0.0, 30.0, 45.0, 60.0, 90.0]), [1.0, 1.1547005384, 1.4142135623, 2.0, -inf]);
847/// ```
848/// <small>End Fun Doc</small>
849pub fn sec_deg_vec(x: &[f64]) -> Vec<f64> {
850    x.iter().map(|&x| sec_deg(x)).collect()
851}
852
853/// ### asec_vec(x)
854///
855/// Inverse Trigonometric Function
856///
857/// The `asec_vec` function computes the inverse secant of each number in the input slice, returning a new vector of angles whose secant is equal to the corresponding input value, in radians.
858///
859/// ### Examples
860/// ```rust
861/// use mathlab::math::{asec_vec, INF_F64 as inf};
862/// assert_eq!(asec_vec(&[1.0, 1.1547005384, 1.4142135623, 2.0, -inf, -1.0]), [0.0, 0.5235987756, 0.7853981634, 1.0471975512, 1.5707963268, 3.1415926536]);
863/// ```
864/// <small>End Fun Doc</small>
865pub fn asec_vec(x: &[f64]) -> Vec<f64> {
866    x.iter().map(|&x| asec(x)).collect()
867}
868
869/// ### asec_deg_vec(x)
870///
871/// Inverse Trigonometric Function
872///
873/// The `asec_deg_vec` function computes the inverse secant of each number in the input slice, returning a new vector of angles whose secant is equal to the corresponding input value, in degrees.
874///
875/// ### Examples
876/// ```rust
877/// use mathlab::math::{asec_deg_vec, INF_F64 as inf};
878/// assert_eq!(asec_deg_vec(&[1.0, 1.1547005384, 1.4142135623, 2.0, -inf, -1.0]), [0.0, 30.0, 45.0, 60.0, 90.0, 180.0]);
879/// ```
880/// <small>End Fun Doc</small>
881pub fn asec_deg_vec(x: &[f64]) -> Vec<f64> {
882    x.iter().map(|&x| asec_deg(x)).collect()
883}
884
885/// ### cot_vec(x)
886///
887/// Trigonometric Function
888///
889/// The `cot_vec` function calculates the cotangent value of each angle represented as a radian in the input iterator,
890/// constructing a new vector from these results.
891///
892/// ### Examples
893/// ```rust
894/// use mathlab::math::{cot_vec, INF_F64 as inf};
895/// assert_eq!(cot_vec(&[0.0, 1e-10, 1.0471975512]), [inf, 10000000000.0, 0.5773502692]);
896/// ```
897/// <small>End Fun Doc</small>
898pub fn cot_vec(x: &[f64]) -> Vec<f64> {
899    x.iter().map(|&x| cot(x)).collect()
900}
901
902/// ### cot_deg_vec(x)
903///
904/// Trigonometric Function
905///
906/// The `cot_deg_vec` function calculates the cotangent value of each angle represented in degrees in the input iterator,
907/// constructing a new vector from these results.
908///
909/// ### Examples
910/// ```rust
911/// use mathlab::math::{cot_deg_vec, INF_F64 as inf};
912/// assert_eq!(cot_deg_vec(&[0.0, 30.0, 45.0, 60.0, 90.0]), [inf, 1.7320508076, 1.0, 0.5773502692, 0.0]);
913/// ```
914/// <small>End Fun Doc</small>
915pub fn cot_deg_vec(x: &[f64]) -> Vec<f64> {
916    x.iter().map(|&x| cot_deg(x)).collect()
917}
918
919/// ### acot_vec(x)
920///
921/// Inverse Trigonometric Function
922///
923/// The `acot_vec` function computes the inverse cotangent of each number in the input slice, returning a new vector of angles whose cotangent is equal to the corresponding input value, in radians.
924///
925/// ### Examples
926/// ```rust
927/// use mathlab::math::{acot_vec, INF_F64 as inf};
928/// assert_eq!(acot_vec(&[inf, 1.7320508076, 1.0, 0.5773502692, 0.0]), [0.0, 0.5235987756, 0.7853981634, 1.0471975512, 1.5707963268]);
929/// ```
930/// <small>End Fun Doc</small>
931pub fn acot_vec(x: &[f64]) -> Vec<f64> {
932    x.iter().map(|&x| acot(x)).collect()
933}
934
935/// ### acot_deg_vec(x)
936///
937/// Inverse Trigonometric Function
938///
939/// The `acot_deg_vec` function computes the inverse cotangent of each number in the input slice, returning a new vector of angles whose cotangent is equal to the corresponding input value, in degrees.
940///
941/// ### Examples
942/// ```rust
943/// use mathlab::math::{acot_deg_vec, INF_F64 as inf};
944/// assert_eq!(acot_deg_vec(&[inf, 1.7320508076, 1.0, 0.5773502692, 0.0]), [0.0, 30.0, 45.0, 60.0, 90.0]);
945/// ```
946/// <small>End Fun Doc</small>
947pub fn acot_deg_vec(x: &[f64]) -> Vec<f64> {
948    x.iter().map(|&x| acot_deg(x)).collect()
949}
950
951/// ### sinh_vec(x)
952///
953/// Hyperbolic Function
954///
955/// The `sinh_vec` function calculates the hyperbolic sine value of each angle represented as a radian in the input iterator,
956/// constructing a new vector from these results.
957///
958/// ### Examples
959/// ```rust
960/// use mathlab::math::sinh_vec;
961/// assert_eq!(sinh_vec(&[0.0, 0.523598775598299, 3.141592653589793]), [0.0, 0.547853473888040, 11.548739357257748]);
962/// ```
963/// <small>End Fun Doc</small>
964pub fn sinh_vec(x: &[f64]) -> Vec<f64> {
965    x.iter().map(|&x| sinh(x)).collect()
966}
967
968/// ### sinh_deg_vec(x)
969///
970/// Hyperbolic Function
971///
972/// The `sinh_deg_vec` function calculates the hyperbolic sine value of each angle represented as a degree in the input iterator,
973/// constructing a new vector from these results.
974///
975/// ### Examples
976/// ```rust
977/// use mathlab::math::sinh_deg_vec;
978/// assert_eq!(sinh_deg_vec(&[0.0, 30.0, 180.0]), [0.0, 0.547853473888040, 11.548739357257748]);
979/// ```
980/// <small>End Fun Doc</small>
981pub fn sinh_deg_vec(x: &[f64]) -> Vec<f64> {
982    x.iter().map(|&x| sinh_deg(x)).collect()
983}
984
985/// ### cosh_vec(x)
986///
987/// Hyperbolic Function
988///
989/// The `cosh_vec` function calculates the hyperbolic cosine value of each angle represented as a radian in the input iterator,
990/// constructing a new vector from these results.
991///
992/// ### Examples
993/// ```rust
994/// use mathlab::math::cosh_vec;
995/// assert_eq!(cosh_vec(&[0.0, 0.523598775598299, 3.141592653589793]), [1.0, 1.140238321076429, 11.591953275521519]);
996/// ```
997/// <small>End Fun Doc</small>
998pub fn cosh_vec(x: &[f64]) -> Vec<f64> {
999    x.iter().map(|&x| cosh(x)).collect()
1000}
1001
1002/// ### cosh_vec(x)
1003///
1004/// Hyperbolic Function
1005///
1006/// The `cosh_deg_vec` function calculates the hyperbolic cosine value of each angle represented as a degree in the input iterator,
1007/// constructing a new vector from these results.
1008///
1009/// ### Examples
1010/// ```rust
1011/// use mathlab::math::cosh_deg_vec;
1012/// assert_eq!(cosh_deg_vec(&[0.0, 30.0, 180.0]), [1.0, 1.140238321076429, 11.591953275521519]);
1013/// ```
1014/// <small>End Fun Doc</small>
1015pub fn cosh_deg_vec(x: &[f64]) -> Vec<f64> {
1016    x.iter().map(|&x| cosh_deg(x)).collect()
1017}
1018
1019/// ### tanh_vec(x)
1020///
1021/// Hyperbolic Function
1022///
1023/// The `tanh_vec` function calculates the hyperbolic tangent value of each angle represented as a radian in the input iterator,
1024/// constructing a new vector from these results.
1025///
1026/// ### Examples
1027/// ```rust
1028/// use mathlab::math::tanh_vec;
1029/// assert_eq!(tanh_vec(&[0.0, 0.523598775598299, 3.141592653589793]), [0.0, 0.480472778156452, 0.99627207622075]);
1030/// ```
1031/// <small>End Fun Doc</small>
1032pub fn tanh_vec(x: &[f64]) -> Vec<f64> {
1033    x.iter().map(|&x| tanh(x)).collect()
1034}
1035
1036/// ### tanh_deg_vec(x)
1037///
1038/// Hyperbolic Function
1039///
1040/// The `tanh_deg_vec` function calculates the hyperbolic tangent value of each angle represented as a degree in the input iterator,
1041/// constructing a new vector from these results.
1042///
1043/// ### Examples
1044/// ```rust
1045/// use mathlab::math::tanh_deg_vec;
1046/// assert_eq!(tanh_deg_vec(&[0.0, 30.0, 180.0]), [0.0, 0.480472778156452, 0.99627207622075]);
1047/// ```
1048/// <small>End Fun Doc</small>
1049pub fn tanh_deg_vec(x: &[f64]) -> Vec<f64> {
1050    x.iter().map(|&x| tanh_deg(x)).collect()
1051}
1052
1053/// ### csch_vec(x)
1054///
1055/// Hyperbolic Function
1056///
1057/// The `csch_vec` function calculates the hyperbolic cosecant value of each angle represented as a radian in the input iterator,
1058/// constructing a new vector from these results.
1059///
1060/// ### Examples
1061/// ```rust
1062/// use mathlab::math::{csch_vec, INF_F64 as inf};
1063/// assert_eq!(csch_vec(&[0.0, 0.523598775598299, 3.141592653589793]), [inf, 1.825305574687952, 0.086589537530047]);
1064/// ```
1065/// <small>End Fun Doc</small>
1066pub fn csch_vec(x: &[f64]) -> Vec<f64> {
1067    x.iter().map(|&x| csch(x)).collect()
1068}
1069
1070/// ### csch_deg_vec(x)
1071///
1072/// Hyperbolic Function
1073///
1074/// The `csch_deg_vec` function calculates the hyperbolic cosecant value of each angle represented as a degree in the input iterator,
1075/// constructing a new vector from these results.
1076///
1077/// ### Examples
1078/// ```rust
1079/// use mathlab::math::{csch_deg_vec, INF_F64 as inf};
1080/// assert_eq!(csch_deg_vec(&[0.0, 30.0, 180.0]), [inf, 1.825305574687954, 0.086589537530047]);
1081/// ```
1082/// <small>End Fun Doc</small>
1083pub fn csch_deg_vec(x: &[f64]) -> Vec<f64> {
1084    x.iter().map(|&x| csch_deg(x)).collect()
1085}
1086
1087/// ### sech_vec(x)
1088///
1089/// Hyperbolic Function
1090///
1091/// The `sech_vec` function calculates the hyperbolic secant value of each angle represented as a radian in the input iterator,
1092/// constructing a new vector from these results.
1093///
1094/// ### Examples
1095/// ```rust
1096/// use mathlab::math::sech_vec;
1097/// assert_eq!(sech_vec(&[0.0, 0.523598775598299, 3.141592653589793]), [1.0, 0.877009640454779, 0.086266738334054]);
1098/// ```
1099/// <small>End Fun Doc</small>
1100pub fn sech_vec(x: &[f64]) -> Vec<f64> {
1101    x.iter().map(|&x| sech(x)).collect()
1102}
1103
1104/// ### sech_deg_vec(x)
1105///
1106/// Hyperbolic Function
1107///
1108/// The `sech_deg_vec` function calculates the hyperbolic secant value of each angle represented as a degree in the input iterator,
1109/// constructing a new vector from these results.
1110///
1111/// ### Examples
1112/// ```rust
1113/// use mathlab::math::sech_deg_vec;
1114/// assert_eq!(sech_deg_vec(&[0.0, 30.0, 180.0]), [1.0, 0.877009640454779, 0.086266738334054]);
1115/// ```
1116/// <small>End Fun Doc</small>
1117pub fn sech_deg_vec(x: &[f64]) -> Vec<f64> {
1118    x.iter().map(|&x| sech_deg(x)).collect()
1119}
1120
1121/// ### coth_vec(x)
1122///
1123/// Hyperbolic Function
1124///
1125/// The `coth_vec` function calculates the hyperbolic cotangent value of each angle represented as a radian in the input iterator,
1126/// constructing a new vector from these results.
1127///
1128/// ### Examples
1129/// ```rust
1130/// use mathlab::math::{coth_vec, INF_F64 as inf};
1131/// assert_eq!(coth_vec(&[0.0, 0.523598775598299, 3.141592653589793]), [inf, 2.081283363933637, 1.003741873197321]);
1132/// ```
1133/// <small>End Fun Doc</small>
1134pub fn coth_vec(x: &[f64]) -> Vec<f64> {
1135    x.iter().map(|&x| coth(x)).collect()
1136}
1137
1138/// ### coth_deg_vec(x)
1139///
1140/// Hyperbolic Function
1141///
1142/// The `coth_deg_vec` function calculates the hyperbolic cotangent value of each angle represented as a degree in the input iterator,
1143/// constructing a new vector from these results.
1144///
1145/// ### Examples
1146/// ```rust
1147/// use mathlab::math::{coth_deg_vec, INF_F64 as inf};
1148/// assert_eq!(coth_deg_vec(&[0.0, 30.0, 180.0]), [inf, 2.081283363933638, 1.003741873197321]);
1149/// ```
1150/// <small>End Fun Doc</small>
1151pub fn coth_deg_vec(x: &[f64]) -> Vec<f64> {
1152    x.iter().map(|&x| coth_deg(x)).collect()
1153}
1154
1155/// ### asinh_vec(x)
1156///
1157/// Inverse Hyperbolic Function
1158///
1159/// The `asinh_vec` function calculates the inverse hyperbolic sine value of each element in the input vector, represented as a `radian`.
1160/// The result is a new vector containing the `arcsinh` values, which are the angles that correspond to the input values.
1161///
1162/// ### Examples
1163/// ```rust
1164/// use mathlab::math::asinh_vec;
1165/// assert_eq!(asinh_vec(&[0.0, 0.547853473888040, 11.548739357257748]), [0.0, 0.523598775598299, 3.141592653589793]);
1166/// ```
1167/// <small>End Fun Doc</small>
1168pub fn asinh_vec(x: &[f64]) -> Vec<f64> {
1169    x.iter().map(|&x| asinh(x)).collect()
1170}
1171
1172/// ### asinh_deg_vec(x)
1173///
1174/// Inverse Hyperbolic Function
1175///
1176/// The `asinh_deg_vec` function calculates the inverse hyperbolic sine value of each element in the input vector, represented as a `degree`.
1177/// The result is a new vector containing the `arcsinh` values, which are the angles that correspond to the input values.
1178///
1179/// ### Examples
1180/// ```rust
1181/// use mathlab::math::asinh_deg_vec;
1182/// assert_eq!(asinh_deg_vec(&[0.0, 0.547853473888040, 11.548739357257748]), [0.0, 30.0, 180.0]);
1183/// ```
1184/// <small>End Fun Doc</small>
1185pub fn asinh_deg_vec(x: &[f64]) -> Vec<f64> {
1186    x.iter().map(|&x| asinh_deg(x)).collect()
1187}
1188
1189/// ### acosh_vec(x)
1190///
1191/// Inverse Hyperbolic Function
1192///
1193/// The `acosh_vec` function calculates the inverse hyperbolic cosine value of each element in the input vector, represented as a `radian`.
1194/// The result is a new vector containing the `arccosh` values, which are the angles that correspond to the input values.
1195///
1196/// ### Examples
1197/// ```rust
1198/// use mathlab::math::acosh_vec;
1199/// assert_eq!(acosh_vec(&[1.0, 1.140238321076429, 11.591953275521519]), [0.0, 0.523598775598299, 3.141592653589793]);
1200/// ```
1201/// <small>End Fun Doc</small>
1202pub fn acosh_vec(x: &[f64]) -> Vec<f64> {
1203    x.iter().map(|&x| acosh(x)).collect()
1204}
1205
1206/// ### acosh_deg_vec(x)
1207///
1208/// Inverse Hyperbolic Function
1209///
1210/// The `acosh_deg_vec` function calculates the inverse hyperbolic cosine value of each element in the input vector, represented as a `degree`.
1211/// The result is a new vector containing the `arccosh` values, which are the angles that correspond to the input values.
1212///
1213/// ### Examples
1214/// ```rust
1215/// use mathlab::math::acosh_deg_vec;
1216/// assert_eq!(acosh_deg_vec(&[1.0, 1.140238321076429, 11.591953275521519]), [0.0, 30.0, 180.0]);
1217/// ```
1218/// <small>End Fun Doc</small>
1219pub fn acosh_deg_vec(x: &[f64]) -> Vec<f64> {
1220    x.iter().map(|&x| acosh_deg(x)).collect()
1221}
1222
1223/// ### atanh_vec(x)
1224///
1225/// Inverse Hyperbolic Function
1226///
1227/// The `atanh_vec` function calculates the inverse hyperbolic tangent value of each element in the input vector, represented as a `radian`.
1228/// The result is a new vector containing the `arctanh` values, which are the angles that correspond to the input values.
1229///
1230/// ### Examples
1231/// ```rust
1232/// use mathlab::math::atanh_vec;
1233/// assert_eq!(atanh_vec(&[0.0, 0.480472778156452, 0.99627207622075]), [0.0, 0.523598775598299, 3.141592653589798]);
1234/// ```
1235/// <small>End Fun Doc</small>
1236pub fn atanh_vec(x: &[f64]) -> Vec<f64> {
1237    x.iter().map(|&x| atanh(x)).collect()
1238}
1239
1240/// ### atanh_deg_vec(x)
1241///
1242/// Inverse Hyperbolic Function
1243///
1244/// The `atanh_deg_vec` function calculates the inverse hyperbolic tangent value of each element in the input vector, represented as a `degree`.
1245/// The result is a new vector containing the `arctanh` values, which are the angles that correspond to the input values.
1246///
1247/// ### Examples
1248/// ```rust
1249/// use mathlab::math::atanh_deg_vec;
1250/// assert_eq!(atanh_deg_vec(&[0.0, 0.480472778156452, 0.99627207622075]), [0.0, 30.0, 180.0]);
1251/// ```
1252/// <small>End Fun Doc</small>
1253pub fn atanh_deg_vec(x: &[f64]) -> Vec<f64> {
1254    x.iter().map(|&x| atanh_deg(x)).collect()
1255}
1256
1257/// ### acsch_vec(x)
1258///
1259/// Inverse Hyperbolic Function
1260///
1261/// The `acsch_vec` function calculates the inverse hyperbolic cosecant value of each element in the input vector, represented as a `radian`.
1262/// The result is a new vector containing the `arccsch` values, which are the angles that correspond to the input values.
1263///
1264/// ### Examples
1265/// ```rust
1266/// use mathlab::math::{acsch_vec, INF_F64 as inf};
1267/// assert_eq!(acsch_vec(&[0.0, 1.825305574687952, 0.086589537530047]), [inf, 0.523598775598299, 3.141592653589793]);
1268/// ```
1269/// <small>End Fun Doc</small>
1270pub fn acsch_vec(x: &[f64]) -> Vec<f64> {
1271    x.iter().map(|&x| acsch(x)).collect()
1272}
1273
1274/// ### acsch_deg_vec(x)
1275///
1276/// Inverse Hyperbolic Function
1277///
1278/// The `acsch_deg_vec` function calculates the inverse hyperbolic cosecant value of each element in the input vector, represented as a `degree`.
1279/// The result is a new vector containing the `arccsch` values, which are the angles that correspond to the input values.
1280///
1281/// ### Examples
1282/// ```rust
1283/// use mathlab::math::{acsch_deg_vec, INF_F64 as inf};
1284/// assert_eq!(acsch_deg_vec(&[0.0, 1.825305574687952, 0.086589537530047]), [inf, 30.0, 180.0]);
1285/// ```
1286/// <small>End Fun Doc</small>
1287pub fn acsch_deg_vec(x: &[f64]) -> Vec<f64> {
1288    x.iter().map(|&x| acsch_deg(x)).collect()
1289}
1290
1291/// ### asech_vec(x)
1292///
1293/// Inverse Hyperbolic Function
1294///
1295/// The `asech_vec` function calculates the inverse hyperbolic secant value of each element in the input vector, represented as a `radian`.
1296/// The result is a new vector containing the `arcsech` values, which are the angles that correspond to the input values.
1297///
1298/// ### Examples
1299/// ```rust
1300/// use mathlab::math::{asech_vec, INF_F64 as inf};
1301/// assert_eq!(asech_vec(&[0.0, 0.877009640454779, 0.086266738334054]), [inf, 0.523598775598299, 3.141592653589798]);
1302/// ```
1303/// <small>End Fun Doc</small>
1304pub fn asech_vec(x: &[f64]) -> Vec<f64> {
1305    x.iter().map(|&x| asech(x)).collect()
1306}
1307
1308/// ### asech_deg_vec(x)
1309///
1310/// Inverse Hyperbolic Function
1311///
1312/// The `asech_deg_vec` function calculates the inverse hyperbolic secant value of each element in the input vector, represented as a `degree`.
1313/// The result is a new vector containing the `arcsech` values, which are the angles that correspond to the input values.
1314///
1315/// ### Examples
1316/// ```rust
1317/// use mathlab::math::{asech_deg_vec, INF_F64 as inf};
1318/// assert_eq!(asech_deg_vec(&[0.0, 0.877009640454779, 0.086266738334054]), [inf, 30.0, 180.0]);
1319/// ```
1320/// <small>End Fun Doc</small>
1321pub fn asech_deg_vec(x: &[f64]) -> Vec<f64> {
1322    x.iter().map(|&x| asech_deg(x)).collect()
1323}
1324
1325/// ### acoth_vec(x)
1326///
1327/// Inverse Hyperbolic Function
1328///
1329/// The `acoth_vec` function calculates the inverse hyperbolic cotangent value of each element in the input vector, represented as a `radian`.
1330/// The result is a new vector containing the `arccoth` values, which are the angles that correspond to the input values.
1331///
1332/// ### Examples
1333/// ```rust
1334/// use mathlab::math::{acoth_vec, INF_F64 as inf};
1335/// assert_eq!(acoth_vec(&[inf, 2.081283363933637, 1.003741873197321]), [0.0, 0.523598775598299, 3.141592653589813]);
1336/// ```
1337/// <small>End Fun Doc</small>
1338pub fn acoth_vec(x: &[f64]) -> Vec<f64> {
1339    x.iter().map(|&x| acoth(x)).collect()
1340}
1341
1342/// ### acoth_deg_vec(x)
1343///
1344/// Inverse Hyperbolic Function
1345///
1346/// The `acoth_deg_vec` function calculates the inverse hyperbolic cotangent value of each element in the input vector, represented as a `degree`.
1347/// The result is a new vector containing the `arccoth` values, which are the angles that correspond to the input values.
1348///
1349/// ### Examples
1350/// ```rust
1351/// use mathlab::math::{acoth_deg_vec, INF_F64 as inf};
1352/// assert_eq!(acoth_deg_vec(&[inf, 2.081283363933637, 1.003741873197321]), [0.0, 30.0, 180.0]);
1353/// ```
1354/// <small>End Fun Doc</small>
1355pub fn acoth_deg_vec(x: &[f64]) -> Vec<f64> {
1356    x.iter().map(|&x| acoth_deg(x)).collect()
1357}
1358
1359/// ### rand_vec(size)
1360///
1361/// Generates a vector of pseudo-random `u64` numbers based on the specified digit sizes.
1362///
1363/// The `size` parameter is a slice of sizes, each representing the number of digits for the corresponding
1364/// random number to be generated. The function will cap each size at 19 to ensure the generated numbers fit
1365/// within the limits of `u64`, preventing overflow.
1366///
1367/// ### Parameters
1368/// - `size`: A slice containing desired digit counts for each random number. Each value must be greater than 0.
1369///
1370/// ### Returns
1371/// A `Vec<u64>` containing random numbers, each with digit counts specified in the `size` slice, capped at 19.
1372///
1373/// ### Examples
1374/// ```rust
1375/// use mathlab::math::rand_vec;
1376///
1377/// fn main() {
1378///    // Generating and printing vectors of random numbers with different sizes
1379///    let sizes = vec![1, 2, 3, 6, 15, 19, 25]; // 25 will be capped at 19
1380///    let random_numbers = rand_vec(&sizes);
1381///
1382///    for (size, number) in sizes.iter().zip(random_numbers.iter()) {
1383///        println!("Random number (size {}): {:?}", size, number);
1384///    }
1385/// }
1386/// ```
1387/// <small>End Fun Doc</small>
1388pub fn rand_vec(size: &[usize]) -> Vec<u64> {
1389    size.iter().map(|&size| rand(size)).collect()
1390}
1391
1392/// ### string_to_u64_vec(strings)
1393///
1394/// Converts a vector of strings into a vector of `u64` values.
1395///
1396/// This function attempts to parse each string in the input vector. If a string fails to parse,
1397/// the corresponding entry in the output vector will be an `Err` containing the parsing error.
1398///
1399/// ### Parameters
1400/// - `strings`: A vector of strings to be converted into `u64` values.
1401///
1402/// ### Returns
1403/// A `Vec<Result<u64, std::num::ParseIntError>>` where each element is a `Result`.
1404/// An `Ok` value represents a successful conversion to `u64`, while an `Err` value indicates a failure.
1405///
1406/// ### Examples
1407/// ```rust
1408/// use mathlab::math::string_to_u64_vec;
1409///
1410/// fn main() {
1411///     let string_numbers = vec![
1412///         "42".to_string(),
1413///         "100".to_string(),
1414///         "not_a_number".to_string(),
1415///         "300".to_string(),
1416///     ];
1417///
1418///     let results = string_to_u64_vec(string_numbers);
1419///
1420///     for (i, result) in results.iter().enumerate() {
1421///         match result {
1422///             Ok(num) => println!("String {} converted to u64: {}", i, num),
1423///             Err(e) => println!("Failed to convert string {}: {}", i, e),
1424///         }
1425///     }
1426/// }
1427/// ```
1428/// <small>End Fun Doc</small>
1429pub fn string_to_u64_vec(strings: Vec<String>) -> Vec<Result<u64, std::num::ParseIntError>> {
1430    strings.into_iter().map(|s| string_to_u64(s)).collect()
1431}