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: doc/devdocs/cartesian.rst
+65-45Lines changed: 65 additions & 45 deletions
Original file line number
Diff line number
Diff line change
@@ -138,72 +138,92 @@ Macro reference
138
138
139
139
.. function:: @nloops N itersym rangeexpr bodyexpr
140
140
141
+
.. Warning: this docstring is autogenerated.
141
142
::
142
-
@nloops N itersym rangeexpr preexpr bodyexpr
143
-
@nloops N itersym rangeexpr preexpr postexpr bodyexpr
144
-
145
-
Generate ``N`` nested loops, using ``itersym`` as the prefix for
146
-
the iteration variables. ``rangeexpr`` may be an
147
-
anonymous-function expression, or a simple symbol ``var`` in which
148
-
case the range is ``1:size(var,d)`` for dimension ``d``.
149
-
150
-
Optionally, you can provide "pre" and "post" expressions. These
151
-
get executed first and last, respectively, in the body of each
152
-
loop. For example,
153
-
::
154
-
155
-
@nloops 2 i A d->j_d=min(i_d,5) begin
156
-
s += @nref 2 A j
157
-
end
158
-
159
-
would generate
160
-
::
161
-
162
-
for i_2 = 1:size(A, 2)
163
-
j_2 = min(i_2, 5)
164
-
for i_1 = 1:size(A, 1)
165
-
j_1 = min(i_1, 5)
166
-
s += A[j_1,j_2]
167
-
end
168
-
end
169
-
170
-
If you want just a post-expression, supply
171
-
``nothing`` for the pre-expression. Using parenthesis and
172
-
semicolons, you can supply multi-statement expressions.
143
+
144
+
@nloops N itersym rangeexpr bodyexpr
145
+
@nloops N itersym rangeexpr preexpr bodyexpr
146
+
@nloops N itersym rangeexpr preexpr postexpr bodyexpr
147
+
148
+
Generate ``N`` nested loops, using ``itersym`` as the prefix for the iteration variables. ``rangeexpr`` may be an anonymous-function expression, or a simple symbol ``var`` in which case the range is ``1:size(var,d)`` for dimension ``d``.
149
+
150
+
Optionally, you can provide "pre" and "post" expressions. These get executed first and last, respectively, in the body of each loop. For example, :
151
+
152
+
::
153
+
154
+
@nloops 2 i A d->j_d=min(i_d,5) begin
155
+
s += @nref 2 A j
156
+
end
157
+
158
+
would generate :
159
+
160
+
::
161
+
162
+
for i_2 = 1:size(A, 2)
163
+
j_2 = min(i_2, 5)
164
+
for i_1 = 1:size(A, 1)
165
+
j_1 = min(i_1, 5)
166
+
s += A[j_1,j_2]
167
+
end
168
+
end
169
+
170
+
If you want just a post-expression, supply ``nothing`` for the pre-expression. Using parenthesis and semicolons, you can supply multi-statement expressions.
173
171
174
172
.. function:: @nref N A indexexpr
175
173
176
-
Generate expressions like ``A[i_1,i_2,...]``. ``indexexpr`` can
177
-
either be an iteration-symbol prefix, or an anonymous-function
178
-
expression.
174
+
.. Warning: this docstring is autogenerated.
175
+
::
176
+
177
+
@nref N A indexexpr
178
+
179
+
Generate expressions like ``A[i_1,i_2,...]``. ``indexexpr`` can either be an iteration-symbol prefix, or an anonymous-function expression.
179
180
180
181
.. function:: @nexprs N expr
181
182
182
-
Generate ``N`` expressions. ``expr`` should be an
183
-
anonymous-function expression.
183
+
.. Warning: this docstring is autogenerated.
184
+
::
185
+
186
+
@nexprs N expr
187
+
188
+
Generate ``N`` expressions. ``expr`` should be an anonymous-function expression.
184
189
185
190
.. function:: @ntuple N expr
186
191
187
-
Generates an ``N``-tuple. ``@ntuple 2 i`` would generate ``(i_1, i_2)``, and ``@ntuple 2 k->k+1`` would generate ``(2,3)``.
192
+
.. Warning: this docstring is autogenerated.
193
+
::
194
+
195
+
@ntuple N expr
196
+
197
+
Generates an ``N``-tuple. ``@ntuple 2 i`` would generate ``(i_1, i_2)``, and ``@ntuple 2 k->k+1`` would generate ``(2,3)``.
188
198
189
199
.. function:: @nall N expr
190
200
191
-
``@nall 3 d->(i_d > 1)`` would generate the expression
192
-
``(i_1 > 1 && i_2 > 1 && i_3 > 1)``. This can be convenient for
193
-
bounds-checking.
201
+
.. Warning: this docstring is autogenerated.
202
+
::
203
+
204
+
@nall N expr
205
+
206
+
``@nall 3 d->(i_d > 1)`` would generate the expression ``(i_1 > 1 && i_2 > 1 && i_3 > 1)``. This can be convenient for bounds-checking.
194
207
195
208
.. function:: @nif N conditionexpr expr
196
209
210
+
.. Warning: this docstring is autogenerated.
197
211
::
198
-
@nif N conditionexpr expr elseexpr
199
212
200
-
Generates a sequence of ``if ... elseif ... else ... end`` statements. For example::
0 commit comments