Class: Numo::DFloat

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

Defined Under Namespace

Modules: Math

Constant Summary

UPCAST =
hCast
ELEMENT_BIT_SIZE =
INT2FIX(sizeof(dtype)*8)
ELEMENT_BYTE_SIZE =
INT2FIX(sizeof(dtype))
CONTIGUOUS_STRIDE =
INT2FIX(sizeof(dtype))

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?, debug=, #debug_info, #deg2rad, #delete, #diagonal, #diff, #dot, #dsplit, dstack, #empty?, #expand_dims, eye, #flatten, #fliplr, #flipud, from_binary, #host_order?, #hsplit, hstack, #initialize, #initialize_copy, #inplace, #inplace!, #inplace?, #insert, inspect_cols, inspect_cols=, inspect_rows, inspect_rows=, linspace, logspace, #marshal_dump, #marshal_load, #ndim, #new_fill, new_like, #new_narray, #new_ones, #new_zeros, ones, #out_of_place!, profile, profile=, #rad2deg, #repeat, #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, #transpose, upcast, #view, #vsplit, vstack, zeros

Constructor Details

This class inherits a constructor from Numo::NArray

Class Method Details

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

Cast object to Numo::DFloat.

Parameters:

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

Returns:



1258
1259
1260
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
# File 'ext/numo/narray/types/dfloat.c', line 1258

static VALUE
dfloat_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 dfloat_new_dim0(x);
    }
    if (RTEST(rb_obj_is_kind_of(obj,rb_cArray))) {
        return dfloat_cast_array(obj);
    }
    if (IsNArray(obj)) {
        GetNArray(obj,na);
        v = nary_new(cT, NA_NDIM(na), NA_SHAPE(na));
        if (NA_SIZE(na) > 0) {
            dfloat_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::DFloat .cast(array) ⇒ Numo::DFloat

Cast object to Numo::DFloat.

Parameters:

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

Returns:



1258
1259
1260
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
# File 'ext/numo/narray/types/dfloat.c', line 1258

static VALUE
dfloat_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 dfloat_new_dim0(x);
    }
    if (RTEST(rb_obj_is_kind_of(obj,rb_cArray))) {
        return dfloat_cast_array(obj);
    }
    if (IsNArray(obj)) {
        GetNArray(obj,na);
        v = nary_new(cT, NA_NDIM(na), NA_SHAPE(na));
        if (NA_SIZE(na) > 0) {
            dfloat_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:



2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
# File 'ext/numo/narray/types/dfloat.c', line 2232

static VALUE
dfloat_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 dfloat_mod_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:



2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
# File 'ext/numo/narray/types/dfloat.c', line 2124

static VALUE
dfloat_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 dfloat_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:



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

static VALUE
dfloat_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 dfloat_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:



2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
# File 'ext/numo/narray/types/dfloat.c', line 2016

static VALUE
dfloat_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 dfloat_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:



2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
# File 'ext/numo/narray/types/dfloat.c', line 2070

static VALUE
dfloat_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 dfloat_sub_self(self, other);
    } else {
        v = rb_funcall(klass, id_cast, 1, self);
        return rb_funcall(v, '-', 1, other);
    }
    
}

#-@Numo::DFloat

Unary minus.

Returns:



2435
2436
2437
2438
2439
2440
2441
2442
2443
# File 'ext/numo/narray/types/dfloat.c', line 2435

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

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

#/(other) ⇒ Numo::NArray

Binary div.

Parameters:

Returns:



2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
# File 'ext/numo/narray/types/dfloat.c', line 2178

static VALUE
dfloat_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 dfloat_div_self(self, other);
    } else {
        v = rb_funcall(klass, id_cast, 1, self);
        return rb_funcall(v, '/', 1, other);
    }
    
}

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

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

    Element object or NArray view.



1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
# File 'ext/numo/narray/types/dfloat.c', line 1330

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



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

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

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

    }
    return argv[argc];
}

#absNumo::DFloat

abs of self.

Returns:



1968
1969
1970
1971
1972
1973
1974
1975
1976
# File 'ext/numo/narray/types/dfloat.c', line 1968

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

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

#allocateObject



135
136
137
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
# File 'ext/numo/narray/types/dfloat.c', line 135

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

#ceilNumo::DFloat

Unary ceil.

Returns:



2976
2977
2978
2979
2980
2981
2982
2983
2984
# File 'ext/numo/narray/types/dfloat.c', line 2976

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

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

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



