Class: Numo::DComplex
Defined Under Namespace
Modules: Math
Constant Summary collapse
- UPCAST =
hCast
- ELEMENT_BIT_SIZE =
INT2FIX(sizeof(dtype) * 8)
- ELEMENT_BYTE_SIZE =
INT2FIX(sizeof(dtype))
- CONTIGUOUS_STRIDE =
INT2FIX(sizeof(dtype))
- EPSILON =
M_EPSILON
- MAX =
M_MAX
- MIN =
M_MIN
Constants inherited from NArray
Class Method Summary collapse
-
.[](obj) ⇒ Numo::DComplex
Cast object to Numo::DComplex.
-
.cast(obj) ⇒ Numo::DComplex
Cast object to Numo::DComplex.
Instance Method Summary collapse
-
#*(other) ⇒ Numo::NArray
Binary mul.
-
#**(other) ⇒ Numo::NArray
(also: #pow)
Binary power.
-
#+(other) ⇒ Numo::NArray
Binary add.
-
#-(other) ⇒ Numo::NArray
Binary sub.
-
#-@ ⇒ Numo::DComplex
Unary minus.
-
#/(other) ⇒ Numo::NArray
Binary div.
-
#[](dim0, ..., dimL) ⇒ Numeric, Numo::DComplex
Multi-dimensional element reference.
-
#[]=(dim0, ..., dimL, val) ⇒ Numeric, ...
Multi-dimensional element assignment.
-
#abs ⇒ Numo::DFloat
abs of self.
- #allocate ⇒ Object
-
#arg ⇒ Numo::DFloat
(also: #angle)
arg of self.
-
#ceil ⇒ Numo::DComplex
Unary ceil.
-
#coerce_cast(type) ⇒ nil
return NArray with cast to the type of self.
-
#conj ⇒ Numo::DComplex
(also: #conjugate)
Unary conj.
-
#copysign(other) ⇒ Numo::NArray
Binary copysign.
-
#cumprod(axis: nil, nan: false) ⇒ Numo::DComplex
cumprod of self.
-
#cumsum(axis: nil, nan: false) ⇒ Numo::DComplex
cumsum of self.
-
#each ⇒ Numo::NArray
Calls the given block once for each element in self, passing that element as a parameter.
-
#each_with_index ⇒ Numo::NArray
Invokes the given block once for each element of self, passing that element and indices along each axis as parameters.
-
#eq(other) ⇒ Numo::Bit
Comparison eq other.
-
#extract ⇒ Numeric, Numo::NArray
Extract an element only if self is a dimensionless NArray.
-
#eye([element,offset]) ⇒ Numo::DComplex
Eye: Set a value to diagonal components, set 0 to non-diagonal components.
-
#fill(other) ⇒ Numo::DComplex
Fill elements with other.
-
#floor ⇒ Numo::DComplex
Unary floor.
-
#format(format) ⇒ Numo::RObject
Format elements into strings.
-
#format_to_a(format) ⇒ Array
Format elements into strings.
-
#im ⇒ Numo::DComplex
Unary im.
-
#imag ⇒ Numo::DFloat
imag of self.
-
#inspect ⇒ String
Returns a string containing a human-readable representation of NArray.
-
#isfinite ⇒ Numo::Bit
Condition of isfinite.
-
#isinf ⇒ Numo::Bit
Condition of isinf.
-
#isnan ⇒ Numo::Bit
Condition of isnan.
-
#isneginf ⇒ Numo::Bit
Condition of isneginf.
-
#isposinf ⇒ Numo::Bit
Condition of isposinf.
-
#kahan_sum(axis: nil, keepdims: false, nan: false) ⇒ Numo::DComplex
kahan_sum of self.
- #logseq(, self) ⇒ Object
-
#map ⇒ Numo::DComplex
Unary map.
-
#map_with_index ⇒ Numo::NArray
Invokes the given block once for each element of self, passing that element and indices along each axis as parameters.
-
#mean(axis: nil, keepdims: false, nan: false) ⇒ Numo::DComplex
mean of self.
-
#mulsum(other, axis: nil, keepdims: false, nan: false) ⇒ Numo::NArray
Binary mulsum.
-
#ne(other) ⇒ Numo::Bit
Comparison ne other.
-
#nearly_eq(other) ⇒ Numo::Bit
(also: #close_to)
Comparison nearly_eq other.
-
#poly(a0, a1, ..., an) ⇒ Numo::DComplex
Calculate polynomial.
-
#prod(axis: nil, keepdims: false, nan: false) ⇒ Numo::DComplex
prod of self.
- #rand(, self) ⇒ Object
- #rand_norm(, self) ⇒ Object
-
#real ⇒ Numo::DFloat
real of self.
-
#reciprocal ⇒ Numo::DComplex
Unary reciprocal.
-
#rint ⇒ Numo::DComplex
Unary rint.
-
#rms(axis: nil, keepdims: false, nan: false) ⇒ Numo::DComplex
rms of self.
-
#round ⇒ Numo::DComplex
Unary round.
- #seq(, self) ⇒ Object (also: #indgen)
- #set_imag(a1) ⇒ Object (also: #imag=)
- #set_real(a1) ⇒ Object (also: #real=)
-
#sign ⇒ Numo::DComplex
Unary sign.
-
#square ⇒ Numo::DComplex
Unary square.
-
#stddev(axis: nil, keepdims: false, nan: false) ⇒ Numo::DComplex
stddev of self.
-
#store(other) ⇒ Numo::DComplex
Store elements to Numo::DComplex from other.
-
#sum(axis: nil, keepdims: false, nan: false) ⇒ Numo::DComplex
sum of self.
-
#to_a ⇒ Array
Convert self to Array.
-
#trunc ⇒ Numo::DComplex
Unary trunc.
-
#var(axis: nil, keepdims: false, nan: false) ⇒ Numo::DComplex
var of self.
Methods inherited from NArray
#==, #append, array_type, asarray, #at, #byte_size, byte_size, #byte_swapped?, #cast_to, #coerce, #column_major?, column_stack, concatenate, #concatenate, #contiguous?, #cov, debug=, #debug_info, #deg2rad, #delete, #diag, diag_indices, #diag_indices, #diagonal, #diff, #dot, #dsplit, dstack, #each_over_axis, #empty?, #expand_dims, eye, #flatten, #fliplr, #flipud, #fortran_contiguous?, #free, from_binary, #host_order?, #hsplit, hstack, #initialize, #initialize_copy, #inner, #inplace, #inplace!, #inplace?, #insert, inspect_cols, inspect_cols=, inspect_rows, inspect_rows=, #kron, linspace, logspace, #marshal_dump, #marshal_load, #ndim, #new_fill, new_like, #new_narray, #new_ones, #new_zeros, ones, #out_of_place!, #outer, parse, #percentile, profile, profile=, #rad2deg, #repeat, #reshape, #reshape!, #reverse, #rot90, #row_major?, #shape, #size, #split, #store_binary, #swap_byte, #swapaxes, #tile, #to_binary, #to_c, #to_f, #to_host, #to_i, #to_network, #to_swapped, #to_vacs, #trace, #transpose, #tril, #tril!, #tril_indices, tril_indices, #triu, #triu!, triu_indices, #triu_indices, upcast, #view, #vsplit, vstack, zeros
Constructor Details
This class inherits a constructor from Numo::NArray
Class Method Details
.[](elements) ⇒ Numo::DComplex .cast(array) ⇒ Numo::DComplex
Cast object to Numo::DComplex.
1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 1230
static VALUE dcomplex_s_cast(VALUE type, VALUE obj) {
VALUE v;
narray_t* na;
dtype x;
if (rb_obj_class(obj) == cT) {
return obj;
}
if (RTEST(rb_obj_is_kind_of(obj, rb_cNumeric))) {
x = m_num_to_data(obj);
return dcomplex_new_dim0(x);
}
if (RTEST(rb_obj_is_kind_of(obj, rb_cArray))) {
return dcomplex_cast_array(obj);
}
if (IsNArray(obj)) {
GetNArray(obj, na);
v = nary_new(cT, NA_NDIM(na), NA_SHAPE(na));
if (NA_SIZE(na) > 0) {
dcomplex_store(v, obj);
}
return v;
}
if (rb_respond_to(obj, id_to_a)) {
obj = rb_funcall(obj, id_to_a, 0);
if (TYPE(obj) != T_ARRAY) {
rb_raise(rb_eTypeError, "`to_a' did not return Array");
}
return dcomplex_cast_array(obj);
}
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.
1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 1230
static VALUE dcomplex_s_cast(VALUE type, VALUE obj) {
VALUE v;
narray_t* na;
dtype x;
if (rb_obj_class(obj) == cT) {
return obj;
}
if (RTEST(rb_obj_is_kind_of(obj, rb_cNumeric))) {
x = m_num_to_data(obj);
return dcomplex_new_dim0(x);
}
if (RTEST(rb_obj_is_kind_of(obj, rb_cArray))) {
return dcomplex_cast_array(obj);
}
if (IsNArray(obj)) {
GetNArray(obj, na);
v = nary_new(cT, NA_NDIM(na), NA_SHAPE(na));
if (NA_SIZE(na) > 0) {
dcomplex_store(v, obj);
}
return v;
}
if (rb_respond_to(obj, id_to_a)) {
obj = rb_funcall(obj, id_to_a, 0);
if (TYPE(obj) != T_ARRAY) {
rb_raise(rb_eTypeError, "`to_a' did not return Array");
}
return dcomplex_cast_array(obj);
}
rb_raise(nary_eCastError, "cannot cast to %s", rb_class2name(type));
return Qnil;
}
|
Instance Method Details
#*(other) ⇒ Numo::NArray
Binary mul.
2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 2181
static VALUE dcomplex_mul(VALUE self, VALUE other) {
VALUE klass, v;
klass = na_upcast(rb_obj_class(self), rb_obj_class(other));
if (klass == cT) {
return dcomplex_mul_self(self, other);
} else {
v = rb_funcall(klass, id_cast, 1, self);
return rb_funcall(v, '*', 1, other);
}
}
|
#**(other) ⇒ Numo::NArray Also known as: pow
Binary power.
2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 2366
static VALUE dcomplex_pow(VALUE self, VALUE other) {
VALUE klass, v;
klass = na_upcast(rb_obj_class(self), rb_obj_class(other));
if (klass == cT) {
return 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.
1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 1949
static VALUE dcomplex_add(VALUE self, VALUE other) {
VALUE klass, v;
klass = na_upcast(rb_obj_class(self), rb_obj_class(other));
if (klass == cT) {
return 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.
2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 2065
static VALUE dcomplex_sub(VALUE self, VALUE other) {
VALUE klass, v;
klass = na_upcast(rb_obj_class(self), rb_obj_class(other));
if (klass == cT) {
return dcomplex_sub_self(self, other);
} else {
v = rb_funcall(klass, id_cast, 1, self);
return rb_funcall(v, '-', 1, other);
}
}
|
#-@ ⇒ Numo::DComplex
Unary minus.
2445 2446 2447 2448 2449 2450 2451 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 2445
static VALUE 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.
2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 2297
static VALUE dcomplex_div(VALUE self, VALUE other) {
VALUE klass, v;
klass = na_upcast(rb_obj_class(self), rb_obj_class(other));
if (klass == cT) {
return dcomplex_div_self(self, other);
} else {
v = rb_funcall(klass, id_cast, 1, self);
return rb_funcall(v, '/', 1, other);
}
}
|
#[](dim0, ..., dimL) ⇒ Numeric, Numo::DComplex
Multi-dimensional element reference. indices.
1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 1274
static VALUE 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, ...
Multi-dimensional element assignment. indices.
1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 1298
static VALUE dcomplex_aset(int argc, VALUE* argv, VALUE self) {
int nd;
size_t pos;
char* ptr;
VALUE a;
dtype x;
argc--;
if (argc == 0) {
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);
dcomplex_store(a, argv[argc]);
} else {
x = dcomplex_extract_data(argv[argc]);
ptr = na_get_pointer_for_read_write(self) + pos;
*(dtype*)ptr = x;
}
}
return argv[argc];
}
|
#abs ⇒ Numo::DFloat
abs of self.
1838 1839 1840 1841 1842 1843 1844 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 1838
static VALUE 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);
}
|
#allocate ⇒ Object
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 119
static VALUE 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);
NA_DATA_PTR(na) = ptr;
NA_DATA_OWNED(na) = TRUE;
}
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;
}
|
#arg ⇒ Numo::DFloat Also known as: angle
arg of self.
2982 2983 2984 2985 2986 2987 2988 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 2982
static VALUE 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);
}
|
#ceil ⇒ Numo::DComplex
Unary ceil.
3454 3455 3456 3457 3458 3459 3460 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 3454
static VALUE 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
return NArray with cast to the type of self.
1327 1328 1329 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 1327
static VALUE dcomplex_coerce_cast(VALUE self, VALUE type) {
return Qnil;
}
|
#conj ⇒ Numo::DComplex Also known as: conjugate
Unary conj.
2745 2746 2747 2748 2749 2750 2751 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 2745
static VALUE 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.
3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 3715
static VALUE dcomplex_copysign(VALUE self, VALUE other) {
VALUE klass, v;
klass = na_upcast(rb_obj_class(self), rb_obj_class(other));
if (klass == cT) {
return dcomplex_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::DComplex
cumprod of self.
4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 4357
static VALUE 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 | NDF_FLAT_REDUCE | NDF_CUM, 2, 1, ain, aout};
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_dcomplex_cumprod_nan);
return na_ndloop(&ndf, 2, self, reduce);
}
|
#cumsum(axis: nil, nan: false) ⇒ Numo::DComplex
cumsum of self.
4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 4296
static VALUE 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 | NDF_FLAT_REDUCE | NDF_CUM, 2, 1, ain, aout};
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_dcomplex_cumsum_nan);
return na_ndloop(&ndf, 2, self, reduce);
}
|
#each ⇒ Numo::NArray
Calls the given block once for each element in self, passing that element as a parameter. For a block ‘{|x| … }`,
1554 1555 1556 1557 1558 1559 1560 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 1554
static VALUE 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_index ⇒ Numo::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,…| … }`,
1693 1694 1695 1696 1697 1698 1699 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 1693
static VALUE 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.
3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 3131
static VALUE dcomplex_eq(VALUE self, VALUE other) {
VALUE klass, v;
klass = na_upcast(rb_obj_class(self), rb_obj_class(other));
if (klass == cT) {
return dcomplex_eq_self(self, other);
} else {
v = rb_funcall(klass, id_cast, 1, self);
return rb_funcall(v, id_eq, 1, other);
}
}
|
#extract ⇒ Numeric, 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.
154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 154
static VALUE 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.
4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 4688
static VALUE 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.
1396 1397 1398 1399 1400 1401 1402 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 1396
static VALUE 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;
}
|
#floor ⇒ Numo::DComplex
Unary floor.
3304 3305 3306 3307 3308 3309 3310 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 3304
static VALUE 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.
1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 1450
static VALUE 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.
1497 1498 1499 1500 1501 1502 1503 1504 1505 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 1497
static VALUE dcomplex_format_to_a(int argc, VALUE* argv, VALUE self) {
VALUE fmt = Qnil;
ndfunc_arg_in_t ain[3] = {{Qnil, 0}, {sym_loop_opt}, {sym_option}};
ndfunc_arg_out_t aout[1] = {{rb_cArray, 0}}; // dummy?
ndfunc_t ndf = {iter_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);
}
|
#im ⇒ Numo::DComplex
Unary im.
2820 2821 2822 2823 2824 2825 2826 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 2820
static VALUE 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);
}
|
#imag ⇒ Numo::DFloat
imag of self.
2928 2929 2930 2931 2932 2933 2934 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 2928
static VALUE 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);
}
|
#inspect ⇒ String
Returns a string containing a human-readable representation of NArray.
1516 1517 1518 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 1516 static VALUE dcomplex_inspect(VALUE ary) { return na_ndloop_inspect(ary, iter_dcomplex_inspect, Qnil); } |
#isfinite ⇒ Numo::Bit
Condition of isfinite.
3930 3931 3932 3933 3934 3935 3936 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 3930
static VALUE 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);
}
|
#isinf ⇒ Numo::Bit
Condition of isinf.
3804 3805 3806 3807 3808 3809 3810 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 3804
static VALUE 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);
}
|
#isnan ⇒ Numo::Bit
Condition of isnan.
3762 3763 3764 3765 3766 3767 3768 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 3762
static VALUE 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);
}
|
#isneginf ⇒ Numo::Bit
Condition of isneginf.
3888 3889 3890 3891 3892 3893 3894 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 3888
static VALUE dcomplex_isneginf(VALUE self) {
ndfunc_arg_in_t ain[1] = {{cT, 0}};
ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
ndfunc_t ndf = {iter_dcomplex_isneginf, FULL_LOOP, 1, 1, ain, aout};
return na_ndloop(&ndf, 1, self);
}
|
#isposinf ⇒ Numo::Bit
Condition of isposinf.
3846 3847 3848 3849 3850 3851 3852 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 3846
static VALUE dcomplex_isposinf(VALUE self) {
ndfunc_arg_in_t ain[1] = {{cT, 0}};
ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
ndfunc_t ndf = {iter_dcomplex_isposinf, FULL_LOOP, 1, 1, ain, aout};
return na_ndloop(&ndf, 1, self);
}
|
#kahan_sum(axis: nil, keepdims: false, nan: false) ⇒ Numo::DComplex
kahan_sum of self.
4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 4057
static VALUE 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, &ndf, iter_dcomplex_kahan_sum_nan);
v = na_ndloop(&ndf, 2, self, reduce);
return dcomplex_extract(v);
}
|
#logseq(, self) ⇒ Object
4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 4631
static VALUE 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;
}
|
#map ⇒ Numo::DComplex
Unary map.
1629 1630 1631 1632 1633 1634 1635 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 1629
static VALUE 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_index ⇒ Numo::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,…| … }`,
1784 1785 1786 1787 1788 1789 1790 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 1784
static VALUE 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(axis: nil, keepdims: false, nan: false) ⇒ Numo::DComplex
mean of self.
4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 4101
static VALUE 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, &ndf, iter_dcomplex_mean_nan);
v = na_ndloop(&ndf, 2, self, reduce);
return dcomplex_extract(v);
}
|
#mulsum(other, axis: nil, keepdims: false, nan: false) ⇒ Numo::NArray
Binary mulsum.
4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 4469
static VALUE 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);
}
//
klass = na_upcast(rb_obj_class(self), rb_obj_class(argv[0]));
if (klass == cT) {
return dcomplex_mulsum_self(argc, argv, self);
} else {
v = rb_funcall(klass, id_cast, 1, self);
//
return rb_funcallv_kw(v, rb_intern("mulsum"), argc, argv, RB_PASS_CALLED_KEYWORDS);
//
}
//
}
|
#ne(other) ⇒ Numo::Bit
Comparison ne other.
3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 3178
static VALUE dcomplex_ne(VALUE self, VALUE other) {
VALUE klass, v;
klass = na_upcast(rb_obj_class(self), rb_obj_class(other));
if (klass == cT) {
return 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.
3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 3225
static VALUE dcomplex_nearly_eq(VALUE self, VALUE other) {
VALUE klass, v;
klass = na_upcast(rb_obj_class(self), rb_obj_class(other));
if (klass == cT) {
return 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, ..., an) ⇒ Numo::DComplex
Calculate polynomial.
`x.poly(a0,a1,a2,...,an) = a0 + a1*x + a2*x**2 + ... + an*x**n`
4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 4939
static VALUE 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 = (int)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 dcomplex_extract(v);
}
|
#prod(axis: nil, keepdims: false, nan: false) ⇒ Numo::DComplex
prod of self.
4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 4013
static VALUE 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, &ndf, iter_dcomplex_prod_nan);
v = na_ndloop(&ndf, 2, self, reduce);
return dcomplex_extract(v);
}
|
#rand(, self) ⇒ Object
4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 4795
static VALUE 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};
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);
} 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);
}
na_ndloop3(&ndf, &g, 1, self);
return self;
}
|
#rand_norm(, self) ⇒ Object
4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 4894
static VALUE 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;
}
|
#real ⇒ Numo::DFloat
real of self.
2874 2875 2876 2877 2878 2879 2880 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 2874
static VALUE 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);
}
|
#reciprocal ⇒ Numo::DComplex
Unary reciprocal.
2520 2521 2522 2523 2524 2525 2526 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 2520
static VALUE 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);
}
|
#rint ⇒ Numo::DComplex
Unary rint.
3604 3605 3606 3607 3608 3609 3610 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 3604
static VALUE 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(axis: nil, keepdims: false, nan: false) ⇒ Numo::DComplex
rms of self.
4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 4233
static VALUE 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, &ndf, iter_dcomplex_rms_nan);
v = na_ndloop(&ndf, 2, self, reduce);
return rb_funcall(v, rb_intern("extract"), 0);
}
|
#round ⇒ Numo::DComplex
Unary round.
3379 3380 3381 3382 3383 3384 3385 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 3379
static VALUE 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(, self) ⇒ Object Also known as: indgen
4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 4548
static VALUE 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);
if (vbeg != Qnil) {
g->beg = m_num_to_data(vbeg);
}
if (vstep != Qnil) {
g->step = m_num_to_data(vstep);
}
na_ndloop3(&ndf, g, 1, self);
return self;
}
|
#set_imag(a1) ⇒ Object Also known as: imag=
3035 3036 3037 3038 3039 3040 3041 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 3035
static VALUE 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=
3088 3089 3090 3091 3092 3093 3094 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 3088
static VALUE 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;
}
|
#sign ⇒ Numo::DComplex
Unary sign.
2595 2596 2597 2598 2599 2600 2601 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 2595
static VALUE 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);
}
|
#square ⇒ Numo::DComplex
Unary square.
2670 2671 2672 2673 2674 2675 2676 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 2670
static VALUE dcomplex_square(VALUE self) {
ndfunc_arg_in_t ain[1] = {{cT, 0}};
ndfunc_arg_out_t aout[1] = {{cT, 0}};
ndfunc_t ndf = {iter_dcomplex_square, FULL_LOOP, 1, 1, ain, aout};
return na_ndloop(&ndf, 1, self);
}
|
#stddev(axis: nil, keepdims: false, nan: false) ⇒ Numo::DComplex
stddev of self.
4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 4145
static VALUE 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, &ndf, iter_dcomplex_stddev_nan);
v = na_ndloop(&ndf, 2, self, reduce);
return rb_funcall(v, rb_intern("extract"), 0);
}
|
#store(other) ⇒ Numo::DComplex
Store elements to Numo::DComplex from other.
995 996 997 998 999 1000 1001 1002 1003 1004 1005 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 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 995
static VALUE dcomplex_store(VALUE self, VALUE obj) {
VALUE r, klass;
klass = rb_obj_class(obj);
if (klass == numo_cDComplex) {
dcomplex_store_dcomplex(self, obj);
return self;
}
if (IS_INTEGER_CLASS(klass) || klass == rb_cFloat || klass == rb_cComplex) {
dcomplex_store_numeric(self, obj);
return self;
}
if (klass == numo_cBit) {
dcomplex_store_bit(self, obj);
return self;
}
if (klass == numo_cSComplex) {
dcomplex_store_scomplex(self, obj);
return self;
}
if (klass == numo_cDFloat) {
dcomplex_store_dfloat(self, obj);
return self;
}
if (klass == numo_cSFloat) {
dcomplex_store_sfloat(self, obj);
return self;
}
if (klass == numo_cInt64) {
dcomplex_store_int64(self, obj);
return self;
}
if (klass == numo_cInt32) {
dcomplex_store_int32(self, obj);
return self;
}
if (klass == numo_cInt16) {
dcomplex_store_int16(self, obj);
return self;
}
if (klass == numo_cInt8) {
dcomplex_store_int8(self, obj);
return self;
}
if (klass == numo_cUInt64) {
dcomplex_store_uint64(self, obj);
return self;
}
if (klass == numo_cUInt32) {
dcomplex_store_uint32(self, obj);
return self;
}
if (klass == numo_cUInt16) {
dcomplex_store_uint16(self, obj);
return self;
}
if (klass == numo_cUInt8) {
dcomplex_store_uint8(self, obj);
return self;
}
if (klass == numo_cRObject) {
dcomplex_store_robject(self, obj);
return self;
}
if (klass == rb_cArray) {
dcomplex_store_array(self, obj);
return self;
}
if (IsNArray(obj)) {
r = rb_funcall(obj, rb_intern("coerce_cast"), 1, cT);
if (rb_obj_class(r) == cT) {
dcomplex_store(self, r);
return self;
}
}
rb_raise(nary_eCastError, "unknown conversion from %s to %s", rb_class2name(rb_obj_class(obj)),
rb_class2name(rb_obj_class(self)));
return self;
}
|
#sum(axis: nil, keepdims: false, nan: false) ⇒ Numo::DComplex
sum of self.
3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 3969
static VALUE 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, &ndf, iter_dcomplex_sum_nan);
v = na_ndloop(&ndf, 2, self, reduce);
return dcomplex_extract(v);
}
|
#to_a ⇒ Array
Convert self to Array.
1362 1363 1364 1365 1366 1367 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 1362
static VALUE 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);
}
|
#trunc ⇒ Numo::DComplex
Unary trunc.
3529 3530 3531 3532 3533 3534 3535 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 3529
static VALUE 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(axis: nil, keepdims: false, nan: false) ⇒ Numo::DComplex
var of self.
4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 |
# File 'ext/numo/narray/src/t_dcomplex.c', line 4189
static VALUE 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, &ndf, iter_dcomplex_var_nan);
v = na_ndloop(&ndf, 2, self, reduce);
return rb_funcall(v, rb_intern("extract"), 0);
}
|