Sha256: b4de14c8ff2db8dafe0fe5f363f4edb4e60898ab06fea293c4176cda7bf854e3

Contents?: true

Size: 1.3 KB

Versions: 10

Compression:

Stored size: 1.3 KB

Contents

/*
  Array element referenece or slice view.
  @overload [](dim0,...,dimL)
  @param [Numeric,Range,etc] dim0,...,dimL  Multi-dimensional Index.
  @return [Numeric,NArray::<%=class_name%>] Element object or NArray view.

  --- Returns the element at +dim0+, +dim1+, ... are Numeric indices
  for each dimension, or returns a NArray View as a sliced subarray if
  +dim0+, +dim1+, ... includes other than Numeric index, e.g., Range
  or Array or true.

  @example
      a = Numo::DFloat.new(4,5).seq
      => Numo::DFloat#shape=[4,5]
      [[0, 1, 2, 3, 4],
       [5, 6, 7, 8, 9],
       [10, 11, 12, 13, 14],
       [15, 16, 17, 18, 19]]

      a[1,1]
      => 6.0

      a[1..3,1]
      => Numo::DFloat#shape=[3]
      [6, 11, 16]

      a[1,[1,3,4]]
      => Numo::DFloat#shape=[3]
      [6, 8, 9]

      a[true,2].fill(99)
      a
      => Numo::DFloat#shape=[4,5]
      [[0, 1, 99, 3, 4],
       [5, 6, 99, 8, 9],
       [10, 11, 99, 13, 14],
       [15, 16, 99, 18, 19]]
 */
static VALUE
<%=c_func(-1)%>(int argc, VALUE *argv, VALUE self)
{
    int nd;
    size_t pos;
    char *ptr;

    nd = na_get_result_dimension(self, argc, argv, sizeof(dtype), &pos);
    if (nd) {
        return na_aref_main(argc, argv, self, 0, nd);
    } else {
        ptr = na_get_pointer_for_read(self) + pos;
        return m_extract(ptr);
    }
}

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
numo-narray-0.9.1.4 ext/numo/narray/gen/tmpl/aref.c
numo-narray-0.9.1.3 ext/numo/narray/gen/tmpl/aref.c
numo-narray-0.9.1.2 ext/numo/narray/gen/tmpl/aref.c
numo-narray-0.9.1.1 ext/numo/narray/gen/tmpl/aref.c
numo-narray-0.9.1.0 ext/numo/narray/gen/tmpl/aref.c
numo-narray-0.9.0.9 ext/numo/narray/gen/tmpl/aref.c
numo-narray-0.9.0.8 ext/numo/narray/gen/tmpl/aref.c
numo-narray-0.9.0.7 ext/numo/narray/gen/tmpl/aref.c
numo-narray-0.9.0.6 ext/numo/narray/gen/tmpl/aref.c
numo-narray-0.9.0.5 ext/numo/narray/gen/tmpl/aref.c