arrayfire / arrayfire-rust

Rust wrapper for ArrayFire
BSD 3-Clause "New" or "Revised" License
810 stars 58 forks source link

How to convert Seq to Array? #332

Closed 3togo closed 1 year ago

3togo commented 1 year ago

In c++, convert seq to array is very simple and is shown as following:

seq s(10, 20, 2); // [10, 20, 2] => 10, 12, 14....20 array arr = s; af_print(arr); // 10 12 14 16 18 20

However, how to do the same in arrayfire-rust?

Eli

9prady9 commented 1 year ago

@3togo I believe there is no direct syntactic form like the C++ wrapper of ArrayFire. However, you can easily implement one by doing the following

let r = range(seq_len);
let sa = seq_begin + seq_step * r;

Please note that the above is only for quick illustration, kindly refer to - C++ code for the exact logic.

3togo commented 1 year ago

many thanks