mathlab 1.5.0

A Powerful Math Library for Rust
Documentation
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
use super::{
    num::{
        abs, acos, acos_deg, acosh, acosh_deg, acot, acot_deg, acoth, acoth_deg, acsc, acsc_deg,
        acsch, acsch_deg, asec, asec_deg, asech, asech_deg, asin, asin_deg, asinh, asinh_deg, atan,
        atan_deg, atanh, atanh_deg, cbrt, ceil, cos, cos_deg, cosh, cosh_deg, cot, cot_deg, coth,
        coth_deg, csc, csc_deg, csch, csch_deg, cube, deg_to_rad, exp, f64_to_f32, fact, fix64,
        floor, fround, gamma, i64_to_f64, inv, ln, ln1p, log10, log2, rad_to_deg, round, sec,
        sec_deg, sech, sech_deg, sign, sin, sin_deg, sinh, sinh_deg, sqr, sqrt, tan, tan_deg, tanh,
        tanh_deg, trunc, u64_to_f64,
    },
    rand, string_to_u64,
};
/// ### abs_vec(x)
///
/// Native Function
///
/// The `abs_vec` function takes a single parameter, a slice of floating-point numbers (`&[f64]`),
/// and returns a vector (`Vec<f64>`) containing the absolute values of each element in the input slice.
/// The function iterates over each element in the slice,
/// computes its absolute value, and collects the results into a new vector.
///
/// The `abs_vec` function can be written in two ways:
///
/// ```rust
/// use mathlab::math::abs;
/// let my_x_f64_array = [0.0, -1.0, 3.33, -3.33];
/// // with a reference (&)
/// pub fn abs_vec(x: &[f64]) -> Vec<f64> {
///     x.iter().map(|&x| x.abs()).collect()
/// }
///
/// assert_eq!(abs_vec(&my_x_f64_array), [0.0, 1.0, 3.33, 3.33]);
/// ```
///
/// or directly without a reference `&`
///
/// ```rust
/// use mathlab::math::abs;
/// let my_x_f64_array = [0.0, -1.0, 3.33, -3.33];
/// pub fn abs_vec<const N: usize>(x: [f64; N]) -> Vec<f64> {
///     x.iter().map(|&x| x.abs()).collect()
/// }
///
/// assert_eq!(abs_vec(my_x_f64_array), vec![0.0, 1.0, 3.33, 3.33]);
/// ```
///
/// For most cases, using a slice (`&[f64]`) is more efficient and flexible,
/// especially for larger arrays or when the function needs to handle variable-length input.
/// It avoids the overhead of copying the entire array and allows the function
/// to work with any contiguous memory block.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{abs, abs_vec};
/// let my_x_f64_array = [0.0, -1.0, 3.33, -3.33];
/// assert_eq!(abs(-1.0), 1.0);
/// assert_eq!(abs_vec(&my_x_f64_array), [0.0, 1.0, 3.33, 3.33]);
/// ```
/// <small>End Fun Doc</small>
pub fn abs_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| abs(x)).collect()
}

/// ### sign_vec(x)
///
/// Native Function
///
/// The `sign_vec` function takes a slice of floating-point numbers (`&[f64]`)
/// and returns a vector (`Vec<f64>`) containing the sign of each element in the input slice.
/// It iterates over each element, applies the sign function, and collects the results into a new vector.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{sign, sign_vec};
/// let my_x_f64_array = [-9.0, 9.0, --9.5, 6.0 - 15.0, 0.0, 0.0 / 0.0];
/// assert_eq!(sign(-9.0), -1.0);
/// assert_eq!(sign_vec(&my_x_f64_array), [-1.0, 1.0, 1.0, -1.0, 0.0, 0.0]);
/// ```
/// <small>End Fun Doc</small>
pub fn sign_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| sign(x)).collect()
}

/// ### fact_vec(x)
///
/// Native Function
///
/// The `fact_vec` function takes a slice of `unsigned` `64-bit` integers
/// and returns a vector containing the factorial of each element in the input slice.
/// It iterates over the input slice, computes the factorial of each element using the fact function,
/// and collects the results into a vector.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{fact, fact_vec, u64_to_f64_vec};
/// let my_x_u64_array = [0, 1, 2, 3, 16, 18];
/// assert_eq!(fact(3), 6);
/// assert_eq!(fact(3) as f64, 6.0);
/// assert_eq!(fact_vec(&my_x_u64_array), [1, 1, 2, 6, 20922789888000, 6402373705728000]);
/// 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]);
/// assert_eq!(u64_to_f64_vec(&fact_vec(&my_x_u64_array)), [1.0, 1.0, 2.0, 6.0, 20922789888000.0, 6402373705728000.0]);
/// ```
/// <small>End Fun Doc</small>
pub fn fact_vec(x: &[u64]) -> Vec<u64> {
    x.iter().map(|&x| fact(x)).collect()
}

/// ### gamma_vec(x)
///
/// Extended Factorial Function
///
/// The `gamma_vec` function takes a slice of `64-bit unsigned` integers (`&[u64]`)
/// and returns a vector of `64-bit unsigned` integers (`Vec<u64]`).
/// It applies the gamma function to each element in the input slice and collects the results into a new vector.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{gamma, gamma_vec, u64_to_f64_vec};
/// let my_x_u64_array = [1, 2, 3, 4, 17, 19];
/// assert_eq!(gamma(3), 2);
/// assert_eq!(gamma(3) as f64, 2.0);
/// assert_eq!(gamma_vec(&my_x_u64_array), [1, 1, 2, 6, 20922789888000, 6402373705728000]);
/// 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]);
/// assert_eq!(u64_to_f64_vec(&gamma_vec(&my_x_u64_array)), [1.0, 1.0, 2.0, 6.0, 20922789888000.0, 6402373705728000.0]);
/// ```
/// <small>End Fun Doc</small>
pub fn gamma_vec(x: &[u64]) -> Vec<u64> {
    x.iter().map(|&x| gamma(x)).collect()
}

