Host array with double?

[Old posts from the commercial version of ArrayFire] Discussion of ArrayFire using CUDA or OpenCL.

Moderator: pavanky

Host array with double?

Postby xiongtx » Tue Feb 26, 2013 12:56 pm

I'm wondering why the following throws an exception:

Code: Select all
array test = randu(5);
double *test =<double>();

which gives the error message: An unhandled exception of type 'System.Runtime.InteropServices.SEHException' occurred in test_arrayfire_vcpp.exe

However, using float instead of double works fine.
Posts: 50
Joined: Fri May 04, 2012 3:50 am

Re: Host array with double?

Postby pavanky » Thu Mar 07, 2013 3:33 pm

By default randu creats floats. Use randu(5,f64) to generate double precision numbers.
Pavan Yalamanchili,
~ If it is not broken, you have not tried hard enough ~
User avatar
Site Admin
Posts: 1123
Joined: Mon Mar 15, 2010 7:39 pm
Location: Atlanta, GA


Postby Medivh » Tue Oct 07, 2014 4:26 am


if i generate an array by randu(4);, it gives same output each time. The output is uniformly distributed but not really random. It should give different values for each execution.

any suggestion?

Arrayfire v2.1 win64
Posts: 6
Joined: Fri Jul 18, 2014 9:19 am

Re: Host array with double?

Postby shehzan » Tue Oct 07, 2014 2:02 pm


The different values are not generated because the starting seed value remains the same.
If you would like to use a different seed, use the af_rand_setseed(unsigned long long seed) function.
User avatar
Posts: 121
Joined: Tue Feb 12, 2013 7:20 pm

Return to [archive-commercial] Programming & Development with ArrayFire