Class: Numo::DFloat
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))
- EPSILON =
M_EPSILON
- MAX =
M_MAX
- MIN =
M_MIN
Constants inherited from NArray
Class Method Summary collapse
-
.[](obj) ⇒ Numo::DFloat
Cast object to Numo::DFloat.
-
.cast(obj) ⇒ Numo::DFloat
Cast object to Numo::DFloat.
-
.maximum(*args) ⇒ Object
-
.minimum(*args) ⇒ Object
Instance Method Summary collapse
-
#%(other) ⇒ Numo::NArray
Binary mod.
-
#*(other) ⇒ Numo::NArray
Binary mul.
-
#**(other) ⇒ Numo::NArray
Binary power.
-
#+(other) ⇒ Numo::NArray
Binary add.
-
#-(other) ⇒ Numo::NArray
Binary sub.
-
#-@ ⇒ Numo::DFloat
Unary minus.
-
#/(other) ⇒ Numo::NArray
Binary div.
-
#[](dim0, ..., dimL) ⇒ Numeric, NArray::DFloat
Array element referenece or slice view.
-
#[]=(dim0, .., dimL, val) ⇒ Numeric
Array element(s) set.
-
#abs ⇒ Numo::DFloat
abs of self.
-
#allocate ⇒ Object
-
#ceil ⇒ Numo::DFloat
Unary ceil.
-
#clip(min, max) ⇒ Numo::NArray
Clip array elements by [min,max].
-
#coerce_cast(type) ⇒ nil
return NArray with cast to the type of self.
-
#copysign(other) ⇒ Numo::NArray
Binary copysign.
-
#cumprod(axis: nil, nan: false) ⇒ Numo::DFloat
cumprod of self.
-
#cumsum(axis: nil, nan: false) ⇒ Numo::DFloat
cumsum of self.
-
#divmod(other) ⇒ Numo::NArray
Binary divmod.
-
#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::DFloat
Eye: Set a value to diagonal components, set 0 to non-diagonal components.
-
#fill(other) ⇒ Numo::DFloat
Fill elements with other.
-
#floor ⇒ Numo::DFloat
Unary floor.
-
#format(format) ⇒ Numo::RObject
Format elements into strings.
-
#format_to_a(format) ⇒ Array
Format elements into strings.
-
#ge(other) ⇒ Numo::Bit
(also: #>=)
Comparison ge other.
-
#gt(other) ⇒ Numo::Bit
(also: #>)
Comparison gt other.
-
#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::DFloat
kahan_sum of self.
-
#le(other) ⇒ Numo::Bit
(also: #<=)
Comparison le other.
-
#logseq(beg, step, [base]) ⇒ Numo::DFloat
Set logarithmic sequence of numbers to self.
-
#lt(other) ⇒ Numo::Bit
(also: #<)
Comparison lt other.
-
#map ⇒ Numo::DFloat
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.
-
#max(axis: nil, keepdims: false, nan: false) ⇒ Numo::DFloat
max of self.
-
#max_index(axis: nil, nan: false) ⇒ Integer, Numo::Int
max_index.
-
#mean(axis: nil, keepdims: false, nan: false) ⇒ Numo::DFloat
mean of self.
-
#median(axis: nil, keepdims: false, nan: false) ⇒ Numo::DFloat
median of self.
-
#min(axis: nil, keepdims: false, nan: false) ⇒ Numo::DFloat
min of self.
-
#min_index(axis: nil, nan: false) ⇒ Integer, Numo::Int
min_index.
-
#minmax(axis: nil, keepdims: false, nan: false) ⇒ Numo::DFloat
minmax of self.
-
#modf ⇒ Numo::DFloat
modf 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, ...) ⇒ Numo::DFloat
Polynomial.: a0 + a1x + a2x2 + a3*x3 + …
-
#prod(axis: nil, keepdims: false, nan: false) ⇒ Numo::DFloat
prod of self.
-
#ptp(axis: nil, keepdims: false, nan: false) ⇒ Numo::DFloat
ptp of self.
-
#rand([[low],high]) ⇒ Numo::DFloat
Generate uniformly distributed random numbers on self narray.
-
#rand_norm([mu,[sigma]]) ⇒ Numo::DFloat
Generates random numbers from the normal distribution on self narray using Box-Muller Transformation.
-
#reciprocal ⇒ Numo::DFloat
Unary reciprocal.
-
#rint ⇒ Numo::DFloat
Unary rint.
-
#rms(axis: nil, keepdims: false, nan: false) ⇒ Numo::DFloat
rms of self.
-
#round ⇒ Numo::DFloat
Unary round.
-
#seq([beg,[step]]) ⇒ Numo::DFloat
(also: #indgen)
Set linear sequence of numbers to self.
-
#sign ⇒ Numo::DFloat
Unary sign.
-
#signbit ⇒ Numo::Bit
Condition of signbit.
-
#sort(axis: nil, nan: false) ⇒ Numo::DFloat
sort of self.
-
#sort_index(axis: nil, nan: false) ⇒ Integer, Numo::Int
sort_index.
-
#square ⇒ Numo::DFloat
Unary square.
-
#stddev(axis: nil, keepdims: false, nan: false) ⇒ Numo::DFloat
stddev of self.
-
#store(other) ⇒ Numo::DFloat
Store elements to Numo::DFloat from other.
-
#sum(axis: nil, keepdims: false, nan: false) ⇒ Numo::DFloat
sum of self.
-
#to_a ⇒ Array
Convert self to Array.
-
#trunc ⇒ Numo::DFloat
Unary trunc.
-
#var(axis: nil, keepdims: false, nan: false) ⇒ Numo::DFloat
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, #empty?, #expand_dims, eye, #flatten, #fliplr, #flipud, from_binary, #host_order?, #hsplit, hstack, #initialize, #initialize_copy, #inner, #inplace, #inplace!, #inplace?, #insert, inspect_cols, inspect_cols=, inspect_rows, inspect_rows=, #kron, linspace, logspace, #marshal_dump, #marshal_load, #ndim, #new_fill, new_like, #new_narray, #new_ones, #new_zeros, ones, #out_of_place!, #outer, parse, profile, profile=, #rad2deg, #repeat, #reshape, #reshape!, #reverse, #rot90, #row_major?, #shape, #size, #split, srand, #store_binary, #swap_byte, #swapaxes, #tile, #to_binary, #to_c, #to_f, #to_host, #to_i, #to_network, #to_swapped, #to_vacs, #trace, #transpose, #tril, #tril!, #tril_indices, tril_indices, #triu, #triu!, #triu_indices, triu_indices, upcast, #view, #vsplit, vstack, zeros
Constructor Details
This class inherits a constructor from Numo::NArray
Class Method Details
.[](elements) ⇒ Numo::DFloat .cast(array) ⇒ Numo::DFloat
Cast object to Numo::DFloat.
1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 |
# File 'ext/numo/narray/types/dfloat.c', line 1262
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.
1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 |
# File 'ext/numo/narray/types/dfloat.c', line 1262
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;
}
|
.maximum(*args) ⇒ Object
5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 |
# File 'ext/numo/narray/types/dfloat.c', line 5272
static VALUE
dfloat_s_maximum(int argc, VALUE *argv, VALUE mod)
{
VALUE a1 = Qnil;
VALUE a2 = Qnil;
ndfunc_arg_in_t ain[2] = {{cT,0},{cT,0}};
ndfunc_arg_out_t aout[1] = {{cT,0}};
ndfunc_t ndf = { iter_dfloat_s_maximum, STRIDE_LOOP_NIP, 2, 1, ain, aout };
VALUE kw_hash = Qnil;
ID kw_table[1] = {id_nan};
VALUE opts[1] = {Qundef};
rb_scan_args(argc, argv, "20:", &a1, &a2, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 1, opts);
if (opts[0] != Qundef) {
ndf.func = iter_dfloat_s_maximum_nan;
}
#line 63 "gen/tmpl/ewcomp.c"
return na_ndloop(&ndf, 2, a1, a2);
}
|
.minimum(*args) ⇒ Object
5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 |
# File 'ext/numo/narray/types/dfloat.c', line 5355
static VALUE
dfloat_s_minimum(int argc, VALUE *argv, VALUE mod)
{
VALUE a1 = Qnil;
VALUE a2 = Qnil;
ndfunc_arg_in_t ain[2] = {{cT,0},{cT,0}};
ndfunc_arg_out_t aout[1] = {{cT,0}};
ndfunc_t ndf = { iter_dfloat_s_minimum, STRIDE_LOOP_NIP, 2, 1, ain, aout };
VALUE kw_hash = Qnil;
ID kw_table[1] = {id_nan};
VALUE opts[1] = {Qundef};
rb_scan_args(argc, argv, "20:", &a1, &a2, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 1, opts);
if (opts[0] != Qundef) {
ndf.func = iter_dfloat_s_minimum_nan;
}
#line 63 "gen/tmpl/ewcomp.c"
return na_ndloop(&ndf, 2, a1, a2);
}
|
Instance Method Details
#%(other) ⇒ Numo::NArray
Binary mod.
2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 |
# File 'ext/numo/narray/types/dfloat.c', line 2453
static VALUE
dfloat_mod(VALUE self, VALUE other)
{
#line 87 "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.
2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 |
# File 'ext/numo/narray/types/dfloat.c', line 2267
static VALUE
dfloat_mul(VALUE self, VALUE other)
{
#line 87 "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.
2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 |
# File 'ext/numo/narray/types/dfloat.c', line 2590
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.
2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 |
# File 'ext/numo/narray/types/dfloat.c', line 2081
static VALUE
dfloat_add(VALUE self, VALUE other)
{
#line 87 "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.
2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 |
# File 'ext/numo/narray/types/dfloat.c', line 2174
static VALUE
dfloat_sub(VALUE self, VALUE other)
{
#line 87 "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.
2680 2681 2682 2683 2684 2685 2686 2687 2688 |
# File 'ext/numo/narray/types/dfloat.c', line 2680
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.
2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 |
# File 'ext/numo/narray/types/dfloat.c', line 2360
static VALUE
dfloat_div(VALUE self, VALUE other)
{
#line 87 "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.
1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 |
# File 'ext/numo/narray/types/dfloat.c', line 1334
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.
1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 |
# File 'ext/numo/narray/types/dfloat.c', line 1391
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];
}
|
#abs ⇒ Numo::DFloat
abs of self.
1995 1996 1997 1998 1999 2000 2001 2002 2003 |
# File 'ext/numo/narray/types/dfloat.c', line 1995
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);
}
|
#allocate ⇒ Object
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'ext/numo/narray/types/dfloat.c', line 139
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;
}
|
#ceil ⇒ Numo::DFloat
Unary ceil.
3359 3360 3361 3362 3363 3364 3365 3366 3367 |
# File 'ext/numo/narray/types/dfloat.c', line 3359
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.
4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 |
# File 'ext/numo/narray/types/dfloat.c', line 4043
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.
1425 1426 1427 1428 1429 |
# File 'ext/numo/narray/types/dfloat.c', line 1425
static VALUE
dfloat_coerce_cast(VALUE self, VALUE type)
{
return Qnil;
}
|
#copysign(other) ⇒ Numo::NArray
Binary copysign.
3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 |
# File 'ext/numo/narray/types/dfloat.c', line 3613
static VALUE
dfloat_copysign(VALUE self, VALUE other)
{
#line 87 "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.
5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 |
# File 'ext/numo/narray/types/dfloat.c', line 5514
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.
5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 |
# File 'ext/numo/narray/types/dfloat.c', line 5439
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.
2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 |
# File 'ext/numo/narray/types/dfloat.c', line 2510
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);
}
}
|
#each ⇒ Numo::NArray
Calls the given block once for each element in self, passing that element as a parameter. For a block {|x| … }
1686 1687 1688 1689 1690 1691 1692 1693 1694 |
# File 'ext/numo/narray/types/dfloat.c', line 1686
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_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,…| … }
1837 1838 1839 1840 1841 1842 1843 1844 1845 |
# File 'ext/numo/narray/types/dfloat.c', line 1837
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.
2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 |
# File 'ext/numo/narray/types/dfloat.c', line 2986
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);
}
}
|
#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.
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'ext/numo/narray/types/dfloat.c', line 178
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.
5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 |
# File 'ext/numo/narray/types/dfloat.c', line 5876
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.
1506 1507 1508 1509 1510 1511 1512 1513 1514 |
# File 'ext/numo/narray/types/dfloat.c', line 1506
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;
}
|
#floor ⇒ Numo::DFloat
Unary floor.
3191 3192 3193 3194 3195 3196 3197 3198 3199 |
# File 'ext/numo/narray/types/dfloat.c', line 3191
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.
1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 |
# File 'ext/numo/narray/types/dfloat.c', line 1566
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.
1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 |
# File 'ext/numo/narray/types/dfloat.c', line 1617
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.
3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 |
# File 'ext/numo/narray/types/dfloat.c', line 3812
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.
3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 |
# File 'ext/numo/narray/types/dfloat.c', line 3755
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);
}
}
|
#inspect ⇒ String
Returns a string containing a human-readable representation of NArray.
1644 1645 1646 1647 1648 |
# File 'ext/numo/narray/types/dfloat.c', line 1644
VALUE
dfloat_inspect(VALUE ary)
{
return na_ndloop_inspect(ary, iter_dfloat_inspect, Qnil);
}
|
#isfinite ⇒ Numo::Bit
Condition of isfinite.
4297 4298 4299 4300 4301 4302 4303 4304 4305 |
# File 'ext/numo/narray/types/dfloat.c', line 4297
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);
}
|
#isinf ⇒ Numo::Bit
Condition of isinf.
4153 4154 4155 4156 4157 4158 4159 4160 4161 |
# File 'ext/numo/narray/types/dfloat.c', line 4153
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);
}
|
#isnan ⇒ Numo::Bit
Condition of isnan.
4105 4106 4107 4108 4109 4110 4111 4112 4113 |
# File 'ext/numo/narray/types/dfloat.c', line 4105
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);
}
|
#isneginf ⇒ Numo::Bit
Condition of isneginf.
4249 4250 4251 4252 4253 4254 4255 4256 4257 |
# File 'ext/numo/narray/types/dfloat.c', line 4249
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);
}
|
#isposinf ⇒ Numo::Bit
Condition of isposinf.
4201 4202 4203 4204 4205 4206 4207 4208 4209 |
# File 'ext/numo/narray/types/dfloat.c', line 4201
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.
4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 |
# File 'ext/numo/narray/types/dfloat.c', line 4465
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.
3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 |
# File 'ext/numo/narray/types/dfloat.c', line 3926
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+istep) where i is 1-dimensional index. Applicable classes: DFloat, SFloat, DComplex, SCopmplex.
5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 |
# File 'ext/numo/narray/types/dfloat.c', line 5813
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.
3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 |
# File 'ext/numo/narray/types/dfloat.c', line 3869
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);
}
}
|
#map ⇒ Numo::DFloat
Unary map.
1770 1771 1772 1773 1774 1775 1776 1777 1778 |
# File 'ext/numo/narray/types/dfloat.c', line 1770
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_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,… | … } |
1934 1935 1936 1937 1938 1939 1940 1941 1942 |
# File 'ext/numo/narray/types/dfloat.c', line 1934
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.
4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 |
# File 'ext/numo/narray/types/dfloat.c', line 4819
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.
4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 |
# File 'ext/numo/narray/types/dfloat.c', line 4990
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.
4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 |
# File 'ext/numo/narray/types/dfloat.c', line 4524
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.
7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 |
# File 'ext/numo/narray/types/dfloat.c', line 7160
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.
4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 |
# File 'ext/numo/narray/types/dfloat.c', line 4760
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.
5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 |
# File 'ext/numo/narray/types/dfloat.c', line 5118
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.
5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 |
# File 'ext/numo/narray/types/dfloat.c', line 5199
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);
}
|
#modf ⇒ Numo::DFloat
modf of self.
3704 3705 3706 3707 3708 3709 3710 3711 3712 |
# File 'ext/numo/narray/types/dfloat.c', line 3704
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.
5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 |
# File 'ext/numo/narray/types/dfloat.c', line 5641
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 92 "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.
3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 |
# File 'ext/numo/narray/types/dfloat.c', line 3043
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.
3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 |
# File 'ext/numo/narray/types/dfloat.c', line 3100
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 + a1x + a2x2 + a3x**3 + … + anxn
6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 |
# File 'ext/numo/narray/types/dfloat.c', line 6162
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.
4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 |
# File 'ext/numo/narray/types/dfloat.c', line 4406
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.
4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 |
# File 'ext/numo/narray/types/dfloat.c', line 4878
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.
5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 |
# File 'ext/numo/narray/types/dfloat.c', line 5990
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.
6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 |
# File 'ext/numo/narray/types/dfloat.c', line 6111
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;
}
|
#reciprocal ⇒ Numo::DFloat
Unary reciprocal.
2764 2765 2766 2767 2768 2769 2770 2771 2772 |
# File 'ext/numo/narray/types/dfloat.c', line 2764
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);
}
|
#rint ⇒ Numo::DFloat
Unary rint.
3527 3528 3529 3530 3531 3532 3533 3534 3535 |
# File 'ext/numo/narray/types/dfloat.c', line 3527
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.
4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 |
# File 'ext/numo/narray/types/dfloat.c', line 4701
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);
}
|
#round ⇒ Numo::DFloat
Unary round.
3275 3276 3277 3278 3279 3280 3281 3282 3283 |
# File 'ext/numo/narray/types/dfloat.c', line 3275
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.
5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 |
# File 'ext/numo/narray/types/dfloat.c', line 5727
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;
}
|
#sign ⇒ Numo::DFloat
Unary sign.
2848 2849 2850 2851 2852 2853 2854 2855 2856 |
# File 'ext/numo/narray/types/dfloat.c', line 2848
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);
}
|
#signbit ⇒ Numo::Bit
Condition of signbit.
3668 3669 3670 3671 3672 3673 3674 3675 3676 |
# File 'ext/numo/narray/types/dfloat.c', line 3668
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.
6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 |
# File 'ext/numo/narray/types/dfloat.c', line 6528
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.
7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 |
# File 'ext/numo/narray/types/dfloat.c', line 7040
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 87 "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 99 "gen/tmpl/sort_index.c"
}
rb_funcall(idx, rb_intern("seq"), 0);
size = na->size*sizeof(void*); // max capa
buf = rb_alloc_tmp_buffer(&tmp, size);
res = na_ndloop3(&ndf, buf, 3, self, idx, reduce);
rb_free_tmp_buffer(&tmp);
return res;
}
|
#square ⇒ Numo::DFloat
Unary square.
2932 2933 2934 2935 2936 2937 2938 2939 2940 |
# File 'ext/numo/narray/types/dfloat.c', line 2932
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.
4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 |
# File 'ext/numo/narray/types/dfloat.c', line 4583
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.
1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 |
# File 'ext/numo/narray/types/dfloat.c', line 1010
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.
4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 |
# File 'ext/numo/narray/types/dfloat.c', line 4347
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_a ⇒ Array
Convert self to Array.
1466 1467 1468 1469 1470 1471 1472 1473 |
# File 'ext/numo/narray/types/dfloat.c', line 1466
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);
}
|
#trunc ⇒ Numo::DFloat
Unary trunc.
3443 3444 3445 3446 3447 3448 3449 3450 3451 |
# File 'ext/numo/narray/types/dfloat.c', line 3443
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.
4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 |
# File 'ext/numo/narray/types/dfloat.c', line 4642
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);
}
|