Class: Numo::Int32

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

Constant Summary collapse

UPCAST =
hCast
ELEMENT_BIT_SIZE =
INT2FIX(sizeof(dtype)*8)
ELEMENT_BYTE_SIZE =
INT2FIX(sizeof(dtype))
CONTIGUOUS_STRIDE =
INT2FIX(sizeof(dtype))
MAX =
M_MAX
MIN =
M_MIN

Constants inherited from NArray

NArray::VERSION

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from NArray

#==, #append, array_type, asarray, #at, byte_size, #byte_size, #byte_swapped?, #cast_to, #coerce, #column_major?, column_stack, concatenate, #concatenate, #contiguous?, #cov, debug=, #debug_info, #deg2rad, #delete, #diag, #diag_indices, diag_indices, #diagonal, #diff, #dot, #dsplit, dstack, #each_over_axis, #empty?, #expand_dims, eye, #flatten, #fliplr, #flipud, #fortran_contiguous?, #free, from_binary, #host_order?, #hsplit, hstack, #initialize, #initialize_copy, #inner, #inplace, #inplace!, #inplace?, #insert, inspect_cols, inspect_cols=, inspect_rows, inspect_rows=, #kron, linspace, logspace, #marshal_dump, #marshal_load, #ndim, #new_fill, new_like, #new_narray, #new_ones, #new_zeros, ones, #out_of_place!, #outer, parse, profile, profile=, #rad2deg, #repeat, #reshape, #reshape!, #reverse, #rot90, #row_major?, #shape, #size, #split, srand, #store_binary, #swap_byte, #swapaxes, #tile, #to_binary, #to_c, #to_f, #to_host, #to_i, #to_network, #to_swapped, #to_vacs, #trace, #transpose, #tril, #tril!, #tril_indices, tril_indices, #triu, #triu!, #triu_indices, triu_indices, upcast, #view, #vsplit, vstack, zeros

Constructor Details

This class inherits a constructor from Numo::NArray

Class Method Details

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

Cast object to Numo::Int32.

Parameters:

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

Returns:



1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
# File 'ext/numo/narray/types/int32.c', line 1278

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

    if (rb_obj_class(obj)==cT) {
        return obj;
    }
    if (RTEST(rb_obj_is_kind_of(obj,rb_cNumeric))) {
        x = m_num_to_data(obj);
        return int32_new_dim0(x);
    }
    if (RTEST(rb_obj_is_kind_of(obj,rb_cArray))) {
        return int32_cast_array(obj);
    }
    if (IsNArray(obj)) {
        GetNArray(obj,na);
        v = nary_new(cT, NA_NDIM(na), NA_SHAPE(na));
        if (NA_SIZE(na) > 0) {
            int32_store(v,obj);
        }
        return v;
    }
    
#line 41 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/cast.c"
    rb_raise(nary_eCastError,"cannot cast to %s",rb_class2name(type));
    return Qnil;
    
}

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

Cast object to Numo::Int32.

Parameters:

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

Returns:



1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
# File 'ext/numo/narray/types/int32.c', line 1278

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

    if (rb_obj_class(obj)==cT) {
        return obj;
    }
    if (RTEST(rb_obj_is_kind_of(obj,rb_cNumeric))) {
        x = m_num_to_data(obj);
        return int32_new_dim0(x);
    }
    if (RTEST(rb_obj_is_kind_of(obj,rb_cArray))) {
        return int32_cast_array(obj);
    }
    if (IsNArray(obj)) {
        GetNArray(obj,na);
        v = nary_new(cT, NA_NDIM(na), NA_SHAPE(na));
        if (NA_SIZE(na) > 0) {
            int32_store(v,obj);
        }
        return v;
    }
    
#line 41 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/cast.c"
    rb_raise(nary_eCastError,"cannot cast to %s",rb_class2name(type));
    return Qnil;
    
}

.maximum(*args) ⇒ Object



5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
# File 'ext/numo/narray/types/int32.c', line 5074

static VALUE
int32_s_maximum(int argc, VALUE *argv, VALUE mod)
{
    VALUE a1 = Qnil;
    VALUE a2 = Qnil;
    ndfunc_arg_in_t ain[2] = {{cT,0},{cT,0}};
    ndfunc_arg_out_t aout[1] = {{cT,0}};
    ndfunc_t ndf = { iter_int32_s_maximum, STRIDE_LOOP_NIP, 2, 1, ain, aout };

    
#line 60 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/ewcomp.c"
    rb_scan_args(argc, argv, "20", &a1, &a2);
    

    return na_ndloop(&ndf, 2, a1, a2);
}

.minimum(*args) ⇒ Object



5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
# File 'ext/numo/narray/types/int32.c', line 5125

static VALUE
int32_s_minimum(int argc, VALUE *argv, VALUE mod)
{
    VALUE a1 = Qnil;
    VALUE a2 = Qnil;
    ndfunc_arg_in_t ain[2] = {{cT,0},{cT,0}};
    ndfunc_arg_out_t aout[1] = {{cT,0}};
    ndfunc_t ndf = { iter_int32_s_minimum, STRIDE_LOOP_NIP, 2, 1, ain, aout };

    
#line 60 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/ewcomp.c"
    rb_scan_args(argc, argv, "20", &a1, &a2);
    

    return na_ndloop(&ndf, 2, a1, a2);
}

Instance Method Details

#%(other) ⇒ Numo::NArray

Binary mod.

Parameters:

Returns:



2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
# File 'ext/numo/narray/types/int32.c', line 2653

