Sha256: 7ef3a85fe78f893a4a9f237b81369e678ae3ba3d18ec0533dc1d35e833238e93

Contents?: true

Size: 1.49 KB

Versions: 19

Compression:

Stored size: 1.49 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 = Cumo::DFloat.new(4,5).seq
      => Cumo::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]
      => Cumo::DFloat#shape=[3]
      [6, 11, 16]

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

      a[true,2].fill(99)
      a
      => Cumo::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;
    dtype x;

    nd = cumo_na_get_result_dimension(self, argc, argv, 1, &pos);
    if (nd) {
        return cumo_na_aref_main(argc, argv, self, 0, nd, pos);
    } else {
        ptr = cumo_na_get_pointer_for_read(self);
        CUMO_SHOW_SYNCHRONIZE_WARNING_ONCE("<%=name%>", "<%=type_name%>");
        cumo_cuda_runtime_check_status(cudaDeviceSynchronize());
        CUMO_LOAD_BIT(ptr,pos,x);
        return m_data_to_num(x);
    }
}

Version data entries

19 entries across 19 versions & 1 rubygems

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