/// ### inv_vec(x)
///
/// Native Function
///
/// The `inv_vec` function takes a slice of floating-point numbers `x` and
/// returns a new vector containing the inverses of each element in `x`
///
/// ### Examples
/// ```rust
/// use mathlab::math::{inv, inv_vec, INF_F64, INF_F32, fround_vec};
/// assert_eq!(inv(0.0), INF_F64);
/// assert_eq!(inv(0.1), 10.0);
/// assert_eq!(inv_vec(&[0.0, 0.1, 0.2, 0.3]), [INF_F64, 10.0, 5.0, 3.3333333333333335]);
/// assert_eq!(fround_vec(&inv_vec(&[0.0, 0.1, 0.2, 0.3])), [INF_F32, 10.0, 5.0, 3.3333333]);
/// assert_eq!(fround_vec(&inv_vec(&[0.0, 0.1, 0.2, 0.3])), [INF_F32, 10.0, 5.0, 3.3333333333333335]);
/// ```
/// <small>End Fun Doc</small>
pub fn inv_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| inv(x)).collect()
}

/// ### floor_vec(x)
///
/// Rounding Function
///
/// The `floor_vec` function takes a slice of `f64` values as input and returns
/// a `Vec<f64>` where each element is the floor value of the corresponding input element.
/// The floor value of a number is the largest integer less than or equal to that number.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{floor, floor_vec};
/// let my_x_f64_array = [0.0, 0.99, 1.01, 1.99, -0.99, -1.01, -1.99];
/// assert_eq!(floor(1.99), 1.0);
/// assert_eq!(floor_vec(&my_x_f64_array), [0.0, 0.0, 1.0, 1.0, -1.0, -2.0, -2.0]);
/// ```
/// <small>End Fun Doc</small>
pub fn floor_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| floor(x)).collect()
}

/// ### ceil_vec(x)
///
/// Rounding Function
///
/// The `ceil_vec` function takes a slice of `f64` values as input and returns
/// a `Vec<f64>` where each element is the ceiling value of the corresponding input element.
/// The ceiling value of a number is the smallest integer greater than or equal to that number.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{ceil, ceil_vec};
/// let my_x_f64_array = [0.0, 0.99, 1.01, 1.99, -0.99, -1.01, -1.99];
/// assert_eq!(ceil(1.99), 2.0);
/// assert_eq!(ceil_vec(&my_x_f64_array), [0.0, 1.0, 2.0, 2.0, 0.0, -1.0, -1.0]);
/// ```
/// <small>End Fun Doc</small>
pub fn ceil_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| ceil(x)).collect()
}

/// ### round_vec(x)
///
/// Rounding Function
///
/// The `round_vec` function takes a slice of `f64` values as input and returns
/// a `Vec<f64>` where each element is the rounded value of the corresponding input element.
/// The `round` function aligns a number to the closest integer,
/// adjusting fractions of `0.5` or greater up, and less than `0.5` down.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{round, round_vec};
/// let my_x_f64_array = [0.0, 0.5, 1.01, 1.49, 1.99, -0.5, -1.01, -1.49, -1.99];
/// assert_eq!(round(1.49), 1.0);
/// assert_eq!(round(1.5), 2.0);
/// 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]);
/// ```
/// <small>End Fun Doc</small>
pub fn round_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| round(x)).collect()
}

/// ### fround_vec(x)
///
/// Rounding Function
///
/// The `fround_vec` function takes a slice of `f64` values as input and returns
/// a `Vec<f32>` where each element is the `f32` representation of the corresponding input element.
/// The `fround` function converts a `f64` value to a `f32` value.
///
/// The `fround_vec` function performs the same operation as the `f64_to_f32_vec` function.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{fround, fround_vec};
/// let my_x_f64_array = [0.6666666666666666, 0.30000000000000004, 0.020000000000000004, 0.09999999999999998];
/// assert_eq!(fround(0.30000000000000004), 0.3);
/// assert_eq!(fround(0.09999999999999998), 0.1);
/// assert_eq!(fround_vec(&my_x_f64_array), [0.6666667, 0.3, 0.02, 0.1]);
/// ```
/// <small>End Fun Doc</small>
pub fn fround_vec(x: &[f64]) -> Vec<f32> {
    x.iter().map(|&x| fround(x)).collect()
}

/// ### f64_to_f32_vec(x)
///
/// Conversion Function
///
/// The `f64_to_f32_vec` function takes a slice of `f64` values as input and returns
/// a `Vec<f32>` where each element is the `f32` representation of the corresponding input element.
/// The `f64_to_f32` function converts a `f64` value to a `f32` value.
///
/// The `f64_to_f32_vec` function performs the same operation as the `fround_vec` function.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{f64_to_f32, f64_to_f32_vec};
/// let my_x_f64_array = [0.6666666666666666, 0.30000000000000004, 0.020000000000000004, 0.09999999999999998];
/// assert_eq!(f64_to_f32(0.30000000000000004), 0.3);
/// assert_eq!(f64_to_f32(0.09999999999999998), 0.1);
/// assert_eq!(f64_to_f32_vec(&my_x_f64_array), [0.6666667, 0.3, 0.02, 0.1]);
/// ```
/// <small>End Fun Doc</small>
pub fn f64_to_f32_vec(x: &[f64]) -> Vec<f32> {
    x.iter().map(|&x| f64_to_f32(x)).collect()
}

/// ### u64_to_f64_vec(x)
///
/// Conversion Function
///
/// The `u64_to_f64_vec` function takes a slice of `u64` values as input
/// and returns a `Vec<f64>` where each element is the `f64`
/// representation of the corresponding input element using the `u64_to_f64` function.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{u64_to_f64, u64_to_f64_vec};
/// let my_x_f64_array = [0, 1, 2, 3];
/// assert_eq!(u64_to_f64(0), 0.0);
/// assert_eq!(u64_to_f64_vec(&my_x_f64_array), [0.0, 1.0, 2.0, 3.0]);
/// ```
/// <small>End Fun Doc</small>
pub fn u64_to_f64_vec(x: &[u64]) -> Vec<f64> {
    x.iter().map(|&x| u64_to_f64(x)).collect()
}

/// ### i64_to_f64_vec(x)
///
/// Conversion Function
///
/// The `i64_to_f64_vec` function takes a slice of `i64` values as input
/// and returns a `Vec<f64>` where each element is the `f64`
/// representation of the corresponding input element using the `i64_to_f64` function.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{i64_to_f64, i64_to_f64_vec};
/// let my_x_f64_array = [-1, -2, 0, 1, 2];
/// assert_eq!(i64_to_f64(0), 0.0);
/// assert_eq!(i64_to_f64_vec(&my_x_f64_array), [-1.0, -2.0, 0.0, 1.0, 2.0]);
/// ```
/// <small>End Fun Doc</small>
pub fn i64_to_f64_vec(x: &[i64]) -> Vec<f64> {
    x.iter().map(|&x| i64_to_f64(x)).collect()
}

