I would like to create the imaginary unit in ArrayFire, but I can't. I can construct a complex matrix from a real matrix, but that will not be pure imaginary. Perhaps I can use function af_cplx2 from this page. I thought of the following:
af_array *R;
const af_array re = 0.0;
const af_array im = 1.0;
af_cplx2(R,re,im,0);
However I get a runtime error (unhandled exception) in Visual Studio 2013. How can I do it? Thank you in advance.
Here's how you would do it using the C and C++ APIs. You can find the APIs here: http://www.arrayfire.com/docs/group__data__func__constant.htm
// Using C++ API
cfloat h_unit = {0, 1} // Host side
af::array unit = af::constant(h_unit, 1, c32); // Creates an array of size 1 containing all {0, 1} on device side.
// Using C API
af_array af_unit = 0;
dim_type dims{} = {1};
dim_type ndims = 1;
af_constant_complex(&af_unit, 0, 1, ndims, dims, c32};
This an answer expands on the answer by Christopher Columbus.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With