Reputation: 323
I am getting a Segmentation Fault, from calling a simple arrayfire constructor.
#include <arrayfire.h>
int main(){
af_array a;
int N = 10;
dim_t dims = 10;
af_randu(&a, N, &dims, f32);
af::array b(a);
return 0;
}
Upvotes: 0
Views: 163
Reputation: 331
af_randu
is C-API function in ArrayFire. Ideally, there is no need for users to be directly calling these functions.
What you would need to call is af::randu(). So your call to randu would be:
af:array b = af::randu(N, f32);
The following is just to answer the question asked, the C-API for af_randu is
AFAPI af_err af_randu(af_array *out,
const unsigned ndims,
const dim_t *const dims,
const af_dtype type
)
So the second argument is ndims
(number of dimensions), which in your case is 1. Hence your call to af_randu is:
af_randu(&a, 1, &dims, f32);
If you were doing a matrix of lets say 10x10, then you would do
dim_t dims[] = {10, 10}
af_randu(&a, 2, dims, f32);
Full disclosure: I am a developer for ArrayFire.
Upvotes: 2