/// ### deg_to_rad_vec(x)
///
/// Conversion Function
///
/// The `deg_to_rad_vec` function takes a slice of `f64` values
/// representing `angles` in `degrees` and returns a `Vec<f64>`
/// containing the corresponding `angles` in `radians`.
/// It uses the `deg_to_rad` function to convert each `angle` from `degrees` to `radians`.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{deg_to_rad, deg_to_rad_vec};
/// let my_x_f64_array = [0.0, 1.0, 30.0, 45.0, 60.0, 90.0, 180.0, 360.0, -360.0];
/// assert_eq!(deg_to_rad(30.0), 0.5235987756);
/// 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]);
/// ```
/// <small>End Fun Doc</small>
pub fn deg_to_rad_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| deg_to_rad(x)).collect()
}

/// ### rad_to_deg_vec(x)
///
/// Conversion Function
///
/// The `rad_to_deg_vec` function takes a slice of `f64` values
/// representing `angles` in `radians` and returns a `Vec<f64>`
/// containing the corresponding `angles` in `degrees`.
/// It uses the `rad_to_deg` function to convert each `angle` from `radians` to `degrees`.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{rad_to_deg, rad_to_deg_vec};
/// let my_x_f64_array = [0.0, 0.0174532925, 0.5235987756, 0.7853981634, 1.0471975512, 1.5707963268, 3.1415926536, 6.2831853072, -6.2831853072];
/// assert_eq!(rad_to_deg(0.5235987756), 30.0);
/// 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]);
/// ```
/// <small>End Fun Doc</small>
pub fn rad_to_deg_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| rad_to_deg(x)).collect()
}

/// ### sqr_vec(x)
///
/// Native Function
///
/// The `sqr_vec` function applies the `sqr` operation to every element of a provided slice of floats,
/// collecting their squares into a new vector.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{sqr, sqr_vec, INF_F64, INF_F32, fround_vec};
/// assert_eq!(sqr(0.1), 0.010000000000000002);
/// assert_eq!(sqr(0.1) as f32, 0.01);
/// 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]);
/// 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]);
/// ```
/// <small>End Fun Doc</small>
pub fn sqr_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| sqr(x)).collect()
}

/// ### sqrt_vec(x)
///
/// Native Function
///
/// The `sqrt_vec` function takes a slice of floating-point numbers as input and applies the square root operation
/// to each element in the slice, returning a new vector containing the squared roots of the original elements.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{sqrt, sqrt_vec, INF_F64 as inf};
/// assert_eq!(sqrt(0.01), 0.1);
/// 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]);
/// ```
/// <small>End Fun Doc</small>
pub fn sqrt_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| sqrt(x)).collect()
}

/// ### exp_vec(x)
///
/// Operation Function
///
/// The `exp_vec` function applies the exponential function `exp(x)` to each element
/// of a provided slice of floats, collects their results into a new vector.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{exp, exp_vec, E};
/// assert_eq!(exp(0.0), 1.0);
/// assert_eq!(exp(-1.0) as f32, 0.36787945);
/// assert_eq!(exp_vec(&[-1.0, 0.0, 1.0]), &[0.36787944117144233, 1.0, E]);
/// ```
/// <small>End Fun Doc</small>
pub fn exp_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| exp(x)).collect()
}

/// ### ln_vec(x)
///
/// Logarithm Function
///
/// The `ln_vec` function applies the natural logarithm `ln` to each element of a given slice of floats,
/// producing a new vector containing the resultant values.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{ln, ln_vec, is_nan_f64, E, INF_F64 as inf, LN10};
/// assert!(is_nan_f64(ln(-inf)));
/// assert_eq!(ln(10.0), 2.302585092994046);
/// assert_eq!(ln_vec(&[0.0, 1.0, E, 10.0, 1.5]), &[-inf, 0.0, 1.0, LN10, 0.4054651081081644]);
/// ```
/// <small>End Fun Doc</small>
pub fn ln_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| ln(x)).collect()
}

/// ### ln1p_vec(x)
///
/// Logarithm Function
///
/// The `ln1p_vec` function computes the natural logarithm (base e) of all elements in a slice,
/// accounting for numerically stable evaluation near zero through the use of the "Lambert W" function,
/// returns the results as a new vector.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{ln1p, ln1p_vec, is_nan_f64, E, INF_F64 as inf, LN10};
/// assert!(is_nan_f64(ln1p(-inf)));
/// assert_eq!(ln1p(0.0), 0.0);
/// assert_eq!(ln1p(1.0), 0.6931471805599453);
/// assert_eq!(ln1p_vec(&[0.0, 1.0, E, 10.0]), &[0.0, 0.6931471805599453, 1.3132616875182228, 2.3978952727983707]);
/// ```
/// <small>End Fun Doc</small>
pub fn ln1p_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| ln1p(x)).collect()
}

/// ### log2_vec(x)
///
/// Logarithm Function
///
/// The `log2_vec` function applies the base-2 logarithm to each element of `x`,
/// returning a new vector containing the results of these computations.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{log2, log2_vec, is_nan_f64, E, INF_F64 as inf, LN10};
/// assert!(is_nan_f64(log2(-inf)));
/// assert_eq!(log2(0.0), -inf);
/// assert_eq!(log2(1.0), 0.0);
/// assert_eq!(log2(E), 1.4426950408889634);
/// assert_eq!(log2_vec(&[0.0, 1.0, E, LN10]), &[-inf, 0.0, 1.4426950408889634, 1.2032544726997219]);
/// ```
/// <small>End Fun Doc</small>
pub fn log2_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| log2(x)).collect()
}