3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
# File 'ext/numo/narray/types/dfloat.c', line 3575

static VALUE
dfloat_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_dfloat_clip_min, STRIDE_LOOP, 2, 1, ain, aout };
    ndfunc_t ndf_max = { iter_dfloat_clip_max, STRIDE_LOOP, 2, 1, ain, aout };
    ndfunc_t ndf_both = { iter_dfloat_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)


1421
1422
1423
1424
1425
# File 'ext/numo/narray/types/dfloat.c', line 1421

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

#copysign(other) ⇒ Numo::NArray

Binary copysign.

Parameters:

Returns:



3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
# File 'ext/numo/narray/types/dfloat.c', line 3146

static VALUE
dfloat_copysign(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 dfloat_copysign_self(self, other);
    } else {
        v = rb_funcall(klass, id_cast, 1, self);
        return rb_funcall(v, id_copysign, 1, other);
    }
    
}

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

cumprod of self.

Parameters:

  • axis (Numeric, Array, Range)

    Affected dimensions.

  • nan (TrueClass)

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

Returns:



4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
# File 'ext/numo/narray/types/dfloat.c', line 4880

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

  
    reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_dfloat_cumprod_nan);
  
#line 48 "gen/tmpl/cum.c"
    return na_ndloop(&ndf, 2, self, reduce);
}

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

cumsum of self.

Parameters:

  • axis (Numeric, Array, Range)

    Affected dimensions.

  • nan (TrueClass)

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

Returns:



4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
# File 'ext/numo/narray/types/dfloat.c', line 4805

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

  
    reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_dfloat_cumsum_nan);
  
#line 48 "gen/tmpl/cum.c"
    return na_ndloop(&ndf, 2, self, reduce);
}

#divmod(other) ⇒ Numo::NArray

Binary divmod.

Parameters:

Returns:



2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
# File 'ext/numo/narray/types/dfloat.c', line 2288

static VALUE
dfloat_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 dfloat_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:



1682
1683
1684
1685
1686
1687
1688
1689
1690
# File 'ext/numo/narray/types/dfloat.c', line 1682

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



1810
1811
1812
1813
1814
1815
1816
1817
1818
# File 'ext/numo/narray/types/dfloat.c', line 1810

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

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

#eq(other) ⇒ Numo::Bit

Comparison eq other.

Parameters:

Returns:



2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
# File 'ext/numo/narray/types/dfloat.c', line 2672

static VALUE
dfloat_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 dfloat_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:



174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'ext/numo/narray/types/dfloat.c', line 174

static VALUE
dfloat_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::DFloat

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:



5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
# File 'ext/numo/narray/types/dfloat.c', line 5233

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

Fill elements with other.

Parameters:

  • other (Numeric)

Returns:



1502
1503
1504
1505
1506
1507
1508
1509
1510
# File 'ext/numo/narray/types/dfloat.c', line 1502

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

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

#floorNumo::DFloat

Unary floor.

Returns:



2854
2855
2856
2857
2858
2859
2860
2861
2862
# File 'ext/numo/narray/types/dfloat.c', line 2854

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

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

#format(format) ⇒ Numo::RObject

Format elements into strings.

Parameters:

  • format (String)

Returns:



1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
# File 'ext/numo/narray/types/dfloat.c', line 1562

static VALUE
dfloat_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_dfloat_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.



1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
# File 'ext/numo/narray/types/dfloat.c', line 1613

static VALUE
dfloat_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_dfloat_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:



3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
# File 'ext/numo/narray/types/dfloat.c', line 3344

static VALUE
dfloat_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 dfloat_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:



3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
# File 'ext/numo/narray/types/dfloat.c', line 3287

static VALUE
dfloat_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 dfloat_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)


1640
1641
1642
1643
1644
# File 'ext/numo/narray/types/dfloat.c', line 1640

VALUE
dfloat_inspect(VALUE ary)
{
    return na_ndloop_inspect(ary, iter_dfloat_inspect, Qnil);
}

#isfiniteNumo::Bit

Condition of isfinite.

Returns:



3829
3830
3831
3832
3833
3834
3835
3836
3837
# File 'ext/numo/narray/types/dfloat.c', line 3829

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

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

#isinfNumo::Bit

Condition of isinf.

Returns:



3685
3686
3687
3688
3689
3690
3691
3692
3693
# File 'ext/numo/narray/types/dfloat.c', line 3685

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

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

#isnanNumo::Bit

Condition of isnan.

Returns:



