Sha256: 5cf76a1b8f28aafa84f46f85634c4178943c832f818c2efc69a059daa07824bb

Contents?: true

Size: 884 Bytes

Versions: 19

Compression:

Stored size: 884 Bytes

Contents

/*
  Extract an element only if self is a dimensionless NArray.
  @overload extract
  @return [Numeric,Cumo::NArray]
  --- Extract element value as Ruby Object if self is a dimensionless NArray,
  otherwise returns self.
*/

// TODO(sonots): Return Cumo::Bit instead of ruby built-in object to avoid synchronization
static VALUE
<%=c_func(0)%>(VALUE self)
{
    CUMO_BIT_DIGIT *ptr, val;
    size_t pos;
    cumo_narray_t *na;
    CumoGetNArray(self,na);

    if (na->ndim==0) {
        pos = cumo_na_get_offset(self);
        ptr = (CUMO_BIT_DIGIT*)cumo_na_get_pointer_for_read(self);

        CUMO_SHOW_SYNCHRONIZE_WARNING_ONCE("<%=name%>", "<%=type_name%>");
        cumo_cuda_runtime_check_status(cudaDeviceSynchronize());

        val = ((*((ptr)+(pos)/CUMO_NB)) >> ((pos)%CUMO_NB)) & 1u;
        cumo_na_release_lock(self);
        return INT2FIX(val);
    }
    return self;
}

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
cumo-0.4.3 ext/cumo/narray/gen/tmpl_bit/extract.c
cumo-0.4.2 ext/cumo/narray/gen/tmpl_bit/extract.c
cumo-0.4.1 ext/cumo/narray/gen/tmpl_bit/extract.c
cumo-0.4.0 ext/cumo/narray/gen/tmpl_bit/extract.c
cumo-0.3.5 ext/cumo/narray/gen/tmpl_bit/extract.c
cumo-0.3.4 ext/cumo/narray/gen/tmpl_bit/extract.c
cumo-0.3.3 ext/cumo/narray/gen/tmpl_bit/extract.c
cumo-0.3.2 ext/cumo/narray/gen/tmpl_bit/extract.c
cumo-0.3.1 ext/cumo/narray/gen/tmpl_bit/extract.c
cumo-0.3.0 ext/cumo/narray/gen/tmpl_bit/extract.c
cumo-0.3.0.pre1 ext/cumo/narray/gen/tmpl_bit/extract.c
cumo-0.2.5 ext/cumo/narray/gen/tmpl_bit/extract.c
cumo-0.2.4 ext/cumo/narray/gen/tmpl_bit/extract.c
cumo-0.2.3 ext/cumo/narray/gen/tmpl_bit/extract.c
cumo-0.2.2 ext/cumo/narray/gen/tmpl_bit/extract.c
cumo-0.2.1 ext/cumo/narray/gen/tmpl_bit/extract.c
cumo-0.2.0 ext/cumo/narray/gen/tmpl_bit/extract.c
cumo-0.1.2 ext/cumo/narray/gen/tmpl_bit/extract.c
cumo-0.1.1 ext/cumo/narray/gen/tmpl_bit/extract.c