Sha256: 7066803e639e7351c772b68d67dd642ef8da14b05ab6a66178b26e19e7f30355

Contents?: true

Size: 607 Bytes

Versions: 17

Compression:

Stored size: 607 Bytes

Contents

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

static VALUE
<%=c_func(0)%>(VALUE self)
{
    BIT_DIGIT *ptr, val;
    size_t pos;
    narray_t *na;
    GetNArray(self,na);

    if (na->ndim==0) {
        pos = na_get_offset(self);
        ptr = (BIT_DIGIT*)na_get_pointer_for_read(self);
        val = ((*((ptr)+(pos)/NB)) >> ((pos)%NB)) & 1u;
        na_release_lock(self);
        return INT2FIX(val);
    }
    return self;
}

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
numo-narray-0.9.2.1 ext/numo/narray/gen/tmpl_bit/extract.c
numo-narray-0.9.2.0 ext/numo/narray/gen/tmpl_bit/extract.c
numo-narray-0.9.1.9 ext/numo/narray/gen/tmpl_bit/extract.c
numo-narray-0.9.1.8 ext/numo/narray/gen/tmpl_bit/extract.c
numo-narray-0.9.1.7 ext/numo/narray/gen/tmpl_bit/extract.c
numo-narray-0.9.1.6 ext/numo/narray/gen/tmpl_bit/extract.c
numo-narray-0.9.1.5 ext/numo/narray/gen/tmpl_bit/extract.c
numo-narray-0.9.1.4 ext/numo/narray/gen/tmpl_bit/extract.c
numo-narray-0.9.1.3 ext/numo/narray/gen/tmpl_bit/extract.c
numo-narray-0.9.1.2 ext/numo/narray/gen/tmpl_bit/extract.c
numo-narray-0.9.1.1 ext/numo/narray/gen/tmpl_bit/extract.c
numo-narray-0.9.1.0 ext/numo/narray/gen/tmpl_bit/extract.c
numo-narray-0.9.0.9 ext/numo/narray/gen/tmpl_bit/extract.c
numo-narray-0.9.0.8 ext/numo/narray/gen/tmpl_bit/extract.c
numo-narray-0.9.0.7 ext/numo/narray/gen/tmpl_bit/extract.c
numo-narray-0.9.0.6 ext/numo/narray/gen/tmpl_bit/extract.c
numo-narray-0.9.0.5 ext/numo/narray/gen/tmpl_bit/extract.c