3637
3638
3639
3640
3641
3642
3643
3644
3645
# File 'ext/numo/narray/types/dfloat.c', line 3637

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

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

#isneginfNumo::Bit

Condition of isneginf.

Returns:



3781
3782
3783
3784
3785
3786
3787
3788
3789
# File 'ext/numo/narray/types/dfloat.c', line 3781

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

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

#isposinfNumo::Bit

Condition of isposinf.

Returns:



3733
3734
3735
3736
3737
3738
3739
3740
3741
# File 'ext/numo/narray/types/dfloat.c', line 3733

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

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

#kahan_sum(axis: nil, keepdims: false, nan: false) ⇒ Numo::DFloat

kahan_sum of self.

Parameters:

  • nan (TrueClass)

    If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).

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



3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
# File 'ext/numo/narray/types/dfloat.c', line 3997

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

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

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

Comparison le other.

Parameters:

Returns:



3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
# File 'ext/numo/narray/types/dfloat.c', line 3458

static VALUE
dfloat_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 dfloat_le_self(self, other);
    } else {
        v = rb_funcall(klass, id_cast, 1, self);
        return rb_funcall(v, id_le, 1, other);
    }
    
}

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

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

base**(beg+i*step)

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

Examples:

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

Parameters:

  • beg (Numeric)

    The begining of sequence.

  • step (Numeric)

    The step of sequence.

  • base (Numeric)

    The base of log space. (default=10)

Returns:



5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
# File 'ext/numo/narray/types/dfloat.c', line 5170

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

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

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

Comparison lt other.

Parameters:

Returns:



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

static VALUE
dfloat_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 dfloat_lt_self(self, other);
    } else {
        v = rb_funcall(klass, id_cast, 1, self);
        return rb_funcall(v, id_lt, 1, other);
    }
    
}

#mapNumo::DFloat

Unary map.

Returns:



1743
1744
1745
1746
1747
1748
1749
1750
1751
# File 'ext/numo/narray/types/dfloat.c', line 1743

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



1907
1908
1909
1910
1911
1912
1913
1914
1915
# File 'ext/numo/narray/types/dfloat.c', line 1907

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

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

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

max of self.

Parameters:

  • nan (TrueClass)

    If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).

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



4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
# File 'ext/numo/narray/types/dfloat.c', line 4351

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

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

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

max_index. Return an index of result.

Examples:

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

Parameters:

  • nan (TrueClass)

    If true, apply NaN-aware algorithm (return NaN posision if exist).

  • axis (Numeric, Array, Range)

    Affected dimensions.

Returns:

  • (Integer, Numo::Int)

    returns result index of max_index.



4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
# File 'ext/numo/narray/types/dfloat.c', line 4522

static VALUE
dfloat_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_dfloat_max_index_index64;
      
        reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_dfloat_max_index_index64_nan);
      
#line 58 "gen/tmpl/accum_index.c"
    } else {
        aout[0].type = numo_cInt32;
        idx = nary_new(numo_cInt32, na->ndim, na->shape);
        ndf.func = iter_dfloat_max_index_index32;
      
        reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_dfloat_max_index_index32_nan);
      
#line 67 "gen/tmpl/accum_index.c"
    }
    rb_funcall(idx, rb_intern("seq"), 0);

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

#mean(axis: nil, keepdims: false, nan: false) ⇒ Numo::DFloat

mean of self.

Parameters:

  • nan (TrueClass)

    If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).

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



4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
# File 'ext/numo/narray/types/dfloat.c', line 4056

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

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

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

median of self.

Parameters:

  • nan (TrueClass)

    (keyword) If true, propagete NaN. If false, ignore NaN.

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



6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
# File 'ext/numo/narray/types/dfloat.c', line 6497

static VALUE
dfloat_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
  
    ndf.func = iter_dfloat_median_ignan;
    reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_dfloat_median_prnan);
  
#line 63 "gen/tmpl/median.c"
    return na_ndloop(&ndf, 2, self, reduce);
}

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

min of self.

Parameters:

  • nan (TrueClass)

    If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).

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



4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
# File 'ext/numo/narray/types/dfloat.c', line 4292

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

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

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

min_index. Return an index of result.

Examples:

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

Parameters:

  • nan (TrueClass)

    If true, apply NaN-aware algorithm (return NaN posision if exist).

  • axis (Numeric, Array, Range)

    Affected dimensions.

Returns:

  • (Integer, Numo::Int)

    returns result index of min_index.



4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
# File 'ext/numo/narray/types/dfloat.c', line 4650

