Class: Numo::RObject

Inherits:
NArray show all
Defined in:
ext/numo/narray/types/robject.c

Constant Summary

UPCAST =
hCast

Constants inherited from NArray

NArray::VERSION

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from NArray

#==, array_type, byte_size, #byte_size, #byte_swapped?, #cast_to, #check_axis, #coerce, #column_major?, concatenate, #concatenate, #contiguous?, debug=, #debug_info, #diagonal, #dot, #dsplit, dstack, #empty?, #expand_dims, eye, #flatten, from_binary, #host_order?, #hsplit, hstack, #initialize, #initialize_copy, #inplace, #inplace!, #inplace?, inspect_cols, inspect_cols=, inspect_rows, inspect_rows=, linspace, logspace, #marshal_dump, #marshal_load, #ndim, ones, #out_of_place!, profile, profile=, #repeat, #reshape, #reverse, #row_major?, #shape, #size, #split, srand, #store_binary, #swap_byte, #tile, #to_binary, #to_host, #to_network, #to_swapped, #to_vacs, #transpose, upcast, #view, #vsplit, vstack, zeros

Constructor Details

This class inherits a constructor from Numo::NArray

Class Method Details

.[](elements) ⇒ Numo::RObject .cast(array) ⇒ Numo::RObject

Cast object to Numo::RObject.

Parameters:

  • elements (Numeric, Array)
  • array (Array)

Returns:



1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
# File 'ext/numo/narray/types/robject.c', line 1128

static VALUE
numo_robject_s_cast(VALUE type, VALUE obj)
{
    VALUE v;
    narray_t *na;
    dtype x;

    if (CLASS_OF(obj)==cT) {
        return obj;
    }
    if (RTEST(rb_obj_is_kind_of(obj,rb_cNumeric))) {
        x = m_num_to_data(obj);
        return numo_robject_new_dim0(x);
    }
    if (RTEST(rb_obj_is_kind_of(obj,rb_cArray))) {
        return numo_robject_cast_array(obj);
    }
    if (IsNArray(obj)) {
        GetNArray(obj,na);
        v = rb_narray_new(cT, NA_NDIM(na), NA_SHAPE(na));
        if (NA_SIZE(na) > 0) {
            numo_robject_allocate(v);
            numo_robject_store(v,obj);
        }
        return v;
    }
    
    return numo_robject_new_dim0(obj);
    
#line 41 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/cast.c"
}

.[](elements) ⇒ Numo::RObject .cast(array) ⇒ Numo::RObject

Cast object to Numo::RObject.

Parameters:

  • elements (Numeric, Array)
  • array (Array)

Returns:



1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
# File 'ext/numo/narray/types/robject.c', line 1128

static VALUE
numo_robject_s_cast(VALUE type, VALUE obj)
{
    VALUE v;
    narray_t *na;
    dtype x;

    if (CLASS_OF(obj)==cT) {
        return obj;
    }
    if (RTEST(rb_obj_is_kind_of(obj,rb_cNumeric))) {
        x = m_num_to_data(obj);
        return numo_robject_new_dim0(x);
    }
    if (RTEST(rb_obj_is_kind_of(obj,rb_cArray))) {
        return numo_robject_cast_array(obj);
    }
    if (IsNArray(obj)) {
        GetNArray(obj,na);
        v = rb_narray_new(cT, NA_NDIM(na), NA_SHAPE(na));
        if (NA_SIZE(na) > 0) {
            numo_robject_allocate(v);
            numo_robject_store(v,obj);
        }
        return v;
    }
    
    return numo_robject_new_dim0(obj);
    
#line 41 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/cast.c"
}

Instance Method Details

#%(other) ⇒ Numo::NArray

Binary mod.

Parameters:

Returns:



2098
2099
2100
2101
2102
2103
2104
2105
# File 'ext/numo/narray/types/robject.c', line 2098

static VALUE
numo_robject_mod(VALUE self, VALUE other)
{
    
    return numo_robject_mod_self(self, other);
    
#line 57 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/binary.c"
}

#&(other) ⇒ Numo::NArray

Binary bit_and.

Parameters:

Returns:



2614
2615
2616
2617
2618
2619
2620
2621
# File 'ext/numo/narray/types/robject.c', line 2614

static VALUE
numo_robject_bit_and(VALUE self, VALUE other)
{
    
    return numo_robject_bit_and_self(self, other);
    
#line 57 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/binary.c"
}

#*(other) ⇒ Numo::NArray

Binary mul.

Parameters:

Returns:



1992
1993
1994
1995
1996
1997
1998
1999
# File 'ext/numo/narray/types/robject.c', line 1992

static VALUE
numo_robject_mul(VALUE self, VALUE other)
{
    
    return numo_robject_mul_self(self, other);
    
#line 57 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/binary.c"
}

#**(other) ⇒ Numo::NArray

Binary power.

Parameters:

Returns:



2227
2228
2229
2230
2231
2232
2233
2234
# File 'ext/numo/narray/types/robject.c', line 2227

static VALUE
numo_robject_pow(VALUE self, VALUE other)
{
    
    return numo_robject_pow_self(self,other);
    
#line 78 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/pow.c"
}

#+(other) ⇒ Numo::NArray

Binary add.

Parameters:

Returns:



1896
1897
1898
1899
1900
1901
1902
1903
# File 'ext/numo/narray/types/robject.c', line 1896

static VALUE
numo_robject_add(VALUE self, VALUE other)
{
    
    return numo_robject_add_self(self, other);
    
#line 57 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/binary.c"
}

#-(other) ⇒ Numo::NArray

Binary sub.

Parameters:

Returns:



1944
1945
1946
1947
1948
1949
1950
1951
# File 'ext/numo/narray/types/robject.c', line 1944

static VALUE
numo_robject_sub(VALUE self, VALUE other)
{
    
    return numo_robject_sub_self(self, other);
    
#line 57 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/binary.c"
}

#-@Numo::RObject

Unary minus.

Returns:



2288
2289
2290
2291
2292
2293
2294
2295
2296
# File 'ext/numo/narray/types/robject.c', line 2288

static VALUE
numo_robject_minus(VALUE self)
{
    ndfunc_arg_in_t ain[1] = {{cT,0}};
    ndfunc_arg_out_t aout[1] = {{cT,0}};
    ndfunc_t ndf = {iter_robject_minus, FULL_LOOP, 1,1, ain,aout};

    return na_ndloop(&ndf, 1, self);
}

#/(other) ⇒ Numo::NArray

Binary div.

