Class: Numo::DComplex

Inherits:
NArray
  • Object
show all
Defined in:
ext/numo/narray/types/dcomplex.c

Defined Under Namespace

Modules: Math

Constant Summary

UPCAST =
hCast

Constants inherited from NArray

NArray::VERSION

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from NArray

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

Constructor Details

This class inherits a constructor from Numo::NArray

Class Method Details

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

Cast object to Numo::DComplex.

Parameters:

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

Returns:



1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
# File 'ext/numo/narray/types/dcomplex.c', line 1189

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

    if (CLASS_OF(obj)==cT) {
        return obj;
    }
    if (RTEST(rb_obj_is_kind_of(obj,rb_cNumeric))) {
        x = m_num_to_data(obj);
        return numo_dcomplex_new_dim0(x);
    }
    if (RTEST(rb_obj_is_kind_of(obj,rb_cArray))) {
        return numo_dcomplex_cast_array(obj);
    }
    if (IsNArray(obj)) {
        GetNArray(obj,na);
        v = rb_narray_new(cT, NA_NDIM(na), NA_SHAPE(na));
        if (NA_SIZE(na) > 0) {
            numo_dcomplex_allocate(v);
            numo_dcomplex_store(v,obj);
        }
        return v;
    }
    
#line 38 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/cast.c"
    rb_raise(nary_eCastError,"cannot cast to %s",rb_class2name(type));
    return Qnil;
    
}

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

Cast object to Numo::DComplex.

Parameters:

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

Returns:



1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
# File 'ext/numo/narray/types/dcomplex.c', line 1189

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

    if (CLASS_OF(obj)==cT) {
        return obj;
    }
    if (RTEST(rb_obj_is_kind_of(obj,rb_cNumeric))) {
        x = m_num_to_data(obj);
        return numo_dcomplex_new_dim0(x);
    }
    if (RTEST(rb_obj_is_kind_of(obj,rb_cArray))) {
        return numo_dcomplex_cast_array(obj);
    }
    if (IsNArray(obj)) {
        GetNArray(obj,na);
        v = rb_narray_new(cT, NA_NDIM(na), NA_SHAPE(na));
        if (NA_SIZE(na) > 0) {
            numo_dcomplex_allocate(v);
            numo_dcomplex_store(v,obj);
        }
        return v;
    }
    
#line 38 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/cast.c"
    rb_raise(nary_eCastError,"cannot cast to %s",rb_class2name(type));
    return Qnil;
    
}

Instance Method Details

#*(other) ⇒ Numo::NArray

Binary mul.

Parameters:

Returns:



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

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



2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
# File 'ext/numo/narray/types/dcomplex.c', line 2204

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



1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
# File 'ext/numo/narray/types/dcomplex.c', line 1958

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



2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
# File 'ext/numo/narray/types/dcomplex.c', line 2013

static VALUE
numo_dcomplex_sub(VALUE self, VALUE other)
{
    
#line 48 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/binary.c"
    VALUE klass, v;
    klass = na_upcast(CLASS_OF(self),CLASS_OF(other));
    if (klass==cT) {
        return numo_dcomplex_sub_self(self, other);
    } else {
        v = rb_funcall(klass, id_cast, 1, self);
        return rb_funcall(v, '-', 1, other);
    }
    
}

#-@Numo::DComplex

Unary minus.

Returns:



2272
2273
2274
2275
2276
2277
2278
2279
2280
# File 'ext/numo/narray/types/dcomplex.c', line 2272

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

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

#/(other) ⇒ Numo::NArray

Binary div.

Parameters:

Returns:



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

static VALUE
numo_dcomplex_div(VALUE self, VALUE other)
{
    
#line 48 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/binary.c"
    VALUE klass, v;
    klass = na_upcast(CLASS_OF(self),CLASS_OF(other));
    if (klass==cT) {
        return numo_dcomplex_div_self(self, other);
    } else {
        v = rb_funcall(klass, id_cast, 1, self);
        return rb_funcall(v, '/', 1, other);
    }
    
}

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

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

    Element object or NArray view.