static VALUE
int32_mod(VALUE self, VALUE other)
{
    
#line 226 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/binary.c"
    VALUE klass, v;

    klass = na_upcast(rb_obj_class(self),rb_obj_class(other));
    if (klass==cT) {
        return int32_mod_self(self, other);
    } else {
        v = rb_funcall(klass, id_cast, 1, self);
        return rb_funcall(v, '%', 1, other);
    }
    
}

#&(other) ⇒ Numo::NArray

Binary bit_and.

Parameters:

Returns:



3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
# File 'ext/numo/narray/types/int32.c', line 3388

static VALUE
int32_bit_and(VALUE self, VALUE other)
{
    
#line 226 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/binary.c"
    VALUE klass, v;

    klass = na_upcast(rb_obj_class(self),rb_obj_class(other));
    if (klass==cT) {
        return int32_bit_and_self(self, other);
    } else {
        v = rb_funcall(klass, id_cast, 1, self);
        return rb_funcall(v, '&', 1, other);
    }
    
}

#*(other) ⇒ Numo::NArray

Binary mul.

Parameters:

Returns:



2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
# File 'ext/numo/narray/types/int32.c', line 2367

static VALUE
int32_mul(VALUE self, VALUE other)
{
    
#line 226 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/binary.c"
    VALUE klass, v;

    klass = na_upcast(rb_obj_class(self),rb_obj_class(other));
    if (klass==cT) {
        return int32_mul_self(self, other);
    } else {
        v = rb_funcall(klass, id_cast, 1, self);
        return rb_funcall(v, '*', 1, other);
    }
    
}

#**(other) ⇒ Numo::NArray

Binary power.

Parameters:

Returns:



2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
# File 'ext/numo/narray/types/int32.c', line 2795

static VALUE
int32_pow(VALUE self, VALUE other)
{
    
#line 69 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/pow.c"
    VALUE klass, v;
    klass = na_upcast(rb_obj_class(self),rb_obj_class(other));
    if (klass==cT) {
        return int32_pow_self(self,other);
    } else {
        v = rb_funcall(klass, id_cast, 1, self);
        return rb_funcall(v, id_pow, 1, other);
    }
    
}

#+(other) ⇒ Numo::NArray

Binary add.

Parameters:

Returns:



2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
# File 'ext/numo/narray/types/int32.c', line 2089

static VALUE
int32_add(VALUE self, VALUE other)
{
    
#line 226 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/binary.c"
    VALUE klass, v;

    klass = na_upcast(rb_obj_class(self),rb_obj_class(other));
    if (klass==cT) {
        return int32_add_self(self, other);
    } else {
        v = rb_funcall(klass, id_cast, 1, self);
        return rb_funcall(v, '+', 1, other);
    }
    
}

#-(other) ⇒ Numo::NArray

Binary sub.

Parameters:

Returns:



2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
# File 'ext/numo/narray/types/int32.c', line 2228

static VALUE
int32_sub(VALUE self, VALUE other)
{
    
#line 226 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/binary.c"
    VALUE klass, v;

    klass = na_upcast(rb_obj_class(self),rb_obj_class(other));
    if (klass==cT) {
        return int32_sub_self(self, other);
    } else {
        v = rb_funcall(klass, id_cast, 1, self);
        return rb_funcall(v, '-', 1, other);
    }
    
}

#-@Numo::Int32

Unary minus.

Returns:



2885
2886
2887
2888
2889
2890
2891
2892
2893
# File 'ext/numo/narray/types/int32.c', line 2885

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

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

#/(other) ⇒ Numo::NArray

Binary div.

Parameters:

Returns:



2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
# File 'ext/numo/narray/types/int32.c', line 2510

static VALUE
int32_div(VALUE self, VALUE other)
{
    
#line 226 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/binary.c"
    VALUE klass, v;

    klass = na_upcast(rb_obj_class(self),rb_obj_class(other));
    if (klass==cT) {
        return int32_div_self(self, other);
    } else {
        v = rb_funcall(klass, id_cast, 1, self);
        return rb_funcall(v, '/', 1, other);
    }
    
}

#<<(other) ⇒ Numo::NArray

Binary left_shift.

Parameters:

Returns:



3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
# File 'ext/numo/narray/types/int32.c', line 3889

static VALUE
int32_left_shift(VALUE self, VALUE other)
{
    
#line 226 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/binary.c"
    VALUE klass, v;

    klass = na_upcast(rb_obj_class(self),rb_obj_class(other));
    if (klass==cT) {
        return int32_left_shift_self(self, other);
    } else {
        v = rb_funcall(klass, id_cast, 1, self);
        return rb_funcall(v, id_left_shift, 1, other);
    }
    
}

#>>(other) ⇒ Numo::NArray

Binary right_shift.

Parameters:

Returns:



4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
# File 'ext/numo/narray/types/int32.c', line 4028

static VALUE
int32_right_shift(VALUE self, VALUE other)
{
    
#line 226 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/binary.c"
    VALUE klass, v;

    klass = na_upcast(rb_obj_class(self),rb_obj_class(other));
    if (klass==cT) {
        return int32_right_shift_self(self, other);
    } else {
        v = rb_funcall(klass, id_cast, 1, self);
        return rb_funcall(v, id_right_shift, 1, other);
    }
    
}

#[](dim0, ..., dimL) ⇒ Numeric, Numo::Int32

Multi-dimensional element reference.

Parameters:

Returns:

  • (Numeric, Numo::Int32)

    an element or NArray view.