Parameters:

Returns:



2045
2046
2047
2048
2049
2050
2051
2052
# File 'ext/numo/narray/types/robject.c', line 2045

static VALUE
numo_robject_div(VALUE self, VALUE other)
{
    
    return numo_robject_div_self(self, other);
    
#line 57 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/binary.c"
}

#[](dim0, ..., dimL) ⇒ Numeric, NArray::RObject

Array element referenece or slice 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.

Examples:

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]]

Parameters:

  • dim0,...,dimL (Numeric, Range, etc)

    Multi-dimensional Index.

Returns:

  • (Numeric, NArray::RObject)

    Element object or NArray view.



1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
# File 'ext/numo/narray/types/robject.c', line 1201

static VALUE
numo_robject_aref(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);
    }
}

#[]=(dim0, .., dimL, val) ⇒ Numeric

Array element(s) set. — Replace element(s) at dim0, dim1, … (index/range/array/true for each dimention). Broadcasting mechanism is applied.

Examples:

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

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

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

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

Parameters:

  • dim0,..,dimL (Numeric, Range, etc)

    Multi-dimensional Index.

  • val (Numeric, Numo::NArray, etc)

    Value(s) to be set to self.

Returns:

  • (Numeric)

    returns val (last argument).



1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
# File 'ext/numo/narray/types/robject.c', line 1259

static VALUE
numo_robject_aset(int argc, VALUE *argv, VALUE self)
{
    int nd;
    size_t pos;
    char *ptr;
    VALUE a;

    argc--;
    if (argc==0) {
        numo_robject_store(self, argv[argc]);
    } else {
        nd = na_get_result_dimension(self, argc, argv, sizeof(dtype), &pos);
        if (nd) {
            a = na_aref_main(argc, argv, self, 0, nd);
            numo_robject_store(a, argv[argc]);
        } else {
            ptr = na_get_pointer_for_read_write(self) + pos;
            *(dtype*)ptr = m_num_to_data(argv[argc]);
        }

    }
    return argv[argc];
}

#^(other) ⇒ Numo::NArray

Binary bit_xor.

Parameters:

Returns:



2710
2711
2712
2713
2714
2715
2716
2717
# File 'ext/numo/narray/types/robject.c', line 2710

static VALUE
numo_robject_bit_xor(VALUE self, VALUE other)
{
    
    return numo_robject_bit_xor_self(self, other);
    
#line 57 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/binary.c"
}

#absNumo::RObject

abs of self.

Returns:



1847
1848
1849
1850
1851
1852
1853
1854
1855
# File 'ext/numo/narray/types/robject.c', line 1847

static VALUE
numo_robject_abs(VALUE self)
{
    ndfunc_arg_in_t ain[1] = {{cT,0}};
    ndfunc_arg_out_t aout[1] = {{cRT,0}};
    ndfunc_t ndf = { iter_robject_abs, FULL_LOOP, 1, 1, ain, aout };

    return na_ndloop(&ndf, 1, self);
}

#allocateObject



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'ext/numo/narray/types/robject.c', line 100

static VALUE
numo_robject_allocate(VALUE self)
{
    narray_t *na;
    char *ptr;

    GetNArray(self,na);

    switch(NA_TYPE(na)) {
    case NARRAY_DATA_T:
        ptr = NA_DATA_PTR(na);
        if (na->size > 0 && ptr == NULL) {
            ptr = xmalloc(sizeof(dtype) * na->size);
            
            {   size_t i;
                VALUE *a = (VALUE*)ptr;
                for (i=na->size; i--;) {
                    *a++ = Qnil;
                }
            }
            
            NA_DATA_PTR(na) = ptr;
        }
        break;
    case NARRAY_VIEW_T:
        rb_funcall(NA_VIEW_DATA(na), rb_intern("allocate"), 0);
        break;
    case NARRAY_FILEMAP_T:
        //ptr = ((narray_filemap_t*)na)->ptr;
        // to be implemented
    default:
        rb_bug("invalid narray type : %d",NA_TYPE(na));
    }
    return self;
}

#ceilNumo::RObject

Unary ceil.

Returns:



2957
2958
2959
2960
2961
2962
2963
2964
2965
# File 'ext/numo/narray/types/robject.c', line 2957

static VALUE
numo_robject_ceil(VALUE self)
{
    ndfunc_arg_in_t ain[1] = {{cT,0}};
    ndfunc_arg_out_t aout[1] = {{cT,0}};
    ndfunc_t ndf = {iter_robject_ceil, FULL_LOOP, 1,1, ain,aout};

    return na_ndloop(&ndf, 1, self);
}

#coerce_cast(type) ⇒ nil

Returns:

  • (nil)


1290
1291
1292
1293
1294
# File 'ext/numo/narray/types/robject.c', line 1290

static VALUE
numo_robject_coerce_cast(VALUE value, VALUE type)
{
    return Qnil;
}

#cumprod(*args) ⇒ Numo::RObject

Cumprod of self.

Parameters:

  • args (Array of Numeric, Range)

    Affected dimensions.

Returns:



3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
# File 'ext/numo/narray/types/robject.c', line 3976

static VALUE
numo_robject_cumprod(int argc, VALUE *argv, VALUE self)
{
    VALUE reduce;
    ndfunc_arg_in_t ain[2] = {{cT,0},{sym_reduce,0}};
    ndfunc_arg_out_t aout[1] = {{cT,0}};
    ndfunc_t ndf = { iter_robject_cumprod, STRIDE_LOOP_NIP|NDF_INPLACE|NDF_FLAT_REDUCE|NDF_CUM,
                     2, 1, ain, aout };

    reduce = na_reduce_dimension(argc, argv, 1, &self);
    return na_ndloop(&ndf, 2, self, reduce);
}

#cumsum(*args) ⇒ Numo::RObject

Cumsum of self.

Parameters:

  • args (Array of Numeric, Range)

    Affected dimensions.

Returns:



3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
# File 'ext/numo/narray/types/robject.c', line 3930

static VALUE
numo_robject_cumsum(int argc, VALUE *argv, VALUE self)
{
    VALUE reduce;
    ndfunc_arg_in_t ain[2] = {{cT,0},{sym_reduce,0}};
    ndfunc_arg_out_t aout[1] = {{cT,0}};
    ndfunc_t ndf = { iter_robject_cumsum, STRIDE_LOOP_NIP|NDF_INPLACE|NDF_FLAT_REDUCE|NDF_CUM,
                     2, 1, ain, aout };

    reduce = na_reduce_dimension(argc, argv, 1, &self);
    return na_ndloop(&ndf, 2, self, reduce);
}