/// ### log10_vec(x)
///
/// Logarithm Function
///
/// The `log10_vec` function applies the base-10 logarithm to each element of `x`,
/// returning a new vector containing the results of these computations.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{log10, log10_vec, is_nan_f64, E, INF_F64 as inf,};
/// assert!(is_nan_f64(log10(-inf)));
/// assert_eq!(log10(E), 0.4342944819032518);
/// assert_eq!(log10_vec(&[0.0, 1.5, 10.0]), &[-inf, 0.17609125905568124, 1.0]);
/// ```
/// <small>End Fun Doc</small>
pub fn log10_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| log10(x)).collect()
}

/// ### fix64_vec(x)
///
/// Fixation Function
///
/// The `fix64_vec` function converts a slice of `double precision floats` to their equivalent
/// `fixed-point values` with `the same bit width`, returning them as a new vector.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{fix64, fix64_vec};
/// // assert_eq!(fix64("abc"), 0.3); // error: expected `f64`, found `&str`
/// // assert_eq!(fix64("0.1"), 0.3); // error: expected `f64`, found `&str`
/// // assert_eq!(fix64(1), 0.3); // error: expected `f64`, found integer
/// assert_eq!(fix64(0.1 + 0.2), 0.3);
/// assert_eq!(fix64(0.30000000000000004), 0.3);
/// assert_eq!(fix64_vec(&[0.3, 0.30000000000000004, 0.1 + 0.2]), [0.3, 0.3, 0.3]);
/// ```
/// <small>End Fun Doc</small>
pub fn fix64_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| fix64(x)).collect()
}

/// ### cube_vec(x)
///
/// Native Function
///
/// The `cube_vec` function applies the cube operation elementwise to each
/// number in input vector x, returning a new vector containing the results.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{cube_vec, fix64_vec};
/// assert_eq!(cube_vec(&[0.0, 0.1, 0.2]), [0.0, 0.0010000000000000002, 0.008000000000000002]);
/// assert_eq!(fix64_vec(&cube_vec(&[0.0, 0.1, 0.2])), [0.0, 0.001, 0.008]);
/// ```
/// <small>End Fun Doc</small>
pub fn cube_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| cube(x)).collect()
}

/// ### cbrt_vec(x)
///
/// Native Function
///
/// The `cbrt_vec` function maps the cbrt function over each element in the provided float slice,
/// collecting the resulting values into a new vector.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{cbrt_vec, fix64_vec};
/// assert_eq!(cbrt_vec(&[0.0, 0.001, 0.008]), [0.0, 0.1, 0.2]);
/// assert_eq!(cbrt_vec(&[8.0, 27.0]), [2.0, 3.0]);
/// assert_eq!(fix64_vec(&cbrt_vec(&[8.0, 27.0])), [2.0, 3.0]);
/// ```
/// <small>End Fun Doc</small>
pub fn cbrt_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| cbrt(x)).collect()
}

/// ### trunc_vec(x)
///
/// Rounding Function
///
/// The `trunc_vec` function performs rounding downwards (i.e. Truncation) on every single-precision
/// floating-point number in the input slice, gathering the outcomes into a new vector.
///
/// ### Examples
/// ```rust
/// use mathlab::math::trunc_vec;
/// assert_eq!(trunc_vec(&[-0.37, 0.37, -3.7, 3.7]), [0.0, 0.0, -3.0, 3.0]);
/// ```
/// <small>End Fun Doc</small>
pub fn trunc_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| trunc(x)).collect()
}

/// ### sin_vec(x)
///
/// Trigonometric Function
///
/// The `sin_vec` function calculates the sine value of each angle represented as a radian in the input iterator,
/// constructing a new vector from these results.
///
/// ### Examples
/// ```rust
/// use mathlab::math::sin_vec;
/// assert_eq!(sin_vec(&[0.0, 1e-10, 0.5235987756]), [0.0, 1e-10, 0.5]);
/// ```
/// <small>End Fun Doc</small>
pub fn sin_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| sin(x)).collect()
}

/// ### sin_deg_vec(x)
///
/// Trigonometric Function
///
/// The `sin_deg_vec` function calculates the sine value of each angle represented in degrees in the input iterator,
/// constructing a new vector from these results.
///
/// ### Examples
/// ```rust
/// use mathlab::math::sin_deg_vec;
/// 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]);
/// ```
/// <small>End Fun Doc</small>
pub fn sin_deg_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| sin_deg(x)).collect()
}

/// ### asin_vec(x)
///
/// Inverse Trigonometric Function
///
/// 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.
///
/// ### Examples
/// ```rust
/// use mathlab::math::asin_vec;
/// assert_eq!(asin_vec(&[0.0, 0.5, 0.7071067812, 0.8660254038, 1.0]), [0.0, 0.5235987756, 0.7853981634, 1.0471975512, 1.5707963268]);
/// ```
/// <small>End Fun Doc</small>
pub fn asin_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| asin(x)).collect()
}

/// ### asin_deg_vec(x)
///
/// Inverse Trigonometric Function
///
/// 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.
///
/// ### Examples
/// ```rust
/// use mathlab::math::asin_deg_vec;
/// 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]);
/// ```
/// <small>End Fun Doc</small>
pub fn asin_deg_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| asin_deg(x)).collect()
}

/// ### cos_vec(x)
///
/// Trigonometric Function
///
/// The `cos_vec` function calculates the cosine value of each angle represented as a radian in the input iterator,
/// constructing a new vector from these results.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{cos_vec, deg_to_rad_vec};
/// assert_eq!(cos_vec(&[0.0, 1e-10, 1.0471975512]), [1.0, 1.0, 0.5]);
/// ```
/// <small>End Fun Doc</small>
pub fn cos_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| cos(x)).collect()
}

/// ### cos_deg_vec(x)
///
/// Trigonometric Function
///
/// The `cos_deg_vec` function calculates the cosine value of each angle represented in degrees in the input iterator,
/// constructing a new vector from these results.
///
/// ### Examples
/// ```rust
/// use mathlab::math::cos_deg_vec;
/// 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]);
/// ```
/// <small>End Fun Doc</small>
pub fn cos_deg_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| cos_deg(x)).collect()
}

/// ### acos_vec(x)
///
/// Inverse Trigonometric Function
///
/// 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.
///
/// ### Examples
/// ```rust
/// use mathlab::math::acos_vec;
/// assert_eq!(acos_vec(&[0.0, 0.5, 0.7071067812, 0.8660254038, 1.0]), [1.5707963268, 1.0471975512, 0.7853981634, 0.5235987756, 0.0]);
/// ```
/// <small>End Fun Doc</small>
pub fn acos_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| acos(x)).collect()
}

