Skip to content

Commit ec0cbbc

Browse files
committed
Use a "special values" header before the list of special values for elementwise functions
This will make these easier to parse from the test suite, barring something like #49.
1 parent 02936ee commit ec0cbbc

File tree

1 file changed

+60
-2
lines changed

1 file changed

+60
-2
lines changed

spec/API_specification/elementwise_functions.md

+60-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ A conforming implementation of the array API standard must provide and support t
1717

1818
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).
1919

20+
#### Special Values
21+
2022
- If `x_i` is `NaN`, the result is `NaN`.
2123
- If `x_i` is `-0`, the result is `+0`.
2224
- 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
3739

3840
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.
3941

42+
#### Special Values
43+
4044
- If `x_i` is `NaN`, the result is `NaN`.
4145
- If `x_i` is greater than `1`, the result is `NaN`.
4246
- 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
5862

5963
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`.
6064

65+
#### Special Values
66+
6167
- If `x_i` is `NaN`, the result is `NaN`.
6268
- If `x_i` is less than `1`, the result is `NaN`.
6369
- If `x_i` is `1`, the result is `+0`.
@@ -79,6 +85,8 @@ Calculates an implementation-dependent approximation to the inverse hyperbolic c
7985

8086
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,
8187

88+
#### Special Values
89+
8290
- If either `x1_i` or `x2_i` is `NaN`, the result is `NaN`.
8391
- If `x1_i` is `+infinity` and `x2_i` is `-infinity`, the result is `NaN`.
8492
- 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
121129

122130
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.
123131

132+
#### Special Values
133+
124134
- If `x_i` is `NaN`, the result is `NaN`.
125135
- If `x_i` is greater than `1`, the result is `NaN`.
126136
- 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
143153

144154
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`.
145155

156+
#### Special Values
157+
146158
- If `x_i` is `NaN`, the result is `NaN`.
147159
- If `x_i` is `+0`, the result is `+0`.
148160
- If `x_i` is `-0`, the result is `-0`.
@@ -165,6 +177,8 @@ Calculates an implementation-dependent approximation to the inverse hyperbolic s
165177

166178
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.
167179

180+
#### Special Values
181+
168182
- If `x_i` is `NaN`, the result is `NaN`.
169183
- If `x_i` is `+0`, the result is `+0`.
170184
- 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
193207

194208
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.
195209

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
197213

198214
- If `x1_i` or `x2_i` is `NaN`, the result is `NaN`.
199215
- 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
239255

240256
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`.
241257

258+
#### Special Values
259+
242260
- If `x_i` is `NaN`, the result is `NaN`.
243261
- If `x_i` is less than `-1`, the result is `NaN`.
244262
- 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
263281

264282
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`.
265283

284+
#### Special Values
285+
266286
- If `x_i` is already integer-valued, the result is `x_i`.
267287

268288
#### Parameters
@@ -281,6 +301,8 @@ Rounds each element `x_i` of the input array `x` to the smallest (i.e., closest
281301

282302
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.
283303

304+
#### Special Values
305+
284306
- If `x_i` is `NaN`, the result is `NaN`.
285307
- If `x_i` is `+0`, the result is `1`.
286308
- If `x_i` is `-0`, the result is `1`.
@@ -325,6 +347,8 @@ Calculates an implementation-dependent approximation to the hyperbolic cosine, h
325347

326348
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,
327349

350+
#### Special Values
351+
328352
- If either `x1_i` or `x2_i` is `NaN`, the result is `NaN`.
329353
- If both `x1_i` and `x2_i` has the same sign, the result is positive.
330354
- 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
381405

382406
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).
383407

408+
#### Special Values
409+
384410
- If `x_i` is `NaN`, the result is `NaN`.
385411
- If `x_i` is `+0`, the result is `1`.
386412
- If `x_i` is `-0`, the result is `1`.
@@ -407,6 +433,8 @@ Calculates an implementation-dependent approximation to `exp(x)-1`, having domai
407433

408434
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.
409435

436+
#### Special Values
437+
410438
- If `x_i` is `NaN`, the result is `NaN`.
411439
- If `x_i` is `+0`, the result is `+0`.
412440
- If `x_i` is `-0`, the result is `-0`.
@@ -429,6 +457,8 @@ Calculates an implementation-dependent approximation to `exp(x)-1`, having domai
429457

