seq::seq(double begin, double end, double step): m_gfor(false) { if (step == 0) { if (begin != end) // Span AF_THROW_ERR("Invalid step size", AF_ERR_ARG); } if (end >= 0 && begin >= 0 && signbit(end-begin) != signbit(step)) AF_THROW_ERR("Sequence is invalid", AF_ERR_ARG); //AF_THROW("step must match direction of sequence"); init(begin, end, step); }
array where(const array& in) { if (gforGet()) { AF_THROW_ERR("WHERE can not be used inside GFOR", AF_ERR_RUNTIME); } af_array out = 0; AF_THROW(af_where(&out, in.get())); return array(out); }
static void initDataArray(af_array *arr, const T *ptr, af::source src, dim_t d0, dim_t d1=1, dim_t d2=1, dim_t d3=1) { af::dtype ty = (af::dtype)dtype_traits<T>::af_type; dim_t my_dims[] = {d0, d1, d2, d3}; switch (src) { case afHost: AF_THROW(af_create_array(arr, (const void * const)ptr, AF_MAX_DIMS, my_dims, ty)); break; case afDevice: AF_THROW(af_device_array(arr, (const void * )ptr, AF_MAX_DIMS, my_dims, ty)); break; default: AF_THROW_ERR("Can not create array from the requested source pointer", AF_ERR_ARG); } }
const array::array_proxy array::operator()(const index &s0) const { index z = index(0); if(isvector()){ switch(numDims(this->arr)) { case 1: return gen_indexing(*this, s0, z, z, z); case 2: return gen_indexing(*this, z, s0, z, z); case 3: return gen_indexing(*this, z, z, s0, z); case 4: return gen_indexing(*this, z, z, z, s0); default: AF_THROW_ERR("ndims for Array is invalid", AF_ERR_SIZE); } } else { return gen_indexing(*this, s0, z, z, z, true); } }