See Also:



1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
# File 'ext/numo/narray/types/int32.c', line 1320

static VALUE
int32_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, ...

Multi-dimensional element assignment.

Parameters:

Returns:

  • (Numeric, Numo::NArray, Array)

    returns val (last argument).

See Also:



1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
# File 'ext/numo/narray/types/int32.c', line 1347

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

    argc--;
    if (argc==0) {
        int32_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);
            int32_store(a, argv[argc]);
        } else {
            x = int32_extract_data(argv[argc]);
            ptr = na_get_pointer_for_read_write(self) + pos;
            *(dtype*)ptr = x;
        }

    }
    return argv[argc];
}

#^(other) ⇒ Numo::NArray

Binary bit_xor.

Parameters:

Returns:



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

static VALUE
int32_bit_xor(VALUE self, VALUE other)
{
    
#line 226 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/binary.c"
    VALUE klass, v;

    klass = na_upcast(rb_obj_class(self),rb_obj_class(other));
    if (klass==cT) {
        return int32_bit_xor_self(self, other);
    } else {
        v = rb_funcall(klass, id_cast, 1, self);
        return rb_funcall(v, '^', 1, other);
    }
    
}

#absNumo::Int32

abs of self.

Returns:



1957
1958
1959
1960
1961
1962
1963
1964
1965
# File 'ext/numo/narray/types/int32.c', line 1957

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

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

#allocateObject



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'ext/numo/narray/types/int32.c', line 143

static VALUE
int32_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);
            
#line 22 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/allocate.c"
            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;
}

#argmax(axis: nil) ⇒ Integer, Numo::Int

Index of the maximum value.

Examples:

a = Numo::NArray[3,4,1,2]
a.argmax  #=> 1

b = Numo::NArray[[3,4,1],[2,0,5]]
b.argmax                       #=> 5
b.argmax(axis:1)               #=> [1, 2]
b.argmax(axis:0)               #=> [0, 0, 1]
b.at(b.argmax(axis:0), 0..-1)  #=> [3, 4, 5]

Parameters:

  • axis (Numeric, Array, Range)

    Finds maximum values along the axis and returns indices along the axis.

Returns:

  • (Integer, Numo::Int)

    returns the result indices.

See Also:



4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
# File 'ext/numo/narray/types/int32.c', line 4873

