@@ -117,20 +117,6 @@ macro_rules! af_print {
117
117
} ;
118
118
}
119
119
120
- /// Evaluate arbitrary number of arrays
121
- #[ macro_export]
122
- macro_rules! eval {
123
- [ $( $x: expr) ,+] => {
124
- {
125
- let mut temp_vec = Vec :: new( ) ;
126
- $(
127
- temp_vec. push( $x) ;
128
- ) *
129
- eval_multiple( temp_vec)
130
- }
131
- } ;
132
- }
133
-
134
120
/// Create a dim4 object from provided dimensions
135
121
///
136
122
/// The user can pass 1 or more sizes and the left over values will default to 1.
@@ -227,16 +213,21 @@ macro_rules! view {
227
213
} ;
228
214
}
229
215
230
- /// This macro is syntactic sugar for modifying portions of Array with another Array using a
231
- /// combination of [Sequences][1] and/or [Array][2] objects.
216
+ /// Macro to evaluate individual Arrays or assignment operations
217
+ ///
218
+ /// - Evaluate on one or more Array identifiers: essentially calls [Array::eval][4] on each of those
219
+ /// Array objects individually.
232
220
///
233
- /// Examples on how to use this macro are provided in the [tutorials book][3]
221
+ /// - Evaluate assignment operations: This is essentially syntactic sugar for modifying portions of
222
+ /// Array with another Array using a combination of [Sequences][1] and/or [Array][2] objects.
223
+ /// Examples for this use case are provided in the [tutorials book][3]
234
224
///
235
225
/// [1]: http://arrayfire.org/arrayfire-rust/arrayfire/struct.Seq.html
236
226
/// [2]: http://arrayfire.org/arrayfire-rust/arrayfire/struct.Array.html
237
227
/// [3]: http://arrayfire.org/arrayfire-rust/book/indexing.html
228
+ /// [4]: http://arrayfire.org/arrayfire-rust/arrayfire/struct.Array.html#method.eval
238
229
#[ macro_export]
239
- macro_rules! equation {
230
+ macro_rules! eval {
240
231
( $l: ident [ $( $lb: literal : $le: literal : $ls: literal) ,+ ] =
241
232
$r: ident [ $( $rb: literal : $re: literal : $rs: literal) ,+ ] ) => {
242
233
{
@@ -284,6 +275,15 @@ macro_rules! equation {
284
275
$crate:: assign_gen( & mut $lhs, & idxrs, & $rhs) ;
285
276
}
286
277
} ;
278
+ [ $( $x: ident) ,+] => {
279
+ {
280
+ let mut temp_vec = Vec :: new( ) ;
281
+ $(
282
+ temp_vec. push( $x) ;
283
+ ) *
284
+ eval_multiple( temp_vec)
285
+ }
286
+ } ;
287
287
}
288
288
289
289
#[ cfg( test) ]
@@ -381,7 +381,7 @@ mod tests {
381
381
let d1 = seq ! ( 1 : 2 : 1 ) ;
382
382
let s0 = seq ! ( 1 : 2 : 1 ) ;
383
383
let s1 = seq ! ( 1 : 2 : 1 ) ;
384
- equation ! ( a[ d0, d1] = b[ s0, s1] ) ;
384
+ eval ! ( a[ d0, d1] = b[ s0, s1] ) ;
385
385
//print(&a);
386
386
//[5 5 1 1]
387
387
// 0.6010 0.5497 0.1583 0.3636 0.6755
@@ -396,15 +396,15 @@ mod tests {
396
396
let dims = dim4 ! ( 5 , 5 ) ;
397
397
let mut a = randu :: < f32 > ( dims) ;
398
398
let b = randu :: < f32 > ( dims) ;
399
- equation ! ( a[ 1 : 2 : 1 , 1 : 2 : 1 ] = b[ 1 : 2 : 1 , 1 : 2 : 1 ] ) ;
399
+ eval ! ( a[ 1 : 2 : 1 , 1 : 2 : 1 ] = b[ 1 : 2 : 1 , 1 : 2 : 1 ] ) ;
400
400
}
401
401
402
402
#[ test]
403
403
fn equation_macro3 ( ) {
404
404
// ANCHOR: macro_seq_assign
405
405
let mut a = randu :: < f32 > ( dim4 ! ( 5 , 5 ) ) ;
406
406
let b = randu :: < f32 > ( dim4 ! ( 2 , 2 ) ) ;
407
- equation ! ( a[ 1 : 2 : 1 , 1 : 2 : 1 ] = b) ;
407
+ eval ! ( a[ 1 : 2 : 1 , 1 : 2 : 1 ] = b) ;
408
408
// ANCHOR_END: macro_seq_assign
409
409
}
410
410
@@ -418,7 +418,7 @@ mod tests {
418
418
419
419
let b = constant ( 2.0 as f32 , dim4 ! ( 3 , 3 ) ) ;
420
420
421
- equation ! ( a[ indices, seq4gen] = b) ;
421
+ eval ! ( a[ indices, seq4gen] = b) ;
422
422
// ANCHOR_END: macro_seq_array_assign
423
423
}
424
424
}
0 commit comments