Skip to content

Commit 8eab12d

Browse files
committed
Refactor eval to handle patterns handled by equation macro(removed now)
1 parent 661f9c5 commit 8eab12d

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

src/core/macros.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -117,20 +117,6 @@ macro_rules! af_print {
117117
};
118118
}
119119

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-
134120
/// Create a dim4 object from provided dimensions
135121
///
136122
/// The user can pass 1 or more sizes and the left over values will default to 1.
@@ -227,16 +213,21 @@ macro_rules! view {
227213
};
228214
}
229215

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.
232220
///
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]
234224
///
235225
/// [1]: http://arrayfire.org/arrayfire-rust/arrayfire/struct.Seq.html
236226
/// [2]: http://arrayfire.org/arrayfire-rust/arrayfire/struct.Array.html
237227
/// [3]: http://arrayfire.org/arrayfire-rust/book/indexing.html
228+
/// [4]: http://arrayfire.org/arrayfire-rust/arrayfire/struct.Array.html#method.eval
238229
#[macro_export]
239-
macro_rules! equation {
230+
macro_rules! eval {
240231
( $l:ident [ $($lb:literal : $le:literal : $ls:literal),+ ] =
241232
$r:ident [ $($rb:literal : $re:literal : $rs:literal),+ ]) => {
242233
{
@@ -284,6 +275,15 @@ macro_rules! equation {
284275
$crate::assign_gen(&mut $lhs, &idxrs, &$rhs);
285276
}
286277
};
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+
};
287287
}
288288

289289
#[cfg(test)]
@@ -381,7 +381,7 @@ mod tests {
381381
let d1 = seq!(1:2:1);
382382
let s0 = seq!(1:2:1);
383383
let s1 = seq!(1:2:1);
384-
equation!(a[d0, d1] = b[s0, s1]);
384+
eval!(a[d0, d1] = b[s0, s1]);
385385
//print(&a);
386386
//[5 5 1 1]
387387
// 0.6010 0.5497 0.1583 0.3636 0.6755
@@ -396,15 +396,15 @@ mod tests {
396396
let dims = dim4!(5, 5);
397397
let mut a = randu::<f32>(dims);
398398
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]);
400400
}
401401

402402
#[test]
403403
fn equation_macro3() {
404404
// ANCHOR: macro_seq_assign
405405
let mut a = randu::<f32>(dim4!(5, 5));
406406
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);
408408
// ANCHOR_END: macro_seq_assign
409409
}
410410

@@ -418,7 +418,7 @@ mod tests {
418418

419419
let b = constant(2.0 as f32, dim4!(3, 3));
420420

421-
equation!(a[indices, seq4gen] = b);
421+
eval!(a[indices, seq4gen] = b);
422422
// ANCHOR_END: macro_seq_array_assign
423423
}
424424
}

0 commit comments

Comments
 (0)