Class: Numo::UInt16

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

Constant Summary

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, #empty?, #expand_dims, eye, #flatten, #fliplr, #flipud, 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::UInt16 .cast(array) ⇒ Numo::UInt16

Cast object to Numo::UInt16.

Parameters:

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

Returns:



1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
# File 'ext/numo/narray/types/uint16.c', line 1261

static VALUE
uint16_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 uint16_new_dim0(x);
    }
    if (RTEST(rb_obj_is_kind_of(obj,rb_cArray))) {
        return uint16_cast_array(obj);
    }
    if (IsNArray(obj)) {
        GetNArray(obj,na);
        v = nary_new(cT, NA_NDIM(na), NA_SHAPE(na));
        if (NA_SIZE(na) > 0) {
            uint16_store(v,obj);
        }
        return v;
    }
    
#line 41 "gen/tmpl/cast.c"
    rb_raise(nary_eCastError,"cannot cast to %s",rb_class2name(type));
    return Qnil;
    
}

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

Cast object to Numo::UInt16.

Parameters:

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

Returns:



1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
# File 'ext/numo/narray/types/uint16.c', line 1261

static VALUE
uint16_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 uint16_new_dim0(x);
    }
    if (RTEST(rb_obj_is_kind_of(obj,rb_cArray))) {
        return uint16_cast_array(obj);
    }
    if (IsNArray(obj)) {
        GetNArray(obj,na);
        v = nary_new(cT, NA_NDIM(na), NA_SHAPE(na));
        if (NA_SIZE(na) > 0) {
            uint16_store(v,obj);
        }
        return v;
    }
    
#line 41 "gen/tmpl/cast.c"
    rb_raise(nary_eCastError,"cannot cast to %s",rb_class2name(type));
    return Qnil;
    
}

Instance Method Details

#%(other) ⇒ Numo::NArray

Binary mod.

Parameters:

Returns:



2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
# File 'ext/numo/narray/types/uint16.c', line 2245