/// ### acos_deg_vec(x)
///
/// Inverse Trigonometric Function
///
/// 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.
///
/// ### Examples
/// ```rust
/// use mathlab::math::acos_deg_vec;
/// 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]);
/// ```
/// <small>End Fun Doc</small>
pub fn acos_deg_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| acos_deg(x)).collect()
}

/// ### tan_vec(x)
///
/// Trigonometric Function
///
/// The `tan_vec` function calculates the tangent value of each angle represented as a radian in the input iterator,
/// constructing a new vector from these results.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{tan_vec, deg_to_rad_vec};
/// assert_eq!(tan_vec(&[0.0, 1e-10, 0.7853981634]), [0.0, 1e-10, 1.0]);
/// ```
/// <small>End Fun Doc</small>
pub fn tan_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| tan(x)).collect()
}

/// ### tan_deg_vec(x)
///
/// Trigonometric Function
///
/// The `tan_deg_vec` function calculates the tangent value of each angle represented in degrees in the input iterator,
/// constructing a new vector from these results.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{tan_deg_vec, INF_F64 as inf};
/// assert_eq!(tan_deg_vec(&[0.0, 30.0, 45.0, 60.0, 90.0]), [0.0, 0.5773502692, 1.0, 1.7320508076, -inf]);
/// ```
/// <small>End Fun Doc</small>
pub fn tan_deg_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| tan_deg(x)).collect()
}

/// ### atan_vec(x)
///
/// Inverse Trigonometric Function
///
/// 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.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{atan_vec, INF_F64 as inf};
/// assert_eq!(atan_vec(&[0.0, 0.5773502692, 1.0, 1.7320508076, inf]), [0.0, 0.5235987756, 0.7853981634, 1.0471975512, 1.5707963268]);
/// ```
/// <small>End Fun Doc</small>
pub fn atan_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| atan(x)).collect()
}

/// ### atan_deg_vec(x)
///
/// Inverse Trigonometric Function
///
/// 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.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{atan_deg_vec, INF_F64 as inf};
/// assert_eq!(atan_deg_vec(&[0.0, 0.5773502692, 1.0, 1.7320508076, inf]), [0.0, 30.0, 45.0, 60.0, 90.0]);
/// ```
/// <small>End Fun Doc</small>
pub fn atan_deg_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| atan_deg(x)).collect()
}

/// ### csc_vec(x)
///
/// Trigonometric Function
///
/// The `csc_vec` function calculates the cosecant value of each angle represented as a radian in the input iterator,
/// constructing a new vector from these results.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{csc_vec, INF_F64 as inf};
/// assert_eq!(csc_vec(&[0.0, 1e-10, 0.5235987756]), [inf, 10000000000.0, 2.0]);
/// ```
/// <small>End Fun Doc</small>
pub fn csc_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| csc(x)).collect()
}

/// ### csc_deg_vec(x)
///
/// Trigonometric Function
///
/// The `csc_deg_vec` function calculates the cosecant value of each angle represented in degrees in the input iterator,
/// constructing a new vector from these results.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{csc_deg_vec, INF_F64 as inf};
/// assert_eq!(csc_deg_vec(&[0.0, 30.0, 45.0, 60.0, 90.0]), [inf, 2.0, 1.4142135623, 1.1547005384, 1.0]);
/// ```
/// <small>End Fun Doc</small>
pub fn csc_deg_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| csc_deg(x)).collect()
}

/// ### acsc_vec(x)
///
/// Inverse Trigonometric Function
///
/// 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.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{acsc_vec, INF_F64 as inf};
/// 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]);
/// ```
/// <small>End Fun Doc</small>
pub fn acsc_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| acsc(x)).collect()
}

/// ### acsc_deg_vec(x)
///
/// Inverse Trigonometric Function
///
/// 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.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{acsc_deg_vec, INF_F64 as inf};
/// 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]);
/// ```
/// <small>End Fun Doc</small>
pub fn acsc_deg_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| acsc_deg(x)).collect()
}

/// ### sec_vec(x)
///
/// Trigonometric Function
///
/// The `sec_vec` function calculates the secant value of each angle represented as a radian in the input iterator,
/// constructing a new vector from these results.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{sec_vec, INF_F64 as inf};
/// assert_eq!(sec_vec(&[0.0, 1e-10, 1.0471975512]), [1.0, 1.0, 2.0]);
/// ```
/// <small>End Fun Doc</small>
pub fn sec_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| sec(x)).collect()
}

/// ### sec_deg_vec(x)
///
/// Trigonometric Function
///
/// The `sec_deg_vec` function calculates the secant value of each angle represented in degrees in the input iterator,
/// constructing a new vector from these results.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{sec_deg_vec, INF_F64 as inf};
/// assert_eq!(sec_deg_vec(&[0.0, 30.0, 45.0, 60.0, 90.0]), [1.0, 1.1547005384, 1.4142135623, 2.0, -inf]);
/// ```
/// <small>End Fun Doc</small>
pub fn sec_deg_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| sec_deg(x)).collect()
}

/// ### asec_vec(x)
///
/// Inverse Trigonometric Function
///
/// 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.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{asec_vec, INF_F64 as inf};
/// 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]);
/// ```
/// <small>End Fun Doc</small>
pub fn asec_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| asec(x)).collect()
}

/// ### asec_deg_vec(x)
///
/// Inverse Trigonometric Function
///
/// 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.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{asec_deg_vec, INF_F64 as inf};
/// 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]);
/// ```
/// <small>End Fun Doc</small>
pub fn asec_deg_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| asec_deg(x)).collect()
}

/// ### cot_vec(x)
///
/// Trigonometric Function
///
/// The `cot_vec` function calculates the cotangent value of each angle represented as a radian in the input iterator,
/// constructing a new vector from these results.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{cot_vec, INF_F64 as inf};
/// assert_eq!(cot_vec(&[0.0, 1e-10, 1.0471975512]), [inf, 10000000000.0, 0.5773502692]);
/// ```
/// <small>End Fun Doc</small>
pub fn cot_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| cot(x)).collect()
}