#divmod(other) ⇒ Numo::NArray

Binary divmod.

Parameters:

Returns:



2153
2154
2155
2156
2157
2158
2159
2160
# File 'ext/numo/narray/types/robject.c', line 2153

static VALUE
numo_robject_divmod(VALUE self, VALUE other)
{
    
    return numo_robject_divmod_self(self, other);
    
#line 59 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/binary2.c"
}

#eachNumo::NArray

Calls the given block once for each element in self, passing that element as a parameter. For a block {|x| … }

Yields:

  • (x)

    x is element of NArray.

Returns:



1557
1558
1559
1560
1561
1562
1563
1564
1565
# File 'ext/numo/narray/types/robject.c', line 1557

static VALUE
numo_robject_each(VALUE self)
{
    ndfunc_arg_in_t ain[1] = {{Qnil,0}};
    ndfunc_t ndf = {iter_robject_each, FULL_LOOP_NIP, 1,0, ain,0};

    na_ndloop(&ndf, 1, self);
    return self;
}

#each_with_indexNumo::NArray

Invokes the given block once for each element of self, passing that element and indices along each axis as parameters. For a block {|x,i,j,…| … }

Yields:

  • (x, i, j, ...)

    x is an element, i,j,… are multidimensional indices.

Returns:



1687
1688
1689
1690
1691
1692
1693
1694
1695
# File 'ext/numo/narray/types/robject.c', line 1687

static VALUE
numo_robject_each_with_index(VALUE self)
{
    ndfunc_arg_in_t ain[1] = {{Qnil,0}};
    ndfunc_t ndf = {iter_robject_each_with_index, FULL_LOOP_NIP, 1,0, ain,0};

    na_ndloop_with_index(&ndf, 1, self);
    return self;
}

#eq(other) ⇒ Numo::Bit

Comparison eq other.

Parameters:

Returns:



2464
2465
2466
2467
2468
2469
2470
2471
# File 'ext/numo/narray/types/robject.c', line 2464

static VALUE
numo_robject_eq(VALUE self, VALUE other)
{
    
    return numo_robject_eq_self(self, other);
    
#line 55 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/cond_binary.c"
}

#extractNumeric, Numo::NArray

Extract an element only if self is a dimensionless NArray. — Extract element value as Ruby Object if self is a dimensionless NArray, otherwise returns self.

Returns:



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'ext/numo/narray/types/robject.c', line 146

VALUE
numo_robject_extract(VALUE self)
{
    volatile VALUE v;
    char *ptr;
    narray_t *na;
    GetNArray(self,na);

    if (na->ndim==0) {
        ptr = na_get_pointer_for_read(self) + na_get_offset(self);
        v = m_extract(ptr);
        na_release_lock(self);
        return v;
    }
    return self;
}

#eye([element,offset]) ⇒ Numo::RObject

Eye: Set a value to diagonal components, set 0 to non-diagonal components.

Parameters:

  • element (Numeric)

    Diagonal element to be stored. Default is 1.

  • offset (Integer)

    Diagonal offset from the main diagonal. The default is 0. k>0 for diagonals above the main diagonal, and k<0 for diagonals below the main diagonal.

Returns:



4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
# File 'ext/numo/narray/types/robject.c', line 4283

static VALUE
numo_robject_eye(int argc, VALUE *argv, VALUE self)
{
    ndfunc_arg_in_t ain[1] = {{OVERWRITE,2}};
    ndfunc_t ndf = {iter_robject_eye, NO_LOOP, 1,0, ain,0};
    ssize_t kofs;
    dtype data;
    char *g;
    int nd;
    narray_t *na;

    // check arguments
    if (argc > 2) {
        rb_raise(rb_eArgError,"too many arguments (%d for 0..2)",argc);
    } else if (argc == 2) {
        data = m_num_to_data(argv[0]);
        kofs = NUM2SSIZET(argv[1]);
    } else if (argc == 1) {
        data = m_num_to_data(argv[0]);
        kofs = 0;
    } else {
        data = m_one;
        kofs = 0;
    }

    GetNArray(self,na);
    nd = na->ndim;
    if (nd < 2) {
        rb_raise(nary_eDimensionError,"less than 2-d array");
    }

    // Diagonal offset from the main diagonal.
    if (kofs >= 0) {
        if ((size_t)(kofs) >= na->shape[nd-1]) {
            rb_raise(rb_eArgError,"invalid diagonal offset(%"SZF"d) for "
                     "last dimension size(%"SZF"d)",kofs,na->shape[nd-1]);
        }
    } else {
        if ((size_t)(-kofs) >= na->shape[nd-2]) {
            rb_raise(rb_eArgError,"invalid diagonal offset(%"SZF"d) for "
                     "last-1 dimension size(%"SZF"d)",kofs,na->shape[nd-2]);
        }
    }

    g = ALLOCA_N(char,sizeof(ssize_t)+sizeof(dtype));
    *(ssize_t*)g = kofs;
    *(dtype*)(g+sizeof(ssize_t)) = data;

    na_ndloop3(&ndf, g, 1, self);
    return self;
}

#fill(other) ⇒ Numo::RObject

Fill elements with other.

Parameters:

  • other (Numeric)

Returns:



1373
1374
1375
1376
1377
1378
1379
1380
1381
# File 'ext/numo/narray/types/robject.c', line 1373

static VALUE
numo_robject_fill(VALUE self, VALUE val)
{
    ndfunc_arg_in_t ain[2] = {{OVERWRITE,0},{sym_option}};
    ndfunc_t ndf = { iter_robject_fill, FULL_LOOP, 2, 0, ain, 0 };

    na_ndloop(&ndf, 2, self, val);
    return self;
}

#floorNumo::RObject

Unary floor.

Returns:



2833
2834
2835
2836
2837
2838
2839
2840
2841
# File 'ext/numo/narray/types/robject.c', line 2833

static VALUE
numo_robject_floor(VALUE self)
{
    ndfunc_arg_in_t ain[1] = {{cT,0}};
    ndfunc_arg_out_t aout[1] = {{cT,0}};
    ndfunc_t ndf = {iter_robject_floor, FULL_LOOP, 1,1, ain,aout};

    return na_ndloop(&ndf, 1, self);
}

#format(format) ⇒ Numo::RObject

Format elements into strings.

Parameters:

  • format (String)

Returns:



1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
# File 'ext/numo/narray/types/robject.c', line 1434