static VALUE
int32_argmax(int argc, VALUE *argv, VALUE self)
{
    narray_t *na;
    VALUE reduce;
    ndfunc_arg_in_t ain[2] = {{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, 2,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;
        ndf.func = iter_int32_argmax_arg64;
      
#line 75 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum_arg.c"
        reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
      
    } else {
        aout[0].type = numo_cInt32;
        ndf.func = iter_int32_argmax_arg32;
      
#line 83 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum_arg.c"
        reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
      
    }

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

#argmin(axis: nil) ⇒ Integer, Numo::Int

Index of the minimum value.

Examples:

a = Numo::NArray[3,4,1,2]
a.argmin  #=> 2

b = Numo::NArray[[3,4,1],[2,0,5]]
b.argmin                       #=> 4
b.argmin(axis:1)               #=> [2, 1]
b.argmin(axis:0)               #=> [1, 1, 0]
b.at(b.argmin(axis:0), 0..-1)  #=> [2, 0, 1]

Parameters:

  • axis (Numeric, Array, Range)

    Finds minimum values along the axis and returns indices along the axis.

Returns:

  • (Integer, Numo::Int)

    returns the result indices.

See Also:



4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
# File 'ext/numo/narray/types/int32.c', line 4965

static VALUE
int32_argmin(int argc, VALUE *argv, VALUE self)
{
    narray_t *na;
    VALUE reduce;
    ndfunc_arg_in_t ain[2] = {{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, 2,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;
        ndf.func = iter_int32_argmin_arg64;
      
#line 75 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum_arg.c"
        reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
      
    } else {
        aout[0].type = numo_cInt32;
        ndf.func = iter_int32_argmin_arg32;
      
#line 83 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum_arg.c"
        reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
      
    }

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

#bincount([weight], minlength: nil) ⇒ UInt32 or UInt64 or SFloat or DFloat

Count the number of occurrences of each non-negative integer value. Only Integer-types has this method.

Examples:

Numo::Int32[0..4].bincount
# => Numo::UInt32#shape=[5]
# [1, 1, 1, 1, 1]

Numo::Int32[0, 1, 1, 3, 2, 1, 7].bincount
# => Numo::UInt32#shape=[8]
# [1, 3, 1, 1, 0, 0, 0, 1]

x = Numo::Int32[0, 1, 1, 3, 2, 1, 7, 23]
x.bincount.size == x.max+1
# => true

w = Numo::DFloat[0.3, 0.5, 0.2, 0.7, 1.0, -0.6]
x = Numo::Int32[0, 1, 1, 2, 2, 2]
x.bincount(w)
# => Numo::DFloat#shape=[3]
# [0.3, 0.7, 1.1]

Parameters:

  • weight (SFloat or DFloat or Array)

    (optional) Array of float values. Its size along last axis should be same as that of self.

  • minlength (Integer)

    (keyword, optional) Minimum size along last axis for the output array.

Returns:

  • (UInt32 or UInt64 or SFloat or DFloat)

    Returns Float NArray if weight array is supplied, otherwise returns UInt32 or UInt64 depending on the size along last axis.



5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
# File 'ext/numo/narray/types/int32.c', line 5360

static VALUE
int32_bincount(int argc, VALUE *argv, VALUE self)
{
    VALUE weight=Qnil, kw=Qnil;
    VALUE opts[1] = {Qundef};
    VALUE v, wclass;
    ID table[1] = {id_minlength};
    size_t length, minlength;

    rb_scan_args(argc, argv, "01:", &weight, &kw);
    rb_get_kwargs(kw, table, 0, 1, opts);

  
#line 151 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/bincount.c"
    v = int32_minmax(0,0,self);
    if (m_num_to_data(RARRAY_AREF(v,0)) < 0) {
        rb_raise(rb_eArgError,"array items must be non-netagive");
    }
    v = RARRAY_AREF(v,1);
  
    length = NUM2SIZET(v) + 1;

    if (opts[0] != Qundef) {
        minlength = NUM2SIZET(opts[0]);
        if (minlength > length) {
            length = minlength;
        }
    }

    if (NIL_P(weight)) {
        if (length > 4294967295ul) {
            return int32_bincount_64(self, length);
        } else {
            return int32_bincount_32(self, length);
        }
    } else {
        wclass = rb_obj_class(weight);
        if (wclass == numo_cSFloat) {
            return int32_bincount_sf(self, weight, length);
        } else {
            return int32_bincount_df(self, weight, length);
        }
    }
}

#clip(min, max) ⇒ Numo::NArray

Clip array elements by [min,max]. If either of min or max is nil, one side is clipped.

Examples:

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

a.clip(1,8)
# => Numo::Int32#shape=[10]
# [1, 1, 2, 3, 4, 5, 6, 7, 8, 8]

a.inplace.clip(3,6)
a
# => Numo::Int32#shape=[10]
# [3, 3, 3, 3, 4, 5, 6, 6, 6, 6]

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

b.clip([3,4,1,1,1,4,4,4,4,4], 8)
# => Numo::Int32#shape=[10]
# [3, 4, 2, 3, 4, 5, 6, 7, 8, 8]

Parameters:

Returns:



4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
# File 'ext/numo/narray/types/int32.c', line 4375

static VALUE
int32_clip(VALUE self, VALUE min, VALUE max)
{
    ndfunc_arg_in_t ain[3] = {{Qnil,0},{cT,0},{cT,0}};
    ndfunc_arg_out_t aout[1] = {{cT,0}};
    ndfunc_t ndf_min = { iter_int32_clip_min, STRIDE_LOOP, 2, 1, ain, aout };
    ndfunc_t ndf_max = { iter_int32_clip_max, STRIDE_LOOP, 2, 1, ain, aout };
    ndfunc_t ndf_both = { iter_int32_clip, STRIDE_LOOP, 3, 1, ain, aout };

    if (RTEST(min)) {
        if (RTEST(max)) {
            return na_ndloop(&ndf_both, 3, self, min, max);
        } else {
            return na_ndloop(&ndf_min, 2, self, min);
        }
    } else {
        if (RTEST(max)) {
            return na_ndloop(&ndf_max, 2, self, max);
        }
    }
    rb_raise(rb_eArgError,"min and max are not given");
    return Qnil;
}

#coerce_cast(type) ⇒ nil

return NArray with cast to the type of self.

Returns:

  • (nil)


1381
1382
1383
1384
1385
# File 'ext/numo/narray/types/int32.c', line 1381

static VALUE
int32_coerce_cast(VALUE self, VALUE type)
{
    return Qnil;
}

#cumprod(axis: nil, nan: false) ⇒ Numo::Int32

cumprod of self.

Parameters:

  • axis (Numeric, Array, Range)

    Performs cumprod along the axis.

  • nan (TrueClass)

    If true, apply NaN-aware algorithm (avoid NaN if exists).

Returns:



5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
# File 'ext/numo/narray/types/int32.c', line 5491

static VALUE
int32_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_int32_cumprod, STRIDE_LOOP|NDF_FLAT_REDUCE|NDF_CUM,
                     2, 1, ain, aout };

  
#line 46 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/cum.c"
    reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
  
    return na_ndloop(&ndf, 2, self, reduce);
}

#cumsum(axis: nil, nan: false) ⇒ Numo::Int32

cumsum of self.

Parameters:

  • axis (Numeric, Array, Range)

    Performs cumsum along the axis.

  • nan (TrueClass)

    If true, apply NaN-aware algorithm (avoid NaN if exists).

Returns:



5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
# File 'ext/numo/narray/types/int32.c', line 5440

static VALUE
int32_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_int32_cumsum, STRIDE_LOOP|NDF_FLAT_REDUCE|NDF_CUM,
                     2, 1, ain, aout };

  
#line 46 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/cum.c"
    reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
  
    return na_ndloop(&ndf, 2, self, reduce);
}

#divmod(other) ⇒ Numo::NArray

Binary divmod.

Parameters:

Returns:



2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
# File 'ext/numo/narray/types/int32.c', line 2715

static VALUE
int32_divmod(VALUE self, VALUE other)
{
    
#line 50 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/binary2.c"
    VALUE klass, v;
    klass = na_upcast(rb_obj_class(self),rb_obj_class(other));
    if (klass==cT) {
        return int32_divmod_self(self, other);
    } else {
        v = rb_funcall(klass, id_cast, 1, self);
        return rb_funcall(v, id_divmod, 1, other);
    }
    
}

#eachNumo::NArray

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

Yield Parameters:

  • x (Numeric)

    an element of NArray.

Returns:

See Also:



1644
1645
1646
1647
1648
1649
1650
1651
1652
# File 'ext/numo/narray/types/int32.c', line 1644

