You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: spec/API_specification/elementwise_functions.md
+60-2
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,8 @@ A conforming implementation of the array API standard must provide and support t
17
17
18
18
Calculates the absolute value for each element `x_i` of the input array `x` (i.e., the element-wise result has the same magnitude as the respective element in `x` but has positive sign).
19
19
20
+
#### Special Values
21
+
20
22
- If `x_i` is `NaN`, the result is `NaN`.
21
23
- If `x_i` is `-0`, the result is `+0`.
22
24
- If `x_i` is `-infinity`, the result is `+infinity`.
@@ -37,6 +39,8 @@ Calculates the absolute value for each element `x_i` of the input array `x` (i.e
37
39
38
40
Calculates an implementation-dependent approximation of the principal value of the inverse cosine, having domain `[-1, +1]` and codomain `[+0, +π]`, for each element `x_i` of the input array `x`. Each element-wise result is expressed in radians.
39
41
42
+
#### Special Values
43
+
40
44
- If `x_i` is `NaN`, the result is `NaN`.
41
45
- If `x_i` is greater than `1`, the result is `NaN`.
42
46
- If `x_i` is less than `-1`, the result is `NaN`.
@@ -58,6 +62,8 @@ Calculates an implementation-dependent approximation of the principal value of t
58
62
59
63
Calculates an implementation-dependent approximation to the inverse hyperbolic cosine, having domain `[+1, +infinity]` and codomain `[+0, +infinity]`, for each element `x_i` of the input array `x`.
60
64
65
+
#### Special Values
66
+
61
67
- If `x_i` is `NaN`, the result is `NaN`.
62
68
- If `x_i` is less than `1`, the result is `NaN`.
63
69
- If `x_i` is `1`, the result is `+0`.
@@ -79,6 +85,8 @@ Calculates an implementation-dependent approximation to the inverse hyperbolic c
79
85
80
86
Calculates the sum for each element `x1_i` of the input array `x1` with the respective element `x2_i` of the input array `x2`. For floating-point arithmetic,
81
87
88
+
#### Special Values
89
+
82
90
- If either `x1_i` or `x2_i` is `NaN`, the result is `NaN`.
83
91
- If `x1_i` is `+infinity` and `x2_i` is `-infinity`, the result is `NaN`.
84
92
- If `x1_i` is `-infinity` and `x2_i` is `+infinity`, the result is `NaN`.
@@ -121,6 +129,8 @@ Calculates the sum for each element `x1_i` of the input array `x1` with the resp
121
129
122
130
Calculates an implementation-dependent approximation of the principal value of the inverse sine, having domain `[-1, +1]` and codomain `[-π/2, +π/2]` for each element `x_i` of the input array `x`. Each element-wise result is expressed in radians.
123
131
132
+
#### Special Values
133
+
124
134
- If `x_i` is `NaN`, the result is `NaN`.
125
135
- If `x_i` is greater than `1`, the result is `NaN`.
126
136
- If `x_i` is less than `-1`, the result is `NaN`.
@@ -143,6 +153,8 @@ Calculates an implementation-dependent approximation of the principal value of t
143
153
144
154
Calculates an implementation-dependent approximation to the inverse hyperbolic sine, having domain `[-infinity, +infinity]` and codomain `[-infinity, +infinity]`, for each element `x_i` in the input array `x`.
145
155
156
+
#### Special Values
157
+
146
158
- If `x_i` is `NaN`, the result is `NaN`.
147
159
- If `x_i` is `+0`, the result is `+0`.
148
160
- If `x_i` is `-0`, the result is `-0`.
@@ -165,6 +177,8 @@ Calculates an implementation-dependent approximation to the inverse hyperbolic s
165
177
166
178
Calculates an implementation-dependent approximation of the principal value of the inverse tangent, having domain `[-infinity, +infinity]` and codomain `[-π/2, +π/2]`, for each element `x_i` of the input array `x`. Each element-wise result is expressed in radians.
167
179
180
+
#### Special Values
181
+
168
182
- If `x_i` is `NaN`, the result is `NaN`.
169
183
- If `x_i` is `+0`, the result is `+0`.
170
184
- If `x_i` is `-0`, the result is `-0`.
@@ -193,7 +207,9 @@ The signs of `x1_i` and `x2_i` determine the quadrant of each element-wise resul
193
207
194
208
Note the role reversal: the "y-coordinate" is the first function parameter; the "x-coordinate" is the second function parameter. The parameter order is intentional and traditional for the two-argument inverse tangent function where the y-coordinate argument is first and the x-coordinate argument is second.
195
209
196
-
By IEEE 754 convention, the inverse tangent of the quotient `x1/x2` is defined for `x2_i` equal to positive or negative zero and for either or both of `x1_i` and `x2_i` equal to positive or negative `infinity`.
210
+
By IEEE 754 convention, the inverse tangent of the quotient `x1/x2` is defined for `x2_i` equal to positive or negative zero and for either or both of `x1_i` and `x2_i` equal to positive or negative `infinity`.
211
+
212
+
#### Special Values
197
213
198
214
- If `x1_i` or `x2_i` is `NaN`, the result is `NaN`.
199
215
- If `x1_i` is greater than `0` and `x2_i` is `+0`, the result is an implementation-dependent approximation to `+π/2`.
@@ -239,6 +255,8 @@ By IEEE 754 convention, the inverse tangent of the quotient `x1/x2` is defined f
239
255
240
256
Calculates an implementation-dependent approximation to the inverse hyperbolic tangent, having domain `[-1, +1]` and codomain `[-infinity, +infinity]`, for each element `x_i` of the input array `x`.
241
257
258
+
#### Special Values
259
+
242
260
- If `x_i` is `NaN`, the result is `NaN`.
243
261
- If `x_i` is less than `-1`, the result is `NaN`.
244
262
- If `x_i` is greater than `1`, the result is `NaN`.
@@ -263,6 +281,8 @@ Calculates an implementation-dependent approximation to the inverse hyperbolic t
263
281
264
282
Rounds each element `x_i` of the input array `x` to the smallest (i.e., closest to `-infinity`) integer-valued number that is not less than `x_i`.
265
283
284
+
#### Special Values
285
+
266
286
- If `x_i` is already integer-valued, the result is `x_i`.
267
287
268
288
#### Parameters
@@ -281,6 +301,8 @@ Rounds each element `x_i` of the input array `x` to the smallest (i.e., closest
281
301
282
302
Calculates an implementation-dependent approximation to the cosine, having domain `(-infinity, +infinity)` and codomain `[-1, +1]`, for each element `x_i` of the input array `x`. Each element `x_i` is assumed to be expressed in radians.
283
303
304
+
#### Special Values
305
+
284
306
- If `x_i` is `NaN`, the result is `NaN`.
285
307
- If `x_i` is `+0`, the result is `1`.
286
308
- If `x_i` is `-0`, the result is `1`.
@@ -325,6 +347,8 @@ Calculates an implementation-dependent approximation to the hyperbolic cosine, h
325
347
326
348
Calculates the division for each element `x1_i` of the input array `x1` with the respective element `x2_i` of the input array `x2`. For floating-point arithmetic,
327
349
350
+
#### Special Values
351
+
328
352
- If either `x1_i` or `x2_i` is `NaN`, the result is `NaN`.
329
353
- If both `x1_i` and `x2_i` has the same sign, the result is positive.
330
354
- If `x1_i` and `x2_i` has different signs, the result is negative.
@@ -381,6 +405,8 @@ Computes the truth value of `x1_i == x2_i` for each element `x1_i` of the input
381
405
382
406
Calculates an implementation-dependent approximation to the exponential function, having domain `[-infinity, +infinity]` and codomain `[+0, +infinity]`, for each element `x_i` of the input array `x` (`e` raised to the power of `x_i`, where `e` is the base of the natural logarithm).
383
407
408
+
#### Special Values
409
+
384
410
- If `x_i` is `NaN`, the result is `NaN`.
385
411
- If `x_i` is `+0`, the result is `1`.
386
412
- If `x_i` is `-0`, the result is `1`.
@@ -407,6 +433,8 @@ Calculates an implementation-dependent approximation to `exp(x)-1`, having domai
407
433
408
434
The purpose of this API is to calculate `exp(x)-1.0` more accurately when `x` is close to zero. Accordingly, conforming implementations should avoid implementing this API as simply `exp(x)-1.0`. See FDLIBM, or some other IEEE 754-2019 compliant mathematical library, for a potential reference implementation.
409
435
436
+
#### Special Values
437
+
410
438
- If `x_i` is `NaN`, the result is `NaN`.
411
439
- If `x_i` is `+0`, the result is `+0`.
412
440
- If `x_i` is `-0`, the result is `-0`.
@@ -429,6 +457,8 @@ Calculates an implementation-dependent approximation to `exp(x)-1`, having domai
429
457
430
458
Rounds each element `x_i` of the input array `x` to the greatest (i.e., closest to `+infinity`) integer-valued number that is not greater than `x_i`.
431
459
460
+
#### Special Values
461
+
432
462
- If `x_i` is already integer-valued, the result is `x_i`.
433
463
434
464
#### Parameters
@@ -455,7 +485,7 @@ Computes the truth value of `x1_i > x2_i` for each element `x1_i` of the input a
455
485
456
486
-**x2**: _<array>_
457
487
458
-
- second input array. Must be compatible with `x1` (see :ref:`broadcasting`).
488
+
- second input array. Must be compatible with `x1` (see :ref:`broadcasting`).
459
489
460
490
#### Returns
461
491
@@ -575,6 +605,8 @@ Computes the truth value of `x1_i <= x2_i` for each element `x1_i` of the input
575
605
576
606
Calculates an implementation-dependent approximation to the natural (base `e`) logarithm, having domain `[0, +infinity]` and codomain `[-infinity, +infinity]`, for each element `x_i` of the input array `x`.
577
607
608
+
#### Special Values
609
+
578
610
- If `x_i` is `NaN`, the result is `NaN`.
579
611
- If `x_i` is less than `0`, the result is `NaN`.
580
612
- If `x_i` is `+0` or `-0`, the result is `-infinity`.
@@ -601,6 +633,8 @@ Calculates an implementation-dependent approximation to `log(1+x)`, where `log`
601
633
602
634
The purpose of this API is to calculate `log(1+x)` more accurately when `x` is close to zero. Accordingly, conforming implementations should avoid implementing this API as simply `log(1+x)`. See FDLIBM, or some other IEEE 754-2019 compliant mathematical library, for a potential reference implementation.
603
635
636
+
#### Special Values
637
+
604
638
- If `x_i` is `NaN`, the result is `NaN`.
605
639
- If `x_i` is less than `-1`, the result is `NaN`.
606
640
- If `x_i` is `-1`, the result is `-infinity`.
@@ -624,6 +658,8 @@ Calculates an implementation-dependent approximation to `log(1+x)`, where `log`
624
658
625
659
Calculates an implementation-dependent approximation to the base `2` logarithm, having domain `[0, +infinity]` and codomain `[-infinity, +infinity]`, for each element `x_i` of the input array `x`.
626
660
661
+
#### Special Values
662
+
627
663
- If `x_i` is `NaN`, the result is `NaN`.
628
664
- If `x_i` is less than `0`, the result is `NaN`.
629
665
- If `x_i` is `+0` or `-0`, the result is `-infinity`.
@@ -646,6 +682,8 @@ Calculates an implementation-dependent approximation to the base `2` logarithm,
646
682
647
683
Calculates an implementation-dependent approximation to the base `10` logarithm, having domain `[0, +infinity]` and codomain `[-infinity, +infinity]`, for each element `x_i` of the input array `x`.
648
684
685
+
#### Special Values
686
+
649
687
- If `x_i` is `NaN`, the result is `NaN`.
650
688
- If `x_i` is less than `0`, the result is `NaN`.
651
689
- If `x_i` is `+0` or `-0`, the result is `-infinity`.
@@ -744,6 +782,8 @@ Computes the logical XOR for each element `x1_i` of the input array `x1` with th
744
782
745
783
Calculates the product for each element `x1_i` of the input array `x1` with the respective element `x2_i` of the input array `x2`. For floating-point arithmetic,
746
784
785
+
#### Special Values
786
+
747
787
- If either `x1_i` or `x2_i` is `NaN`, the result is `NaN`.
748
788
- If both `x1_i` and `x2_i` have the same sign, the result is positive.
749
789
- If `x1_i` and `x2_i` have different signs, the result is negative.
@@ -798,6 +838,8 @@ Computes the truth value of `x1_i != x2_i` for each element `x1_i` of the input
798
838
799
839
Calculates an implementation-dependent approximation of exponentiation by raising each element `x1_i` (the base) of the input array `x1` to the power of `x2_i` (the exponent), where `x2_i` is the corresponding element of the input array `x2`.
800
840
841
+
#### Special Values
842
+
801
843
- If `x1_i` is not equal to `1` and `x2_i` is `NaN`, the result is `NaN`.
802
844
- If `x2_i` is `+0`, the result is `1`, even if `x1_i` is `NaN`.
803
845
- If `x2_i` is `-0`, the result is `1`, even if `x1_i` is `NaN`.
@@ -843,6 +885,8 @@ Calculates an implementation-dependent approximation of exponentiation by raisin
843
885
844
886
Rounds each element `x_i` of the input array `x` to the nearest integer-valued number.
845
887
888
+
#### Special Values
889
+
846
890
- If `x_i` is already integer-valued, the result is `x_i`.
847
891
- If two integers are equally close to `x_i`, the result is whichever integer is farthest from `0`.
848
892
@@ -862,6 +906,8 @@ Rounds each element `x_i` of the input array `x` to the nearest integer-valued n
862
906
863
907
Returns an indication of the sign of a number for each element `x_i` of the input array `x`.
864
908
909
+
#### Special Values
910
+
865
911
- If `x_i` is less than `0`, the result is `-1`.
866
912
- If `x_i` is `-0` or `+0`, the result is `0`.
867
913
- If `x_i` is greater than `0`, the result is `+1`.
@@ -882,6 +928,8 @@ Returns an indication of the sign of a number for each element `x_i` of the inpu
882
928
883
929
Calculates an implementation-dependent approximation to the sine, having domain `(-infinity, +infinity)` and codomain `[-1, +1]`, for each element `x_i` of the input array `x`. Each element `x_i` is assumed to be expressed in radians.
884
930
931
+
#### Special Values
932
+
885
933
- If `x_i` is `NaN`, the result is `NaN`.
886
934
- If `x_i` is `+0`, the result is `+0`.
887
935
- If `x_i` is `-0`, the result is `-0`.
@@ -903,6 +951,8 @@ Calculates an implementation-dependent approximation to the sine, having domain
903
951
904
952
Calculates an implementation-dependent approximation to the hyperbolic sine, having domain `[-infinity, +infinity]` and codomain `[-infinity, +infinity]`, for each element `x_i` of the input array `x`.
905
953
954
+
#### Special Values
955
+
906
956
- If `x_i` is `NaN`, the result is `NaN`.
907
957
- If `x_i` is `+0`, the result is `+0`.
908
958
- If `x_i` is `-0`, the result is `-0`.
@@ -941,6 +991,8 @@ Squares (`x_i * x_i`) each element `x_i` of the input array `x`.
941
991
942
992
Calculates the square root, having domain `[0, +infinity]` and codomain `[0, +infinity]`, for each element `x_i` of the input array `x`. After rounding, each result should be indistinguishable from the infinitely precise result (as required by IEEE 754).
943
993
994
+
#### Special Values
995
+
944
996
- If `x_i` is `NaN`, the result is `NaN`.
945
997
- If `x_i` is less than `0`, the result is `NaN`.
946
998
- If `x_i` is `+0`, the result is `+0`.
@@ -983,6 +1035,8 @@ Calculates the difference for each element `x1_i` of the input array `x1` with t
983
1035
984
1036
Calculates an implementation-dependent approximation to the tangent, having domain `(-infinity, +infinity)` and codomain `(-infinity, +infinity)`, for each element `x_i` of the input array `x`. Each element `x_i` is assumed to be expressed in radians.
985
1037
1038
+
#### Special Values
1039
+
986
1040
- If `x_i` is `NaN`, the result is `NaN`.
987
1041
- If `x_i` is `+0`, the result is `+0`.
988
1042
- If `x_i` is `-0`, the result is `-0`.
@@ -1004,6 +1058,8 @@ Calculates an implementation-dependent approximation to the tangent, having doma
1004
1058
1005
1059
Calculates an implementation-dependent approximation to the hyperbolic tangent, having domain `[-infinity, +infinity]` and codomain `[-1, +1]`, for each element `x_i` of the input array `x`.
1006
1060
1061
+
#### Special Values
1062
+
1007
1063
- If `x_i` is `NaN`, the result is `NaN`.
1008
1064
- If `x_i` is `+0`, the result is `+0`.
1009
1065
- If `x_i` is `-0`, the result is `-0`.
@@ -1026,6 +1082,8 @@ Calculates an implementation-dependent approximation to the hyperbolic tangent,
1026
1082
1027
1083
Rounds each element `x_i` of the input array `x` to the integer-valued number that is closest to but no greater than `x_i`.
1028
1084
1085
+
#### Special Values
1086
+
1029
1087
- If `x_i` is already integer-valued, the result is `x_i`.
0 commit comments