static VALUE
numo_robject_format(int argc, VALUE *argv, VALUE self)
{
    VALUE fmt=Qnil;

    ndfunc_arg_in_t ain[2] = {{Qnil,0},{sym_option}};
    ndfunc_arg_out_t aout[1] = {{numo_cRObject,0}};
    ndfunc_t ndf = { iter_robject_format, FULL_LOOP_NIP, 2, 1, ain, aout };

    rb_scan_args(argc, argv, "01", &fmt);
    return na_ndloop(&ndf, 2, self, fmt);
}

#format_to_a(format) ⇒ Array

Format elements into strings.

Parameters:

  • format (String)

Returns:

  • (Array)

    array of formated strings.



1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
# File 'ext/numo/narray/types/robject.c', line 1486

static VALUE
numo_robject_format_to_a(int argc, VALUE *argv, VALUE self)
{
    volatile VALUE fmt=Qnil;
    ndfunc_arg_in_t ain[3] = {{Qnil,0},{sym_loop_opt},{sym_option}};
    ndfunc_arg_out_t aout[1] = {{rb_cArray,0}}; // dummy?
    ndfunc_t ndf = { iter_robject_format_to_a, FULL_LOOP_NIP, 3, 1, ain, aout };

    rb_scan_args(argc, argv, "01", &fmt);
    return na_ndloop_cast_narray_to_rarray(&ndf, self, fmt);
}

#ge(other) ⇒ Numo::Bit Also known as: >=

Comparison ge other.

Parameters:

Returns:



3122
3123
3124
3125
3126
3127
3128
3129
# File 'ext/numo/narray/types/robject.c', line 3122

static VALUE
numo_robject_ge(VALUE self, VALUE other)
{
    
    return numo_robject_ge_self(self, other);
    
#line 55 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/cond_binary.c"
}

#gt(other) ⇒ Numo::Bit Also known as: >

Comparison gt other.

Parameters:

Returns:



3071
3072
3073
3074
3075
3076
3077
3078
# File 'ext/numo/narray/types/robject.c', line 3071

static VALUE
numo_robject_gt(VALUE self, VALUE other)
{
    
    return numo_robject_gt_self(self, other);
    
#line 55 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/cond_binary.c"
}

#inspectString

Returns a string containing a human-readable representation of NArray.

Returns:

  • (String)


1514
1515
1516
1517
1518
# File 'ext/numo/narray/types/robject.c', line 1514

VALUE
numo_robject_inspect(VALUE ary)
{
    return na_ndloop_inspect(ary, iter_robject_inspect, Qnil);
}

#isfiniteNumo::Bit

Condition of isfinite.

Returns:



3370
3371
3372
3373
3374
3375
3376
3377
3378
# File 'ext/numo/narray/types/robject.c', line 3370

static VALUE
numo_robject_isfinite(VALUE self)
{
    ndfunc_arg_in_t ain[1] = {{cT,0}};
    ndfunc_arg_out_t aout[1] = {{numo_cBit,0}};
    ndfunc_t ndf = { iter_robject_isfinite, FULL_LOOP, 1, 1, ain, aout };

    return na_ndloop(&ndf, 1, self);
}

#isinfNumo::Bit

Condition of isinf.

Returns:



3321
3322
3323
3324
3325
3326
3327
3328
3329
# File 'ext/numo/narray/types/robject.c', line 3321

static VALUE
numo_robject_isinf(VALUE self)
{
    ndfunc_arg_in_t ain[1] = {{cT,0}};
    ndfunc_arg_out_t aout[1] = {{numo_cBit,0}};
    ndfunc_t ndf = { iter_robject_isinf, FULL_LOOP, 1, 1, ain, aout };

    return na_ndloop(&ndf, 1, self);
}

#isnanNumo::Bit

Condition of isnan.

Returns:



3272
3273
3274
3275
3276
3277
3278
3279
3280
# File 'ext/numo/narray/types/robject.c', line 3272

static VALUE
numo_robject_isnan(VALUE self)
{
    ndfunc_arg_in_t ain[1] = {{cT,0}};
    ndfunc_arg_out_t aout[1] = {{numo_cBit,0}};
    ndfunc_t ndf = { iter_robject_isnan, FULL_LOOP, 1, 1, ain, aout };

    return na_ndloop(&ndf, 1, self);
}

#le(other) ⇒ Numo::Bit Also known as: <=

Comparison le other.

Parameters:

Returns:



3224
3225
3226
3227
3228
3229
3230
3231
# File 'ext/numo/narray/types/robject.c', line 3224

static VALUE
numo_robject_le(VALUE self, VALUE other)
{
    
    return numo_robject_le_self(self, other);
    
#line 55 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/cond_binary.c"
}

#logseq(beg, step, [base]) ⇒ Numo::RObject

Set logarithmic sequence of numbers to self. The sequence is obtained from

base**(beg+i*step)

where i is 1-dimensional index. Applicable classes: DFloat, SFloat, DComplex, SCopmplex.

Examples:

Numo::DFloat.new(5).logseq(4,-1,2)
=> Numo::DFloat#shape=[5]
  [16, 8, 4, 2, 1]
Numo::DComplex.new(5).logseq(0,1i*Math::PI/3,Math::E)
=> Numo::DComplex#shape=[5]
  [1+7.26156e-310i, 0.5+0.866025i, -0.5+0.866025i, -1+1.22465e-16i, ...]

Parameters:

  • beg (Numeric)

    The begining of sequence.

  • step (Numeric)

    The step of sequence.

  • base (Numeric)

    The base of log space. (default=10)

Returns:



4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
# File 'ext/numo/narray/types/robject.c', line 4219

static VALUE
numo_robject_logseq(int argc, VALUE *args, VALUE self)
{
    logseq_opt_t *g;
    VALUE vbeg, vstep, vbase;
    ndfunc_arg_in_t ain[1] = {{OVERWRITE,0}};
    ndfunc_t ndf = {iter_robject_logseq, FULL_LOOP, 1,0, ain,0};

    g = ALLOCA_N(logseq_opt_t,1);
    rb_scan_args(argc, args, "21", &vbeg, &vstep, &vbase);
    g->beg = m_num_to_data(vbeg);
    g->step = m_num_to_data(vstep);
    if (vbase==Qnil) {
        g->base = m_from_real(10);
    } else {
        g->base = m_num_to_data(vbase);
    }
    na_ndloop3(&ndf, g, 1, self);
    return self;
}

#lt(other) ⇒ Numo::Bit Also known as: <