1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
# File 'ext/numo/narray/types/dcomplex.c', line 1263

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



1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
# File 'ext/numo/narray/types/dcomplex.c', line 1321

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

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

    }
    return argv[argc];
}

#absNumo::DFloat

abs of self.

Returns:



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

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

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

#allocateObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'ext/numo/narray/types/dcomplex.c', line 39

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

    GetNArray(self,na);

    switch(NA_TYPE(na)) {
    case NARRAY_DATA_T:
        ptr = NA_DATA_PTR(na);
        if (na->size > 0 && ptr == NULL) {
            ptr = xmalloc(sizeof(dtype) * na->size);
            
#line 22 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/allocate.c"
            NA_DATA_PTR(na) = ptr;
        }
        break;
    case NARRAY_VIEW_T:
        rb_funcall(NA_VIEW_DATA(na), rb_intern("allocate"), 0);
        break;
    case NARRAY_FILEMAP_T:
        //ptr = ((narray_filemap_t*)na)->ptr;
        // to be implemented
    default:
        rb_bug("invalid narray type : %d",NA_TYPE(na));
    }
    return self;
}

#argNumo::DFloat Also known as: angle

arg of self.

Returns:



2706
2707
2708
2709
2710
2711
2712
2713
2714
# File 'ext/numo/narray/types/dcomplex.c', line 2706

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

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

#ceilNumo::DComplex

Unary ceil.

Returns:



3186
3187
3188
3189
3190
3191
3192
3193
3194
# File 'ext/numo/narray/types/dcomplex.c', line 3186

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

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

#coerce_cast(type) ⇒ nil

Returns:

  • (nil)


1352
1353
1354
1355
1356
# File 'ext/numo/narray/types/dcomplex.c', line 1352

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

#conjNumo::DComplex Also known as: conjugate

Unary conj.

Returns:



2458
2459
2460
2461
2462
2463
2464
2465
2466
# File 'ext/numo/narray/types/dcomplex.c', line 2458

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

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

#copysign(other) ⇒ Numo::NArray

Binary copysign.

Parameters:

Returns:



3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
# File 'ext/numo/narray/types/dcomplex.c', line 3359

static VALUE
numo_dcomplex_copysign(VALUE self, VALUE other)
{
    
#line 48 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/binary.c"
    VALUE klass, v;
    klass = na_upcast(CLASS_OF(self),CLASS_OF(other));
    if (klass==cT) {
        return numo_dcomplex_copysign_self(self, other);
    } else {
        v = rb_funcall(klass, id_cast, 1, self);
        return rb_funcall(v, id_copysign, 1, other);
    }
    
}

#cumprod(*args) ⇒ Numo::DComplex

Cumprod of self.

Parameters:

  • args (Array of Numeric, Range)

    Affected dimensions.

Returns:



3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
# File 'ext/numo/narray/types/dcomplex.c', line 3867

static VALUE
numo_dcomplex_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_dcomplex_cumprod, STRIDE_LOOP_NIP|NDF_INPLACE|NDF_FLAT_REDUCE|NDF_CUM,
                     2, 1, ain, aout };

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

#cumsum(*args) ⇒ Numo::DComplex

Cumsum of self.

Parameters:

  • args (Array of Numeric, Range)

    Affected dimensions.

Returns:



3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
# File 'ext/numo/narray/types/dcomplex.c', line 3821

static VALUE
numo_dcomplex_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_dcomplex_cumsum, STRIDE_LOOP_NIP|NDF_INPLACE|NDF_FLAT_REDUCE|NDF_CUM,
                     2, 1, ain, aout };

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

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



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

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



1749
1750
1751
1752
1753
1754
1755
1756
1757
# File 'ext/numo/narray/types/dcomplex.c', line 1749

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