static VALUE
dfloat_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_dfloat_min_index_index64;
      
        reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_dfloat_min_index_index64_nan);
      
#line 58 "gen/tmpl/accum_index.c"
    } else {
        aout[0].type = numo_cInt32;
        idx = nary_new(numo_cInt32, na->ndim, na->shape);
        ndf.func = iter_dfloat_min_index_index32;
      
        reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_dfloat_min_index_index32_nan);
      
#line 67 "gen/tmpl/accum_index.c"
    }
    rb_funcall(idx, rb_intern("seq"), 0);

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

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

minmax of self.

Parameters:

  • nan (TrueClass)

    If true, apply NaN-aware algorithm (return NaN if exist).

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



4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
# File 'ext/numo/narray/types/dfloat.c', line 4731

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

  
    reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_dfloat_minmax_nan);
  
#line 45 "gen/tmpl/minmax.c"
    return na_ndloop(&ndf, 2, self, reduce);
}

#modfNumo::DFloat

modf of self.

Returns:



3236
3237
3238
3239
3240
3241
3242
3243
3244
# File 'ext/numo/narray/types/dfloat.c', line 3236

static VALUE
dfloat_modf(VALUE self)
{
    ndfunc_arg_in_t ain[1] = {{cT,0}};
    ndfunc_arg_out_t aout[2] = {{cT,0},{cT,0}};
    ndfunc_t ndf = {iter_dfloat_modf, STRIDE_LOOP, 1,2, ain,aout};

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

#mulsum(other, axis: nil, keepdims: false, nan: 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.

  • nan (TrueClass)

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

Returns:



4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
# File 'ext/numo/narray/types/dfloat.c', line 4998

static VALUE
dfloat_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 dfloat_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:



2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
# File 'ext/numo/narray/types/dfloat.c', line 2729

static VALUE
dfloat_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 dfloat_ne_self(self, other);
    } else {
        v = rb_funcall(klass, id_cast, 1, self);
        return rb_funcall(v, id_ne, 1, other);
    }
    
}

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

Comparison nearly_eq other.

Parameters:

Returns:

  • (Numo::Bit)

    result of self nearly_eq other.



2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
# File 'ext/numo/narray/types/dfloat.c', line 2786

static VALUE
dfloat_nearly_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 dfloat_nearly_eq_self(self, other);
    } else {
        v = rb_funcall(klass, id_cast, 1, self);
        return rb_funcall(v, id_nearly_eq, 1, other);
    }
    
}

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

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

Parameters:

Returns:



5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
# File 'ext/numo/narray/types/dfloat.c', line 5519

static VALUE
dfloat_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_dfloat_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 dfloat_extract(v);
}

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

prod of self.

Parameters:

  • nan (TrueClass)

    If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).

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



3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
# File 'ext/numo/narray/types/dfloat.c', line 3938

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

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

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

ptp of self.

Parameters:

  • nan (TrueClass)

    If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).

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



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

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

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

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

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:



5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
# File 'ext/numo/narray/types/dfloat.c', line 5347

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

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

#rand_norm([mu,[sigma]]) ⇒ Numo::DFloat

Generates random numbers from the normal distribution on self narray using Box-Muller Transformation.

Examples:

Numo::DFloat.new(5,5).rand_norm
=> Numo::DFloat#shape=[5,5]
   [[-0.581255, -0.168354, 0.586895, -0.595142, -0.802802],
    [-0.326106, 0.282922, 1.68427, 0.918499, -0.0485384],
    [-0.464453, -0.992194, 0.413794, -0.60717, -0.699695],
    [-1.64168, 0.48676, -0.875871, -1.43275, 0.812172],
    [-0.209975, -0.103612, -0.878617, -1.42495, 1.0968]]
Numo::DFloat.new(5,5).rand_norm(10,0.1)
=> Numo::DFloat#shape=[5,5]
   [[9.9019, 9.90339, 10.0826, 9.98384, 9.72861],
    [9.81507, 10.0272, 9.91445, 10.0568, 9.88923],
    [10.0234, 9.97874, 9.96011, 9.9006, 9.99964],
    [10.0186, 9.94598, 9.92236, 9.99811, 9.97003],
    [9.79266, 9.95044, 9.95212, 9.93692, 10.2027]]