static VALUE
int32_each(VALUE self)
{
    ndfunc_arg_in_t ain[1] = {{Qnil,0}};
    ndfunc_t ndf = {iter_int32_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,...| ... },

Yield Parameters:

  • x (Numeric)

    an element

  • i,j,... (Integer)

    multitimensional indices

Returns:

See Also:



1799
1800
1801
1802
1803
1804
1805
1806
1807
# File 'ext/numo/narray/types/int32.c', line 1799

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

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

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

Comparison eq other.

Parameters:

Returns:



3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
# File 'ext/numo/narray/types/int32.c', line 3191

static VALUE
int32_eq(VALUE self, VALUE other)
{
    
#line 46 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/cond_binary.c"
    VALUE klass, v;
    klass = na_upcast(rb_obj_class(self),rb_obj_class(other));
    if (klass==cT) {
        return int32_eq_self(self, other);
    } else {
        v = rb_funcall(klass, id_cast, 1, self);
        return rb_funcall(v, id_eq, 1, other);
    }
    
}

#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:



182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'ext/numo/narray/types/int32.c', line 182

static VALUE
int32_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::Int32

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:



5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
# File 'ext/numo/narray/types/int32.c', line 5731

static VALUE
int32_eye(int argc, VALUE *argv, VALUE self)
{
    ndfunc_arg_in_t ain[1] = {{OVERWRITE,2}};
    ndfunc_t ndf = {iter_int32_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::Int32

Fill elements with other.

Parameters:

  • other (Numeric)

Returns:



1462
1463
1464
1465
1466
1467
1468
1469
1470
# File 'ext/numo/narray/types/int32.c', line 1462

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

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

#format(format) ⇒ Numo::RObject

Format elements into strings.

Parameters:

  • format (String)

Returns:



1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
# File 'ext/numo/narray/types/int32.c', line 1522

static VALUE
int32_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_int32_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.



1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
# File 'ext/numo/narray/types/int32.c', line 1573

static VALUE
int32_format_to_a(int argc, VALUE *argv, VALUE self)
{
    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_int32_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:



4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
# File 'ext/numo/narray/types/int32.c', line 4148

static VALUE
int32_ge(VALUE self, VALUE other)
{
    
#line 46 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/cond_binary.c"
    VALUE klass, v;
    klass = na_upcast(rb_obj_class(self),rb_obj_class(other));
    if (klass==cT) {
        return int32_ge_self(self, other);
    } else {
        v = rb_funcall(klass, id_cast, 1, self);
        return rb_funcall(v, id_ge, 1, other);
    }
    
}

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

Comparison gt other.

Parameters:

Returns:



4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
# File 'ext/numo/narray/types/int32.c', line 4091

static VALUE
int32_gt(VALUE self, VALUE other)
{
    
#line 46 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/cond_binary.c"
    VALUE klass, v;
    klass = na_upcast(rb_obj_class(self),rb_obj_class(other));
    if (klass==cT) {
        return int32_gt_self(self, other);
    } else {
        v = rb_funcall(klass, id_cast, 1, self);
        return rb_funcall(v, id_gt, 1, other);
    }
    
}

#inspectString

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

Returns:

  • (String)


1600
1601
1602
1603
1604
# File 'ext/numo/narray/types/int32.c', line 1600

static VALUE
int32_inspect(VALUE ary)
{
    return na_ndloop_inspect(ary, iter_int32_inspect, Qnil);
}

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

Comparison le other.

Parameters:

Returns:



4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
# File 'ext/numo/narray/types/int32.c', line 4262

static VALUE
int32_le(VALUE self, VALUE other)
{
    
#line 46 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/cond_binary.c"
    VALUE klass, v;
    klass = na_upcast(rb_obj_class(self),rb_obj_class(other));
    if (klass==cT) {
        return int32_le_self(self, other);
    } else {
        v = rb_funcall(klass, id_cast, 1, self);
        return rb_funcall(v, id_le, 1, other);
    }
    
}

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

Comparison lt other.

Parameters:

Returns:



4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
# File 'ext/numo/narray/types/int32.c', line 4205

static VALUE
int32_lt(VALUE self, VALUE other)
{
    
#line 46 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/cond_binary.c"
    VALUE klass, v;
    klass = na_upcast(rb_obj_class(self),rb_obj_class(other));
    if (klass==cT) {
        return int32_lt_self(self, other);
    } else {
        v = rb_funcall(klass, id_cast, 1, self);
        return rb_funcall(v, id_lt, 1, other);
    }
    
}

#mapNumo::Int32

Unary map.

Returns:



1728
1729
1730
1731
1732
1733
1734
1735
1736
# File 'ext/numo/narray/types/int32.c', line 1728

static VALUE
int32_map(VALUE self)
{
    ndfunc_arg_in_t ain[1] = {{cT,0}};
    ndfunc_arg_out_t aout[1] = {{cT,0}};
    ndfunc_t ndf = {iter_int32_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,...| ... },

Yield Parameters:

  • x (Numeric)

    an element

  • i,j,... (Integer)

    multitimensional indices

Returns:

See Also:



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

static VALUE
int32_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_int32_map_with_index, FULL_LOOP, 1,1, ain,aout};

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

#max(axis: nil, keepdims: false) ⇒ Numo::Int32

max of self.

Parameters:

  • axis (Numeric, Array, Range)

    Performs max along the axis.

  • keepdims (TrueClass)

    If true, the reduced axes are left in the result array as dimensions with size one.

Returns:



4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
# File 'ext/numo/narray/types/int32.c', line 4556

static VALUE
int32_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_int32_max, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE, 2, 1, ain, aout };

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

#max_index(axis: nil) ⇒ Integer, Numo::Int

Index of the maximum value.

Examples:

a = Numo::NArray[3,4,1,2]
a.max_index  #=> 1

b = Numo::NArray[[3,4,1],[2,0,5]]
b.max_index             #=> 5
b.max_index(axis:1)     #=> [1, 5]
b.max_index(axis:0)     #=> [0, 1, 5]
b[b.max_index(axis:0)]  #=> [3, 4, 5]

Parameters:

  • axis (Numeric, Array, Range)

    Finds maximum values along the axis and returns flat 1-d indices.

Returns:

  • (Integer, Numo::Int)

    returns result indices.

See Also:



4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
# File 'ext/numo/narray/types/int32.c', line 4681

static VALUE
int32_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 = nary_new(numo_cInt64, na->ndim, na->shape);
        ndf.func = iter_int32_max_index_index64;
      
#line 77 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum_index.c"
        reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
      
    } else {
        aout[0].type = numo_cInt32;
        idx = nary_new(numo_cInt32, na->ndim, na->shape);
        ndf.func = iter_int32_max_index_index32;
      
#line 86 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum_index.c"
        reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
      
    }
    rb_funcall(idx, rb_intern("seq"), 0);

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

#median(axis: nil, keepdims: false) ⇒ Numo::Int32

median of self.

Parameters:

  • axis (Numeric, Array, Range)

    Finds median along the axis.

  • keepdims (TrueClass)

    If true, the reduced axes are left in the result array as dimensions with size one.

Returns:



6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
# File 'ext/numo/narray/types/int32.c', line 6609

static VALUE
int32_median(int argc, VALUE *argv, VALUE self)
{
    VALUE v, reduce;
    ndfunc_arg_in_t ain[2] = {{OVERWRITE,0},{sym_reduce,0}};
    ndfunc_arg_out_t aout[1] = {{INT2FIX(0),0}};
    ndfunc_t ndf = {0, NDF_HAS_LOOP|NDF_FLAT_REDUCE, 2,1, ain,aout};

    self = na_copy(self); // as temporary buffer
  
#line 60 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/median.c"
    ndf.func = iter_int32_median;
    reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
  
    v = na_ndloop(&ndf, 2, self, reduce);
    return int32_extract(v);
}

#min(axis: nil, keepdims: false) ⇒ Numo::Int32

min of self.

Parameters:

  • axis (Numeric, Array, Range)

    Performs min along the axis.

  • keepdims (TrueClass)

    If true, the reduced axes are left in the result array as dimensions with size one.

Returns:



4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
# File 'ext/numo/narray/types/int32.c', line 4512

static VALUE
int32_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_int32_min, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE, 2, 1, ain, aout };

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

#min_index(axis: nil) ⇒ Integer, Numo::Int

Index of the minimum value.

Examples:

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

b = Numo::NArray[[3,4,1],[2,0,5]]
b.min_index             #=> 4
b.min_index(axis:1)     #=> [2, 4]
b.min_index(axis:0)     #=> [3, 4, 2]
b[b.min_index(axis:0)]  #=> [2, 0, 1]

Parameters:

  • axis (Numeric, Array, Range)

    Finds minimum values along the axis and returns flat 1-d indices.

Returns:

  • (Integer, Numo::Int)

    returns result indices.

See Also:



4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
# File 'ext/numo/narray/types/int32.c', line 4778

static VALUE
int32_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 = nary_new(numo_cInt64, na->ndim, na->shape);
        ndf.func = iter_int32_min_index_index64;
      
#line 77 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum_index.c"
        reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
      
    } else {
        aout[0].type = numo_cInt32;
        idx = nary_new(numo_cInt32, na->ndim, na->shape);
        ndf.func = iter_int32_min_index_index32;
      
#line 86 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum_index.c"
        reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
      
    }
    rb_funcall(idx, rb_intern("seq"), 0);

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