/// ### cot_deg_vec(x)
///
/// Trigonometric Function
///
/// The `cot_deg_vec` function calculates the cotangent value of each angle represented in degrees in the input iterator,
/// constructing a new vector from these results.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{cot_deg_vec, INF_F64 as inf};
/// assert_eq!(cot_deg_vec(&[0.0, 30.0, 45.0, 60.0, 90.0]), [inf, 1.7320508076, 1.0, 0.5773502692, 0.0]);
/// ```
/// <small>End Fun Doc</small>
pub fn cot_deg_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| cot_deg(x)).collect()
}

/// ### acot_vec(x)
///
/// Inverse Trigonometric Function
///
/// 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.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{acot_vec, INF_F64 as inf};
/// assert_eq!(acot_vec(&[inf, 1.7320508076, 1.0, 0.5773502692, 0.0]), [0.0, 0.5235987756, 0.7853981634, 1.0471975512, 1.5707963268]);
/// ```
/// <small>End Fun Doc</small>
pub fn acot_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| acot(x)).collect()
}

/// ### acot_deg_vec(x)
///
/// Inverse Trigonometric Function
///
/// 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.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{acot_deg_vec, INF_F64 as inf};
/// assert_eq!(acot_deg_vec(&[inf, 1.7320508076, 1.0, 0.5773502692, 0.0]), [0.0, 30.0, 45.0, 60.0, 90.0]);
/// ```
/// <small>End Fun Doc</small>
pub fn acot_deg_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| acot_deg(x)).collect()
}

/// ### sinh_vec(x)
///
/// Hyperbolic Function
///
/// The `sinh_vec` function calculates the hyperbolic sine value of each angle represented as a radian in the input iterator,
/// constructing a new vector from these results.
///
/// ### Examples
/// ```rust
/// use mathlab::math::sinh_vec;
/// assert_eq!(sinh_vec(&[0.0, 0.523598775598299, 3.141592653589793]), [0.0, 0.547853473888040, 11.548739357257748]);
/// ```
/// <small>End Fun Doc</small>
pub fn sinh_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| sinh(x)).collect()
}

/// ### sinh_deg_vec(x)
///
/// Hyperbolic Function
///
/// The `sinh_deg_vec` function calculates the hyperbolic sine value of each angle represented as a degree in the input iterator,
/// constructing a new vector from these results.
///
/// ### Examples
/// ```rust
/// use mathlab::math::sinh_deg_vec;
/// assert_eq!(sinh_deg_vec(&[0.0, 30.0, 180.0]), [0.0, 0.547853473888040, 11.548739357257748]);
/// ```
/// <small>End Fun Doc</small>
pub fn sinh_deg_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| sinh_deg(x)).collect()
}

/// ### cosh_vec(x)
///
/// Hyperbolic Function
///
/// The `cosh_vec` function calculates the hyperbolic cosine value of each angle represented as a radian in the input iterator,
/// constructing a new vector from these results.
///
/// ### Examples
/// ```rust
/// use mathlab::math::cosh_vec;
/// assert_eq!(cosh_vec(&[0.0, 0.523598775598299, 3.141592653589793]), [1.0, 1.140238321076429, 11.591953275521519]);
/// ```
/// <small>End Fun Doc</small>
pub fn cosh_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| cosh(x)).collect()
}

/// ### cosh_vec(x)
///
/// Hyperbolic Function
///
/// The `cosh_deg_vec` function calculates the hyperbolic cosine value of each angle represented as a degree in the input iterator,
/// constructing a new vector from these results.
///
/// ### Examples
/// ```rust
/// use mathlab::math::cosh_deg_vec;
/// assert_eq!(cosh_deg_vec(&[0.0, 30.0, 180.0]), [1.0, 1.140238321076429, 11.591953275521519]);
/// ```
/// <small>End Fun Doc</small>
pub fn cosh_deg_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| cosh_deg(x)).collect()
}

/// ### tanh_vec(x)
///
/// Hyperbolic Function
///
/// The `tanh_vec` function calculates the hyperbolic tangent value of each angle represented as a radian in the input iterator,
/// constructing a new vector from these results.
///
/// ### Examples
/// ```rust
/// use mathlab::math::tanh_vec;
/// assert_eq!(tanh_vec(&[0.0, 0.523598775598299, 3.141592653589793]), [0.0, 0.480472778156452, 0.99627207622075]);
/// ```
/// <small>End Fun Doc</small>
pub fn tanh_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| tanh(x)).collect()
}

/// ### tanh_deg_vec(x)
///
/// Hyperbolic Function
///
/// The `tanh_deg_vec` function calculates the hyperbolic tangent value of each angle represented as a degree in the input iterator,
/// constructing a new vector from these results.
///
/// ### Examples
/// ```rust
/// use mathlab::math::tanh_deg_vec;
/// assert_eq!(tanh_deg_vec(&[0.0, 30.0, 180.0]), [0.0, 0.480472778156452, 0.99627207622075]);
/// ```
/// <small>End Fun Doc</small>
pub fn tanh_deg_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| tanh_deg(x)).collect()
}

/// ### csch_vec(x)
///
/// Hyperbolic Function
///
/// The `csch_vec` function calculates the hyperbolic cosecant value of each angle represented as a radian in the input iterator,
/// constructing a new vector from these results.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{csch_vec, INF_F64 as inf};
/// assert_eq!(csch_vec(&[0.0, 0.523598775598299, 3.141592653589793]), [inf, 1.825305574687952, 0.086589537530047]);
/// ```
/// <small>End Fun Doc</small>
pub fn csch_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| csch(x)).collect()
}

/// ### csch_deg_vec(x)
///
/// Hyperbolic Function
///
/// The `csch_deg_vec` function calculates the hyperbolic cosecant value of each angle represented as a degree in the input iterator,
/// constructing a new vector from these results.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{csch_deg_vec, INF_F64 as inf};
/// assert_eq!(csch_deg_vec(&[0.0, 30.0, 180.0]), [inf, 1.825305574687954, 0.086589537530047]);
/// ```
/// <small>End Fun Doc</small>
pub fn csch_deg_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| csch_deg(x)).collect()
}