430458
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`.
431459

460+
#### Special Values
461+
432462
- If `x_i` is already integer-valued, the result is `x_i`.
433463

434464
#### Parameters
@@ -455,7 +485,7 @@ Computes the truth value of `x1_i > x2_i` for each element `x1_i` of the input a
455485

456486
- **x2**: _<array>_
457487

458-
- second input array. Must be compatible with `x1` (see :ref:`broadcasting`).
488+
- second input array. Must be compatible with `x1` (see :ref:`broadcasting`).
459489

460490
#### Returns
461491

@@ -575,6 +605,8 @@ Computes the truth value of `x1_i <= x2_i` for each element `x1_i` of the input
575605

576606
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`.
577607

608+
#### Special Values
609+
578610
- If `x_i` is `NaN`, the result is `NaN`.
579611
- If `x_i` is less than `0`, the result is `NaN`.
580612
- 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`
601633

602634
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.
603635

636+
#### Special Values
637+
604638
- If `x_i` is `NaN`, the result is `NaN`.
605639
- If `x_i` is less than `-1`, the result is `NaN`.
606640
- If `x_i` is `-1`, the result is `-infinity`.
@@ -624,6 +658,8 @@ Calculates an implementation-dependent approximation to `log(1+x)`, where `log`
624658

625659
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`.
626660

661+
#### Special Values
662+
627663
- If `x_i` is `NaN`, the result is `NaN`.
628664
- If `x_i` is less than `0`, the result is `NaN`.
629665
- 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,
646682

647683
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`.
648684

685+
#### Special Values
686+
649687
- If `x_i` is `NaN`, the result is `NaN`.
650688
- If `x_i` is less than `0`, the result is `NaN`.
651689
- 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
744782

745783
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,
746784

785+
#### Special Values
786+
747787
- If either `x1_i` or `x2_i` is `NaN`, the result is `NaN`.
748788
- If both `x1_i` and `x2_i` have the same sign, the result is positive.
749789
- 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
798838

799839
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`.
800840

841+
#### Special Values
842+
801843
- If `x1_i` is not equal to `1` and `x2_i` is `NaN`, the result is `NaN`.
802844
- If `x2_i` is `+0`, the result is `1`, even if `x1_i` is `NaN`.
803845
- 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
843885

844886
Rounds each element `x_i` of the input array `x` to the nearest integer-valued number.
845887

888+
#### Special Values
889+
846890
- If `x_i` is already integer-valued, the result is `x_i`.
847891
- If two integers are equally close to `x_i`, the result is whichever integer is farthest from `0`.
848892

@@ -862,6 +906,8 @@ Rounds each element `x_i` of the input array `x` to the nearest integer-valued n
862906

863907
Returns an indication of the sign of a number for each element `x_i` of the input array `x`.
864908

909+
#### Special Values
910+
865911
- If `x_i` is less than `0`, the result is `-1`.
866912
- If `x_i` is `-0` or `+0`, the result is `0`.
867913
- 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
882928

883929
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.
884930

931+
#### Special Values
932+
885933
- If `x_i` is `NaN`, the result is `NaN`.
886934
- If `x_i` is `+0`, the result is `+0`.
887935
- If `x_i` is `-0`, the result is `-0`.
@@ -903,6 +951,8 @@ Calculates an implementation-dependent approximation to the sine, having domain
903951

904952
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`.
905953

954+
#### Special Values
955+
906956
- If `x_i` is `NaN`, the result is `NaN`.
907957
- If `x_i` is `+0`, the result is `+0`.
908958
- 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`.
941991

942992
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).
943993

994+
#### Special Values
995+
944996
- If `x_i` is `NaN`, the result is `NaN`.
945997
- If `x_i` is less than `0`, the result is `NaN`.
946998
- 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
9831035

9841036
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.
9851037

1038+
#### Special Values
1039+
9861040
- If `x_i` is `NaN`, the result is `NaN`.
9871041
- If `x_i` is `+0`, the result is `+0`.
9881042
- If `x_i` is `-0`, the result is `-0`.
@@ -1004,6 +1058,8 @@ Calculates an implementation-dependent approximation to the tangent, having doma
10041058

10051059
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`.
10061060

1061+
#### Special Values
1062+
10071063
- If `x_i` is `NaN`, the result is `NaN`.
10081064
- If `x_i` is `+0`, the result is `+0`.
10091065
- If `x_i` is `-0`, the result is `-0`.
@@ -1026,6 +1082,8 @@ Calculates an implementation-dependent approximation to the hyperbolic tangent,
10261082

10271083
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`.
10281084

1085+
#### Special Values
1086+
10291087
- If `x_i` is already integer-valued, the result is `x_i`.
10301088

10311089
#### Parameters

0 commit comments

Comments
 (0)