#minmax(axis: nil, keepdims: false) ⇒ Numo::Int32

minmax of self.

Parameters:

  • axis (Numeric, Array, Range)

    Finds min-max along the axis.

  • keepdims (TrueClass)

    (keyword) If true, the reduced axes are left in the result array as dimensions with size one.

Returns:



5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
# File 'ext/numo/narray/types/int32.c', line 5025

static VALUE
int32_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_int32_minmax, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE|NDF_EXTRACT, 2,2, ain,aout};

  
#line 43 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/minmax.c"
    reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
  
    return na_ndloop(&ndf, 2, self, reduce);
}

#mulsum(other, axis: nil, keepdims: false) ⇒ Numo::NArray

Binary mulsum.

Parameters:

  • other (Numo::NArray, Numeric)
  • axis (Numeric, Array, Range)

    Performs mulsum along the axis.

  • keepdims (TrueClass)

    (keyword) If true, the reduced axes are left in the result array as dimensions with size one.

Returns:



5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
# File 'ext/numo/narray/types/int32.c', line 5580

static VALUE
int32_mulsum(int argc, VALUE *argv, VALUE self)
{
    //
    VALUE klass, v;
    //
    if (argc < 1) {
        rb_raise(rb_eArgError,"wrong number of arguments (%d for >=1)",argc);
    }
    //
#line 92 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum_binary.c"
    klass = na_upcast(rb_obj_class(self),rb_obj_class(argv[0]));
    if (klass==cT) {
        return int32_mulsum_self(argc, argv, self);
    } else {
        v = rb_funcall(klass, id_cast, 1, self);
        return rb_funcall2(v, rb_intern("mulsum"), argc, argv);
    }
    //
}