Comparison lt other.

Parameters:

Returns:



3173
3174
3175
3176
3177
3178
3179
3180
# File 'ext/numo/narray/types/robject.c', line 3173

static VALUE
numo_robject_lt(VALUE self, VALUE other)
{
    
    return numo_robject_lt_self(self, other);
    
#line 55 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/cond_binary.c"
}

#mapNumo::RObject

Unary map.

Returns:



1619
1620
1621
1622
1623
1624
1625
1626
1627
# File 'ext/numo/narray/types/robject.c', line 1619

static VALUE
numo_robject_map(VALUE self)
{
    ndfunc_arg_in_t ain[1] = {{cT,0}};
    ndfunc_arg_out_t aout[1] = {{cT,0}};
    ndfunc_t ndf = {iter_robject_map, FULL_LOOP, 1,1, ain,aout};

    return na_ndloop(&ndf, 1, self);
}

#map_with_indexNumo::NArray

Invokes the given block once for each element of self, passing that element and indices along each axis as parameters. Creates a new NArray containing the values returned by the block. Inplace option is allowed, i.e., `nary.inplace.map` overwrites `nary`.

For a block {|x,i,j,…| … }

Yields:

  • (x, i, j, ...)

    x is an element, i,j,… are multidimensional indices.

Returns:



1785
1786
1787
1788
1789
1790
1791
1792
1793
# File 'ext/numo/narray/types/robject.c', line 1785

static VALUE
numo_robject_map_with_index(VALUE self)
{
    ndfunc_arg_in_t ain[1] = {{Qnil,0}};
    ndfunc_arg_out_t aout[1] = {{cT,0}};
    ndfunc_t ndf = {iter_robject_map_with_index, FULL_LOOP, 1,1, ain,aout};

    return na_ndloop_with_index(&ndf, 1, self);
}

#max(*args) ⇒ Numo::RObject

Max of self.

Parameters:

  • args (Array of Numeric, Range)

    Affected dimensions.

Returns:



3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
# File 'ext/numo/narray/types/robject.c', line 3669

static VALUE
numo_robject_max(int argc, VALUE *argv, VALUE self)
{
    VALUE v, reduce;
    ndfunc_arg_in_t ain[2] = {{cT,0},{sym_reduce,0}};
    ndfunc_arg_out_t aout[1] = {{cT,0}};
    ndfunc_t ndf = { iter_robject_max, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE, 2, 1, ain, aout };

    reduce = na_reduce_dimension(argc, argv, 1, &self);
    v =  na_ndloop(&ndf, 2, self, reduce);
#line 32 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/accum.c"
    return numo_robject_extract(v);
#line 36 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/accum.c"
}

#max_indexInteger #max_index(dim0, dim1, ..) ⇒ Integer, Numo::Int32/64

Return an index of result.

Numo::NArray[3,4,1,2].min_index => 3

Overloads:

  • #max_indexInteger

    Returns:

    • (Integer)
  • #max_index(dim0, dim1, ..) ⇒ Integer, Numo::Int32/64

    Returns:



3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
# File 'ext/numo/narray/types/robject.c', line 3736

static VALUE
numo_robject_max_index(int argc, VALUE *argv, VALUE self)
{
    narray_t *na;
    VALUE idx, reduce;
    ndfunc_arg_in_t ain[3] = {{Qnil,0},{Qnil,0},{sym_reduce,0}};
    ndfunc_arg_out_t aout[1] = {{0,0,0}};
    ndfunc_t ndf = {0, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE|NDF_EXTRACT, 3,1, ain,aout};

    GetNArray(self,na);
    if (na->ndim==0) {
        return INT2FIX(0);
    }
    if (na->size > (~(u_int32_t)0)) {
        aout[0].type = numo_cInt64;
        idx = rb_narray_new(numo_cInt64, na->ndim, na->shape);
        ndf.func = iter_robject_max_index_index64;
    } else {
        aout[0].type = numo_cInt32;
        idx = rb_narray_new(numo_cInt32, na->ndim, na->shape);
        ndf.func = iter_robject_max_index_index32;
    }
    rb_funcall(idx, rb_intern("seq"), 0);

    reduce = na_reduce_dimension(argc, argv, 1, &self);

    return na_ndloop(&ndf, 3, self, idx, reduce);
}

#mean(*args) ⇒ Numo::RObject

Mean of self.

Parameters:

  • args (Array of Numeric, Range)

    Affected dimensions.

Returns:



3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
# File 'ext/numo/narray/types/robject.c', line 3479

static VALUE
numo_robject_mean(int argc, VALUE *argv, VALUE self)
{
    VALUE v, reduce;
    ndfunc_arg_in_t ain[2] = {{cT,0},{sym_reduce,0}};
    ndfunc_arg_out_t aout[1] = {{cT,0}};
    ndfunc_t ndf = { iter_robject_mean, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE, 2, 1, ain, aout };

    reduce = na_reduce_dimension(argc, argv, 1, &self);
    v =  na_ndloop(&ndf, 2, self, reduce);
#line 32 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/accum.c"
    return numo_robject_extract(v);
#line 36 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/accum.c"
}

#min(*args) ⇒ Numo::RObject

Min of self.

Parameters:

  • args (Array of Numeric, Range)

    Affected dimensions.

Returns:



3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
# File 'ext/numo/narray/types/robject.c', line 3631

static VALUE
numo_robject_min(int argc, VALUE *argv, VALUE self)
{
    VALUE v, reduce;
    ndfunc_arg_in_t ain[2] = {{cT,0},{sym_reduce,0}};
    ndfunc_arg_out_t aout[1] = {{cT,0}};
    ndfunc_t ndf = { iter_robject_min, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE, 2, 1, ain, aout };

    reduce = na_reduce_dimension(argc, argv, 1, &self);
    v =  na_ndloop(&ndf, 2, self, reduce);
#line 32 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/accum.c"
    return numo_robject_extract(v);
#line 36 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/accum.c"
}

#min_indexInteger #min_index(dim0, dim1, ..) ⇒ Integer, Numo::Int32/64

Return an index of result.

Numo::NArray[3,4,1,2].min_index => 3

Overloads:

  • #min_indexInteger

    Returns:

    • (Integer)
  • #min_index(dim0, dim1, ..) ⇒ Integer, Numo::Int32/64

    Returns:



3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
# File 'ext/numo/narray/types/robject.c', line 3817