Numo::DComplex.new(3,3).rand_norm(5+5i)
=> Numo::DComplex#shape=[3,3]
   [[5.84303+4.40052i, 4.00984+6.08982i, 5.10979+5.13215i],
    [4.26477+3.99655i, 4.90052+5.00763i, 4.46607+2.3444i],
    [4.5528+7.11003i, 5.62117+6.69094i, 5.05443+5.35133i]]

Parameters:

  • mu (Numeric)

    mean of normal distribution. (default=0)

  • sigma (Numeric)

    standard deviation of normal distribution. (default=1)

Returns:



5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
# File 'ext/numo/narray/types/dfloat.c', line 5468

static VALUE
dfloat_rand_norm(int argc, VALUE *args, VALUE self)
{
    int n;
    randn_opt_t g;
    VALUE v1=Qnil, v2=Qnil;
    ndfunc_arg_in_t ain[1] = {{OVERWRITE,0}};
    ndfunc_t ndf = {iter_dfloat_rand_norm, FULL_LOOP, 1,0, ain,0};

    n = rb_scan_args(argc, args, "02", &v1, &v2);
    if (n == 0) {
        g.mu = m_zero;
    } else {
        g.mu = m_num_to_data(v1);
    }
    if (n == 2) {
        g.sigma = NUM2DBL(v2);
    } else {
        g.sigma = 1;
    }
    na_ndloop3(&ndf, &g, 1, self);
    return self;
}

#reciprocalNumo::DFloat

Unary reciprocal.

Returns:



2496
2497
2498
2499
2500
2501
2502
2503
2504
# File 'ext/numo/narray/types/dfloat.c', line 2496

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

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

#rintNumo::DFloat

Unary rint.

Returns:



3098
3099
3100
3101
3102
3103
3104
3105
3106
# File 'ext/numo/narray/types/dfloat.c', line 3098

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

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

#rms(axis: nil, keepdims: false, nan: false) ⇒ Numo::DFloat

rms of self.

Parameters:

  • nan (TrueClass)

    If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).

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



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

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

  
    reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_dfloat_rms_nan);
  
#line 42 "gen/tmpl/accum.c"
    v =  na_ndloop(&ndf, 2, self, reduce);
  
#line 46 "gen/tmpl/accum.c"
    return rb_funcall(v,rb_intern("extract"),0);
  
}

#roundNumo::DFloat

Unary round.

Returns:



2915
2916
2917
2918
2919
2920
2921
2922
2923
# File 'ext/numo/narray/types/dfloat.c', line 2915

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

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

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



5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
# File 'ext/numo/narray/types/dfloat.c', line 5084

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

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

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

#signNumo::DFloat

Unary sign.

Returns:



2557
2558
2559
2560
2561
2562
2563
2564
2565
# File 'ext/numo/narray/types/dfloat.c', line 2557

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

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

#signbitNumo::Bit

Condition of signbit.

Returns:



3200
3201
3202
3203
3204
3205
3206
3207
3208
# File 'ext/numo/narray/types/dfloat.c', line 3200

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

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

#sort(axis: nil, nan: false) ⇒ Numo::DFloat

sort of self.

Examples:

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

Parameters:

  • nan (TrueClass)

    If true, propagete NaN. If false, ignore NaN.

  • axis (Numeric, Array, Range)

    Affected dimensions.

Returns:



5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
# File 'ext/numo/narray/types/dfloat.c', line 5885

static VALUE
dfloat_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);
    }
  
    ndf.func = iter_dfloat_sort_ignan;
    reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_dfloat_sort_prnan);
  
#line 45 "gen/tmpl/sort.c"
    na_ndloop(&ndf, 2, self, reduce);
    return self;
}

#sort_index(axis: nil, nan: false) ⇒ 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:

  • nan (TrueClass)

    If true, propagete NaN. If false, ignore NaN.

  • axis (Numeric, Array, Range)

    Affected dimensions.

Returns:

  • (Integer, Numo::Int)

    returns result index of sort_index.



6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
# File 'ext/numo/narray/types/dfloat.c', line 6377

static VALUE
dfloat_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);
       
         ndf.func = dfloat_index64_qsort_ignan;
         reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf,
                                      dfloat_index64_qsort_prnan);
       
#line 82 "gen/tmpl/sort_index.c"
    } else {
        ain[1].type =
        aout[0].type = numo_cInt32;
        idx = nary_new(numo_cInt32, na->ndim, na->shape);
       
         ndf.func = dfloat_index32_qsort_ignan;
         reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf,
                                      dfloat_index32_qsort_prnan);
       
#line 94 "gen/tmpl/sort_index.c"
    }
    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::DFloat

