Class: Numo::RObject
Constant Summary collapse
- UPCAST =
hCast
- ELEMENT_BIT_SIZE =
INT2FIX(sizeof(dtype)*8)
- ELEMENT_BYTE_SIZE =
INT2FIX(sizeof(dtype))
- CONTIGUOUS_STRIDE =
INT2FIX(sizeof(dtype))
Constants inherited from NArray
Class Method Summary collapse
-
.[](obj) ⇒ Numo::RObject
Cast object to Numo::RObject.
-
.cast(obj) ⇒ Numo::RObject
Cast object to Numo::RObject.
-
.maximum(*args) ⇒ Object
-
.minimum(*args) ⇒ Object
Instance Method Summary collapse
-
#%(other) ⇒ Numo::NArray
Binary mod.
-
#&(other) ⇒ Numo::NArray
Binary bit_and.
-
#*(other) ⇒ Numo::NArray
Binary mul.
-
#**(other) ⇒ Numo::NArray
Binary power.
-
#+(other) ⇒ Numo::NArray
Binary add.
-
#-(other) ⇒ Numo::NArray
Binary sub.
-
#-@ ⇒ Numo::RObject
Unary minus.
-
#/(other) ⇒ Numo::NArray
Binary div.
-
#<<(other) ⇒ Numo::NArray
Binary left_shift.
-
#>>(other) ⇒ Numo::NArray
Binary right_shift.
-
#[](dim0, ..., dimL) ⇒ Numeric, Numo::RObject
Multi-dimensional element reference.
-
#[]=(dim0, ..., dimL, val) ⇒ Numeric, ...
Multi-dimensional element assignment.
-
#^(other) ⇒ Numo::NArray
Binary bit_xor.
-
#abs ⇒ Numo::RObject
abs of self.
-
#allocate ⇒ Object
-
#argmax(axis: nil, nan: false) ⇒ Integer, Numo::Int
Index of the maximum value.
-
#argmin(axis: nil, nan: false) ⇒ Integer, Numo::Int
Index of the minimum value.
-
#ceil ⇒ Numo::RObject
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.
-
#cumprod(axis: nil, nan: false) ⇒ Numo::RObject
cumprod of self.
-
#cumsum(axis: nil, nan: false) ⇒ Numo::RObject
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::RObject
Eye: Set a value to diagonal components, set 0 to non-diagonal components.
-
#fill(other) ⇒ Numo::RObject
Fill elements with other.
-
#floor ⇒ Numo::RObject
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.
-
#le(other) ⇒ Numo::Bit
(also: #<=)
Comparison le other.
-
#logseq(beg, step, [base]) ⇒ Numo::RObject
Set logarithmic sequence of numbers to self.
-
#lt(other) ⇒ Numo::Bit
(also: #<)
Comparison lt other.
-
#map ⇒ Numo::RObject
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::RObject
max of self.
-
#max_index(axis: nil, nan: false) ⇒ Integer, Numo::Int
Index of the maximum value.
-
#mean(axis: nil, keepdims: false, nan: false) ⇒ Numo::RObject
mean of self.
-
#min(axis: nil, keepdims: false, nan: false) ⇒ Numo::RObject
min of self.
-
#min_index(axis: nil, nan: false) ⇒ Integer, Numo::Int
Index of the minimum value.
-
#minmax(axis: nil, keepdims: false, nan: false) ⇒ Numo::RObject
minmax 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::RObject
Calculate polynomial.
-
#prod(axis: nil, keepdims: false, nan: false) ⇒ Numo::RObject
prod of self.
-
#ptp(axis: nil, keepdims: false, nan: false) ⇒ Numo::RObject
ptp of self.
-
#rand([[low],high]) ⇒ Numo::RObject
Generate uniformly distributed random numbers on self narray.
-
#reciprocal ⇒ Numo::RObject
Unary reciprocal.
-
#rms(axis: nil, keepdims: false, nan: false) ⇒ Numo::RObject
rms of self.
-
#round ⇒ Numo::RObject
Unary round.
-
#seq([beg,[step]]) ⇒ Numo::RObject
(also: #indgen)
Set linear sequence of numbers to self.
-
#sign ⇒ Numo::RObject
Unary sign.
-
#square ⇒ Numo::RObject
Unary square.
-
#stddev(axis: nil, keepdims: false, nan: false) ⇒ Numo::RObject
stddev of self.
-
#store(other) ⇒ Numo::RObject
Store elements to Numo::RObject from other.
-
#sum(axis: nil, keepdims: false, nan: false) ⇒ Numo::RObject
sum of self.
-
#to_a ⇒ Array
Convert self to Array.
-
#trunc ⇒ Numo::RObject
Unary trunc.
-
#var(axis: nil, keepdims: false, nan: false) ⇒ Numo::RObject
var of self.
-
#|(other) ⇒ Numo::NArray
Binary bit_or.
-
#~ ⇒ Numo::RObject
Unary bit_not.
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, 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::RObject .cast(array) ⇒ Numo::RObject
Cast object to Numo::RObject.
1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 |
# File 'ext/numo/narray/types/robject.c', line 1319
static VALUE
robject_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 robject_new_dim0(x);
}
if (RTEST(rb_obj_is_kind_of(obj,rb_cArray))) {
return robject_cast_array(obj);
}
if (IsNArray(obj)) {
GetNArray(obj,na);
v = nary_new(cT, NA_NDIM(na), NA_SHAPE(na));
if (NA_SIZE(na) > 0) {
robject_store(v,obj);
}
return v;
}
return robject_new_dim0(obj);
#line 44 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/cast.c"
}
|
.[](elements) ⇒ Numo::RObject .cast(array) ⇒ Numo::RObject
Cast object to Numo::RObject.
1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 |
# File 'ext/numo/narray/types/robject.c', line 1319
static VALUE
robject_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 robject_new_dim0(x);
}
if (RTEST(rb_obj_is_kind_of(obj,rb_cArray))) {
return robject_cast_array(obj);
}
if (IsNArray(obj)) {
GetNArray(obj,na);
v = nary_new(cT, NA_NDIM(na), NA_SHAPE(na));
if (NA_SIZE(na) > 0) {
robject_store(v,obj);
}
return v;
}
return robject_new_dim0(obj);
#line 44 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/cast.c"
}
|
.maximum(*args) ⇒ Object
5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 |
# File 'ext/numo/narray/types/robject.c', line 5571
static VALUE
robject_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_robject_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_robject_s_maximum_nan;
}
#line 63 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/ewcomp.c"
return na_ndloop(&ndf, 2, a1, a2);
}
|
.minimum(*args) ⇒ Object
5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 |
# File 'ext/numo/narray/types/robject.c', line 5654
static VALUE
robject_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_robject_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_robject_s_minimum_nan;
}
#line 63 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/ewcomp.c"
return na_ndloop(&ndf, 2, a1, a2);
}
|
Instance Method Details
#%(other) ⇒ Numo::NArray
Binary mod.
2463 2464 2465 2466 2467 2468 2469 2470 |
# File 'ext/numo/narray/types/robject.c', line 2463
static VALUE
robject_mod(VALUE self, VALUE other)
{
return robject_mod_self(self, other);
#line 236 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/binary.c"
}
|
#&(other) ⇒ Numo::NArray
Binary bit_and.
3103 3104 3105 3106 3107 3108 3109 3110 |
# File 'ext/numo/narray/types/robject.c', line 3103
static VALUE
robject_bit_and(VALUE self, VALUE other)
{
return robject_bit_and_self(self, other);
#line 236 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/binary.c"
}
|
#*(other) ⇒ Numo::NArray
Binary mul.
2265 2266 2267 2268 2269 2270 2271 2272 |
# File 'ext/numo/narray/types/robject.c', line 2265
static VALUE
robject_mul(VALUE self, VALUE other)
{
return robject_mul_self(self, other);
#line 236 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/binary.c"
}
|
#**(other) ⇒ Numo::NArray
Binary power.
2590 2591 2592 2593 2594 2595 2596 2597 |
# File 'ext/numo/narray/types/robject.c', line 2590
static VALUE
robject_pow(VALUE self, VALUE other)
{
return robject_pow_self(self,other);
#line 78 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/pow.c"
}
|
#+(other) ⇒ Numo::NArray
Binary add.
2075 2076 2077 2078 2079 2080 2081 2082 |
# File 'ext/numo/narray/types/robject.c', line 2075
static VALUE
robject_add(VALUE self, VALUE other)
{
return robject_add_self(self, other);
#line 236 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/binary.c"
}
|
#-(other) ⇒ Numo::NArray
Binary sub.
2170 2171 2172 2173 2174 2175 2176 2177 |
# File 'ext/numo/narray/types/robject.c', line 2170
static VALUE
robject_sub(VALUE self, VALUE other)
{
return robject_sub_self(self, other);
#line 236 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/binary.c"
}
|
#-@ ⇒ Numo::RObject
Unary minus.
2655 2656 2657 2658 2659 2660 2661 2662 2663 |
# File 'ext/numo/narray/types/robject.c', line 2655
static VALUE
robject_minus(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{cT,0}};
ndfunc_arg_out_t aout[1] = {{cT,0}};
ndfunc_t ndf = {iter_robject_minus, FULL_LOOP, 1,1, ain,aout};
return na_ndloop(&ndf, 1, self);
}
|
#/(other) ⇒ Numo::NArray
Binary div.
2364 2365 2366 2367 2368 2369 2370 2371 |
# File 'ext/numo/narray/types/robject.c', line 2364
static VALUE
robject_div(VALUE self, VALUE other)
{
return robject_div_self(self, other);
#line 236 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/binary.c"
}
|
#<<(other) ⇒ Numo::NArray
Binary left_shift.
3454 3455 3456 3457 3458 3459 3460 3461 |
# File 'ext/numo/narray/types/robject.c', line 3454
static VALUE
robject_left_shift(VALUE self, VALUE other)
{
return robject_left_shift_self(self, other);
#line 236 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/binary.c"
}
|
#>>(other) ⇒ Numo::NArray
Binary right_shift.
3549 3550 3551 3552 3553 3554 3555 3556 |
# File 'ext/numo/narray/types/robject.c', line 3549
static VALUE
robject_right_shift(VALUE self, VALUE other)
{
return robject_right_shift_self(self, other);
#line 236 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/binary.c"
}
|
#[](dim0, ..., dimL) ⇒ Numeric, Numo::RObject
Multi-dimensional element reference.
1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 |
# File 'ext/numo/narray/types/robject.c', line 1360
static VALUE
robject_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.
1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 |
# File 'ext/numo/narray/types/robject.c', line 1387
static VALUE
robject_aset(int argc, VALUE *argv, VALUE self)
{
int nd;
size_t pos;
char *ptr;
VALUE a;
dtype x;
argc--;
if (argc==0) {
robject_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);
robject_store(a, argv[argc]);
} else {
x = robject_extract_data(argv[argc]);
ptr = na_get_pointer_for_read_write(self) + pos;
*(dtype*)ptr = x;
}
}
return argv[argc];
}
|
#^(other) ⇒ Numo::NArray
Binary bit_xor.
3293 3294 3295 3296 3297 3298 3299 3300 |
# File 'ext/numo/narray/types/robject.c', line 3293
static VALUE
robject_bit_xor(VALUE self, VALUE other)
{
return robject_bit_xor_self(self, other);
#line 236 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/binary.c"
}
|
#abs ⇒ Numo::RObject
abs of self.
1979 1980 1981 1982 1983 1984 1985 1986 1987 |
# File 'ext/numo/narray/types/robject.c', line 1979
static VALUE
robject_abs(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{cT,0}};
ndfunc_arg_out_t aout[1] = {{cRT,0}};
ndfunc_t ndf = { iter_robject_abs, FULL_LOOP, 1, 1, ain, aout };
return na_ndloop(&ndf, 1, self);
}
|
#allocate ⇒ Object
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'ext/numo/narray/types/robject.c', line 182
static VALUE
robject_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);
{ size_t i;
VALUE *a = (VALUE*)ptr;
for (i=na->size; i--;) {
*a++ = Qnil;
}
}
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;
}
|
#argmax(axis: nil, nan: false) ⇒ Integer, Numo::Int
Index of the maximum value.
5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 |
# File 'ext/numo/narray/types/robject.c', line 5289
static VALUE
robject_argmax(int argc, VALUE *argv, VALUE self)
{
narray_t *na;
VALUE reduce;
ndfunc_arg_in_t ain[2] = {{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, 2,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;
ndf.func = iter_robject_argmax_arg64;
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_argmax_arg64_nan);
#line 77 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum_arg.c"
} else {
aout[0].type = numo_cInt32;
ndf.func = iter_robject_argmax_arg32;
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_argmax_arg32_nan);
#line 85 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum_arg.c"
}
return na_ndloop(&ndf, 2, self, reduce);
}
|
#argmin(axis: nil, nan: false) ⇒ Integer, Numo::Int
Index of the minimum value.
5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 |
# File 'ext/numo/narray/types/robject.c', line 5420
static VALUE
robject_argmin(int argc, VALUE *argv, VALUE self)
{
narray_t *na;
VALUE reduce;
ndfunc_arg_in_t ain[2] = {{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, 2,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;
ndf.func = iter_robject_argmin_arg64;
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_argmin_arg64_nan);
#line 77 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum_arg.c"
} else {
aout[0].type = numo_cInt32;
ndf.func = iter_robject_argmin_arg32;
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_argmin_arg32_nan);
#line 85 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum_arg.c"
}
return na_ndloop(&ndf, 2, self, reduce);
}
|
#ceil ⇒ Numo::RObject
Unary ceil.
3746 3747 3748 3749 3750 3751 3752 3753 3754 |
# File 'ext/numo/narray/types/robject.c', line 3746
static VALUE
robject_ceil(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{cT,0}};
ndfunc_arg_out_t aout[1] = {{cT,0}};
ndfunc_t ndf = {iter_robject_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.
4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 |
# File 'ext/numo/narray/types/robject.c', line 4119
static VALUE
robject_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_robject_clip_min, STRIDE_LOOP, 2, 1, ain, aout };
ndfunc_t ndf_max = { iter_robject_clip_max, STRIDE_LOOP, 2, 1, ain, aout };
ndfunc_t ndf_both = { iter_robject_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.
1421 1422 1423 1424 1425 |
# File 'ext/numo/narray/types/robject.c', line 1421
static VALUE
robject_coerce_cast(VALUE self, VALUE type)
{
return Qnil;
}
|
#cumprod(axis: nil, nan: false) ⇒ Numo::RObject
cumprod of self.
5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 |
# File 'ext/numo/narray/types/robject.c', line 5813
static VALUE
robject_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_robject_cumprod, STRIDE_LOOP|NDF_FLAT_REDUCE|NDF_CUM,
2, 1, ain, aout };
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_cumprod_nan);
#line 48 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/cum.c"
return na_ndloop(&ndf, 2, self, reduce);
}
|
#cumsum(axis: nil, nan: false) ⇒ Numo::RObject
cumsum of self.
5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 |
# File 'ext/numo/narray/types/robject.c', line 5738
static VALUE
robject_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_robject_cumsum, STRIDE_LOOP|NDF_FLAT_REDUCE|NDF_CUM,
2, 1, ain, aout };
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_cumsum_nan);
#line 48 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/cum.c"
return na_ndloop(&ndf, 2, self, reduce);
}
|
#divmod(other) ⇒ Numo::NArray
Binary divmod.
2517 2518 2519 2520 2521 2522 2523 2524 |
# File 'ext/numo/narray/types/robject.c', line 2517
static VALUE
robject_divmod(VALUE self, VALUE other)
{
return robject_divmod_self(self, other);
#line 59 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/binary2.c"
}
|
#each ⇒ Numo::NArray
Calls the given block once for each element in self,
passing that element as a parameter.
For a block {|x| ... }
,
1684 1685 1686 1687 1688 1689 1690 1691 1692 |
# File 'ext/numo/narray/types/robject.c', line 1684
static VALUE
robject_each(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{Qnil,0}};
ndfunc_t ndf = {iter_robject_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,...| ... }
,
1821 1822 1823 1824 1825 1826 1827 1828 1829 |
# File 'ext/numo/narray/types/robject.c', line 1821
static VALUE
robject_each_with_index(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{Qnil,0}};
ndfunc_t ndf = {iter_robject_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.
2907 2908 2909 2910 2911 2912 2913 2914 |
# File 'ext/numo/narray/types/robject.c', line 2907
static VALUE
robject_eq(VALUE self, VALUE other)
{
return robject_eq_self(self, other);
#line 55 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/cond_binary.c"
}
|
#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.
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
# File 'ext/numo/narray/types/robject.c', line 227
static VALUE
robject_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::RObject
Eye: Set a value to diagonal components, set 0 to non-diagonal components.
6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 |
# File 'ext/numo/narray/types/robject.c', line 6170
static VALUE
robject_eye(int argc, VALUE *argv, VALUE self)
{
ndfunc_arg_in_t ain[1] = {{OVERWRITE,2}};
ndfunc_t ndf = {iter_robject_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::RObject
Fill elements with other.
1502 1503 1504 1505 1506 1507 1508 1509 1510 |
# File 'ext/numo/narray/types/robject.c', line 1502
static VALUE
robject_fill(VALUE self, VALUE val)
{
ndfunc_arg_in_t ain[2] = {{OVERWRITE,0},{sym_option}};
ndfunc_t ndf = { iter_robject_fill, FULL_LOOP, 2, 0, ain, 0 };
na_ndloop(&ndf, 2, self, val);
return self;
}
|
#floor ⇒ Numo::RObject
Unary floor.
3614 3615 3616 3617 3618 3619 3620 3621 3622 |
# File 'ext/numo/narray/types/robject.c', line 3614
static VALUE
robject_floor(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{cT,0}};
ndfunc_arg_out_t aout[1] = {{cT,0}};
ndfunc_t ndf = {iter_robject_floor, FULL_LOOP, 1,1, ain,aout};
return na_ndloop(&ndf, 1, self);
}
|
#format(format) ⇒ Numo::RObject
Format elements into strings.
1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 |
# File 'ext/numo/narray/types/robject.c', line 1562
static VALUE
robject_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_robject_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.
1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 |
# File 'ext/numo/narray/types/robject.c', line 1613
static VALUE
robject_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_robject_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.
3913 3914 3915 3916 3917 3918 3919 3920 |
# File 'ext/numo/narray/types/robject.c', line 3913
static VALUE
robject_ge(VALUE self, VALUE other)
{
return robject_ge_self(self, other);
#line 55 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/cond_binary.c"
}
|
#gt(other) ⇒ Numo::Bit Also known as: >
Comparison gt other.
3863 3864 3865 3866 3867 3868 3869 3870 |
# File 'ext/numo/narray/types/robject.c', line 3863
static VALUE
robject_gt(VALUE self, VALUE other)
{
return robject_gt_self(self, other);
#line 55 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/cond_binary.c"
}
|
#inspect ⇒ String
Returns a string containing a human-readable representation of NArray.
1640 1641 1642 1643 1644 |
# File 'ext/numo/narray/types/robject.c', line 1640
static VALUE
robject_inspect(VALUE ary)
{
return na_ndloop_inspect(ary, iter_robject_inspect, Qnil);
}
|
#isfinite ⇒ Numo::Bit
Condition of isfinite.
4373 4374 4375 4376 4377 4378 4379 4380 4381 |
# File 'ext/numo/narray/types/robject.c', line 4373
static VALUE
robject_isfinite(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{cT,0}};
ndfunc_arg_out_t aout[1] = {{numo_cBit,0}};
ndfunc_t ndf = { iter_robject_isfinite, FULL_LOOP, 1, 1, ain, aout };
return na_ndloop(&ndf, 1, self);
}
|
#isinf ⇒ Numo::Bit
Condition of isinf.
4229 4230 4231 4232 4233 4234 4235 4236 4237 |
# File 'ext/numo/narray/types/robject.c', line 4229
static VALUE
robject_isinf(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{cT,0}};
ndfunc_arg_out_t aout[1] = {{numo_cBit,0}};
ndfunc_t ndf = { iter_robject_isinf, FULL_LOOP, 1, 1, ain, aout };
return na_ndloop(&ndf, 1, self);
}
|
#isnan ⇒ Numo::Bit
Condition of isnan.
4181 4182 4183 4184 4185 4186 4187 4188 4189 |
# File 'ext/numo/narray/types/robject.c', line 4181
static VALUE
robject_isnan(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{cT,0}};
ndfunc_arg_out_t aout[1] = {{numo_cBit,0}};
ndfunc_t ndf = { iter_robject_isnan, FULL_LOOP, 1, 1, ain, aout };
return na_ndloop(&ndf, 1, self);
}
|
#isneginf ⇒ Numo::Bit
Condition of isneginf.
4325 4326 4327 4328 4329 4330 4331 4332 4333 |
# File 'ext/numo/narray/types/robject.c', line 4325
static VALUE
robject_isneginf(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{cT,0}};
ndfunc_arg_out_t aout[1] = {{numo_cBit,0}};
ndfunc_t ndf = { iter_robject_isneginf, FULL_LOOP, 1, 1, ain, aout };
return na_ndloop(&ndf, 1, self);
}
|
#isposinf ⇒ Numo::Bit
Condition of isposinf.
4277 4278 4279 4280 4281 4282 4283 4284 4285 |
# File 'ext/numo/narray/types/robject.c', line 4277
static VALUE
robject_isposinf(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{cT,0}};
ndfunc_arg_out_t aout[1] = {{numo_cBit,0}};
ndfunc_t ndf = { iter_robject_isposinf, FULL_LOOP, 1, 1, ain, aout };
return na_ndloop(&ndf, 1, self);
}
|
#le(other) ⇒ Numo::Bit Also known as: <=
Comparison le other.
4013 4014 4015 4016 4017 4018 4019 4020 |
# File 'ext/numo/narray/types/robject.c', line 4013
static VALUE
robject_le(VALUE self, VALUE other)
{
return robject_le_self(self, other);
#line 55 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/cond_binary.c"
}
|
#logseq(beg, step, [base]) ⇒ Numo::RObject
Set logarithmic sequence of numbers to self. The sequence is obtained from
base**(beg+i*step)
where i is 1-dimensional index.
Applicable classes: DFloat, SFloat, DComplex, SCopmplex.
6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 |
# File 'ext/numo/narray/types/robject.c', line 6107
static VALUE
robject_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_robject_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.
3963 3964 3965 3966 3967 3968 3969 3970 |
# File 'ext/numo/narray/types/robject.c', line 3963
static VALUE
robject_lt(VALUE self, VALUE other)
{
return robject_lt_self(self, other);
#line 55 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/cond_binary.c"
}
|
#map ⇒ Numo::RObject
Unary map.
1750 1751 1752 1753 1754 1755 1756 1757 1758 |
# File 'ext/numo/narray/types/robject.c', line 1750
static VALUE
robject_map(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{cT,0}};
ndfunc_arg_out_t aout[1] = {{cT,0}};
ndfunc_t ndf = {iter_robject_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,...| ... }
,
1918 1919 1920 1921 1922 1923 1924 1925 1926 |
# File 'ext/numo/narray/types/robject.c', line 1918
static VALUE
robject_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_robject_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::RObject
max of self.
4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 |
# File 'ext/numo/narray/types/robject.c', line 4836
static VALUE
robject_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_robject_max, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE, 2, 1, ain, aout };
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_max_nan);
#line 42 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum.c"
v = na_ndloop(&ndf, 2, self, reduce);
return robject_extract(v);
#line 48 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum.c"
}
|
#max_index(axis: nil, nan: false) ⇒ Integer, Numo::Int
Index of the maximum value.
5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 |
# File 'ext/numo/narray/types/robject.c', line 5017
static VALUE
robject_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_robject_max_index_index64;
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_max_index_index64_nan);
#line 79 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum_index.c"
} else {
aout[0].type = numo_cInt32;
idx = nary_new(numo_cInt32, na->ndim, na->shape);
ndf.func = iter_robject_max_index_index32;
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_max_index_index32_nan);
#line 88 "/home/masa/numo/numo-narray/ext/numo/narray/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::RObject
mean of self.
4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 |
# File 'ext/numo/narray/types/robject.c', line 4541
static VALUE
robject_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_robject_mean, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE, 2, 1, ain, aout };
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_mean_nan);
#line 42 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum.c"
v = na_ndloop(&ndf, 2, self, reduce);
return robject_extract(v);
#line 48 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum.c"
}
|
#min(axis: nil, keepdims: false, nan: false) ⇒ Numo::RObject
min of self.
4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 |
# File 'ext/numo/narray/types/robject.c', line 4777
static VALUE
robject_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_robject_min, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE, 2, 1, ain, aout };
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_min_nan);
#line 42 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum.c"
v = na_ndloop(&ndf, 2, self, reduce);
return robject_extract(v);
#line 48 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum.c"
}
|
#min_index(axis: nil, nan: false) ⇒ Integer, Numo::Int
Index of the minimum value.
5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 |
# File 'ext/numo/narray/types/robject.c', line 5155
static VALUE
robject_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_robject_min_index_index64;
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_min_index_index64_nan);
#line 79 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum_index.c"
} else {
aout[0].type = numo_cInt32;
idx = nary_new(numo_cInt32, na->ndim, na->shape);
ndf.func = iter_robject_min_index_index32;
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_min_index_index32_nan);
#line 88 "/home/masa/numo/numo-narray/ext/numo/narray/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::RObject
minmax of self.
5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 |
# File 'ext/numo/narray/types/robject.c', line 5498
static VALUE
robject_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_robject_minmax, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE|NDF_EXTRACT, 2,2, ain,aout};
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_minmax_nan);
#line 45 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/minmax.c"
return na_ndloop(&ndf, 2, self, reduce);
}
|
#mulsum(other, axis: nil, keepdims: false, nan: false) ⇒ Numo::NArray
Binary mulsum.
5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 |
# File 'ext/numo/narray/types/robject.c', line 5940
static VALUE
robject_mulsum(int argc, VALUE *argv, VALUE self)
{
//
#line 86 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum_binary.c"
if (argc < 1) {
rb_raise(rb_eArgError,"wrong number of arguments (%d for >=1)",argc);
}
//
return robject_mulsum_self(argc, argv, self);
//
#line 100 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum_binary.c"
}
|
#ne(other) ⇒ Numo::Bit
Comparison ne other.
2957 2958 2959 2960 2961 2962 2963 2964 |
# File 'ext/numo/narray/types/robject.c', line 2957
static VALUE
robject_ne(VALUE self, VALUE other)
{
return robject_ne_self(self, other);
#line 55 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/cond_binary.c"
}
|
#nearly_eq(other) ⇒ Numo::Bit Also known as: close_to
Comparison nearly_eq other.
3007 3008 3009 3010 3011 3012 3013 3014 |
# File 'ext/numo/narray/types/robject.c', line 3007
static VALUE
robject_nearly_eq(VALUE self, VALUE other)
{
return robject_nearly_eq_self(self, other);
#line 55 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/cond_binary.c"
}
|
#poly(a0, a1, ..., an) ⇒ Numo::RObject
Calculate polynomial.
x.poly(a0,a1,a2,...,an) = a0 + a1*x + a2*x**2 + ... + an*x**n
6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 |
# File 'ext/numo/narray/types/robject.c', line 6347
static VALUE
robject_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_robject_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 robject_extract(v);
}
|
#prod(axis: nil, keepdims: false, nan: false) ⇒ Numo::RObject
prod of self.
4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 |
# File 'ext/numo/narray/types/robject.c', line 4482
static VALUE
robject_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] = {{numo_cInt64,0}};
ndfunc_t ndf = { iter_robject_prod, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE, 2, 1, ain, aout };
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_prod_nan);
#line 42 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum.c"
v = na_ndloop(&ndf, 2, self, reduce);
#line 46 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum.c"
return rb_funcall(v,rb_intern("extract"),0);
}
|
#ptp(axis: nil, keepdims: false, nan: false) ⇒ Numo::RObject
ptp of self.
4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 |
# File 'ext/numo/narray/types/robject.c', line 4895
static VALUE
robject_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_robject_ptp, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE, 2, 1, ain, aout };
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_ptp_nan);
#line 42 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum.c"
v = na_ndloop(&ndf, 2, self, reduce);
return robject_extract(v);
#line 48 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum.c"
}
|
#rand([[low],high]) ⇒ Numo::RObject
Generate uniformly distributed random numbers on self narray.
6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 |
# File 'ext/numo/narray/types/robject.c', line 6286
static VALUE
robject_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_robject_rand, FULL_LOOP, 1,0, ain,0};
#line 142 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/rand.c"
rb_scan_args(argc, args, "02", &v1, &v2);
if (v2==Qnil) {
g.low = m_zero;
if (v1==Qnil) {
#line 149 "/home/masa/numo/numo-narray/ext/numo/narray/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 165 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/rand.c"
na_ndloop3(&ndf, &g, 1, self);
return self;
}
|
#reciprocal ⇒ Numo::RObject
Unary reciprocal.
2721 2722 2723 2724 2725 2726 2727 2728 2729 |
# File 'ext/numo/narray/types/robject.c', line 2721
static VALUE
robject_reciprocal(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{cT,0}};
ndfunc_arg_out_t aout[1] = {{cT,0}};
ndfunc_t ndf = {iter_robject_reciprocal, FULL_LOOP, 1,1, ain,aout};
return na_ndloop(&ndf, 1, self);
}
|
#rms(axis: nil, keepdims: false, nan: false) ⇒ Numo::RObject
rms of self.
4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 |
# File 'ext/numo/narray/types/robject.c', line 4718
static VALUE
robject_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_robject_rms, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE, 2, 1, ain, aout };
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_rms_nan);
#line 42 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum.c"
v = na_ndloop(&ndf, 2, self, reduce);
#line 46 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum.c"
return rb_funcall(v,rb_intern("extract"),0);
}
|
#round ⇒ Numo::RObject
Unary round.
3680 3681 3682 3683 3684 3685 3686 3687 3688 |
# File 'ext/numo/narray/types/robject.c', line 3680
static VALUE
robject_round(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{cT,0}};
ndfunc_arg_out_t aout[1] = {{cT,0}};
ndfunc_t ndf = {iter_robject_round, FULL_LOOP, 1,1, ain,aout};
return na_ndloop(&ndf, 1, self);
}
|
#seq([beg,[step]]) ⇒ Numo::RObject 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.
6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 |
# File 'ext/numo/narray/types/robject.c', line 6020
static VALUE
robject_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_robject_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 87 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/seq.c"
if (vbeg!=Qnil) {g->beg = m_num_to_data(vbeg);}
if (vstep!=Qnil) {g->step = m_num_to_data(vstep);}
#line 91 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/seq.c"
na_ndloop3(&ndf, g, 1, self);
return self;
}
|
#sign ⇒ Numo::RObject
Unary sign.
2787 2788 2789 2790 2791 2792 2793 2794 2795 |
# File 'ext/numo/narray/types/robject.c', line 2787
static VALUE
robject_sign(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{cT,0}};
ndfunc_arg_out_t aout[1] = {{cT,0}};
ndfunc_t ndf = {iter_robject_sign, FULL_LOOP, 1,1, ain,aout};
return na_ndloop(&ndf, 1, self);
}
|
#square ⇒ Numo::RObject
Unary square.
2853 2854 2855 2856 2857 2858 2859 2860 2861 |
# File 'ext/numo/narray/types/robject.c', line 2853
static VALUE
robject_square(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{cT,0}};
ndfunc_arg_out_t aout[1] = {{cT,0}};
ndfunc_t ndf = {iter_robject_square, FULL_LOOP, 1,1, ain,aout};
return na_ndloop(&ndf, 1, self);
}
|
#stddev(axis: nil, keepdims: false, nan: false) ⇒ Numo::RObject
stddev of self.
4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 |
# File 'ext/numo/narray/types/robject.c', line 4600
static VALUE
robject_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_robject_stddev, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE, 2, 1, ain, aout };
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_stddev_nan);
#line 42 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum.c"
v = na_ndloop(&ndf, 2, self, reduce);
#line 46 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum.c"
return rb_funcall(v,rb_intern("extract"),0);
}
|
#store(other) ⇒ Numo::RObject
Store elements to Numo::RObject from other.
1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 |
# File 'ext/numo/narray/types/robject.c', line 1071
static VALUE
robject_store(VALUE self, VALUE obj)
{
VALUE r, klass;
klass = rb_obj_class(obj);
if (klass==numo_cRObject) {
robject_store_robject(self,obj);
return self;
}
#line 19 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/store.c"
if (IS_INTEGER_CLASS(klass) || klass==rb_cFloat || klass==rb_cComplex) {
robject_store_numeric(self,obj);
return self;
}
#line 19 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/store.c"
if (klass==numo_cBit) {
robject_store_bit(self,obj);
return self;
}
#line 19 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/store.c"
if (klass==numo_cDFloat) {
robject_store_dfloat(self,obj);
return self;
}
#line 19 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/store.c"
if (klass==numo_cSFloat) {
robject_store_sfloat(self,obj);
return self;
}
#line 19 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/store.c"
if (klass==numo_cInt64) {
robject_store_int64(self,obj);
return self;
}
#line 19 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/store.c"
if (klass==numo_cInt32) {
robject_store_int32(self,obj);
return self;
}
#line 19 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/store.c"
if (klass==numo_cInt16) {
robject_store_int16(self,obj);
return self;
}
#line 19 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/store.c"
if (klass==numo_cInt8) {
robject_store_int8(self,obj);
return self;
}
#line 19 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/store.c"
if (klass==numo_cUInt64) {
robject_store_uint64(self,obj);
return self;
}
#line 19 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/store.c"
if (klass==numo_cUInt32) {
robject_store_uint32(self,obj);
return self;
}
#line 19 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/store.c"
if (klass==numo_cUInt16) {
robject_store_uint16(self,obj);
return self;
}
#line 19 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/store.c"
if (klass==numo_cUInt8) {
robject_store_uint8(self,obj);
return self;
}
#line 19 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/store.c"
if (klass==rb_cArray) {
robject_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) {
robject_store(self,r);
return self;
}
}
robject_store_numeric(self,obj);
#line 40 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/store.c"
return self;
}
|
#sum(axis: nil, keepdims: false, nan: false) ⇒ Numo::RObject
sum of self.
4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 |
# File 'ext/numo/narray/types/robject.c', line 4423
static VALUE
robject_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] = {{numo_cInt64,0}};
ndfunc_t ndf = { iter_robject_sum, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE, 2, 1, ain, aout };
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_sum_nan);
#line 42 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum.c"
v = na_ndloop(&ndf, 2, self, reduce);
#line 46 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum.c"
return rb_funcall(v,rb_intern("extract"),0);
}
|
#to_a ⇒ Array
Convert self to Array.
1462 1463 1464 1465 1466 1467 1468 1469 |
# File 'ext/numo/narray/types/robject.c', line 1462
static VALUE
robject_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_robject_to_a, FULL_LOOP_NIP, 3, 1, ain, aout };
return na_ndloop_cast_narray_to_rarray(&ndf, self, Qnil);
}
|
#trunc ⇒ Numo::RObject
Unary trunc.
3812 3813 3814 3815 3816 3817 3818 3819 3820 |
# File 'ext/numo/narray/types/robject.c', line 3812
static VALUE
robject_trunc(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{cT,0}};
ndfunc_arg_out_t aout[1] = {{cT,0}};
ndfunc_t ndf = {iter_robject_trunc, FULL_LOOP, 1,1, ain,aout};
return na_ndloop(&ndf, 1, self);
}
|
#var(axis: nil, keepdims: false, nan: false) ⇒ Numo::RObject
var of self.
4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 |
# File 'ext/numo/narray/types/robject.c', line 4659
static VALUE
robject_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_robject_var, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE, 2, 1, ain, aout };
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_var_nan);
#line 42 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum.c"
v = na_ndloop(&ndf, 2, self, reduce);
#line 46 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum.c"
return rb_funcall(v,rb_intern("extract"),0);
}
|
#|(other) ⇒ Numo::NArray
Binary bit_or.
3198 3199 3200 3201 3202 3203 3204 3205 |
# File 'ext/numo/narray/types/robject.c', line 3198
static VALUE
robject_bit_or(VALUE self, VALUE other)
{
return robject_bit_or_self(self, other);
#line 236 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/binary.c"
}
|
#~ ⇒ Numo::RObject
Unary bit_not.
3358 3359 3360 3361 3362 3363 3364 3365 3366 |
# File 'ext/numo/narray/types/robject.c', line 3358
static VALUE
robject_bit_not(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{cT,0}};
ndfunc_arg_out_t aout[1] = {{cT,0}};
ndfunc_t ndf = {iter_robject_bit_not, FULL_LOOP, 1,1, ain,aout};
return na_ndloop(&ndf, 1, self);
}
|