static VALUE
numo_robject_min_index(int argc, VALUE *argv, VALUE self)
{
    narray_t *na;
    VALUE idx, reduce;
    ndfunc_arg_in_t ain[3] = {{Qnil,0},{Qnil,0},{sym_reduce,0}};
    ndfunc_arg_out_t aout[1] = {{0,0,0}};
    ndfunc_t ndf = {0, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE|NDF_EXTRACT, 3,1, ain,aout};

    GetNArray(self,na);
    if (na->ndim==0) {
        return INT2FIX(0);
    }
    if (na->size > (~(u_int32_t)0)) {
        aout[0].type = numo_cInt64;
        idx = rb_narray_new(numo_cInt64, na->ndim, na->shape);
        ndf.func = iter_robject_min_index_index64;
    } else {
        aout[0].type = numo_cInt32;
        idx = rb_narray_new(numo_cInt32, na->ndim, na->shape);
        ndf.func = iter_robject_min_index_index32;
    }
    rb_funcall(idx, rb_intern("seq"), 0);

    reduce = na_reduce_dimension(argc, argv, 1, &self);

    return na_ndloop(&ndf, 3, self, idx, reduce);
}

#minmax(*args) ⇒ Numo::RObject

Minmax of self.

Parameters:

  • args (Array of Numeric, Range)

    Affected dimensions.

Returns:



3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
# File 'ext/numo/narray/types/robject.c', line 3885

static VALUE
numo_robject_minmax(int argc, VALUE *argv, VALUE self)
{
    VALUE reduce;
    ndfunc_arg_in_t ain[2] = {{cT,0},{sym_reduce,0}};
    ndfunc_arg_out_t aout[2] = {{cT,0},{cT,0}};
    ndfunc_t ndf = {iter_robject_minmax, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE|NDF_EXTRACT, 2,2, ain,aout};

    reduce = na_reduce_dimension(argc, argv, 1, &self);
    return na_ndloop(&ndf, 2, self, reduce);
}

#mulsum(other) ⇒ Numo::NArray

Binary mulsum.

Parameters:

Returns:



4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
# File 'ext/numo/narray/types/robject.c', line 4052

static VALUE
numo_robject_mulsum(int argc, VALUE *argv, VALUE self)
{
    
#line 67 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/accum_binary.c"
    if (argc < 1) {
        rb_raise(rb_eArgError,"wrong number of arguments (%d for >=1)",argc);
    }
    
    return numo_robject_mulsum_self(argc, argv, self);
    
#line 81 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/accum_binary.c"
}

#ne(other) ⇒ Numo::Bit

Comparison ne other.

Parameters:

Returns:



2515
2516
2517
2518
2519
2520
2521
2522
# File 'ext/numo/narray/types/robject.c', line 2515

static VALUE
numo_robject_ne(VALUE self, VALUE other)
{
    
    return numo_robject_ne_self(self, other);
    
#line 55 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/cond_binary.c"
}

#nearly_eq(other) ⇒ Numo::Bit Also known as: close_to

Comparison nearly_eq other.

Parameters:

Returns:

  • (Numo::Bit)

    result of self nearly_eq other.



2566
2567
2568
2569
2570
2571
2572
2573
# File 'ext/numo/narray/types/robject.c', line 2566

static VALUE
numo_robject_nearly_eq(VALUE self, VALUE other)
{
    
    return numo_robject_nearly_eq_self(self, other);
    
#line 55 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/cond_binary.c"
}

#poly(a0, a1, ...) ⇒ Numo::RObject

Polynomial.: a0 + a1*x + a2*x**2 + a3*x**3 + … + an*x**n

Parameters:

Returns:



4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
# File 'ext/numo/narray/types/robject.c', line 4459

static VALUE
numo_robject_poly(VALUE self, VALUE args)
{
    int argc, i;
    VALUE *argv;
    volatile VALUE v, a;
    ndfunc_arg_out_t aout[1] = {{cT,0}};
    ndfunc_t ndf = { iter_robject_poly, NO_LOOP, 0, 1, 0, aout };

    argc = RARRAY_LEN(args);
    ndf.nin = argc+1;
    ndf.ain = ALLOCA_N(ndfunc_arg_in_t,argc+1);
    for (i=0; i<argc+1; i++) {
        ndf.ain[i].type = cT;
    }
    argv = ALLOCA_N(VALUE,argc+1);
    argv[0] = self;
    for (i=0; i<argc; i++) {
        argv[i+1] = RARRAY_PTR(args)[i];
    }
    a = rb_ary_new4(argc+1, argv);
    v = na_ndloop2(&ndf, a);
    return numo_robject_extract(v);
}

#prod(*args) ⇒ Numo::RObject

Prod of self.

Parameters:

  • args (Array of Numeric, Range)

    Affected dimensions.

Returns:



3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
# File 'ext/numo/narray/types/robject.c', line 3441

static VALUE
numo_robject_prod(int argc, VALUE *argv, VALUE self)
{
    VALUE v, reduce;
    ndfunc_arg_in_t ain[2] = {{cT,0},{sym_reduce,0}};
    ndfunc_arg_out_t aout[1] = {{cT,0}};
    ndfunc_t ndf = { iter_robject_prod, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE, 2, 1, ain, aout };

    reduce = na_reduce_dimension(argc, argv, 1, &self);
    v =  na_ndloop(&ndf, 2, self, reduce);
#line 32 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/accum.c"
    return numo_robject_extract(v);
#line 36 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/accum.c"
}

#rand([[low],high]) ⇒ Numo::RObject

Generate uniformly distributed random numbers on self narray.

Examples:

Numo::DFloat.new(6).rand
=> Numo::DFloat#shape=[6]
   [0.0617545, 0.373067, 0.794815, 0.201042, 0.116041, 0.344032]
Numo::DComplex.new(6).rand(5+5i)
=> Numo::DComplex#shape=[6]
   [2.69974+3.68908i, 0.825443+0.254414i, 0.540323+0.34354i, 4.52061+2.39322i, ...]
Numo::Int32.new(6).rand(2,5)
=> Numo::Int32#shape=[6]
   [4, 3, 3, 2, 4, 2]

Parameters:

  • low (Numeric)

    lower inclusive boundary of random numbers. (default=0)

  • high (Numeric)

    upper exclusive boundary of random numbers. (default=1 or 1+1i for complex types)

Returns:



4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
# File 'ext/numo/narray/types/robject.c', line 4397