Unary square.

Returns:



2618
2619
2620
2621
2622
2623
2624
2625
2626
# File 'ext/numo/narray/types/dfloat.c', line 2618

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

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

#stddev(axis: nil, keepdims: false, nan: false) ⇒ Numo::DFloat

stddev of self.

Parameters:

  • nan (TrueClass)

    If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).

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



4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
# File 'ext/numo/narray/types/dfloat.c', line 4115

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

  
    reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_dfloat_stddev_nan);
  
#line 42 "gen/tmpl/accum.c"
    v =  na_ndloop(&ndf, 2, self, reduce);
  
#line 46 "gen/tmpl/accum.c"
    return rb_funcall(v,rb_intern("extract"),0);
  
}

#store(other) ⇒ Numo::DFloat

Store elements to Numo::DFloat from other.

Parameters:

  • other (Object)

Returns:



1006
1007
1008
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
# File 'ext/numo/narray/types/dfloat.c', line 1006

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

    klass = CLASS_OF(obj);

    
    if (klass==numo_cDFloat) {
        dfloat_store_dfloat(self,obj);
        return self;
    }
    
#line 19 "gen/tmpl/store.c"
    if (IS_INTEGER_CLASS(klass) || klass==rb_cFloat || klass==rb_cComplex) {
        dfloat_store_numeric(self,obj);
        return self;
    }
    
#line 19 "gen/tmpl/store.c"
    if (klass==numo_cBit) {
        dfloat_store_bit(self,obj);
        return self;
    }
    
#line 19 "gen/tmpl/store.c"
    if (klass==numo_cSFloat) {
        dfloat_store_sfloat(self,obj);
        return self;
    }
    
#line 19 "gen/tmpl/store.c"
    if (klass==numo_cInt64) {
        dfloat_store_int64(self,obj);
        return self;
    }
    
#line 19 "gen/tmpl/store.c"
    if (klass==numo_cInt32) {
        dfloat_store_int32(self,obj);
        return self;
    }
    
#line 19 "gen/tmpl/store.c"
    if (klass==numo_cInt16) {
        dfloat_store_int16(self,obj);
        return self;
    }
    
#line 19 "gen/tmpl/store.c"
    if (klass==numo_cInt8) {
        dfloat_store_int8(self,obj);
        return self;
    }
    
#line 19 "gen/tmpl/store.c"
    if (klass==numo_cUInt64) {
        dfloat_store_uint64(self,obj);
        return self;
    }
    
#line 19 "gen/tmpl/store.c"
    if (klass==numo_cUInt32) {
        dfloat_store_uint32(self,obj);
        return self;
    }
    
#line 19 "gen/tmpl/store.c"
    if (klass==numo_cUInt16) {
        dfloat_store_uint16(self,obj);
        return self;
    }
    
#line 19 "gen/tmpl/store.c"
    if (klass==numo_cUInt8) {
        dfloat_store_uint8(self,obj);
        return self;
    }
    
#line 19 "gen/tmpl/store.c"
    if (klass==numo_cRObject) {
        dfloat_store_robject(self,obj);
        return self;
    }
    
#line 19 "gen/tmpl/store.c"
    if (klass==rb_cArray) {
        dfloat_store_array(self,obj);
        return self;
    }
    

    if (IsNArray(obj)) {
        r = rb_funcall(obj, rb_intern("coerce_cast"), 1, cT);
        if (CLASS_OF(r)==cT) {
            dfloat_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, nan: false) ⇒ Numo::DFloat

sum of self.

Parameters:

  • nan (TrueClass)

    If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).

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



3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
# File 'ext/numo/narray/types/dfloat.c', line 3879

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

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

#to_aArray

Convert self to Array.

Returns:

  • (Array)


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

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

#truncNumo::DFloat

Unary trunc.

Returns:



3037
3038
3039
3040
3041
3042
3043
3044
3045
# File 'ext/numo/narray/types/dfloat.c', line 3037

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

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

#var(axis: nil, keepdims: false, nan: false) ⇒ Numo::DFloat

var of self.

Parameters:

  • nan (TrueClass)

    If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).

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



4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
# File 'ext/numo/narray/types/dfloat.c', line 4174

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

  
    reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_dfloat_var_nan);
  
#line 42 "gen/tmpl/accum.c"
    v =  na_ndloop(&ndf, 2, self, reduce);
  
#line 46 "gen/tmpl/accum.c"
    return rb_funcall(v,rb_intern("extract"),0);
  
}