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 = test.host<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.
xiongtx
 
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,
ArrayFire
--
~ If it is not broken, you have not tried hard enough ~
User avatar
pavanky
Site Admin
 
Posts: 1123
Joined: Mon Mar 15, 2010 7:39 pm
Location: Atlanta, GA

Randu

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

Hi

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
Medivh
 
Posts: 6
Joined: Fri Jul 18, 2014 9:19 am

Re: Host array with double?

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

Hi

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.
----
Shehzan
Developer
AccelerEyes
User avatar
shehzan
 
Posts: 121
Joined: Tue Feb 12, 2013 7:20 pm


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

cron