#ne(other) ⇒ Numo::Bit

Comparison ne other.

Parameters:

Returns:



3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
# File 'ext/numo/narray/types/int32.c', line 3248

static VALUE
int32_ne(VALUE self, VALUE other)
{
    
#line 46 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/cond_binary.c"
    VALUE klass, v;
    klass = na_upcast(rb_obj_class(self),rb_obj_class(other));
    if (klass==cT) {
        return int32_ne_self(self, other);
    } else {
        v = rb_funcall(klass, id_cast, 1, self);
        return rb_funcall(v, id_ne, 1, other);
    }
    
}

#poly(a0, a1, ..., an) ⇒ Numo::Int32

Calculate polynomial. x.poly(a0,a1,a2,...,an) = a0 + a1*x + a2*x**2 + ... + an*x**n

Parameters:

Returns:



5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
# File 'ext/numo/narray/types/int32.c', line 5940

static VALUE
int32_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_int32_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 int32_extract(v);
}

#prod(axis: nil, keepdims: false) ⇒ Numo::Int32

prod of self.

Parameters:

  • axis (Numeric, Array, Range)

    Performs prod along the axis.

  • keepdims (TrueClass)

    If true, the reduced axes are left in the result array as dimensions with size one.

Returns:



4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
# File 'ext/numo/narray/types/int32.c', line 4468

static VALUE
int32_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] = {{numo_cInt64,0}};
    ndfunc_t ndf = { iter_int32_prod, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE, 2, 1, ain, aout };

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

#ptp(axis: nil, keepdims: false) ⇒ Numo::Int32

ptp of self.

Parameters:

  • axis (Numeric, Array, Range)

    Performs ptp along the axis.

  • keepdims (TrueClass)

    If true, the reduced axes are left in the result array as dimensions with size one.

Returns:



4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
# File 'ext/numo/narray/types/int32.c', line 4600

static VALUE
int32_ptp(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_int32_ptp, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE, 2, 1, ain, aout };

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

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

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:



5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
# File 'ext/numo/narray/types/int32.c', line 5883

static VALUE
int32_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_int32_rand, FULL_LOOP, 1,0, ain,0};

    
    rb_scan_args(argc, args, "11", &v1, &v2);
    if (v2==Qnil) {
        g.low = m_zero;
        g.max = high = m_num_to_data(v1);
    
#line 155 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/rand.c"
    } else {
        g.low = m_num_to_data(v1);
        high = m_num_to_data(v2);
        g.max = m_sub(high,g.low);
    }
    
    if (high <= g.low) {
        rb_raise(rb_eArgError,"high must be larger than low");
    }
    
    na_ndloop3(&ndf, &g, 1, self);
    return self;
}

#reciprocalNumo::Int32

Unary reciprocal.

Returns:



2969
2970
2971
2972
2973
2974
2975
2976
2977
# File 'ext/numo/narray/types/int32.c', line 2969

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

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

#seq([beg,[step]]) ⇒ Numo::Int32 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:



5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
# File 'ext/numo/narray/types/int32.c', line 5667

static VALUE
int32_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_int32_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 84 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/seq.c"
    if (vbeg!=Qnil) {g->beg = NUM2DBL(vbeg);}
    if (vstep!=Qnil) {g->step = NUM2DBL(vstep);}

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

#signNumo::Int32

Unary sign.

Returns:



3053
3054
3055
3056
3057
3058
3059
3060
3061
# File 'ext/numo/narray/types/int32.c', line 3053

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

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

#sort(axis: nil) ⇒ Numo::Int32

sort of self.

Examples:

Numo::DFloat[3,4,1,2].sort #=> Numo::DFloat[1,2,3,4]

Parameters:

  • axis (Numeric, Array, Range)

    Performs sort along the axis.

Returns:



6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
# File 'ext/numo/narray/types/int32.c', line 6198

static VALUE
int32_sort(int argc, VALUE *argv, VALUE self)
{
    VALUE reduce;
    ndfunc_arg_in_t ain[2] = {{OVERWRITE,0},{sym_reduce,0}};
    ndfunc_t ndf = {0, NDF_HAS_LOOP|NDF_FLAT_REDUCE, 2,0, ain,0};

    if (!TEST_INPLACE(self)) {
        self = na_copy(self);
    }
  
#line 42 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/sort.c"
    ndf.func = iter_int32_sort;
    reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
  
    na_ndloop(&ndf, 2, self, reduce);
    return self;
}

#sort_index(axis: nil) ⇒ Integer, Numo::Int

sort_index. Returns an index array of sort result.

Examples:

Numo::NArray[3,4,1,2].sort_index #=> Numo::Int32[2,3,0,1]

Parameters:

  • axis (Numeric, Array, Range)

    Performs sort_index along the axis.

Returns:

  • (Integer, Numo::Int)

    returns result index of sort_index.



6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
# File 'ext/numo/narray/types/int32.c', line 6526

