Class: Numo::Int8
Constant Summary
- UPCAST =
hCast
- ELEMENT_BIT_SIZE =
INT2FIX(sizeof(dtype)*8)
- ELEMENT_BYTE_SIZE =
INT2FIX(sizeof(dtype))
- CONTIGUOUS_STRIDE =
INT2FIX(sizeof(dtype))
- MAX =
M_MAX
- MIN =
M_MIN
Constants inherited from NArray
Class Method Summary collapse
-
.[](obj) ⇒ Numo::Int8
Cast object to Numo::Int8.
-
.cast(obj) ⇒ Numo::Int8
Cast object to Numo::Int8.
-
.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::Int8
Unary minus.
-
#/(other) ⇒ Numo::NArray
Binary div.
-
#<<(other) ⇒ Numo::NArray
Binary left_shift.
-
#>>(other) ⇒ Numo::NArray
Binary right_shift.
-
#[](dim0, ..., dimL) ⇒ Numeric, NArray::Int8
Array element referenece or slice view.
-
#[]=(dim0, .., dimL, val) ⇒ Numeric
Array element(s) set.
-
#^(other) ⇒ Numo::NArray
Binary bit_xor.
-
#abs ⇒ Numo::Int8
abs of self.
-
#allocate ⇒ Object
-
#bincount([weight], minlength: nil) ⇒ UInt32 or UInt64 or SFloat or DFloat
Count the number of occurrences of each non-negative integer value.
-
#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::Int8
cumprod of self.
-
#cumsum(axis: nil, nan: false) ⇒ Numo::Int8
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
(also: #nearly_eq)
Comparison eq other.
-
#extract ⇒ Numeric, Numo::NArray
Extract an element only if self is a dimensionless NArray.
-
#eye([element,offset]) ⇒ Numo::Int8
Eye: Set a value to diagonal components, set 0 to non-diagonal components.
-
#fill(other) ⇒ Numo::Int8
Fill elements with other.
-
#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.
-
#le(other) ⇒ Numo::Bit
(also: #<=)
Comparison le other.
-
#lt(other) ⇒ Numo::Bit
(also: #<)
Comparison lt other.
-
#map ⇒ Numo::Int8
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) ⇒ Numo::Int8
max of self.
-
#max_index(axis: nil) ⇒ Integer, Numo::Int
max_index.
-
#median(axis: nil, keepdims: false) ⇒ Numo::Int8
median of self.
-
#min(axis: nil, keepdims: false) ⇒ Numo::Int8
min of self.
-
#min_index(axis: nil) ⇒ Integer, Numo::Int
min_index.
-
#minmax(axis: nil, keepdims: false) ⇒ Numo::Int8
minmax of self.
-
#mulsum(other, axis: nil, keepdims: false) ⇒ Numo::NArray
Binary mulsum.
-
#ne(other) ⇒ Numo::Bit
Comparison ne other.
-
#poly(a0, a1, ...) ⇒ Numo::Int8
Polynomial.: a0 + a1x + a2x2 + a3*x3 + …
-
#prod(axis: nil, keepdims: false) ⇒ Numo::Int8
prod of self.
-
#ptp(axis: nil, keepdims: false) ⇒ Numo::Int8
ptp of self.
-
#rand([[low],high]) ⇒ Numo::Int8
Generate uniformly distributed random numbers on self narray.
-
#reciprocal ⇒ Numo::Int8
Unary reciprocal.
-
#seq([beg,[step]]) ⇒ Numo::Int8
(also: #indgen)
Set linear sequence of numbers to self.
-
#sign ⇒ Numo::Int8
Unary sign.
-
#sort(axis: nil) ⇒ Numo::Int8
sort of self.
-
#sort_index(axis: nil) ⇒ Integer, Numo::Int
sort_index.
-
#square ⇒ Numo::Int8
Unary square.
-
#store(other) ⇒ Numo::Int8
Store elements to Numo::Int8 from other.
-
#sum(axis: nil, keepdims: false) ⇒ Numo::Int8
sum of self.
-
#to_a ⇒ Array
Convert self to Array.
-
#|(other) ⇒ Numo::NArray
Binary bit_or.
-
#~ ⇒ Numo::Int8
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, #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::Int8 .cast(array) ⇒ Numo::Int8
Cast object to Numo::Int8.
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/int8.c', line 1262
static VALUE
int8_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 int8_new_dim0(x);
}
if (RTEST(rb_obj_is_kind_of(obj,rb_cArray))) {
return int8_cast_array(obj);
}
if (IsNArray(obj)) {
GetNArray(obj,na);
v = nary_new(cT, NA_NDIM(na), NA_SHAPE(na));
if (NA_SIZE(na) > 0) {
int8_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::Int8 .cast(array) ⇒ Numo::Int8
Cast object to Numo::Int8.
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/int8.c', line 1262
static VALUE
int8_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 int8_new_dim0(x);
}
if (RTEST(rb_obj_is_kind_of(obj,rb_cArray))) {
return int8_cast_array(obj);
}
if (IsNArray(obj)) {
GetNArray(obj,na);
v = nary_new(cT, NA_NDIM(na), NA_SHAPE(na));
if (NA_SIZE(na) > 0) {
int8_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
4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 |
# File 'ext/numo/narray/types/int8.c', line 4074
static VALUE
int8_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_int8_s_maximum, STRIDE_LOOP_NIP, 2, 1, ain, aout };
#line 60 "gen/tmpl/ewcomp.c"
rb_scan_args(argc, argv, "20", &a1, &a2);
return na_ndloop(&ndf, 2, a1, a2);
}
|
.minimum(*args) ⇒ Object
4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 |
# File 'ext/numo/narray/types/int8.c', line 4125
static VALUE
int8_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_int8_s_minimum, STRIDE_LOOP_NIP, 2, 1, ain, aout };
#line 60 "gen/tmpl/ewcomp.c"
rb_scan_args(argc, argv, "20", &a1, &a2);
return na_ndloop(&ndf, 2, a1, a2);
}
|
Instance Method Details
#%(other) ⇒ Numo::NArray
Binary mod.
2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 |
# File 'ext/numo/narray/types/int8.c', line 2308
static VALUE
int8_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 int8_mod_self(self, other);
} else {
v = rb_funcall(klass, id_cast, 1, self);
return rb_funcall(v, '%', 1, other);
}
}
|
#&(other) ⇒ Numo::NArray
Binary bit_and.
2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 |
# File 'ext/numo/narray/types/int8.c', line 2898
static VALUE
int8_bit_and(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 int8_bit_and_self(self, other);
} else {
v = rb_funcall(klass, id_cast, 1, self);
return rb_funcall(v, '&', 1, other);
}
}
|
#*(other) ⇒ Numo::NArray
Binary mul.
2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 |
# File 'ext/numo/narray/types/int8.c', line 2168
static VALUE
int8_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 int8_mul_self(self, other);
} else {
v = rb_funcall(klass, id_cast, 1, self);
return rb_funcall(v, '*', 1, other);
}
}
|
#**(other) ⇒ Numo::NArray
Binary power.
2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 |
# File 'ext/numo/narray/types/int8.c', line 2450
static VALUE
int8_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 int8_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.
2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 |
# File 'ext/numo/narray/types/int8.c', line 2036
static VALUE
int8_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 int8_add_self(self, other);
} else {
v = rb_funcall(klass, id_cast, 1, self);
return rb_funcall(v, '+', 1, other);
}
}
|
#-(other) ⇒ Numo::NArray
Binary sub.
2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 |
# File 'ext/numo/narray/types/int8.c', line 2102
static VALUE
int8_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 int8_sub_self(self, other);
} else {
v = rb_funcall(klass, id_cast, 1, self);
return rb_funcall(v, '-', 1, other);
}
}
|
#-@ ⇒ Numo::Int8
Unary minus.
2522 2523 2524 2525 2526 2527 2528 2529 2530 |
# File 'ext/numo/narray/types/int8.c', line 2522
static VALUE
int8_minus(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{cT,0}};
ndfunc_arg_out_t aout[1] = {{cT,0}};
ndfunc_t ndf = {iter_int8_minus, FULL_LOOP, 1,1, ain,aout};
return na_ndloop(&ndf, 1, self);
}
|
#/(other) ⇒ Numo::NArray
Binary div.
2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 |
# File 'ext/numo/narray/types/int8.c', line 2238
static VALUE
int8_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 int8_div_self(self, other);
} else {
v = rb_funcall(klass, id_cast, 1, self);
return rb_funcall(v, '/', 1, other);
}
}
|
#<<(other) ⇒ Numo::NArray
Binary left_shift.
3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 |
# File 'ext/numo/narray/types/int8.c', line 3162
static VALUE
int8_left_shift(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 int8_left_shift_self(self, other);
} else {
v = rb_funcall(klass, id_cast, 1, self);
return rb_funcall(v, id_left_shift, 1, other);
}
}
|
#>>(other) ⇒ Numo::NArray
Binary right_shift.
3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 |
# File 'ext/numo/narray/types/int8.c', line 3228
static VALUE
int8_right_shift(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 int8_right_shift_self(self, other);
} else {
v = rb_funcall(klass, id_cast, 1, self);
return rb_funcall(v, id_right_shift, 1, other);
}
}
|
#[](dim0, ..., dimL) ⇒ Numeric, NArray::Int8
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/int8.c', line 1334
static VALUE
int8_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/int8.c', line 1391
static VALUE
int8_aset(int argc, VALUE *argv, VALUE self)
{
int nd;
size_t pos;
char *ptr;
VALUE a;
dtype x;
argc--;
if (argc==0) {
int8_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);
int8_store(a, argv[argc]);
} else {
x = int8_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.
3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 |
# File 'ext/numo/narray/types/int8.c', line 3030
static VALUE
int8_bit_xor(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 int8_bit_xor_self(self, other);
} else {
v = rb_funcall(klass, id_cast, 1, self);
return rb_funcall(v, '^', 1, other);
}
}
|
#abs ⇒ Numo::Int8
abs of self.
1977 1978 1979 1980 1981 1982 1983 1984 1985 |
# File 'ext/numo/narray/types/int8.c', line 1977
static VALUE
int8_abs(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{cT,0}};
ndfunc_arg_out_t aout[1] = {{cRT,0}};
ndfunc_t ndf = { iter_int8_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/int8.c', line 139
static VALUE
int8_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;
}
|
#bincount([weight], minlength: nil) ⇒ UInt32 or UInt64 or SFloat or DFloat
Count the number of occurrences of each non-negative integer value. Only Integer-types has this method.
4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 |
# File 'ext/numo/narray/types/int8.c', line 4360
static VALUE
int8_bincount(int argc, VALUE *argv, VALUE self)
{
VALUE weight=Qnil, kw=Qnil;
VALUE opts[1] = {Qundef};
VALUE v, wclass;
ID table[1] = {id_minlength};
size_t length, minlength;
rb_scan_args(argc, argv, "01:", &weight, &kw);
rb_get_kwargs(kw, table, 0, 1, opts);
#line 151 "gen/tmpl/bincount.c"
v = int8_minmax(0,0,self);
if (m_num_to_data(RARRAY_AREF(v,0)) < 0) {
rb_raise(rb_eArgError,"array items must be non-netagive");
}
v = RARRAY_AREF(v,1);
length = NUM2SIZET(v) + 1;
if (opts[0] != Qundef) {
minlength = NUM2SIZET(opts[0]);
if (minlength > length) {
length = minlength;
}
}
if (NIL_P(weight)) {
if (length > 4294967295ul) {
return int8_bincount_64(self, length);
} else {
return int8_bincount_32(self, length);
}
} else {
wclass = CLASS_OF(weight);
if (wclass == numo_cSFloat) {
return int8_bincount_sf(self, weight, length);
} else {
return int8_bincount_df(self, weight, length);
}
}
}
|
#clip(min, max) ⇒ Numo::NArray
Clip array elements by [min,max]. If either of min or max is nil, one side is clipped.
3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 |
# File 'ext/numo/narray/types/int8.c', line 3579
static VALUE
int8_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_int8_clip_min, STRIDE_LOOP, 2, 1, ain, aout };
ndfunc_t ndf_max = { iter_int8_clip_max, STRIDE_LOOP, 2, 1, ain, aout };
ndfunc_t ndf_both = { iter_int8_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/int8.c', line 1425
static VALUE
int8_coerce_cast(VALUE self, VALUE type)
{
return Qnil;
}
|
#cumprod(axis: nil, nan: false) ⇒ Numo::Int8
cumprod of self.
4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 |
# File 'ext/numo/narray/types/int8.c', line 4491
static VALUE
int8_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_int8_cumprod, STRIDE_LOOP|NDF_FLAT_REDUCE|NDF_CUM,
2, 1, ain, aout };
#line 46 "gen/tmpl/cum.c"
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
return na_ndloop(&ndf, 2, self, reduce);
}
|
#cumsum(axis: nil, nan: false) ⇒ Numo::Int8
cumsum of self.
4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 |
# File 'ext/numo/narray/types/int8.c', line 4440
static VALUE
int8_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_int8_cumsum, STRIDE_LOOP|NDF_FLAT_REDUCE|NDF_CUM,
2, 1, ain, aout };
#line 46 "gen/tmpl/cum.c"
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
return na_ndloop(&ndf, 2, self, reduce);
}
|
#divmod(other) ⇒ Numo::NArray
Binary divmod.
2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 |
# File 'ext/numo/narray/types/int8.c', line 2370
static VALUE
int8_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 int8_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/int8.c', line 1686
static VALUE
int8_each(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{Qnil,0}};
ndfunc_t ndf = {iter_int8_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,…| … }
1819 1820 1821 1822 1823 1824 1825 1826 1827 |
# File 'ext/numo/narray/types/int8.c', line 1819
static VALUE
int8_each_with_index(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{Qnil,0}};
ndfunc_t ndf = {iter_int8_each_with_index, FULL_LOOP_NIP, 1,0, ain,0};
na_ndloop_with_index(&ndf, 1, self);
return self;
}
|
#eq(other) ⇒ Numo::Bit Also known as: nearly_eq
Comparison eq other.
2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 |
# File 'ext/numo/narray/types/int8.c', line 2774
static VALUE
int8_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 int8_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/int8.c', line 178
static VALUE
int8_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::Int8
Eye: Set a value to diagonal components, set 0 to non-diagonal components.
4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 |
# File 'ext/numo/narray/types/int8.c', line 4730
static VALUE
int8_eye(int argc, VALUE *argv, VALUE self)
{
ndfunc_arg_in_t ain[1] = {{OVERWRITE,2}};
ndfunc_t ndf = {iter_int8_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::Int8
Fill elements with other.
1506 1507 1508 1509 1510 1511 1512 1513 1514 |
# File 'ext/numo/narray/types/int8.c', line 1506
static VALUE
int8_fill(VALUE self, VALUE val)
{
ndfunc_arg_in_t ain[2] = {{OVERWRITE,0},{sym_option}};
ndfunc_t ndf = { iter_int8_fill, FULL_LOOP, 2, 0, ain, 0 };
na_ndloop(&ndf, 2, self, val);
return 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/int8.c', line 1566
static VALUE
int8_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_int8_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/int8.c', line 1617
static VALUE
int8_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_int8_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.
3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 |
# File 'ext/numo/narray/types/int8.c', line 3348
static VALUE
int8_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 int8_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.
3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 |
# File 'ext/numo/narray/types/int8.c', line 3291
static VALUE
int8_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 int8_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/int8.c', line 1644
VALUE
int8_inspect(VALUE ary)
{
return na_ndloop_inspect(ary, iter_int8_inspect, Qnil);
}
|
#le(other) ⇒ Numo::Bit Also known as: <=
Comparison le other.
3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 |
# File 'ext/numo/narray/types/int8.c', line 3462
static VALUE
int8_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 int8_le_self(self, other);
} else {
v = rb_funcall(klass, id_cast, 1, self);
return rb_funcall(v, id_le, 1, other);
}
}
|
#lt(other) ⇒ Numo::Bit Also known as: <
Comparison lt other.
3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 |
# File 'ext/numo/narray/types/int8.c', line 3405
static VALUE
int8_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 int8_lt_self(self, other);
} else {
v = rb_funcall(klass, id_cast, 1, self);
return rb_funcall(v, id_lt, 1, other);
}
}
|
#map ⇒ Numo::Int8
Unary map.
1752 1753 1754 1755 1756 1757 1758 1759 1760 |
# File 'ext/numo/narray/types/int8.c', line 1752
static VALUE
int8_map(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{cT,0}};
ndfunc_arg_out_t aout[1] = {{cT,0}};
ndfunc_t ndf = {iter_int8_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,… | … } |
1916 1917 1918 1919 1920 1921 1922 1923 1924 |
# File 'ext/numo/narray/types/int8.c', line 1916
static VALUE
int8_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_int8_map_with_index, FULL_LOOP, 1,1, ain,aout};
return na_ndloop_with_index(&ndf, 1, self);
}
|
#max(axis: nil, keepdims: false) ⇒ Numo::Int8
max of self.
3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 |
# File 'ext/numo/narray/types/int8.c', line 3760
static VALUE
int8_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_int8_max, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE, 2, 1, ain, aout };
#line 40 "gen/tmpl/accum.c"
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
v = na_ndloop(&ndf, 2, self, reduce);
return int8_extract(v);
#line 48 "gen/tmpl/accum.c"
}
|
#max_index(axis: nil) ⇒ Integer, Numo::Int
max_index. Return an index of result.
3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 |
# File 'ext/numo/narray/types/int8.c', line 3875
static VALUE
int8_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_int8_max_index_index64;
#line 56 "gen/tmpl/accum_index.c"
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
} else {
aout[0].type = numo_cInt32;
idx = nary_new(numo_cInt32, na->ndim, na->shape);
ndf.func = iter_int8_max_index_index32;
#line 65 "gen/tmpl/accum_index.c"
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
}
rb_funcall(idx, rb_intern("seq"), 0);
return na_ndloop(&ndf, 3, self, idx, reduce);
}
|
#median(axis: nil, keepdims: false) ⇒ Numo::Int8
median of self.
5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 |
# File 'ext/numo/narray/types/int8.c', line 5482
static VALUE
int8_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
#line 60 "gen/tmpl/median.c"
ndf.func = iter_int8_median;
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
return na_ndloop(&ndf, 2, self, reduce);
}
|
#min(axis: nil, keepdims: false) ⇒ Numo::Int8
min of self.
3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 |
# File 'ext/numo/narray/types/int8.c', line 3716
static VALUE
int8_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_int8_min, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE, 2, 1, ain, aout };
#line 40 "gen/tmpl/accum.c"
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
v = na_ndloop(&ndf, 2, self, reduce);
return int8_extract(v);
#line 48 "gen/tmpl/accum.c"
}
|
#min_index(axis: nil) ⇒ Integer, Numo::Int
min_index. Return an index of result.
3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 |
# File 'ext/numo/narray/types/int8.c', line 3962
static VALUE
int8_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_int8_min_index_index64;
#line 56 "gen/tmpl/accum_index.c"
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
} else {
aout[0].type = numo_cInt32;
idx = nary_new(numo_cInt32, na->ndim, na->shape);
ndf.func = iter_int8_min_index_index32;
#line 65 "gen/tmpl/accum_index.c"
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
}
rb_funcall(idx, rb_intern("seq"), 0);
return na_ndloop(&ndf, 3, self, idx, reduce);
}
|
#minmax(axis: nil, keepdims: false) ⇒ Numo::Int8
minmax of self.
4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 |
# File 'ext/numo/narray/types/int8.c', line 4025
static VALUE
int8_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_int8_minmax, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE|NDF_EXTRACT, 2,2, ain,aout};
#line 43 "gen/tmpl/minmax.c"
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
return na_ndloop(&ndf, 2, self, reduce);
}
|
#mulsum(other, axis: nil, keepdims: false) ⇒ Numo::NArray
Binary mulsum.
4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 |
# File 'ext/numo/narray/types/int8.c', line 4580
static VALUE
int8_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 int8_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.
2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 |
# File 'ext/numo/narray/types/int8.c', line 2831
static VALUE
int8_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 int8_ne_self(self, other);
} else {
v = rb_funcall(klass, id_cast, 1, self);
return rb_funcall(v, id_ne, 1, other);
}
}
|
#poly(a0, a1, ...) ⇒ Numo::Int8
Polynomial.: a0 + a1x + a2x2 + a3x**3 + … + anxn
4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 |
# File 'ext/numo/narray/types/int8.c', line 4937
static VALUE
int8_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_int8_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 int8_extract(v);
}
|
#prod(axis: nil, keepdims: false) ⇒ Numo::Int8
prod of self.
3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 |
# File 'ext/numo/narray/types/int8.c', line 3672
static VALUE
int8_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_int8_prod, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE, 2, 1, ain, aout };
#line 40 "gen/tmpl/accum.c"
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
v = na_ndloop(&ndf, 2, self, reduce);
return int8_extract(v);
#line 48 "gen/tmpl/accum.c"
}
|
#ptp(axis: nil, keepdims: false) ⇒ Numo::Int8
ptp of self.
3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 |
# File 'ext/numo/narray/types/int8.c', line 3804
static VALUE
int8_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_int8_ptp, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE, 2, 1, ain, aout };
#line 40 "gen/tmpl/accum.c"
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
v = na_ndloop(&ndf, 2, self, reduce);
return int8_extract(v);
#line 48 "gen/tmpl/accum.c"
}
|
#rand([[low],high]) ⇒ Numo::Int8
Generate uniformly distributed random numbers on self narray.
4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 |
# File 'ext/numo/narray/types/int8.c', line 4880
static VALUE
int8_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_int8_rand, FULL_LOOP, 1,0, ain,0};
rb_scan_args(argc, args, "11", &v1, &v2);
if (v2==Qnil) {
g.low = m_zero;
g.max = high = m_num_to_data(v1);
#line 153 "gen/tmpl/rand.c"
} else {
g.low = m_num_to_data(v1);
high = m_num_to_data(v2);
g.max = m_sub(high,g.low);
}
if (high <= g.low) {
rb_raise(rb_eArgError,"high must be larger than low");
}
na_ndloop3(&ndf, &g, 1, self);
return self;
}
|
#reciprocal ⇒ Numo::Int8
Unary reciprocal.
2588 2589 2590 2591 2592 2593 2594 2595 2596 |
# File 'ext/numo/narray/types/int8.c', line 2588
static VALUE
int8_reciprocal(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{cT,0}};
ndfunc_arg_out_t aout[1] = {{cT,0}};
ndfunc_t ndf = {iter_int8_reciprocal, FULL_LOOP, 1,1, ain,aout};
return na_ndloop(&ndf, 1, self);
}
|
#seq([beg,[step]]) ⇒ Numo::Int8 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.
4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 |
# File 'ext/numo/narray/types/int8.c', line 4666
static VALUE
int8_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_int8_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 83 "gen/tmpl/seq.c"
if (vbeg!=Qnil) {g->beg = NUM2DBL(vbeg);}
if (vstep!=Qnil) {g->step = NUM2DBL(vstep);}
#line 90 "gen/tmpl/seq.c"
na_ndloop3(&ndf, g, 1, self);
return self;
}
|
#sign ⇒ Numo::Int8
Unary sign.
2654 2655 2656 2657 2658 2659 2660 2661 2662 |
# File 'ext/numo/narray/types/int8.c', line 2654
static VALUE
int8_sign(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{cT,0}};
ndfunc_arg_out_t aout[1] = {{cT,0}};
ndfunc_t ndf = {iter_int8_sign, FULL_LOOP, 1,1, ain,aout};
return na_ndloop(&ndf, 1, self);
}
|
#sort(axis: nil) ⇒ Numo::Int8
sort of self.
5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 |
# File 'ext/numo/narray/types/int8.c', line 5133
static VALUE
int8_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);
}
#line 42 "gen/tmpl/sort.c"
ndf.func = iter_int8_sort;
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
na_ndloop(&ndf, 2, self, reduce);
return self;
}
|
#sort_index(axis: nil) ⇒ Integer, Numo::Int
sort_index. Returns an index array of sort result.
5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 |
# File 'ext/numo/narray/types/int8.c', line 5399
static VALUE
int8_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);
#line 84 "gen/tmpl/sort_index.c"
ndf.func = int8_index64_qsort;
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
} else {
ain[1].type =
aout[0].type = numo_cInt32;
idx = nary_new(numo_cInt32, na->ndim, na->shape);
#line 96 "gen/tmpl/sort_index.c"
ndf.func = int8_index32_qsort;
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
}
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::Int8
Unary square.
2720 2721 2722 2723 2724 2725 2726 2727 2728 |
# File 'ext/numo/narray/types/int8.c', line 2720
static VALUE
int8_square(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{cT,0}};
ndfunc_arg_out_t aout[1] = {{cT,0}};
ndfunc_t ndf = {iter_int8_square, FULL_LOOP, 1,1, ain,aout};
return na_ndloop(&ndf, 1, self);
}
|
#store(other) ⇒ Numo::Int8
Store elements to Numo::Int8 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/int8.c', line 1010
static VALUE
int8_store(VALUE self, VALUE obj)
{
VALUE r, klass;
klass = CLASS_OF(obj);
if (klass==numo_cInt8) {
int8_store_int8(self,obj);
return self;
}
#line 19 "gen/tmpl/store.c"
if (IS_INTEGER_CLASS(klass) || klass==rb_cFloat || klass==rb_cComplex) {
int8_store_numeric(self,obj);
return self;
}
#line 19 "gen/tmpl/store.c"
if (klass==numo_cBit) {
int8_store_bit(self,obj);
return self;
}
#line 19 "gen/tmpl/store.c"
if (klass==numo_cDFloat) {
int8_store_dfloat(self,obj);
return self;
}
#line 19 "gen/tmpl/store.c"
if (klass==numo_cSFloat) {
int8_store_sfloat(self,obj);
return self;
}
#line 19 "gen/tmpl/store.c"
if (klass==numo_cInt64) {
int8_store_int64(self,obj);
return self;
}
#line 19 "gen/tmpl/store.c"
if (klass==numo_cInt32) {
int8_store_int32(self,obj);
return self;
}
#line 19 "gen/tmpl/store.c"
if (klass==numo_cInt16) {
int8_store_int16(self,obj);
return self;
}
#line 19 "gen/tmpl/store.c"
if (klass==numo_cUInt64) {
int8_store_uint64(self,obj);
return self;
}
#line 19 "gen/tmpl/store.c"
if (klass==numo_cUInt32) {
int8_store_uint32(self,obj);
return self;
}
#line 19 "gen/tmpl/store.c"
if (klass==numo_cUInt16) {
int8_store_uint16(self,obj);
return self;
}
#line 19 "gen/tmpl/store.c"
if (klass==numo_cUInt8) {
int8_store_uint8(self,obj);
return self;
}
#line 19 "gen/tmpl/store.c"
if (klass==numo_cRObject) {
int8_store_robject(self,obj);
return self;
}
#line 19 "gen/tmpl/store.c"
if (klass==rb_cArray) {
int8_store_array(self,obj);
return self;
}
if (IsNArray(obj)) {
r = rb_funcall(obj, rb_intern("coerce_cast"), 1, cT);
if (CLASS_OF(r)==cT) {
int8_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) ⇒ Numo::Int8
sum of self.
3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 |
# File 'ext/numo/narray/types/int8.c', line 3628
static VALUE
int8_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_int8_sum, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE, 2, 1, ain, aout };
#line 40 "gen/tmpl/accum.c"
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
v = na_ndloop(&ndf, 2, self, reduce);
return int8_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/int8.c', line 1466
static VALUE
int8_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_int8_to_a, FULL_LOOP_NIP, 3, 1, ain, aout };
return na_ndloop_cast_narray_to_rarray(&ndf, self, Qnil);
}
|
#|(other) ⇒ Numo::NArray
Binary bit_or.
2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 |
# File 'ext/numo/narray/types/int8.c', line 2964
static VALUE
int8_bit_or(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 int8_bit_or_self(self, other);
} else {
v = rb_funcall(klass, id_cast, 1, self);
return rb_funcall(v, '|', 1, other);
}
}
|
#~ ⇒ Numo::Int8
Unary bit_not.
3103 3104 3105 3106 3107 3108 3109 3110 3111 |
# File 'ext/numo/narray/types/int8.c', line 3103
static VALUE
int8_bit_not(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{cT,0}};
ndfunc_arg_out_t aout[1] = {{cT,0}};
ndfunc_t ndf = {iter_int8_bit_not, FULL_LOOP, 1,1, ain,aout};
return na_ndloop(&ndf, 1, self);
}
|