static VALUE
numo_robject_rand(int argc, VALUE *args, VALUE self)
{
    rand_opt_t g;
    VALUE v1=Qnil, v2=Qnil;
    dtype high;
    ndfunc_arg_in_t ain[1] = {{OVERWRITE,0}};
    ndfunc_t ndf = {iter_robject_rand, FULL_LOOP, 1,0, ain,0};

    
#line 140 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/rand.c"
    rb_scan_args(argc, args, "02", &v1, &v2);
    if (v2==Qnil) {
        g.low = m_zero;
        if (v1==Qnil) {
            
#line 147 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/rand.c"
            g.max = high = m_one;
            
        } else {
            g.max = high = m_num_to_data(v1);
        }
    
    } else {
        g.low = m_num_to_data(v1);
        high = m_num_to_data(v2);
        g.max = m_sub(high,g.low);
    }
    
#line 163 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/rand.c"
    na_ndloop3(&ndf, &g, 1, self);
    return self;
}

#reciprocalNumo::RObject

Unary reciprocal.

Returns:



2350
2351
2352
2353
2354
2355
2356
2357
2358
# File 'ext/numo/narray/types/robject.c', line 2350

static VALUE
numo_robject_reciprocal(VALUE self)
{
    ndfunc_arg_in_t ain[1] = {{cT,0}};
    ndfunc_arg_out_t aout[1] = {{cT,0}};
    ndfunc_t ndf = {iter_robject_reciprocal, FULL_LOOP, 1,1, ain,aout};

    return na_ndloop(&ndf, 1, self);
}

#rms(*args) ⇒ Numo::RObject

Rms of self.

Parameters:

  • args (Array of Numeric, Range)

    Affected dimensions.

Returns:



3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
# File 'ext/numo/narray/types/robject.c', line 3593

static VALUE
numo_robject_rms(int argc, VALUE *argv, VALUE self)
{
    VALUE v, reduce;
    ndfunc_arg_in_t ain[2] = {{cT,0},{sym_reduce,0}};
    ndfunc_arg_out_t aout[1] = {{cRT,0}};
    ndfunc_t ndf = { iter_robject_rms, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE, 2, 1, ain, aout };

    reduce = na_reduce_dimension(argc, argv, 1, &self);
    v =  na_ndloop(&ndf, 2, self, reduce);
#line 34 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/accum.c"
    return rb_funcall(v,rb_intern("extract"),0);
#line 36 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/accum.c"
}

#roundNumo::RObject

Unary round.

Returns:



2895
2896
2897
2898
2899
2900
2901
2902
2903
# File 'ext/numo/narray/types/robject.c', line 2895

static VALUE
numo_robject_round(VALUE self)
{
    ndfunc_arg_in_t ain[1] = {{cT,0}};
    ndfunc_arg_out_t aout[1] = {{cT,0}};
    ndfunc_t ndf = {iter_robject_round, FULL_LOOP, 1,1, ain,aout};

    return na_ndloop(&ndf, 1, self);
}

#seq([beg,[step]]) ⇒ Numo::RObject Also known as: indgen

Set linear sequence of numbers to self. The sequence is obtained from

beg+i*step

where i is 1-dimensional index.

Examples:

Numo::DFloat.new(6).seq(1,-0.2)
=> Numo::DFloat#shape=[6]
   [1, 0.8, 0.6, 0.4, 0.2, 0]
Numo::DComplex.new(6).seq(1,-0.2+0.2i)
=> Numo::DComplex#shape=[6]
   [1+0i, 0.8+0.2i, 0.6+0.4i, 0.4+0.6i, 0.2+0.8i, 0+1i]

Parameters:

  • beg (Numeric)

    begining of sequence. (default=0)

  • step (Numeric)

    step of sequence. (default=1)

Returns:



4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
# File 'ext/numo/narray/types/robject.c', line 4132

static VALUE
numo_robject_seq(int argc, VALUE *args, VALUE self)
{
    seq_opt_t *g;
    VALUE vbeg=Qnil, vstep=Qnil;
    ndfunc_arg_in_t ain[1] = {{OVERWRITE,0}};
    ndfunc_t ndf = {iter_robject_seq, FULL_LOOP, 1,0, ain,0};

    g = ALLOCA_N(seq_opt_t,1);
    g->beg = m_zero;
    g->step = m_one;
    g->count = 0;
    rb_scan_args(argc, args, "02", &vbeg, &vstep);
#line 86 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/seq.c"
    if (vbeg!=Qnil) {g->beg = m_num_to_data(vbeg);}
    if (vstep!=Qnil) {g->step = m_num_to_data(vstep);}

#line 90 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/seq.c"
    na_ndloop3(&ndf, g, 1, self);
    return self;
}

#signNumo::RObject

Unary sign.

Returns:



2412
2413
2414
2415
2416
2417
2418
2419
2420
# File 'ext/numo/narray/types/robject.c', line 2412

static VALUE
numo_robject_sign(VALUE self)
{
    ndfunc_arg_in_t ain[1] = {{cT,0}};
    ndfunc_arg_out_t aout[1] = {{cT,0}};
    ndfunc_t ndf = {iter_robject_sign, FULL_LOOP, 1,1, ain,aout};

    return na_ndloop(&ndf, 1, self);
}

#stddev(*args) ⇒ Numo::RObject

Stddev of self.

Parameters:

  • args (Array of Numeric, Range)

    Affected dimensions.

Returns:



3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
# File 'ext/numo/narray/types/robject.c', line 3517

static VALUE
numo_robject_stddev(int argc, VALUE *argv, VALUE self)
{
    VALUE v, reduce;
    ndfunc_arg_in_t ain[2] = {{cT,0},{sym_reduce,0}};
    ndfunc_arg_out_t aout[1] = {{cRT,0}};
    ndfunc_t ndf = { iter_robject_stddev, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE, 2, 1, ain, aout };

    reduce = na_reduce_dimension(argc, argv, 1, &self);
    v =  na_ndloop(&ndf, 2, self, reduce);
#line 34 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/accum.c"
    return rb_funcall(v,rb_intern("extract"),0);
#line 36 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/accum.c"
}

#store(other) ⇒ Numo::RObject

Store elements to Numo::RObject from other.

Parameters:

  • other (Object)

Returns:



1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
# File 'ext/numo/narray/types/robject.c', line 1012