2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
# File 'ext/numo/narray/types/dcomplex.c', line 2878

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



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'ext/numo/narray/types/dcomplex.c', line 79

VALUE
numo_dcomplex_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::DComplex

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:



4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
# File 'ext/numo/narray/types/dcomplex.c', line 4181

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

Fill elements with other.

Parameters:

  • other (Numeric)

Returns:



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

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

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

#floorNumo::DComplex

Unary floor.

Returns:



3062
3063
3064
3065
3066
3067
3068
3069
3070
# File 'ext/numo/narray/types/dcomplex.c', line 3062

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



1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
# File 'ext/numo/narray/types/dcomplex.c', line 1496

static VALUE
numo_dcomplex_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_dcomplex_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.



1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
# File 'ext/numo/narray/types/dcomplex.c', line 1548

static VALUE
numo_dcomplex_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_dcomplex_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);
}

#imNumo::DComplex

Unary im.

Returns:



2520
2521
2522
2523
2524
2525
2526
2527
2528
# File 'ext/numo/narray/types/dcomplex.c', line 2520

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

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

#imagNumo::DFloat

imag of self.

Returns:



2644
2645
2646
2647
2648
2649
2650
2651
2652
# File 'ext/numo/narray/types/dcomplex.c', line 2644

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

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

#inspectString

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

Returns:

  • (String)


1576
1577
1578
1579
1580
# File 'ext/numo/narray/types/dcomplex.c', line 1576

VALUE
numo_dcomplex_inspect(VALUE ary)
{
    return na_ndloop_inspect(ary, iter_dcomplex_inspect, Qnil);
}

#isfiniteNumo::Bit

Condition of isfinite.

Returns:



3512
3513
3514
3515
3516
3517
3518
3519
3520
# File 'ext/numo/narray/types/dcomplex.c', line 3512

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

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

#isinfNumo::Bit

Condition of isinf.

Returns:



3463
3464
3465
3466
3467
3468
3469
3470
3471
# File 'ext/numo/narray/types/dcomplex.c', line 3463

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

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

#isnanNumo::Bit

Condition of isnan.

Returns:



3414
3415
3416
3417
3418
3419
3420
3421
3422
# File 'ext/numo/narray/types/dcomplex.c', line 3414

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

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

#kahan_sum(*args) ⇒ Numo::DComplex

Kahan_sum of self.

Parameters:

  • args (Array of Numeric, Range)

    Affected dimensions.

Returns:



3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
# File 'ext/numo/narray/types/dcomplex.c', line 3621

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

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

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

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:



4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
# File 'ext/numo/narray/types/dcomplex.c', line 4117

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

#mapNumo::DComplex

Unary map.

Returns:



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

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



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

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

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

#mean(*args) ⇒ Numo::DComplex

Mean of self.

Parameters:

  • args (Array of Numeric, Range)

    Affected dimensions.

Returns:



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

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

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

#mulsum(other) ⇒ Numo::NArray

Binary mulsum.

Parameters:

Returns:



3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
# File 'ext/numo/narray/types/dcomplex.c', line 3943

