That is unexpected, here is a full blown standalone example code (followed by the sample output) that works fine.
#include <arrayfire.h>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <iostream>
#include <vector>
using namespace af;
int main(int argc, char* argv[]) {
try {
int device = argc > 1 ? atoi(argv[1]) : 0;
af::setDevice(device);
af::info();
array A = randu(5, 3, c32);
af_print(A);
std::vector< std::complex<float> > hostca(A.elements());
A.host(hostca.data());
std::ostream_iterator< std::complex<float> > out_it(std::cout,", ");
std::copy(hostca.begin(), hostca.end(), out_it);
} catch (af::exception& e) {
fprintf(stderr, "%s\n", e.what());
throw;
}
return 0;
}
./build/ninja-cpu-mkl-debug/examples/helloworld/helloworld_cpu
ArrayFire v3.9.0 (CPU, 64-bit Linux, build 293601beb)
[0] AMD: AMD A10-7850K Radeon R7, 12 Compute Cores 4C+8GA
[5 3 1 1]
Offset: 0
Strides: [1 5 15 15]
(0.6010,0.0278) (0.1583,0.3712) (0.6755,0.6105)
(0.9806,0.2126) (0.3543,0.6450) (0.5232,0.5567)
(0.0655,0.5497) (0.9675,0.3636) (0.7896,0.8966)
(0.2864,0.3410) (0.4165,0.5814) (0.0536,0.5775)
(0.7509,0.4105) (0.8962,0.3712) (0.2908,0.9941)
(0.601,0.02776), (0.9806,0.2126), (0.06546,0.5497), (0.2864,0.341), (0.7509,0.4105), (0.1583,0.3712), (0.3543,0.645), (0.9675,0.3636), (0.4165,0.5814), (0.8962,0.3712), (0.6755,0.6105), (0.5232,0.5567), (0.7896,0.8966), (0.05364,0.5775), (0.2908,0.9941)
The example from Umar doesn't work.
Could you provide a working compilable example please?
Thanks!
--