static VALUE
numo_robject_store(VALUE self, VALUE obj)
{
    VALUE r;

    
    if (FIXNUM_P(obj) || TYPE(obj)==T_FLOAT || TYPE(obj)==T_BIGNUM || rb_obj_is_kind_of(obj,rb_cComplex)) {
        numo_robject_store_numeric(self,obj);
        return self;
    }
    
#line 13 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/store.c"
    if (rb_obj_is_kind_of(obj,numo_cBit)) {
        numo_robject_store_bit(self,obj);
        return self;
    }
    
#line 13 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/store.c"
    if (rb_obj_is_kind_of(obj,numo_cDFloat)) {
        numo_robject_store_dfloat(self,obj);
        return self;
    }
    
#line 13 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/store.c"
    if (rb_obj_is_kind_of(obj,numo_cSFloat)) {
        numo_robject_store_sfloat(self,obj);
        return self;
    }
    
#line 13 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/store.c"
    if (rb_obj_is_kind_of(obj,numo_cInt64)) {
        numo_robject_store_int64(self,obj);
        return self;
    }
    
#line 13 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/store.c"
    if (rb_obj_is_kind_of(obj,numo_cInt32)) {
        numo_robject_store_int32(self,obj);
        return self;
    }
    
#line 13 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/store.c"
    if (rb_obj_is_kind_of(obj,numo_cInt16)) {
        numo_robject_store_int16(self,obj);
        return self;
    }
    
#line 13 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/store.c"
    if (rb_obj_is_kind_of(obj,numo_cInt8)) {
        numo_robject_store_int8(self,obj);
        return self;
    }
    
#line 13 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/store.c"
    if (rb_obj_is_kind_of(obj,numo_cUInt64)) {
        numo_robject_store_uint64(self,obj);
        return self;
    }
    
#line 13 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/store.c"
    if (rb_obj_is_kind_of(obj,numo_cUInt32)) {
        numo_robject_store_uint32(self,obj);
        return self;
    }
    
#line 13 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/store.c"
    if (rb_obj_is_kind_of(obj,numo_cUInt16)) {
        numo_robject_store_uint16(self,obj);
        return self;
    }
    
#line 13 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/store.c"
    if (rb_obj_is_kind_of(obj,numo_cUInt8)) {
        numo_robject_store_uint8(self,obj);
        return self;
    }
    
#line 13 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/store.c"
    if (rb_obj_is_kind_of(obj,numo_cRObject)) {
        numo_robject_store_robject(self,obj);
        return self;
    }
    
#line 13 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/store.c"
    if (TYPE(obj)==T_ARRAY) {
        numo_robject_store_array(self,obj);
        return self;
    }
    

    if (IsNArray(obj)) {
        r = rb_funcall(obj, rb_intern("coerce_cast"), 1, cT);
        if (CLASS_OF(r)==cT) {
            numo_robject_store(self,r);
            return self;
        }
    }

    
    numo_robject_store_numeric(self,obj);
    
#line 34 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/store.c"
    return self;
}

#sum(*args) ⇒ Numo::RObject

Sum of self.

Parameters:

  • args (Array of Numeric, Range)

    Affected dimensions.

Returns:



3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
# File 'ext/numo/narray/types/robject.c', line 3403

static VALUE
numo_robject_sum(int argc, VALUE *argv, VALUE self)
{
    VALUE v, reduce;
    ndfunc_arg_in_t ain[2] = {{cT,0},{sym_reduce,0}};
    ndfunc_arg_out_t aout[1] = {{cT,0}};
    ndfunc_t ndf = { iter_robject_sum, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE, 2, 1, ain, aout };

    reduce = na_reduce_dimension(argc, argv, 1, &self);
    v =  na_ndloop(&ndf, 2, self, reduce);
#line 32 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/accum.c"
    return numo_robject_extract(v);
#line 36 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/accum.c"
}

#to_aArray

Convert self to Array.

Returns:

  • (Array)


1332
1333
1334
1335
1336
1337
1338
1339
# File 'ext/numo/narray/types/robject.c', line 1332

static VALUE
numo_robject_to_a(VALUE self)
{
    ndfunc_arg_in_t ain[3] = {{Qnil,0},{sym_loop_opt},{sym_option}};
    ndfunc_arg_out_t aout[1] = {{rb_cArray,0}}; // dummy?
    ndfunc_t ndf = { iter_robject_to_a, FULL_LOOP_NIP, 3, 1, ain, aout };
    return na_ndloop_cast_narray_to_rarray(&ndf, self, Qnil);
}

#truncNumo::RObject

Unary trunc.

Returns:



3019
3020
3021
3022
3023
3024
3025
3026
3027
# File 'ext/numo/narray/types/robject.c', line 3019

static VALUE
numo_robject_trunc(VALUE self)
{
    ndfunc_arg_in_t ain[1] = {{cT,0}};
    ndfunc_arg_out_t aout[1] = {{cT,0}};
    ndfunc_t ndf = {iter_robject_trunc, FULL_LOOP, 1,1, ain,aout};

    return na_ndloop(&ndf, 1, self);
}

#var(*args) ⇒ Numo::RObject

Var of self.

Parameters:

  • args (Array of Numeric, Range)

    Affected dimensions.

Returns:



3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
# File 'ext/numo/narray/types/robject.c', line 3555

static VALUE
numo_robject_var(int argc, VALUE *argv, VALUE self)
{
    VALUE v, reduce;
    ndfunc_arg_in_t ain[2] = {{cT,0},{sym_reduce,0}};
    ndfunc_arg_out_t aout[1] = {{cRT,0}};
    ndfunc_t ndf = { iter_robject_var, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE, 2, 1, ain, aout };

    reduce = na_reduce_dimension(argc, argv, 1, &self);
    v =  na_ndloop(&ndf, 2, self, reduce);
#line 34 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/accum.c"
    return rb_funcall(v,rb_intern("extract"),0);
#line 36 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/accum.c"
}

#|(other) ⇒ Numo::NArray

Binary bit_or.

Parameters:

Returns:



2662
2663
2664
2665
2666
2667
2668
2669
# File 'ext/numo/narray/types/robject.c', line 2662

static VALUE
numo_robject_bit_or(VALUE self, VALUE other)
{
    
    return numo_robject_bit_or_self(self, other);
    
#line 57 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/binary.c"
}

#~Numo::RObject

Unary bit_not.

Returns:



2771
2772
2773
2774
2775
2776
2777
2778
2779
# File 'ext/numo/narray/types/robject.c', line 2771

static VALUE
numo_robject_bit_not(VALUE self)
{
    ndfunc_arg_in_t ain[1] = {{cT,0}};
    ndfunc_arg_out_t aout[1] = {{cT,0}};
    ndfunc_t ndf = {iter_robject_bit_not, FULL_LOOP, 1,1, ain,aout};

    return na_ndloop(&ndf, 1, self);
}