static VALUE
numo_dcomplex_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 73 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/accum_binary.c"
    klass = na_upcast(CLASS_OF(self),CLASS_OF(argv[0]));
    if (klass==cT) {
        return numo_dcomplex_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:



2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
# File 'ext/numo/narray/types/dcomplex.c', line 2936

static VALUE
numo_dcomplex_ne(VALUE self, VALUE other)
{
    
#line 46 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/cond_binary.c"
    VALUE klass, v;
    klass = na_upcast(CLASS_OF(self),CLASS_OF(other));
    if (klass==cT) {
        return numo_dcomplex_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.



2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
# File 'ext/numo/narray/types/dcomplex.c', line 2994

static VALUE
numo_dcomplex_nearly_eq(VALUE self, VALUE other)
{
    
#line 46 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/cond_binary.c"
    VALUE klass, v;
    klass = na_upcast(CLASS_OF(self),CLASS_OF(other));
    if (klass==cT) {
        return numo_dcomplex_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::DComplex

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

Parameters:

Returns:



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

static VALUE
numo_dcomplex_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_dcomplex_poly, NO_LOOP, 0, 1, 0, aout };

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

#prod(*args) ⇒ Numo::DComplex

Prod of self.

Parameters:

  • args (Array of Numeric, Range)

    Affected dimensions.

Returns:



3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
# File 'ext/numo/narray/types/dcomplex.c', line 3583

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

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

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

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:



4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
# File 'ext/numo/narray/types/dcomplex.c', line 4295

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

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

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

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:



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

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

#realNumo::DFloat

real of self.

Returns:



2582
2583
2584
2585
2586
2587
2588
2589
2590
# File 'ext/numo/narray/types/dcomplex.c', line 2582

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

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

#reciprocalNumo::DComplex

Unary reciprocal.

Returns:



2334
2335
2336
2337
2338
2339
2340
2341
2342
# File 'ext/numo/narray/types/dcomplex.c', line 2334

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

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

#rintNumo::DComplex

Unary rint.

Returns:



3310
3311
3312
3313
3314
3315
3316
3317
3318
# File 'ext/numo/narray/types/dcomplex.c', line 3310

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

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

#rms(*args) ⇒ Numo::DComplex

Rms of self.

Parameters:

  • args (Array of Numeric, Range)

    Affected dimensions.

Returns:



3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
# File 'ext/numo/narray/types/dcomplex.c', line 3773

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

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

#roundNumo::DComplex

Unary round.

Returns:



3124
3125
3126
3127
3128
3129
3130
3131
3132
# File 'ext/numo/narray/types/dcomplex.c', line 3124

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

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

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



4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
# File 'ext/numo/narray/types/dcomplex.c', line 4030

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

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

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

#set_imag(a1) ⇒ Object Also known as: imag=



2766
2767
2768
2769
2770
2771
2772
2773
2774
# File 'ext/numo/narray/types/dcomplex.c', line 2766

static VALUE
numo_dcomplex_set_imag(VALUE self, VALUE a1)
{
    ndfunc_arg_in_t ain[2] = {{OVERWRITE,0},{cRT,0}};
    ndfunc_t ndf = { iter_dcomplex_set_imag, FULL_LOOP, 2, 0, ain, 0 };

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

#set_real(a1) ⇒ Object Also known as: real=



2826
2827
2828
2829
2830
2831
2832
2833
2834
# File 'ext/numo/narray/types/dcomplex.c', line 2826

static VALUE
numo_dcomplex_set_real(VALUE self, VALUE a1)
{
    ndfunc_arg_in_t ain[2] = {{OVERWRITE,0},{cRT,0}};
    ndfunc_t ndf = { iter_dcomplex_set_real, FULL_LOOP, 2, 0, ain, 0 };

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

#signNumo::DComplex

Unary sign.

Returns:



2396
2397
2398
2399
2400
2401
2402
2403
2404
# File 'ext/numo/narray/types/dcomplex.c', line 2396

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

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

#stddev(*args) ⇒ Numo::DComplex

Stddev of self.

Parameters:

  • args (Array of Numeric, Range)

    Affected dimensions.

Returns:



3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
# File 'ext/numo/narray/types/dcomplex.c', line 3697

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

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

#store(other) ⇒ Numo::DComplex

Store elements to Numo::DComplex from other.

Parameters:

  • other (Object)

Returns:



1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
# File 'ext/numo/narray/types/dcomplex.c', line 1059

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

    
    if (FIXNUM_P(obj) || TYPE(obj)==T_FLOAT || TYPE(obj)==T_BIGNUM || rb_obj_is_kind_of(obj,rb_cComplex)) {
        numo_dcomplex_store_numeric(self,obj);
        return self;
    }
    
#line 13 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/store.c"
    if (rb_obj_is_kind_of(obj,numo_cBit)) {
        numo_dcomplex_store_bit(self,obj);
        return self;
    }
    
#line 13 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/store.c"
    if (rb_obj_is_kind_of(obj,numo_cDComplex)) {
        numo_dcomplex_store_dcomplex(self,obj);
        return self;
    }
    
#line 13 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/store.c"
    if (rb_obj_is_kind_of(obj,numo_cSComplex)) {
        numo_dcomplex_store_scomplex(self,obj);
        return self;
    }
    
#line 13 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/store.c"
    if (rb_obj_is_kind_of(obj,numo_cDFloat)) {
        numo_dcomplex_store_dfloat(self,obj);
        return self;
    }
    
#line 13 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/store.c"
    if (rb_obj_is_kind_of(obj,numo_cSFloat)) {
        numo_dcomplex_store_sfloat(self,obj);
        return self;
    }
    
#line 13 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/store.c"
    if (rb_obj_is_kind_of(obj,numo_cInt64)) {
        numo_dcomplex_store_int64(self,obj);
        return self;
    }
    
#line 13 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/store.c"
    if (rb_obj_is_kind_of(obj,numo_cInt32)) {
        numo_dcomplex_store_int32(self,obj);
        return self;
    }
    
#line 13 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/store.c"
    if (rb_obj_is_kind_of(obj,numo_cInt16)) {
        numo_dcomplex_store_int16(self,obj);
        return self;
    }
    
#line 13 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/store.c"
    if (rb_obj_is_kind_of(obj,numo_cInt8)) {
        numo_dcomplex_store_int8(self,obj);
        return self;
    }
    
#line 13 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/store.c"
    if (rb_obj_is_kind_of(obj,numo_cUInt64)) {
        numo_dcomplex_store_uint64(self,obj);
        return self;
    }
    
#line 13 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/store.c"
    if (rb_obj_is_kind_of(obj,numo_cUInt32)) {
        numo_dcomplex_store_uint32(self,obj);
        return self;
    }
    
#line 13 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/store.c"
    if (rb_obj_is_kind_of(obj,numo_cUInt16)) {
        numo_dcomplex_store_uint16(self,obj);
        return self;
    }
    
#line 13 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/store.c"
    if (rb_obj_is_kind_of(obj,numo_cUInt8)) {
        numo_dcomplex_store_uint8(self,obj);
        return self;
    }
    
#line 13 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/store.c"
    if (rb_obj_is_kind_of(obj,numo_cRObject)) {
        numo_dcomplex_store_robject(self,obj);
        return self;
    }
    
#line 13 "/home/masa/numo/narray/ext/numo/narray/gen/tmpl/store.c"
    if (TYPE(obj)==T_ARRAY) {
        numo_dcomplex_store_array(self,obj);
        return self;
    }
    

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

    
#line 30 "/home/masa/numo/narray/ext/numo/narray/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(*args) ⇒ Numo::DComplex

Sum of self.

Parameters:

  • args (Array of Numeric, Range)

    Affected dimensions.

Returns:



3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
# File 'ext/numo/narray/types/dcomplex.c', line 3545

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

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

#to_aArray

Convert self to Array.

Returns:

  • (Array)


1394
1395
1396
1397
1398
1399
1400
1401
# File 'ext/numo/narray/types/dcomplex.c', line 1394

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

#truncNumo::DComplex

Unary trunc.

Returns:



3248
3249
3250
3251
3252
3253
3254
3255
3256
# File 'ext/numo/narray/types/dcomplex.c', line 3248

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

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

#var(*args) ⇒ Numo::DComplex

Var of self.

Parameters:

  • args (Array of Numeric, Range)

    Affected dimensions.

Returns:



3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
# File 'ext/numo/narray/types/dcomplex.c', line 3735

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

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