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/broadcasting.rst
+20-20Lines changed: 20 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -21,49 +21,49 @@ If two arrays are of unequal rank, the array having a lower rank is promoted to
21
21
22
22
The results of the element-wise operation must be stored in an array having a shape determined by the following algorithm.
23
23
24
-
1. Let ``A`` and ``B`` both be arrays.
24
+
#. Let ``A`` and ``B`` both be arrays.
25
25
26
-
1. Let ``shape1`` be a tuple describing the shape of array ``A``.
26
+
#. Let ``shape1`` be a tuple describing the shape of array ``A``.
27
27
28
-
1. Let ``shape2`` be a tuple describing the shape of array ``B``.
28
+
#. Let ``shape2`` be a tuple describing the shape of array ``B``.
29
29
30
-
1. Let ``N1`` be the number of dimensions of array ``A`` (i.e., the result of ``len(shape1)``).
30
+
#. Let ``N1`` be the number of dimensions of array ``A`` (i.e., the result of ``len(shape1)``).
31
31
32
-
1. Let ``N2`` be the number of dimensions of array ``B`` (i.e., the result of ``len(shape2)``).
32
+
#. Let ``N2`` be the number of dimensions of array ``B`` (i.e., the result of ``len(shape2)``).
33
33
34
-
1. Let ``N`` be the maximum value of ``N1`` and ``N2`` (i.e., the result of ``max(N1, N2)``).
34
+
#. Let ``N`` be the maximum value of ``N1`` and ``N2`` (i.e., the result of ``max(N1, N2)``).
35
35
36
-
1. Let ``shape`` be a temporary list of length ``N`` for storing the shape of the result array.
36
+
#. Let ``shape`` be a temporary list of length ``N`` for storing the shape of the result array.
37
37
38
-
1. Let ``i`` be ``N-1``.
38
+
#. Let ``i`` be ``N-1``.
39
39
40
-
1. Repeat, while ``i >= 0``
40
+
#. Repeat, while ``i >= 0``
41
41
42
-
1. Let ``n1`` be ``N1 - N + i``.
42
+
#. Let ``n1`` be ``N1 - N + i``.
43
43
44
-
1. If ``n1 >= 0``, let ``d1`` be the size of dimension ``n1`` for array ``A`` (i.e., the result of ``shape1[n1]``); else, let ``d1`` be ``1``.
44
+
#. If ``n1 >= 0``, let ``d1`` be the size of dimension ``n1`` for array ``A`` (i.e., the result of ``shape1[n1]``); else, let ``d1`` be ``1``.
45
45
46
-
1. Let ``n2`` be ``N2 - N + i``.
46
+
#. Let ``n2`` be ``N2 - N + i``.
47
47
48
-
1. If ``n2 >= 0``, let ``d2`` be the size of dimension ``n2`` for array ``B`` (i.e., the result of ``shape2[n2]``); else, let ``d2`` be ``1``.
48
+
#. If ``n2 >= 0``, let ``d2`` be the size of dimension ``n2`` for array ``B`` (i.e., the result of ``shape2[n2]``); else, let ``d2`` be ``1``.
49
49
50
-
1. If ``d1 == 1``, then
50
+
#. If ``d1 == 1``, then
51
51
52
52
- set the ``i``th element of ``shape`` to ``d2``.
53
53
54
-
1. Else, if ``d2 == 1``, then
54
+
#. Else, if ``d2 == 1``, then
55
55
56
56
- set the ``i``th element of ``shape`` to ``d1``.
57
57
58
-
1. Else, if ``d1 == d2``, then
58
+
#. Else, if ``d1 == d2``, then
59
59
60
60
- set the ``i``th element of ``shape`` to ``d1``.
61
61
62
-
1. Else, throw an exception.
62
+
#. Else, throw an exception.
63
63
64
-
1. Set ``i`` to ``i-1``.
64
+
#. Set ``i`` to ``i-1``.
65
65
66
-
1. Let ``tuple(shape)`` be the shape of the result array.
66
+
#. Let ``tuple(shape)`` be the shape of the result array.
67
67
68
68
Examples
69
69
~~~~~~~~
@@ -117,4 +117,4 @@ The following examples demonstrate array shapes which do **not** broadcast.
117
117
In-place Semantics
118
118
------------------
119
119
120
-
As implied by the broadcasting algorithm, in-place element-wise operations must not change the shape of the in-place array as a result of broadcasting.
120
+
As implied by the broadcasting algorithm, in-place element-wise operations must not change the shape of the in-place array as a result of broadcasting.
0 commit comments