static VALUE
uint16_mod(VALUE self, VALUE other)
{
    
#line 48 "gen/tmpl/binary.c"
    VALUE klass, v;
    klass = na_upcast(CLASS_OF(self),CLASS_OF(other));
    if (klass==cT) {
        return uint16_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:



2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
# File 'ext/numo/narray/types/uint16.c', line 2803

static VALUE
uint16_bit_and(VALUE self, VALUE other)
{
    
#line 48 "gen/tmpl/binary.c"
    VALUE klass, v;
    klass = na_upcast(CLASS_OF(self),CLASS_OF(other));
    if (klass==cT) {
        return uint16_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:



2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
# File 'ext/numo/narray/types/uint16.c', line 2127

static VALUE
uint16_mul(VALUE self, VALUE other)
{
    
#line 48 "gen/tmpl/binary.c"
    VALUE klass, v;
    klass = na_upcast(CLASS_OF(self),CLASS_OF(other));
    if (klass==cT) {
        return uint16_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:



2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
# File 'ext/numo/narray/types/uint16.c', line 2386

static VALUE
uint16_pow(VALUE self, VALUE other)
{
    
#line 69 "gen/tmpl/pow.c"
    VALUE klass, v;
    klass = na_upcast(CLASS_OF(self),CLASS_OF(other));
    if (klass==cT) {
        return uint16_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:



2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
# File 'ext/numo/narray/types/uint16.c', line 2019

static VALUE
uint16_add(VALUE self, VALUE other)
{
    
#line 48 "gen/tmpl/binary.c"
    VALUE klass, v;
    klass = na_upcast(CLASS_OF(self),CLASS_OF(other));
    if (klass==cT) {
        return uint16_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:



2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
# File 'ext/numo/narray/types/uint16.c', line 2073

static VALUE
uint16_sub(VALUE self, VALUE other)
{
    
#line 48 "gen/tmpl/binary.c"
    VALUE klass, v;
    klass = na_upcast(CLASS_OF(self),CLASS_OF(other));
    if (klass==cT) {
        return uint16_sub_self(self, other);
    } else {
        v = rb_funcall(klass, id_cast, 1, self);
        return rb_funcall(v, '-', 1, other);
    }
    
}

#-@Numo::UInt16

Unary minus.

Returns:



2453
2454
2455
2456
2457
2458
2459
2460
2461
# File 'ext/numo/narray/types/uint16.c', line 2453

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

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

#/(other) ⇒ Numo::NArray

Binary div.

Parameters:

Returns:



2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
# File 'ext/numo/narray/types/uint16.c', line 2186

static VALUE
uint16_div(VALUE self, VALUE other)
{
    
#line 48 "gen/tmpl/binary.c"
    VALUE klass, v;
    klass = na_upcast(CLASS_OF(self),CLASS_OF(other));
    if (klass==cT) {
        return uint16_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:



3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
# File 'ext/numo/narray/types/uint16.c', line 3026

static VALUE
uint16_left_shift(VALUE self, VALUE other)
{
    
#line 48 "gen/tmpl/binary.c"
    VALUE klass, v;
    klass = na_upcast(CLASS_OF(self),CLASS_OF(other));
    if (klass==cT) {
        return uint16_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:



3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
# File 'ext/numo/narray/types/uint16.c', line 3080

static VALUE
uint16_right_shift(VALUE self, VALUE other)
{
    
#line 48 "gen/tmpl/binary.c"
    VALUE klass, v;
    klass = na_upcast(CLASS_OF(self),CLASS_OF(other));
    if (klass==cT) {
        return uint16_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, NArray::UInt16

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::UInt16)

    Element object or NArray view.



1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
# File 'ext/numo/narray/types/uint16.c', line 1333

static VALUE
uint16_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).



1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
# File 'ext/numo/narray/types/uint16.c', line 1390

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

    argc--;
    if (argc==0) {
        uint16_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);
            uint16_store(a, argv[argc]);
        } else {
            x = uint16_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:



2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
# File 'ext/numo/narray/types/uint16.c', line 2911

static VALUE
uint16_bit_xor(VALUE self, VALUE other)
{
    
#line 48 "gen/tmpl/binary.c"
    VALUE klass, v;
    klass = na_upcast(CLASS_OF(self),CLASS_OF(other));
    if (klass==cT) {
        return uint16_bit_xor_self(self, other);
    } else {
        v = rb_funcall(klass, id_cast, 1, self);
        return rb_funcall(v, '^', 1, other);
    }
    
}

#absNumo::UInt16

abs of self.

Returns:



1971
1972
1973
1974
1975
1976
1977
1978
1979
# File 'ext/numo/narray/types/uint16.c', line 1971

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

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

#allocateObject



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'ext/numo/narray/types/uint16.c', line 138

static VALUE
uint16_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 "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;
}

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



4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
# File 'ext/numo/narray/types/uint16.c', line 4109

static VALUE
uint16_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);

  
    v = uint16_max(0,0,self);
  
#line 157 "gen/tmpl/bincount.c"
    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 uint16_bincount_64(self, length);
        } else {
            return uint16_bincount_32(self, length);
        }
    } else {
        wclass = CLASS_OF(weight);
        if (wclass == numo_cSFloat) {
            return uint16_bincount_sf(self, weight, length);
        } else {
            return uint16_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
p a.clip(1,8)
# Numo::Int32#shape=[10]
# [1, 1, 2, 3, 4, 5, 6, 7, 8, 8]

p a
# Numo::Int32#shape=[10]
# [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

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

p a
# Numo::Int32#shape=[10]
# [3, 3, 3, 3, 4, 5, 6, 6, 6, 6]

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

p a.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:



3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
# File 'ext/numo/narray/types/uint16.c', line 3430

static VALUE
uint16_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_uint16_clip_min, STRIDE_LOOP, 2, 1, ain, aout };
    ndfunc_t ndf_max = { iter_uint16_clip_max, STRIDE_LOOP, 2, 1, ain, aout };
    ndfunc_t ndf_both = { iter_uint16_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)


1424
1425
1426
1427
1428
# File 'ext/numo/narray/types/uint16.c', line 1424

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

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

cumprod of self.

Parameters:

  • axis (Numeric, Array, Range)

    Affected dimensions.

  • nan (TrueClass)

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

Returns:



4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
# File 'ext/numo/narray/types/uint16.c', line 4236

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

  
#line 46 "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::UInt16

cumsum of self.

Parameters:

  • axis (Numeric, Array, Range)

    Affected dimensions.

  • nan (TrueClass)

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

Returns:



4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
# File 'ext/numo/narray/types/uint16.c', line 4185

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

  
#line 46 "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:



2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
# File 'ext/numo/narray/types/uint16.c', line 2306

static VALUE
uint16_divmod(VALUE self, VALUE other)
{
    
#line 50 "gen/tmpl/binary2.c"
    VALUE klass, v;
    klass = na_upcast(CLASS_OF(self),CLASS_OF(other));
    if (klass==cT) {
        return uint16_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| … }

Yields:

  • (x)

    x is element of NArray.

Returns:



1685
1686
1687
1688
1689
1690
1691
1692
1693
# File 'ext/numo/narray/types/uint16.c', line 1685

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



1813
1814
1815
1816
1817
1818
1819
1820
1821
# File 'ext/numo/narray/types/uint16.c', line 1813

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



2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
# File 'ext/numo/narray/types/uint16.c', line 2690

static VALUE
uint16_eq(VALUE self, VALUE other)
{
    
#line 46 "gen/tmpl/cond_binary.c"
    VALUE klass, v;
    klass = na_upcast(CLASS_OF(self),CLASS_OF(other));
    if (klass==cT) {
        return uint16_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:



177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'ext/numo/narray/types/uint16.c', line 177

static VALUE
uint16_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::UInt16

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:



4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
# File 'ext/numo/narray/types/uint16.c', line 4471

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

Fill elements with other.

Parameters:

  • other (Numeric)

Returns:



1505
1506
1507
1508
1509
1510
1511
1512
1513
# File 'ext/numo/narray/types/uint16.c', line 1505

static VALUE
uint16_fill(VALUE self, VALUE val)
{
    ndfunc_arg_in_t ain[2] = {{OVERWRITE,0},{sym_option}};
    ndfunc_t ndf = { iter_uint16_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:



1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
# File 'ext/numo/narray/types/uint16.c', line 1565

static VALUE
uint16_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_uint16_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.



1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
# File 'ext/numo/narray/types/uint16.c', line 1616

static VALUE
uint16_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_uint16_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:



3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
# File 'ext/numo/narray/types/uint16.c', line 3199

static VALUE
uint16_ge(VALUE self, VALUE other)
{
    
#line 46 "gen/tmpl/cond_binary.c"
    VALUE klass, v;
    klass = na_upcast(CLASS_OF(self),CLASS_OF(other));
    if (klass==cT) {
        return uint16_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:



3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
# File 'ext/numo/narray/types/uint16.c', line 3142

static VALUE
uint16_gt(VALUE self, VALUE other)
{
    
#line 46 "gen/tmpl/cond_binary.c"
    VALUE klass, v;
    klass = na_upcast(CLASS_OF(self),CLASS_OF(other));
    if (klass==cT) {
        return uint16_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)


1643
1644
1645
1646
1647
# File 'ext/numo/narray/types/uint16.c', line 1643

VALUE
uint16_inspect(VALUE ary)
{
    return na_ndloop_inspect(ary, iter_uint16_inspect, Qnil);
}

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

Comparison le other.

Parameters:

Returns:



3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
# File 'ext/numo/narray/types/uint16.c', line 3313

static VALUE
uint16_le(VALUE self, VALUE other)
{
    
#line 46 "gen/tmpl/cond_binary.c"
    VALUE klass, v;
    klass = na_upcast(CLASS_OF(self),CLASS_OF(other));
    if (klass==cT) {
        return uint16_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:



3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
# File 'ext/numo/narray/types/uint16.c', line 3256

static VALUE
uint16_lt(VALUE self, VALUE other)
{
    
#line 46 "gen/tmpl/cond_binary.c"
    VALUE klass, v;
    klass = na_upcast(CLASS_OF(self),CLASS_OF(other));
    if (klass==cT) {
        return uint16_lt_self(self, other);
    } else {
        v = rb_funcall(klass, id_cast, 1, self);
        return rb_funcall(v, id_lt, 1, other);
    }
    
}

#mapNumo::UInt16

Unary map.

Returns:



1746
1747
1748
1749
1750
1751
1752
1753
1754
# File 'ext/numo/narray/types/uint16.c', line 1746

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



1910
1911
1912
1913
1914
1915
1916
1917
1918
# File 'ext/numo/narray/types/uint16.c', line 1910

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

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

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

max of self.

Parameters:

  • axis (Numeric, Array, Range)

    (keyword) Affected dimensions.

  • keepdims (TrueClass)

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

Returns:



3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
# File 'ext/numo/narray/types/uint16.c', line 3611

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

  
#line 40 "gen/tmpl/accum.c"
    reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
  
    v =  na_ndloop(&ndf, 2, self, reduce);
  
    return uint16_extract(v);
  
#line 48 "gen/tmpl/accum.c"
}

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

max_index. Return an index of result.

Examples:

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

Parameters:

  • axis (Numeric, Array, Range)

    Affected dimensions.

Returns:

  • (Integer, Numo::Int)

    returns result index of max_index.



3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
# File 'ext/numo/narray/types/uint16.c', line 3726

static VALUE
uint16_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_uint16_max_index_index64;
      
#line 56 "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_uint16_max_index_index32;
      
#line 65 "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::UInt16

median of self.

Parameters:

  • axis (Numeric, Array, Range)

    (keyword) Affected dimensions.

  • keepdims (TrueClass)

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

Returns:



5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
# File 'ext/numo/narray/types/uint16.c', line 5213

static VALUE
uint16_median(int argc, VALUE *argv, VALUE self)
{
    VALUE 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 "gen/tmpl/median.c"
    ndf.func = iter_uint16_median;
    reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
  
    return na_ndloop(&ndf, 2, self, reduce);
}

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

min of self.

Parameters:

  • axis (Numeric, Array, Range)

    (keyword) Affected dimensions.

  • keepdims (TrueClass)

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

Returns:



3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
# File 'ext/numo/narray/types/uint16.c', line 3567

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

  
#line 40 "gen/tmpl/accum.c"
    reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
  
    v =  na_ndloop(&ndf, 2, self, reduce);
  
    return uint16_extract(v);
  
#line 48 "gen/tmpl/accum.c"
}

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

min_index. Return an index of result.

Examples:

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

Parameters:

  • axis (Numeric, Array, Range)

    Affected dimensions.

Returns:

  • (Integer, Numo::Int)

    returns result index of min_index.



3813
3814
3815
3816
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
3845
3846
# File 'ext/numo/narray/types/uint16.c', line 3813

static VALUE
uint16_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_uint16_min_index_index64;
      
#line 56 "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_uint16_min_index_index32;
      
#line 65 "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::UInt16

minmax of self.

Parameters:

  • axis (Numeric, Array, Range)

    (keyword) Affected dimensions.

  • keepdims (TrueClass)

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

Returns:



3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
# File 'ext/numo/narray/types/uint16.c', line 3876

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

  
#line 43 "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)

    (keyword) Affected dimensions.

  • keepdims (TrueClass)

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

Returns:



4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
# File 'ext/numo/narray/types/uint16.c', line 4321

static VALUE
uint16_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 88 "gen/tmpl/accum_binary.c"
    klass = na_upcast(CLASS_OF(self),CLASS_OF(argv[0]));
    if (klass==cT) {
        return uint16_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:



2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
# File 'ext/numo/narray/types/uint16.c', line 2747

static VALUE
uint16_ne(VALUE self, VALUE other)
{
    
#line 46 "gen/tmpl/cond_binary.c"
    VALUE klass, v;
    klass = na_upcast(CLASS_OF(self),CLASS_OF(other));
    if (klass==cT) {
        return uint16_ne_self(self, other);
    } else {
        v = rb_funcall(klass, id_cast, 1, self);
        return rb_funcall(v, id_ne, 1, other);
    }
    
}

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

Polynomial.: a0 + a1x + a2x2 + a3_x_3 + … + anxn

Parameters:

Returns:



4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
# File 'ext/numo/narray/types/uint16.c', line 4678

static VALUE
uint16_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_uint16_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 uint16_extract(v);
}

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

prod of self.

Parameters:

  • axis (Numeric, Array, Range)

    (keyword) Affected dimensions.

  • keepdims (TrueClass)

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

Returns:



3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
# File 'ext/numo/narray/types/uint16.c', line 3523

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

  
#line 40 "gen/tmpl/accum.c"
    reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
  
    v =  na_ndloop(&ndf, 2, self, reduce);
  
    return uint16_extract(v);
  
#line 48 "gen/tmpl/accum.c"
}

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

ptp of self.

Parameters:

  • axis (Numeric, Array, Range)

    (keyword) Affected dimensions.

  • keepdims (TrueClass)

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

Returns:



3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
# File 'ext/numo/narray/types/uint16.c', line 3655

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

  
#line 40 "gen/tmpl/accum.c"
    reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
  
    v =  na_ndloop(&ndf, 2, self, reduce);
  
    return uint16_extract(v);
  
#line 48 "gen/tmpl/accum.c"
}

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

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:



4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
# File 'ext/numo/narray/types/uint16.c', line 4621

static VALUE
uint16_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_uint16_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 153 "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::UInt16

Unary reciprocal.

Returns:



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

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

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

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



4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
# File 'ext/numo/narray/types/uint16.c', line 4407

static VALUE
uint16_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_uint16_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 83 "gen/tmpl/seq.c"
    if (vbeg!=Qnil) {g->beg = NUM2DBL(vbeg);}
    if (vstep!=Qnil) {g->step = NUM2DBL(vstep);}

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

#signNumo::UInt16

Unary sign.

Returns:



2575
2576
2577
2578
2579
2580
2581
2582
2583
# File 'ext/numo/narray/types/uint16.c', line 2575

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

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

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

sort of self.

Examples:

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

Parameters:

  • axis (Numeric, Array, Range)

    Affected dimensions.

Returns:



4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
# File 'ext/numo/narray/types/uint16.c', line 4874

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

    if (!TEST_INPLACE(self)) {
        self = na_copy(self);
    }
  
#line 42 "gen/tmpl/sort.c"
    ndf.func = iter_uint16_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)

    Affected dimensions.

Returns:

  • (Integer, Numo::Int)

    returns result index of sort_index.



5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
# File 'ext/numo/narray/types/uint16.c', line 5130

static VALUE
uint16_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 79 "gen/tmpl/sort_index.c"
         ndf.func = uint16_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 91 "gen/tmpl/sort_index.c"
         ndf.func = uint16_index32_qsort;
         reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
       
    }
    rb_funcall(idx, rb_intern("seq"), 0);

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

#squareNumo::UInt16

Unary square.

Returns:



2636
2637
2638
2639
2640
2641
2642
2643
2644
# File 'ext/numo/narray/types/uint16.c', line 2636

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

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

#store(other) ⇒ Numo::UInt16

Store elements to Numo::UInt16 from other.

Parameters:

  • other (Object)

Returns:



1009
1010
1011
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
1116
# File 'ext/numo/narray/types/uint16.c', line 1009

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

    klass = CLASS_OF(obj);

    
    if (klass==numo_cUInt16) {
        uint16_store_uint16(self,obj);
        return self;
    }
    
#line 19 "gen/tmpl/store.c"
    if (IS_INTEGER_CLASS(klass) || klass==rb_cFloat || klass==rb_cComplex) {
        uint16_store_numeric(self,obj);
        return self;
    }
    
#line 19 "gen/tmpl/store.c"
    if (klass==numo_cBit) {
        uint16_store_bit(self,obj);
        return self;
    }
    
#line 19 "gen/tmpl/store.c"
    if (klass==numo_cDFloat) {
        uint16_store_dfloat(self,obj);
        return self;
    }
    
#line 19 "gen/tmpl/store.c"
    if (klass==numo_cSFloat) {
        uint16_store_sfloat(self,obj);
        return self;
    }
    
#line 19 "gen/tmpl/store.c"
    if (klass==numo_cInt64) {
        uint16_store_int64(self,obj);
        return self;
    }
    
#line 19 "gen/tmpl/store.c"
    if (klass==numo_cInt32) {
        uint16_store_int32(self,obj);
        return self;
    }
    
#line 19 "gen/tmpl/store.c"
    if (klass==numo_cInt16) {
        uint16_store_int16(self,obj);
        return self;
    }
    
#line 19 "gen/tmpl/store.c"
    if (klass==numo_cInt8) {
        uint16_store_int8(self,obj);
        return self;
    }
    
#line 19 "gen/tmpl/store.c"
    if (klass==numo_cUInt64) {
        uint16_store_uint64(self,obj);
        return self;
    }
    
#line 19 "gen/tmpl/store.c"
    if (klass==numo_cUInt32) {
        uint16_store_uint32(self,obj);
        return self;
    }
    
#line 19 "gen/tmpl/store.c"
    if (klass==numo_cUInt8) {
        uint16_store_uint8(self,obj);
        return self;
    }
    
#line 19 "gen/tmpl/store.c"
    if (klass==numo_cRObject) {
        uint16_store_robject(self,obj);
        return self;
    }
    
#line 19 "gen/tmpl/store.c"
    if (klass==rb_cArray) {
        uint16_store_array(self,obj);
        return self;
    }
    

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

    
#line 36 "gen/tmpl/store.c"
    rb_raise(nary_eCastError, "unknown conversion from %s to %s",
             rb_class2name(CLASS_OF(obj)),
             rb_class2name(CLASS_OF(self)));
    
    return self;
}

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

sum of self.

Parameters:

  • axis (Numeric, Array, Range)

    (keyword) Affected dimensions.

  • keepdims (TrueClass)

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

Returns:



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

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

  
#line 40 "gen/tmpl/accum.c"
    reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
  
    v =  na_ndloop(&ndf, 2, self, reduce);
  
    return uint16_extract(v);
  
#line 48 "gen/tmpl/accum.c"
}

#to_aArray

Convert self to Array.

Returns:

  • (Array)


1465
1466
1467
1468
1469
1470
1471
1472
# File 'ext/numo/narray/types/uint16.c', line 1465

static VALUE
uint16_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_uint16_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:



2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
# File 'ext/numo/narray/types/uint16.c', line 2857

static VALUE
uint16_bit_or(VALUE self, VALUE other)
{
    
#line 48 "gen/tmpl/binary.c"
    VALUE klass, v;
    klass = na_upcast(CLASS_OF(self),CLASS_OF(other));
    if (klass==cT) {
        return uint16_bit_or_self(self, other);
    } else {
        v = rb_funcall(klass, id_cast, 1, self);
        return rb_funcall(v, '|', 1, other);
    }
    
}

#~Numo::UInt16

Unary bit_not.

Returns:



2978
2979
2980
2981
2982
2983
2984
2985
2986
# File 'ext/numo/narray/types/uint16.c', line 2978

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

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