Sha256: c9df218508ad89eef73e512d085c243925f25e2d3edbb0bb750930e9b40d78e5

Contents?: true

Size: 615 Bytes

Versions: 3

Compression:

Stored size: 615 Bytes

Contents

static VALUE
create_new_narray(VALUE datatype, VALUE vshape)
{
    size_t size, *shape;
    int j, ndim;

    switch(TYPE(vshape)) {
    case T_FIXNUM:
    case T_BIGNUM:
        size = NUM2SIZET(vshape);
        ndim = 1;
        shape = &size;
        break;
    case T_ARRAY:
        ndim = RARRAY_LEN(vshape);
        shape = ALLOCA_N(size_t,ndim);
        size = 1;
        for (j=0; j<ndim; j++) {
            shape[j] = NUM2SIZET(RARRAY_AREF(vshape,j));
        }
        break;
    default:
        rb_raise(rb_eArgError,"invalid argument for shape");
    }
    return rb_narray_new(datatype,ndim,shape);
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
numo-gsl-0.1.2 ext/numo/gsl/gen/tmpl/create_new_narray.c
numo-gsl-0.1.1 ext/numo/gsl/gen/tmpl/create_new_narray.c
numo-gsl-0.1.0 ext/numo/gsl/gen/tmpl/create_new_narray.c