static VALUE
int32_sort_index(int argc, VALUE *argv, VALUE self)
{
    size_t size;
    narray_t *na;
    VALUE idx, tmp, reduce, res;
    char *buf;
    ndfunc_arg_in_t ain[3] = {{cT,0},{0,0},{sym_reduce,0}};
    ndfunc_arg_out_t aout[1] = {{0,0,0}};
    ndfunc_t ndf = {0, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE|NDF_CUM, 3,1, ain,aout};

    GetNArray(self,na);
    if (na->ndim==0) {
        return INT2FIX(0);
    }
    if (na->size > (~(u_int32_t)0)) {
        ain[1].type =
        aout[0].type = numo_cInt64;
        idx = nary_new(numo_cInt64, na->ndim, na->shape);
       
#line 84 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/sort_index.c"
         ndf.func = int32_index64_qsort;
         reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
       
    } else {
        ain[1].type =
        aout[0].type = numo_cInt32;
        idx = nary_new(numo_cInt32, na->ndim, na->shape);
       
#line 96 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/sort_index.c"
         ndf.func = int32_index32_qsort;
         reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
       
    }
    rb_funcall(idx, rb_intern("seq"), 0);

    size = na->size*sizeof(void*); // max capa
    buf = rb_alloc_tmp_buffer(&tmp, size);
    res = na_ndloop3(&ndf, buf, 3, self, idx, reduce);
    rb_free_tmp_buffer(&tmp);
    return res;
}

#squareNumo::Int32

Unary square.

Returns:



3137
3138
3139
3140
3141
3142
3143
3144
3145
# File 'ext/numo/narray/types/int32.c', line 3137

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

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

#store(other) ⇒ Numo::Int32

Store elements to Numo::Int32 from other.

Parameters:

  • other (Object)

Returns:



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
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
# File 'ext/numo/narray/types/int32.c', line 1026

static VALUE
int32_store(VALUE self, VALUE obj)
{
    VALUE r, klass;

    klass = rb_obj_class(obj);

    
    if (klass==numo_cInt32) {
        int32_store_int32(self,obj);
        return self;
    }
    
#line 19 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/store.c"
    if (IS_INTEGER_CLASS(klass) || klass==rb_cFloat || klass==rb_cComplex) {
        int32_store_numeric(self,obj);
        return self;
    }
    
#line 19 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/store.c"
    if (klass==numo_cBit) {
        int32_store_bit(self,obj);
        return self;
    }
    
#line 19 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/store.c"
    if (klass==numo_cDFloat) {
        int32_store_dfloat(self,obj);
        return self;
    }
    
#line 19 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/store.c"
    if (klass==numo_cSFloat) {
        int32_store_sfloat(self,obj);
        return self;
    }
    
#line 19 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/store.c"
    if (klass==numo_cInt64) {
        int32_store_int64(self,obj);
        return self;
    }
    
#line 19 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/store.c"
    if (klass==numo_cInt16) {
        int32_store_int16(self,obj);
        return self;
    }
    
#line 19 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/store.c"
    if (klass==numo_cInt8) {
        int32_store_int8(self,obj);
        return self;
    }
    
#line 19 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/store.c"
    if (klass==numo_cUInt64) {
        int32_store_uint64(self,obj);
        return self;
    }
    
#line 19 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/store.c"
    if (klass==numo_cUInt32) {
        int32_store_uint32(self,obj);
        return self;
    }
    
#line 19 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/store.c"
    if (klass==numo_cUInt16) {
        int32_store_uint16(self,obj);
        return self;
    }
    
#line 19 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/store.c"
    if (klass==numo_cUInt8) {
        int32_store_uint8(self,obj);
        return self;
    }
    
#line 19 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/store.c"
    if (klass==numo_cRObject) {
        int32_store_robject(self,obj);
        return self;
    }
    
#line 19 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/store.c"
    if (klass==rb_cArray) {
        int32_store_array(self,obj);
        return self;
    }
    

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

    
#line 36 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/store.c"
    rb_raise(nary_eCastError, "unknown conversion from %s to %s",
             rb_class2name(rb_obj_class(obj)),
             rb_class2name(rb_obj_class(self)));
    
    return self;
}

#sum(axis: nil, keepdims: false) ⇒ Numo::Int32

sum of self.

Parameters:

  • axis (Numeric, Array, Range)

    Performs sum along the axis.

  • keepdims (TrueClass)

    If true, the reduced axes are left in the result array as dimensions with size one.

Returns:



4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
# File 'ext/numo/narray/types/int32.c', line 4424

static VALUE
int32_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] = {{numo_cInt64,0}};
    ndfunc_t ndf = { iter_int32_sum, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE, 2, 1, ain, aout };

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

#to_aArray

Convert self to Array.

Returns:

  • (Array)


1422
1423
1424
1425
1426
1427
1428
1429
# File 'ext/numo/narray/types/int32.c', line 1422

static VALUE
int32_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_int32_to_a, FULL_LOOP_NIP, 3, 1, ain, aout };
    return na_ndloop_cast_narray_to_rarray(&ndf, self, Qnil);
}

#|(other) ⇒ Numo::NArray

Binary bit_or.

Parameters:

Returns:



3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
# File 'ext/numo/narray/types/int32.c', line 3527

static VALUE
int32_bit_or(VALUE self, VALUE other)
{
    
#line 226 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/binary.c"
    VALUE klass, v;

    klass = na_upcast(rb_obj_class(self),rb_obj_class(other));
    if (klass==cT) {
        return int32_bit_or_self(self, other);
    } else {
        v = rb_funcall(klass, id_cast, 1, self);
        return rb_funcall(v, '|', 1, other);
    }
    
}

#~Numo::Int32

Unary bit_not.

Returns:



3757
3758
3759
3760
3761
3762
3763
3764
3765
# File 'ext/numo/narray/types/int32.c', line 3757

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

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