Sha256: baeccaded46452764ad0cfb64c908d4e5210f3b758eea2214defa7b4997e034d

Contents?: true

Size: 781 Bytes

Versions: 3

Compression:

Stored size: 781 Bytes

Contents

<% nd = (/histogram2d/ =~ struct) ? 2 : 1 %>
/*
  @overload <%=name%>()
  @return [DFloat]    narray of <%=name%> field in <%=struct%>.

  returns <%=name%> field in <%=struct%> struct.
  <%= description %>
*/
static VALUE
<%=c_func(0)%>(VALUE self)
{
    <%=struct%> *w;
    double *d;
    VALUE v;
    size_t n, i, shape[<%=nd%>];

    TypedData_Get_Struct(self, <%=struct%>, &<%=data_type_var%>, w);

    <%if /([xy]?)range/ =~ name %>
    shape[0] = n = w->n<%=$1%>+1;
    <%elsif nd==1%>
    shape[0] = n = w->n;
    <%else%>
    n = w->nx * w->ny;
    shape[0] = w->nx;
    shape[1] = w->ny;
    <%end%>

    v = rb_narray_new(cDF, <%=nd%>, shape);
    d = (double*)na_get_pointer_for_write(v);
    for (i=0; i<n; i++) {
        d[i] = w-><%=name%>[i];
    }
    return v;
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
numo-gsl-0.1.2 ext/numo/gsl/histogram/tmpl/c_DFloat_f_field.c
numo-gsl-0.1.1 ext/numo/gsl/histogram/tmpl/c_DFloat_f_field.c
numo-gsl-0.1.0 ext/numo/gsl/histogram/tmpl/c_DFloat_f_field.c