wide 1.6.1

A crate to help you go wide.
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
macro_rules! impl_simd_float {
  (
    // SAFETY: The contents of this macro assume that:
    //
    // - `T` implements `Pod`
    // - `Pod` can be implemented for `Simd`
    // - `size_of::<Simd>()` is `size_of::<T>() * N`
    // - `align_of::<Simd>()` is `size_of::<Simd>()`
    unsafe {
      T = $T:ident,
      N = $N:literal,
      Simd = $Simd:ident,
      UnsignedT = $UnsignedT:ident,
      UnsignedSimd = $UnsignedSimd:ident,
    }
    old_powf_simd_fn_name = $old_powf_simd_fn_name:ident,

    $fn_neg:item
    $fn_not:item
    $fn_add:item
    $fn_sub:item
    $fn_mul:item
    $fn_div:item
    $fn_rem:item
    $fn_bitand:item
    $fn_bitor:item
    $fn_bitxor:item
    $fn_reduce_add:item
    $fn_reduce_mul:item
    $fn_is_nan:item
    $fn_is_inf:item
    $fn_is_finite:item
    $fn_is_sign_positive:item
    $fn_is_sign_negative:item
    $fn_recip:item
    $fn_recip_sqrt:item
    $fn_max:item
    $fn_fast_max:item
    $fn_min:item
    $fn_fast_min:item
    $fn_clamp:item
    $fn_fast_clamp:item
    $fn_abs:item
    $fn_floor:item
    $fn_ceil:item
    $fn_round:item
    $fn_round_int:item
    $fn_fast_round_int:item
    $fn_round_ties_even:item
    $fn_trunc:item
    $fn_trunc_int:item
    $fn_fast_trunc_int:item
    $fn_mul_add:item
    $fn_mul_sub:item
    $fn_mul_neg_add:item
    $fn_mul_neg_sub:item
    $fn_powf_simd:item
    $fn_sqrt:item
    $fn_exp:item
    $fn_exp2:item
    $fn_ln:item
    $fn_cbrt:item
    $fn_asin:item
    $fn_acos:item
    $fn_atan:item
    $fn_atan2:item
    $fn_sin_cos:item
    $fn_asin_acos:item
    $fn_exp_m1:item
    $fn_ln_1p:item
    $fn_sinh:item
    $fn_cosh:item
    $fn_tanh:item
  ) => {
    impl_unary_operator!(
      $Simd,
      Neg,
      neg,
      $fn_neg,
      /// Returns the negative of each element of `self`.
      ///
      /// This always returns the precise result, simply flipping the sign-bit.
    );
    impl_unary_operator!(
      $Simd,
      Not,
      not,
      $fn_not,
      /// Computes bitwise NOT for each element of `self`.
      ///
      /// This operator is not implemented for primitive scalar floats, but its
      /// behavior here is the same as for integers.
    );

    impl_binary_operator!(
      $T,
      $Simd,
      Add,
      add,
      AddAssign,
      add_assign,
      $fn_add,
      /// Computes addition for each element of `self` and the corresponding
      /// element of `rhs`.
      ///
      /// This always returns the precise result.
      ,
      /// Computes addition for each element of `self` and the uniform scalar
      /// `rhs`.
      ///
      /// This always returns the precise result.
      ,
      /// Computes addition for the uniform scalar `self` and each element of
      /// `rhs`, returning a SIMD vector.
      ///
      /// This always returns the precise result.
    );
    impl_binary_operator!(
      $T,
      $Simd,
      Sub,
      sub,
      SubAssign,
      sub_assign,
      $fn_sub,
      /// Computes subtraction for each element of `self` and the corresponding
      /// element of `rhs`.
      ///
      /// This always returns the precise result.
      ,
      /// Computes subtraction for each element of `self` and the uniform scalar
      /// `rhs`.
      ///
      /// This always returns the precise result.
      ,
      /// Computes subtraction for the uniform scalar `self` and each element of
      /// `rhs`, returning a SIMD vector.
      ///
      /// This always returns the precise result.
    );
    impl_binary_operator!(
      $T,
      $Simd,
      Mul,
      mul,
      MulAssign,
      mul_assign,
      $fn_mul,
      /// Computes multiplication for each element of `self` and the
      /// corresponding element of `rhs`.
      ///
      /// This always returns the precise result.
      ,
      /// Computes multiplication for each element of `self` and the uniform
      /// scalar `rhs`.
      ///
      /// This always returns the precise result.
      ,
      /// Computes multiplication for the uniform scalar `self` and each element
      /// of `rhs`, returning a SIMD vector.
      ///
      /// This always returns the precise result.
    );
    impl_binary_operator!(
      $T,
      $Simd,
      Div,
      div,
      DivAssign,
      div_assign,
      $fn_div,
      /// Computes division for each element of `self` and the corresponding
      /// element of `rhs`.
      ///
      /// This always returns the precise result.
      ,
      /// Computes division for each element of `self` and the uniform scalar
      /// `rhs`.
      ///
      /// This always returns the precise result.
      ,
      /// Computes division for the uniform scalar `self` and each element of
      /// `rhs`, returning a SIMD vector.
      ///
      /// This always returns the precise result.
    );
    impl_binary_operator!(
      $T,
      $Simd,
      Rem,
      rem,
      RemAssign,
      rem_assign,
      $fn_rem,
      /// Computes the remainder for each element of `self` and the
      /// corresponding element of `rhs`.
      ///
      /// This always returns the precise result.
      ,
      /// Computes the remainder for each element of `self` and the uniform
      /// scalar `rhs`.
      ///
      /// This always returns the precise result.
      ,
      /// Computes the remainder for the uniform scalar `self` and each element
      /// of `rhs`, returning a SIMD vector.
      ///
      /// This always returns the precise result.
    );
    impl_binary_operator!(
      $T,
      $Simd,
      BitAnd,
      bitand,
      BitAndAssign,
      bitand_assign,
      $fn_bitand,
      /// Computes bitwise AND for each element of `self` and the corresponding
      /// element of `rhs`.
      ///
      /// This operator is not implemented for primitive scalar floats, but its
      /// behavior here is the same as for integers.
      ,
      /// Computes bitwise AND for each element of `self` and the uniform scalar
      /// `rhs`.
      ///
      /// This operator is not implemented for primitive scalar floats, but its
      /// behavior here is the same as for integers.
      ,
      /// Computes bitwise AND for the uniform scalar `self` and each element of
      /// `rhs`, returning a SIMD vector.
      ///
      /// This operator is not implemented for primitive scalar floats, but its
      /// behavior here is the same as for integers.
    );
    impl_binary_operator!(
      $T,
      $Simd,
      BitOr,
      bitor,
      BitOrAssign,
      bitor_assign,
      $fn_bitor,
      /// Computes bitwise OR for each element of `self` and the corresponding
      /// element of `rhs`.
      ///
      /// This operator is not implemented for primitive scalar floats, but its
      /// behavior here is the same as for integers.
      ,
      /// Computes bitwise OR for each element of `self` and the uniform scalar
      /// `rhs`.
      ///
      /// This operator is not implemented for primitive scalar floats, but its
      /// behavior here is the same as for integers.
      ,
      /// Computes bitwise OR for the uniform scalar `self` and each element of
      /// `rhs`, returning a SIMD vector.
      ///
      /// This operator is not implemented for primitive scalar floats, but its
      /// behavior here is the same as for integers.
    );
    impl_binary_operator!(
      $T,
      $Simd,
      BitXor,
      bitxor,
      BitXorAssign,
      bitxor_assign,
      $fn_bitxor,
      /// Computes bitwise XOR for each element of `self` and the corresponding
      /// element of `rhs`.
      ///
      /// This operator is not implemented for primitive scalar floats, but its
      /// behavior here is the same as for integers.
      ,
      /// Computes bitwise XOR for each element of `self` and the uniform scalar
      /// `rhs`.
      ///
      /// This operator is not implemented for primitive scalar floats, but its
      /// behavior here is the same as for integers.
      ,
      /// Computes bitwise XOR for the uniform scalar `self` and each element of
      /// `rhs`, returning a SIMD vector.
      ///
      /// This operator is not implemented for primitive scalar floats, but its
      /// behavior here is the same as for integers.
    );

    impl<Rhs> core::iter::Sum<Rhs> for $Simd
    where
      $Simd: AddAssign<Rhs>,
    {
      /// Computes the sum of multiple SIMD vectors for each lane.
      ///
      /// The order of addition is not specified.
      #[inline]
      fn sum<I: Iterator<Item = Rhs>>(iter: I) -> Self {
        let mut total = Self::zeroed();
        for val in iter {
          total += val;
        }
        total
      }
    }

    impl<Rhs> core::iter::Product<Rhs> for $Simd
    where
      $Simd: MulAssign<Rhs>,
    {
      /// Computes the product of multiple SIMD vectors for each lane.
      ///
      /// The order of multiplication is not specified.
      #[inline]
      fn product<I: Iterator<Item = Rhs>>(iter: I) -> Self {
        let mut total = Self::from(1.0);
        for val in iter {
          total *= val;
        }
        total
      }
    }

    macro_rules! impl_formatting_trait {
      ($Trait:path) => {
        impl $Trait for $Simd {
          #[allow(clippy::missing_inline_in_public_items)]
          fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
            write!(f, "(")?;
            for (i, x) in self.to_array().iter().enumerate() {
              if i > 0 {
                write!(f, ", ")?;
              }
              <$UnsignedT as $Trait>::fmt(&x.to_bits(), f)?;
            }
            write!(f, ")")
          }
        }
      }
    }
    impl_formatting_trait!(core::fmt::Binary);
    impl_formatting_trait!(core::fmt::LowerHex);
    impl_formatting_trait!(core::fmt::Octal);
    impl_formatting_trait!(core::fmt::UpperHex);

    /// The following functionality exists for all SIMD vectors of floats.
    impl $Simd {
      /// A SIMD vector with all elements set to `1.0`.
      pub const ONE: Self = Self::splat(1.0);

      /// A SIMD vector with all elements set to `0.5`.
      pub const HALF: Self = Self::splat(0.5);

      /// A SIMD vector with all elements set to `0.0`.
      pub const ZERO: Self = Self::splat(0.0);

      #[doc = concat!("A SIMD vector with all elements set to [`", stringify!($T) ,"::EPSILON`].")]
      pub const EPSILON: Self = Self::splat($T::EPSILON);

      #[doc = concat!("A SIMD vector with all elements set to [`", stringify!($T) ,"::MIN`].")]
      pub const MIN: Self = Self::splat($T::MIN);

      #[doc = concat!("A SIMD vector with all elements set to [`", stringify!($T) ,"::MIN_POSITIVE`].")]
      pub const MIN_POSITIVE: Self = Self::splat($T::MIN_POSITIVE);

      #[doc = concat!("A SIMD vector with all elements set to [`", stringify!($T) ,"::MAX`].")]
      pub const MAX: Self = Self::splat($T::MAX);

      #[doc = concat!("A SIMD vector with all elements set to [`", stringify!($T) ,"::NAN`].")]
      pub const NAN: Self = Self::splat($T::NAN);

      #[doc = concat!("A SIMD vector with all elements set to [`", stringify!($T) ,"::INFINITY`].")]
      pub const INFINITY: Self = Self::splat($T::INFINITY);

      #[doc = concat!("A SIMD vector with all elements set to [`", stringify!($T) ,"::NEG_INFINITY`].")]
      pub const NEG_INFINITY: Self = Self::splat($T::NEG_INFINITY);

      /// A SIMD vector with all elements set to [Euler's number (e)].
      ///
      #[doc = concat!("[Euler's number (e)]: core::", stringify!($T), "::consts::E")]
      pub const E: Self = Self::splat(core::$T::consts::E);

      /// A SIMD vector with all elements set to [1/Ï€].
      ///
      #[doc = concat!("[1/Ï€]: core::", stringify!($T), "::consts::FRAC_1_PI")]
      pub const FRAC_1_PI: Self = Self::splat(core::$T::consts::FRAC_1_PI);

      /// A SIMD vector with all elements set to [2/Ï€].
      ///
      #[doc = concat!("[2/Ï€]: core::", stringify!($T), "::consts::FRAC_2_PI")]
      pub const FRAC_2_PI: Self = Self::splat(core::$T::consts::FRAC_2_PI);

      /// A SIMD vector with all elements set to [2/sqrt(Ï€)].
      ///
      #[doc = concat!("[2/sqrt(Ï€)]: core::", stringify!($T), "::consts::FRAC_2_SQRT_PI")]
      pub const FRAC_2_SQRT_PI: Self =
        Self::splat(core::$T::consts::FRAC_2_SQRT_PI);

      /// A SIMD vector with all elements set to [1/sqrt(2)].
      ///
      #[doc = concat!("[1/sqrt(2)]: core::", stringify!($T), "::consts::FRAC_1_SQRT_2")]
      pub const FRAC_1_SQRT_2: Self =
        Self::splat(core::$T::consts::FRAC_1_SQRT_2);

      /// A SIMD vector with all elements set to [Ï€/2].
      ///
      #[doc = concat!("[Ï€/2]: core::", stringify!($T), "::consts::FRAC_PI_2")]
      pub const FRAC_PI_2: Self = Self::splat(core::$T::consts::FRAC_PI_2);

      /// A SIMD vector with all elements set to [Ï€/3].
      ///
      #[doc = concat!("[Ï€/3]: core::", stringify!($T), "::consts::FRAC_PI_3")]
      pub const FRAC_PI_3: Self = Self::splat(core::$T::consts::FRAC_PI_3);

      /// A SIMD vector with all elements set to [Ï€/4].
      ///
      #[doc = concat!("[Ï€/4]: core::", stringify!($T), "::consts::FRAC_PI_4")]
      pub const FRAC_PI_4: Self = Self::splat(core::$T::consts::FRAC_PI_4);

      /// A SIMD vector with all elements set to [Ï€/6].
      ///
      #[doc = concat!("[Ï€/6]: core::", stringify!($T), "::consts::FRAC_PI_6")]
      pub const FRAC_PI_6: Self = Self::splat(core::$T::consts::FRAC_PI_6);

      /// A SIMD vector with all elements set to [Ï€/8].
      ///
      #[doc = concat!("[Ï€/8]: core::", stringify!($T), "::consts::FRAC_PI_8")]
      pub const FRAC_PI_8: Self = Self::splat(core::$T::consts::FRAC_PI_8);

      /// A SIMD vector with all elements set to [ln(2)].
      ///
      #[doc = concat!("[ln(2)]: core::", stringify!($T), "::consts::LN_2")]
      pub const LN_2: Self = Self::splat(core::$T::consts::LN_2);

      /// A SIMD vector with all elements set to [ln(10)].
      ///
      #[doc = concat!("[ln(10)]: core::", stringify!($T), "::consts::LN_10")]
      pub const LN_10: Self = Self::splat(core::$T::consts::LN_10);

      /// A SIMD vector with all elements set to [log<sub>2</sub>(e)].
      ///
      #[doc = concat!("[log<sub>2</sub>(e)]: core::", stringify!($T), "::consts::LOG2_E")]
      pub const LOG2_E: Self = Self::splat(core::$T::consts::LOG2_E);

      /// A SIMD vector with all elements set to [log<sub>10</sub>(e)].
      ///
      #[doc = concat!("[log<sub>10</sub>(e)]: core::", stringify!($T), "::consts::LOG10_E")]
      pub const LOG10_E: Self = Self::splat(core::$T::consts::LOG10_E);

      /// A SIMD vector with all elements set to [log<sub>10</sub>(2)].
      ///
      #[doc = concat!("[log<sub>10</sub>(2)]: core::", stringify!($T), "::consts::LOG10_2")]
      pub const LOG10_2: Self = Self::splat(core::$T::consts::LOG10_2);

      /// A SIMD vector with all elements set to [log<sub>2</sub>(10)].
      ///
      #[doc = concat!("[log<sub>2</sub>(10)]: core::", stringify!($T), "::consts::LOG2_10")]
      pub const LOG2_10: Self = Self::splat(core::$T::consts::LOG2_10);

      /// A SIMD vector with all elements set to [Archimedes’ constant (π)].
      ///
      #[doc = concat!("[Archimedes’ constant (π)]: core::", stringify!($T), "::consts::PI")]
      pub const PI: Self = Self::splat(core::$T::consts::PI);

      /// A SIMD vector with all elements set to [sqrt(2)].
      ///
      #[doc = concat!("[sqrt(2)]: core::", stringify!($T), "::consts::SQRT_2")]
      pub const SQRT_2: Self = Self::splat(core::$T::consts::SQRT_2);

      /// A SIMD vector with all elements set to [the full circle constant (Ï„)].
      ///
      /// Equal to 2Ï€.
      ///
      #[doc = concat!("[the full circle constant (Ï„)]: core::", stringify!($T), "::consts::TAU")]
      pub const TAU: Self = Self::splat(core::$T::consts::TAU);

      /// Reducing addition. Returns the sum of the vector's elements.
      ///
      /// Equivalent to `self[0] + self[1] + ...`.
      ///
      /// # Unspecified precision
      ///
      /// The order of addition is non-deterministic. This means it varies by
      /// platform, version, and can even differ within the same execution from
      /// one invocation to the next.
      #[must_use]
      $fn_reduce_add

      /// Reducing multiplication. Returns the product of the vector's elements.
      ///
      /// Equivalent to `self[0] * self[1] * ...`.
      ///
      /// # Unspecified precision
      ///
      /// The order of multiplication is non-deterministic. This means it varies
      /// by platform, version, and can even differ within the same execution
      /// from one invocation to the next.
      #[must_use]
      $fn_reduce_mul

      /// Returns a [mask] that checks if each element is NaN.
      ///
      /// [mask]: crate#masks
      #[must_use]
      $fn_is_nan

      /// Returns a [mask] that checks if each element is infinity (either
      /// positive or negative).
      ///
      /// [mask]: crate#masks
      #[must_use]
      $fn_is_inf

      /// Returns a [mask] that checks if each element is neither infinite nor
      /// NaN.
      ///
      /// [mask]: crate#masks
      #[must_use]
      $fn_is_finite

      /// Returns a [mask] that checks if each element has a positive sign,
      /// including `+0.0`, NaNs with positive sign bit and positive infinity.
      ///
      /// [mask]: crate#masks
      #[must_use]
      $fn_is_sign_positive

      /// Returns a [mask] that checks if each element has a negative sign,
      /// including `-0.0`, NaNs with negative sign bit and negative infinity.
      ///
      /// [mask]: crate#masks
      #[must_use]
      $fn_is_sign_negative

      /// Returns the reciprocal (inverse) of a number, `1/x`.
      ///
      /// # Unspecified precision
      ///
      /// The precision of this function is non-deterministic. This means it
      /// varies by platform, version, and can even differ within the same
      /// execution from one invocation to the next.
      ///
      #[doc = concat!(
        "To compute the reciprocal deterministically, use `",
        stringify!($Simd),
        "::ONE / x`."
      )]
      #[must_use]
      $fn_recip

      /// Returns the square root of the reciprocal (inverse) of a number,
      /// `sqrt(1/x)`.
      ///
      /// # Unspecified precision
      ///
      /// The precision of this function is non-deterministic. This means it
      /// varies by platform, version, and can even differ within the same
      /// execution from one invocation to the next.
      #[must_use]
      $fn_recip_sqrt

      /// Converts radians to degrees.
      ///
      /// # Unspecified precision
      ///
      /// The precision of this function is non-deterministic. This means it
      /// varies by platform, version, and can even differ within the same
      /// execution from one invocation to the next.
      #[inline]
      #[must_use]
      pub fn to_degrees(self) -> Self {
        const RAD_TO_DEG_RATIO: $Simd = $Simd::splat(180.0 / core::$T::consts::PI);
        self * RAD_TO_DEG_RATIO
      }

      /// Converts degrees to radians.
      ///
      /// # Unspecified precision
      ///
      /// The precision of this function is non-deterministic. This means it
      /// varies by platform, version, and can even differ within the same
      /// execution from one invocation to the next.
      #[inline]
      #[must_use]
      pub fn to_radians(self) -> Self {
        const DEG_TO_RAD_RATIO: $Simd = $Simd::splat(core::$T::consts::PI / 180.0);
        self * DEG_TO_RAD_RATIO
      }

      /// Returns the maximum between each element of `self` and the
      /// corresponding element of `other`, ignoring NaN.
      ///
      /// For each lane, if exactly one of the arguments is NaN, then the other
      /// argument is returned. If both arguments are NaN, the return value is
      /// NaN. If the inputs compare equal (such as for the case of `+0.0` and
      /// `-0.0`), either input may be returned non-deterministically.
      ///
      /// See [`fast_max`] for a faster variant that does not handle NaNs.
      ///
      /// [`fast_max`]: Self::fast_max
      #[must_use]
      $fn_max

      /// Returns the maximum between each element of `self` and the
      /// corresponding element of `other`, not specifying behavior for NaNs.
      ///
      /// For each lane, if both arguments are NaN, the return value is NaN. If
      /// the inputs compare equal (such as for the case of `+0.0` and `-0.0`),
      /// or if exactly one of the arguments is NaN, either input may be
      /// returned non-deterministically.
      ///
      /// See [`max`] for a slower variant that does handle NaNs.
      ///
      /// [`max`]: Self::max
      #[must_use]
      $fn_fast_max

      /// Returns the minimum between each element of `self` and the
      /// corresponding element of `other`, ignoring NaN.
      ///
      /// For each lane, if exactly one of the arguments is NaN, then the other
      /// argument is returned. If both arguments are NaN, the return value is
      /// NaN. If the inputs compare equal (such as for the case of `+0.0` and
      /// `-0.0`), either input may be returned non-deterministically.
      ///
      /// See [`fast_min`] for a faster variant that does not handle NaNs.
      ///
      /// [`fast_min`]: Self::fast_min
      #[must_use]
      $fn_min

      /// Returns the minimum between each element of `self` and the
      /// corresponding element of `other`, not specifying behavior for NaNs.
      ///
      /// For each lane, if both arguments are NaN, the return value is NaN. If
      /// the inputs compare equal (such as for the case of `+0.0` and `-0.0`),
      /// or if exactly one of the arguments is NaN, either input may be
      /// returned non-deterministically.
      ///
      /// See [`min`] for a slower variant that does handle NaNs.
      ///
      /// [`min`]: Self::min
      #[must_use]
      $fn_fast_min

      /// Calculates the midpoint (average) between `self` and `other`.
      ///
      /// This returns NaN when *either* argument is NaN or if a combination of
      /// +inf and -inf is provided as arguments.
      ///
      /// This function currently returns a less precise result than
      #[doc = concat!("[`", stringify!($T), "::midpoint`]")]
      /// in order to gain performance, but this may change in the future.
      ///
      /// # Unspecified precision
      ///
      /// The precision of this function is non-deterministic. This means it
      /// varies by platform, version, and can even differ within the same
      /// execution from one invocation to the next.
      #[inline]
      #[must_use]
      pub fn midpoint(self, other: Self) -> Self {
        (self + other) * 0.5
      }

      /// Raw transmutation to unsigned integer vector.
      ///
      /// Note that this function preserves the *bitwise* value, and not the
      /// numeric value.
      #[inline]
      #[must_use]
      pub const fn to_bits(self) -> $UnsignedSimd {
        // SAFETY: Both types accept all bit-patterns and only contain
        // initialized memory.
        unsafe { core::mem::transmute::<$Simd, $UnsignedSimd>(self) }
      }

      /// Raw transmutation from unsigned integer vector.
      ///
      /// Note that this function preserves the *bitwise* value, and not the
      /// numeric value.
      #[inline]
      #[must_use]
      pub const fn from_bits(bits: $UnsignedSimd) -> Self {
        // SAFETY: Both types accept all bit-patterns and only contain
        // initialized memory.
        unsafe { core::mem::transmute::<$UnsignedSimd, $Simd>(bits) }
      }

      /// Restrict a value to a certain interval unless it is NaN.
      ///
      /// If `self`, `min` or `max` are NaN, the result is NaN. If `min > max`,
      /// the result is `min`. If inputs compare equal (such as for the case of
      /// `+0.0` and `-0.0`), either input may be returned
      /// non-deterministically.
      ///
      /// See [`fast_clamp`] for a faster variant that does not handle `min` or
      /// `max` being NaN.
      ///
      /// [`fast_clamp`]: Self::fast_clamp
      #[must_use]
      $fn_clamp

      /// Restrict a value to a certain interval unless it is NaN.
      ///
      /// If `self` is NaN, the result is NaN. If `min > max`, the result is
      /// `min`. If inputs compare equal (such as for the case of
      /// `+0.0` and `-0.0`), or if `min` or `max` are NaN, any input may be
      /// returned non-deterministically.
      ///
      /// See [`clamp`] for a slower variant that also handles `min` or `max`
      /// being NaN.
      ///
      /// [`clamp`]: Self::clamp
      #[must_use]
      $fn_fast_clamp

      /// Computes the absolute value of `self`.
      ///
      /// This function always returns the precise result.
      #[must_use]
      $fn_abs

      /// Returns numbers that represents the signs of each element.
      ///
      /// - `1.0` if the element is positive, `+0.0` or `INFINITY`
      /// - `-1.0` if the element is negative, `-0.0` or `NEG_INFINITY`
      /// - NaN if the element is NaN
      #[inline]
      #[must_use]
      pub fn signum(self) -> Self {
        let result = Self::ONE | self & -Self::ZERO;

        self.is_nan().select(self, result)
      }

      /// Returns numbers composed of the magnitudes of `self` and the signs of
      /// `sign`.
      ///
      /// Equal to `self` if the sign of `self` and `sign` are the same,
      /// otherwise equal to `-self`. Even if `self` or `sign` are NaN, the
      /// result is the exact bit pattern of `self` with the sign bit of `sign`.
      #[inline]
      #[must_use]
      pub fn copysign(self, sign: Self) -> Self {
        let magnitude_mask = Self::from($T::from_bits($UnsignedT::MAX >> 1));
        (self & magnitude_mask) | (sign & Self::from(-0.0))
      }

      /// Flips the sign of `self` based on the sign of `sign`.
      ///
      /// If `sign` has a positive sign, the result is `self`. If `sign` has a
      /// negative sign, the result is `-self`. Even if `self` or `sign` are
      /// NaN, the result is the exact bit pattern of `self` with a sign flipped
      /// based on the sign bit of `sign`.
      #[inline]
      #[must_use]
      pub fn flip_signs(self, sign: Self) -> Self {
        self ^ (sign & Self::from(-0.0))
      }

      /// Returns the largest integer less than or equal to each input element.
      ///
      /// This function always returns the precise result.
      #[must_use]
      $fn_floor

      /// Returns the smallest integer greater than or equal to each input
      /// element.
      ///
      /// This function always returns the precise result.
      #[must_use]
      $fn_ceil

      /// Returns the nearest integer to each input element. If a value is
      /// half-way between two integers, round away from `0.0`.
      ///
      /// This function always returns the precise result.
      ///
      /// For most targets architectures, [`round`] is slower than
      /// [`round_ties_even`]. If you do not care about the difference, consider
      /// using that instead.
      ///
      /// [`round`]: Self::round
      /// [`round_ties_even`]: Self::round_ties_even
      #[must_use]
      $fn_round

      /// Returns the nearest integer to each input element.
      ///
      /// The result for values half-way between two integers is currently not
      /// specified.
      ///
      /// This saturates out of range values and turns NaNs to `0`. See
      /// [`fast_round_int`] for a faster variant that does not handle out of
      /// range values or NaNs.
      ///
      /// [`fast_round_int`]: Self::fast_round_int
      #[must_use]
      $fn_round_int

      /// Returns the nearest integer to each input element.
      ///
      /// The result for values half-way between two integers is currently not
      /// specified.
      ///
      /// This function does not handle out of range values or NaNs. See
      /// [`round_int`] for a slower variant that does handle out of range
      /// values and NaNs.
      ///
      /// [`round_int`]: Self::round_int
      #[must_use]
      $fn_fast_round_int

      /// Returns the nearest integer to each input element. Rounds half-way
      /// cases to the number with an even least significant digit.
      ///
      /// This function always returns the precise result.
      #[must_use]
      $fn_round_ties_even

      /// Returns the integer part of each input element. This means that
      /// non-integer numbers are always truncated towards zero.
      ///
      /// This function always returns the precise result.
      #[must_use]
      $fn_trunc

      /// Returns the integer part of each input element. This means that
      /// non-integer numbers are always truncated towards zero.
      ///
      /// This saturates out of range values and turns NaNs to `0`. See
      /// [`fast_trunc_int`] for a faster variant that does not handle out of
      /// range values or NaNs.
      ///
      /// [`fast_trunc_int`]: Self::fast_trunc_int
      #[must_use]
      $fn_trunc_int

      /// Returns the integer part of each input element. This means that
      /// non-integer numbers are always truncated towards zero.
      ///
      /// This function does not handle out of range values or NaNs. See
      /// [`trunc_int`] for a slower variant that does handle out of range
      /// values and NaNs.
      ///
      /// [`trunc_int`]: Self::trunc_int
      #[must_use]
      $fn_fast_trunc_int

      /// Returns the fractional part of each input element.
      ///
      /// This function always returns the precise result.
      #[inline]
      #[must_use]
      pub fn fract(self) -> Self {
        self - self.trunc()
      }

      /// Fused multiply-add. Computes `(self * a) + b`.
      ///
      /// If there is hardware FMA support, this computes the result with only
      /// one rounding error. If not, this falls back to separate multiply and
      /// add operations, resulting in two rounding errors. Note that in the
      /// future, this function may change to always having one rounding error,
      /// at the cost of worse performance.
      #[must_use]
      $fn_mul_add

      /// Fused multiply-sub. Computes `(self * a) - b`.
      ///
      /// If there is hardware FMA support, this computes the result with only
      /// one rounding error. If not, this falls back to separate multiply and
      /// add operations, resulting in two rounding errors. Note that in the
      /// future, this function may change to always having one rounding error,
      /// at the cost of worse performance.
      #[must_use]
      $fn_mul_sub

      /// Fused multiply-negate-add. Computes `-(self * a) + b`.
      ///
      /// If there is hardware FMA support, this computes the result with only
      /// one rounding error. If not, this falls back to separate multiply and
      /// add operations, resulting in two rounding errors. Note that in the
      /// future, this function may change to always having one rounding error,
      /// at the cost of worse performance.
      #[must_use]
      $fn_mul_neg_add

      /// Fused multiply-negate-sub. Computes `-(self * a) - b`.
      ///
      /// If there is hardware FMA support, this computes the result with only
      /// one rounding error. If not, this falls back to separate multiply and
      /// add operations, resulting in two rounding errors. Note that in the
      /// future, this function may change to always having one rounding error,
      /// at the cost of worse performance.
      #[must_use]
      $fn_mul_neg_sub

      /// Calculates Euclidean division, the matching function for
      /// [`rem_euclid`].
      ///
      /// This computes the integer `n` such that
      /// `self = n * rhs + self.rem_euclid(rhs)`. In other words, the result is
      /// `self / rhs` rounded to the integer `n` such that `self >= n * rhs`.
      ///
      /// This function is not guaranteed to exactly match
      #[doc = concat!("[`", stringify!($T), "::div_euclid`].")]
      ///
      /// [`rem_euclid`]: Self::rem_euclid
      #[inline]
      #[must_use]
      pub fn div_euclid(self, rhs: Self) -> Self {
        let q = (self / rhs).trunc();
        (self % rhs)
          .simd_lt(Self::ZERO)
          .select(rhs.simd_gt(Self::ZERO).select(q - Self::ONE, q + Self::ONE), q)
      }

      /// Calculates the least nonnegative remainder of `self` when divided by
      /// `rhs`.
      ///
      /// In particular, the return value `r` satisfies `0.0 <= r < rhs.abs()` in
      /// most cases. However, due to a floating point round-off error it can
      /// result in `r == rhs.abs()`, violating the mathematical definition, if
      /// `self` is much smaller than `rhs.abs()` in magnitude and `self < 0.0`.
      /// This result is not an element of the function's codomain, but it is the
      /// closest floating point number in the real numbers and thus fulfills the
      /// property `self == self.div_euclid(rhs) * rhs + self.rem_euclid(rhs)`
      /// approximately.
      ///
      /// This function is not guaranteed to exactly match
      #[doc = concat!("[`", stringify!($T), "::rem_euclid`].")]
      #[inline]
      #[must_use]
      pub fn rem_euclid(self, rhs: Self) -> Self {
        let r = self % rhs;
        r.simd_lt(Self::ZERO).select(r + rhs.abs(), r)
      }

      /// Raises each element of the number `self` to the corresponding element
      /// of the floating point power `n`.
      ///
      /// This function cannot be named simply `powf`, because a now deprecated
      /// function already uses that name.
      ///
      /// # Unspecified precision
      ///
      /// The precision of this function is non-deterministic. This means it
      /// varies by platform, version, and can even differ within the same
      /// execution from one invocation to the next.
      #[must_use]
      $fn_powf_simd

      /// Returns the square root of a number for each input element.
      ///
      /// Returns NaN if `self` is a negative number other than `-0.0`.
      ///
      /// This function always returns the precise result.
      #[must_use]
      $fn_sqrt

      /// Returns `e^(self)`, (the exponential function) for each input element.
      ///
      /// # Unspecified precision
      ///
      /// The precision of this function is non-deterministic. This means it
      /// varies by platform, version, and can even differ within the same
      /// execution from one invocation to the next.
      #[must_use]
      $fn_exp

      /// Returns `2^(self)` for each input element.
      ///
      /// # Unspecified precision
      ///
      /// The precision of this function is non-deterministic. This means it
      /// varies by platform, version, and can even differ within the same
      /// execution from one invocation to the next.
      #[must_use]
      $fn_exp2

      /// Returns the natural logarithm of a number for each input element.
      ///
      /// # Unspecified precision
      ///
      /// The precision of this function is non-deterministic. This means it
      /// varies by platform, version, and can even differ within the same
      /// execution from one invocation to the next.
      #[must_use]
      $fn_ln

      /// Returns the base 2 logarithm of a number for each input element.
      ///
      /// # Unspecified precision
      ///
      /// The precision of this function is non-deterministic. This means it
      /// varies by platform, version, and can even differ within the same
      /// execution from one invocation to the next.
      #[inline]
      #[must_use]
      pub fn log2(self) -> Self {
        Self::ln(self) * Self::LOG2_E
      }

      /// Returns the base 10 logarithm of a number for each input element.
      ///
      /// # Unspecified precision
      ///
      /// The precision of this function is non-deterministic. This means it
      /// varies by platform, version, and can even differ within the same
      /// execution from one invocation to the next.
      #[inline]
      #[must_use]
      pub fn log10(self) -> Self {
        Self::ln(self) * Self::LOG10_E
      }

      /// Returns the cube root of a number for each input element.
      ///
      /// # Unspecified precision
      ///
      /// The precision of this function is non-deterministic. This means it
      /// varies by platform, version, and can even differ within the same
      /// execution from one invocation to the next.
      #[must_use]
      $fn_cbrt

      /// Computes the sine of a number (in radians) for each input element.
      ///
      /// # Unspecified precision
      ///
      /// The precision of this function is non-deterministic. This means it
      /// varies by platform, version, and can even differ within the same
      /// execution from one invocation to the next.
      #[inline]
      #[must_use]
      pub fn sin(self) -> Self {
        let (s, _) = self.sin_cos();
        s
      }

      /// Computes the cosine of a number (in radians) for each input element.
      ///
      /// # Unspecified precision
      ///
      /// The precision of this function is non-deterministic. This means it
      /// varies by platform, version, and can even differ within the same
      /// execution from one invocation to the next.
      #[inline]
      #[must_use]
      pub fn cos(self) -> Self {
        let (_, c) = self.sin_cos();
        c
      }

      /// Computes the tangent of a number (in radians) for each input element.
      ///
      /// # Unspecified precision
      ///
      /// The precision of this function is non-deterministic. This means it
      /// varies by platform, version, and can even differ within the same
      /// execution from one invocation to the next.
      #[inline]
      #[must_use]
      pub fn tan(self) -> Self {
        let (s, c) = self.sin_cos();
        s / c
      }

      /// Computes the arcsine of a number for each input element. Return value
      /// is in radians in the range [-pi/2, pi/2] or NaN if the number is
      /// outside the range [-1, 1].
      ///
      /// # Unspecified precision
      ///
      /// The precision of this function is non-deterministic. This means it
      /// varies by platform, version, and can even differ within the same
      /// execution from one invocation to the next.
      #[must_use]
      $fn_asin

      /// Computes the arccosine of a number for each input element. Return
      /// value is in radians in the range [0, pi] or NaN if the number is
      /// outside the range [-1, 1].
      ///
      /// # Unspecified precision
      ///
      /// The precision of this function is non-deterministic. This means it
      /// varies by platform, version, and can even differ within the same
      /// execution from one invocation to the next.
      #[must_use]
      $fn_acos

      /// Computes the arctangent of a number for each input element. Return
      /// value is in radians in the range [-pi/2, pi/2].
      ///
      /// # Unspecified precision
      ///
      /// The precision of this function is non-deterministic. This means it
      /// varies by platform, version, and can even differ within the same
      /// execution from one invocation to the next.
      #[must_use]
      $fn_atan

      /// Computes the four quadrant arctangent of each element of `self` (`y`)
      /// and the corresponding element of `other` (`x`) in radians.
      ///
      /// | `x`     | `y`     | Piecewise Definition | Range         |
      /// |---------|---------|----------------------|---------------|
      /// | `>= +0` | `>= +0` | `arctan(y/x)`        | `[+0, +pi/2]` |
      /// | `>= +0` | `<= -0` | `arctan(y/x)`        | `[-pi/2, -0]` |
      /// | `<= -0` | `>= +0` | `arctan(y/x) + pi`   | `[+pi/2, +pi]`|
      /// | `<= -0` | `<= -0` | `arctan(y/x) - pi`   | `[-pi, -pi/2]`|
      ///
      /// # Unspecified precision
      ///
      /// The precision of this function is non-deterministic. This means it
      /// varies by platform, version, and can even differ within the same
      /// execution from one invocation to the next.
      #[must_use]
      $fn_atan2

      /// Simultaneously computes the sine and cosine of a number `x` for each
      /// input element. Returns `(sin(x), cos(x))`.
      ///
      /// # Unspecified precision
      ///
      /// The precision of this function is non-deterministic. This means it
      /// varies by platform, version, and can even differ within the same
      /// execution from one invocation to the next.
      #[must_use]
      $fn_sin_cos

      /// Simultaneously computes the arcsine and arccosine of a number `x` for
      /// each input element. Returns `(asin(x), acos(x))`.
      ///
      /// # Unspecified precision
      ///
      /// The precision of this function is non-deterministic. This means it
      /// varies by platform, version, and can even differ within the same
      /// execution from one invocation to the next.
      #[must_use]
      $fn_asin_acos

      /// Returns `e^(self) - 1` for each input element in a way that is
      /// accurate even if a number is close to zero.
      ///
      /// # Unspecified precision
      ///
      /// The precision of this function is non-deterministic. This means it
      /// varies by platform, version, and can even differ within the same
      /// execution from one invocation to the next.
      #[must_use]
      $fn_exp_m1

      /// Returns `ln(1+n)` (natural logarithm) for each input element more
      /// accurately than if the operations were performed separately.
      ///
      /// # Unspecified precision
      ///
      /// The precision of this function is non-deterministic. This means it
      /// varies by platform, version, and can even differ within the same
      /// execution from one invocation to the next.
      #[must_use]
      $fn_ln_1p

      /// Returns the hyperbolic sine (`(e^self - e^(-self))/2`) for each input
      /// element.
      ///
      /// # Unspecified precision
      ///
      /// The precision of this function is non-deterministic. This means it
      /// varies by platform, version, and can even differ within the same
      /// execution from one invocation to the next.
      #[must_use]
      $fn_sinh

      /// Returns the hyperbolic cosine (`(e^self + e^(-self))/2`) for each
      /// input element.
      ///
      /// # Unspecified precision
      ///
      /// The precision of this function is non-deterministic. This means it
      /// varies by platform, version, and can even differ within the same
      /// execution from one invocation to the next.
      #[must_use]
      $fn_cosh

      /// Returns the hyperbolic tangent (`sinh(self)/cosh(self)`) for each
      /// input element.
      ///
      /// # Unspecified precision
      ///
      /// The precision of this function is non-deterministic. This means it
      /// varies by platform, version, and can even differ within the same
      /// execution from one invocation to the next.
      #[must_use]
      $fn_tanh

      /// Raises each element of the number `self` to the corresponding element
      /// of the floating point power `n`.
      ///
      /// This function has been renamed to [`powf_simd`].
      ///
      /// # Unspecified precision
      ///
      /// The precision of this function is non-deterministic. This means it
      /// varies by platform, version, and can even differ within the same
      /// execution from one invocation to the next.
      ///
      /// [`powf_simd`]: Self::powf_simd
      #[deprecated(since = "1.6.0", note = "renamed to `powf_simd`")]
      #[inline]
      #[must_use]
      pub fn $old_powf_simd_fn_name(self, n: Self) -> Self {
        self.powf_simd(n)
      }

      /// Raises each element of the number `self` to the scalar floating point
      /// power `n`.
      ///
      /// This function has been deprecated because it raises all elements of
      /// `x` to the same power, even though that brings no performance benefit.
      #[doc = concat!("Use `x.powf_simd(", stringify!($Simd), "::splat(n))` instead.")]
      ///
      /// # Unspecified precision
      ///
      /// The precision of this function is non-deterministic. This means it
      /// varies by platform, version, and can even differ within the same
      /// execution from one invocation to the next.
      #[deprecated(since = "1.6.0", note = "use `x.powf_simd(splat(n))` instead")]
      #[inline]
      #[must_use]
      pub fn powf(self, n: $T) -> Self {
        self.powf_simd(Self::splat(n))
      }
    }
  };
}