/// ### sech_vec(x)
///
/// Hyperbolic Function
///
/// The `sech_vec` function calculates the hyperbolic secant value of each angle represented as a radian in the input iterator,
/// constructing a new vector from these results.
///
/// ### Examples
/// ```rust
/// use mathlab::math::sech_vec;
/// assert_eq!(sech_vec(&[0.0, 0.523598775598299, 3.141592653589793]), [1.0, 0.877009640454779, 0.086266738334054]);
/// ```
/// <small>End Fun Doc</small>
pub fn sech_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| sech(x)).collect()
}

/// ### sech_deg_vec(x)
///
/// Hyperbolic Function
///
/// The `sech_deg_vec` function calculates the hyperbolic secant value of each angle represented as a degree in the input iterator,
/// constructing a new vector from these results.
///
/// ### Examples
/// ```rust
/// use mathlab::math::sech_deg_vec;
/// assert_eq!(sech_deg_vec(&[0.0, 30.0, 180.0]), [1.0, 0.877009640454779, 0.086266738334054]);
/// ```
/// <small>End Fun Doc</small>
pub fn sech_deg_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| sech_deg(x)).collect()
}

/// ### coth_vec(x)
///
/// Hyperbolic Function
///
/// The `coth_vec` function calculates the hyperbolic cotangent value of each angle represented as a radian in the input iterator,
/// constructing a new vector from these results.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{coth_vec, INF_F64 as inf};
/// assert_eq!(coth_vec(&[0.0, 0.523598775598299, 3.141592653589793]), [inf, 2.081283363933637, 1.003741873197321]);
/// ```
/// <small>End Fun Doc</small>
pub fn coth_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| coth(x)).collect()
}

/// ### coth_deg_vec(x)
///
/// Hyperbolic Function
///
/// The `coth_deg_vec` function calculates the hyperbolic cotangent value of each angle represented as a degree in the input iterator,
/// constructing a new vector from these results.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{coth_deg_vec, INF_F64 as inf};
/// assert_eq!(coth_deg_vec(&[0.0, 30.0, 180.0]), [inf, 2.081283363933638, 1.003741873197321]);
/// ```
/// <small>End Fun Doc</small>
pub fn coth_deg_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| coth_deg(x)).collect()
}

/// ### asinh_vec(x)
///
/// Inverse Hyperbolic Function
///
/// The `asinh_vec` function calculates the inverse hyperbolic sine value of each element in the input vector, represented as a `radian`.
/// The result is a new vector containing the `arcsinh` values, which are the angles that correspond to the input values.
///
/// ### Examples
/// ```rust
/// use mathlab::math::asinh_vec;
/// assert_eq!(asinh_vec(&[0.0, 0.547853473888040, 11.548739357257748]), [0.0, 0.523598775598299, 3.141592653589793]);
/// ```
/// <small>End Fun Doc</small>
pub fn asinh_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| asinh(x)).collect()
}

/// ### asinh_deg_vec(x)
///
/// Inverse Hyperbolic Function
///
/// The `asinh_deg_vec` function calculates the inverse hyperbolic sine value of each element in the input vector, represented as a `degree`.
/// The result is a new vector containing the `arcsinh` values, which are the angles that correspond to the input values.
///
/// ### Examples
/// ```rust
/// use mathlab::math::asinh_deg_vec;
/// assert_eq!(asinh_deg_vec(&[0.0, 0.547853473888040, 11.548739357257748]), [0.0, 30.0, 180.0]);
/// ```
/// <small>End Fun Doc</small>
pub fn asinh_deg_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| asinh_deg(x)).collect()
}

/// ### acosh_vec(x)
///
/// Inverse Hyperbolic Function
///
/// The `acosh_vec` function calculates the inverse hyperbolic cosine value of each element in the input vector, represented as a `radian`.
/// The result is a new vector containing the `arccosh` values, which are the angles that correspond to the input values.
///
/// ### Examples
/// ```rust
/// use mathlab::math::acosh_vec;
/// assert_eq!(acosh_vec(&[1.0, 1.140238321076429, 11.591953275521519]), [0.0, 0.523598775598299, 3.141592653589793]);
/// ```
/// <small>End Fun Doc</small>
pub fn acosh_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| acosh(x)).collect()
}

/// ### acosh_deg_vec(x)
///
/// Inverse Hyperbolic Function
///
/// The `acosh_deg_vec` function calculates the inverse hyperbolic cosine value of each element in the input vector, represented as a `degree`.
/// The result is a new vector containing the `arccosh` values, which are the angles that correspond to the input values.
///
/// ### Examples
/// ```rust
/// use mathlab::math::acosh_deg_vec;
/// assert_eq!(acosh_deg_vec(&[1.0, 1.140238321076429, 11.591953275521519]), [0.0, 30.0, 180.0]);
/// ```
/// <small>End Fun Doc</small>
pub fn acosh_deg_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| acosh_deg(x)).collect()
}

/// ### atanh_vec(x)
///
/// Inverse Hyperbolic Function
///
/// The `atanh_vec` function calculates the inverse hyperbolic tangent value of each element in the input vector, represented as a `radian`.
/// The result is a new vector containing the `arctanh` values, which are the angles that correspond to the input values.
///
/// ### Examples
/// ```rust
/// use mathlab::math::atanh_vec;
/// assert_eq!(atanh_vec(&[0.0, 0.480472778156452, 0.99627207622075]), [0.0, 0.523598775598299, 3.141592653589798]);
/// ```
/// <small>End Fun Doc</small>
pub fn atanh_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| atanh(x)).collect()
}

/// ### atanh_deg_vec(x)
///
/// Inverse Hyperbolic Function
///
/// The `atanh_deg_vec` function calculates the inverse hyperbolic tangent value of each element in the input vector, represented as a `degree`.
/// The result is a new vector containing the `arctanh` values, which are the angles that correspond to the input values.
///
/// ### Examples
/// ```rust
/// use mathlab::math::atanh_deg_vec;
/// assert_eq!(atanh_deg_vec(&[0.0, 0.480472778156452, 0.99627207622075]), [0.0, 30.0, 180.0]);
/// ```
/// <small>End Fun Doc</small>
pub fn atanh_deg_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| atanh_deg(x)).collect()
}

