Sha256: 49882d868a5c4a75d3590c6d55cf4b9ac188e406076cf1184d255f10f680b4a2

Contents?: true

Size: 1.33 KB

Versions: 19

Compression:

Stored size: 1.33 KB

Contents

/*
  Array element(s) set.
  @overload []=(dim0,..,dimL,val)
  @param [Numeric,Range,etc] dim0,..,dimL  Multi-dimensional Index.
  @param [Numeric,Cumo::NArray,etc] val  Value(s) to be set to self.
  @return [Numeric] returns val (last argument).

  --- Replace element(s) at +dim0+, +dim1+, ... (index/range/array/true
  for each dimention). Broadcasting mechanism is applied.

  @example
      a = Cumo::DFloat.new(3,4).seq
      => Cumo::DFloat#shape=[3,4]
      [[0, 1, 2, 3],
       [4, 5, 6, 7],
       [8, 9, 10, 11]]

      a[1,2]=99
      a
      => Cumo::DFloat#shape=[3,4]
      [[0, 1, 2, 3],
       [4, 5, 99, 7],
       [8, 9, 10, 11]]

      a[1,[0,2]] = [101,102]
      a
      => Cumo::DFloat#shape=[3,4]
      [[0, 1, 2, 3],
       [101, 5, 102, 7],
       [8, 9, 10, 11]]

      a[1,true]=99
      a
      => Cumo::DFloat#shape=[3,4]
      [[0, 1, 2, 3],
       [99, 99, 99, 99],
       [8, 9, 10, 11]]

*/
static VALUE
<%=c_func(-1)%>(int argc, VALUE *argv, VALUE self)
{
    int nd;
    size_t pos;
    VALUE a;

    argc--;
    if (argc==0) {
        <%=c_func.sub(/_aset/,"_store")%>(self, argv[argc]);
    } else {
        nd = cumo_na_get_result_dimension(self, argc, argv, 1, &pos);
        a = cumo_na_aref_main(argc, argv, self, 0, nd, pos);
        <%=c_func.sub(/_aset/,"_store")%>(a, argv[argc]);
    }
    return argv[argc];
}

Version data entries

19 entries across 19 versions & 1 rubygems

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