/// ### acsch_vec(x)
///
/// Inverse Hyperbolic Function
///
/// The `acsch_vec` function calculates the inverse hyperbolic cosecant value of each element in the input vector, represented as a `radian`.
/// The result is a new vector containing the `arccsch` values, which are the angles that correspond to the input values.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{acsch_vec, INF_F64 as inf};
/// assert_eq!(acsch_vec(&[0.0, 1.825305574687952, 0.086589537530047]), [inf, 0.523598775598299, 3.141592653589793]);
/// ```
/// <small>End Fun Doc</small>
pub fn acsch_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| acsch(x)).collect()
}

/// ### acsch_deg_vec(x)
///
/// Inverse Hyperbolic Function
///
/// The `acsch_deg_vec` function calculates the inverse hyperbolic cosecant value of each element in the input vector, represented as a `degree`.
/// The result is a new vector containing the `arccsch` values, which are the angles that correspond to the input values.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{acsch_deg_vec, INF_F64 as inf};
/// assert_eq!(acsch_deg_vec(&[0.0, 1.825305574687952, 0.086589537530047]), [inf, 30.0, 180.0]);
/// ```
/// <small>End Fun Doc</small>
pub fn acsch_deg_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| acsch_deg(x)).collect()
}

/// ### asech_vec(x)
///
/// Inverse Hyperbolic Function
///
/// The `asech_vec` function calculates the inverse hyperbolic secant value of each element in the input vector, represented as a `radian`.
/// The result is a new vector containing the `arcsech` values, which are the angles that correspond to the input values.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{asech_vec, INF_F64 as inf};
/// assert_eq!(asech_vec(&[0.0, 0.877009640454779, 0.086266738334054]), [inf, 0.523598775598299, 3.141592653589798]);
/// ```
/// <small>End Fun Doc</small>
pub fn asech_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| asech(x)).collect()
}

/// ### asech_deg_vec(x)
///
/// Inverse Hyperbolic Function
///
/// The `asech_deg_vec` function calculates the inverse hyperbolic secant value of each element in the input vector, represented as a `degree`.
/// The result is a new vector containing the `arcsech` values, which are the angles that correspond to the input values.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{asech_deg_vec, INF_F64 as inf};
/// assert_eq!(asech_deg_vec(&[0.0, 0.877009640454779, 0.086266738334054]), [inf, 30.0, 180.0]);
/// ```
/// <small>End Fun Doc</small>
pub fn asech_deg_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| asech_deg(x)).collect()
}

/// ### acoth_vec(x)
///
/// Inverse Hyperbolic Function
///
/// The `acoth_vec` function calculates the inverse hyperbolic cotangent value of each element in the input vector, represented as a `radian`.
/// The result is a new vector containing the `arccoth` values, which are the angles that correspond to the input values.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{acoth_vec, INF_F64 as inf};
/// assert_eq!(acoth_vec(&[inf, 2.081283363933637, 1.003741873197321]), [0.0, 0.523598775598299, 3.141592653589813]);
/// ```
/// <small>End Fun Doc</small>
pub fn acoth_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| acoth(x)).collect()
}

/// ### acoth_deg_vec(x)
///
/// Inverse Hyperbolic Function
///
/// The `acoth_deg_vec` function calculates the inverse hyperbolic cotangent value of each element in the input vector, represented as a `degree`.
/// The result is a new vector containing the `arccoth` values, which are the angles that correspond to the input values.
///
/// ### Examples
/// ```rust
/// use mathlab::math::{acoth_deg_vec, INF_F64 as inf};
/// assert_eq!(acoth_deg_vec(&[inf, 2.081283363933637, 1.003741873197321]), [0.0, 30.0, 180.0]);
/// ```
/// <small>End Fun Doc</small>
pub fn acoth_deg_vec(x: &[f64]) -> Vec<f64> {
    x.iter().map(|&x| acoth_deg(x)).collect()
}

/// ### rand_vec(size)
///
/// Generates a vector of pseudo-random `u64` numbers based on the specified digit sizes.
///
/// The `size` parameter is a slice of sizes, each representing the number of digits for the corresponding
/// random number to be generated. The function will cap each size at 19 to ensure the generated numbers fit
/// within the limits of `u64`, preventing overflow.
///
/// ### Parameters
/// - `size`: A slice containing desired digit counts for each random number. Each value must be greater than 0.
///
/// ### Returns
/// A `Vec<u64>` containing random numbers, each with digit counts specified in the `size` slice, capped at 19.
///
/// ### Examples
/// ```rust
/// use mathlab::math::rand_vec;
///
/// fn main() {
///    // Generating and printing vectors of random numbers with different sizes
///    let sizes = vec![1, 2, 3, 6, 15, 19, 25]; // 25 will be capped at 19
///    let random_numbers = rand_vec(&sizes);
///
///    for (size, number) in sizes.iter().zip(random_numbers.iter()) {
///        println!("Random number (size {}): {:?}", size, number);
///    }
/// }
/// ```
/// <small>End Fun Doc</small>
pub fn rand_vec(size: &[usize]) -> Vec<u64> {
    size.iter().map(|&size| rand(size)).collect()
}

/// ### string_to_u64_vec(strings)
///
/// Converts a vector of strings into a vector of `u64` values.
///
/// This function attempts to parse each string in the input vector. If a string fails to parse,
/// the corresponding entry in the output vector will be an `Err` containing the parsing error.
///
/// ### Parameters
/// - `strings`: A vector of strings to be converted into `u64` values.
///
/// ### Returns
/// A `Vec<Result<u64, std::num::ParseIntError>>` where each element is a `Result`.
/// An `Ok` value represents a successful conversion to `u64`, while an `Err` value indicates a failure.
///
/// ### Examples
/// ```rust
/// use mathlab::math::string_to_u64_vec;
///
/// fn main() {
///     let string_numbers = vec![
///         "42".to_string(),
///         "100".to_string(),
///         "not_a_number".to_string(),
///         "300".to_string(),
///     ];
///
///     let results = string_to_u64_vec(string_numbers);
///
///     for (i, result) in results.iter().enumerate() {
///         match result {
///             Ok(num) => println!("String {} converted to u64: {}", i, num),
///             Err(e) => println!("Failed to convert string {}: {}", i, e),
///         }
///     }
/// }
/// ```
/// <small>End Fun Doc</small>
pub fn string_to_u64_vec(strings: Vec<String>) -> Vec<Result<u64, std::num::ParseIntError>> {
    strings.into_iter().map(|s| string_to_u64(s)).collect()
}