Class: Numo::SFloat
Defined Under Namespace
Modules: Math
Constant Summary collapse
- UPCAST =
hCast
- ELEMENT_BIT_SIZE =
INT2FIX(sizeof(dtype)*8)
- ELEMENT_BYTE_SIZE =
INT2FIX(sizeof(dtype))
- CONTIGUOUS_STRIDE =
INT2FIX(sizeof(dtype))
- EPSILON =
M_EPSILON
- MAX =
M_MAX
- MIN =
M_MIN
Constants inherited from NArray
Class Method Summary collapse
-
.[](obj) ⇒ Numo::SFloat
Cast object to Numo::SFloat.
-
.cast(obj) ⇒ Numo::SFloat
Cast object to Numo::SFloat.
-
.maximum(*args) ⇒ Object
-
.minimum(*args) ⇒ Object
Instance Method Summary collapse
-
#%(other) ⇒ Numo::NArray
Binary mod.
-
#*(other) ⇒ Numo::NArray
Binary mul.
-
#**(other) ⇒ Numo::NArray
Binary power.
-
#+(other) ⇒ Numo::NArray
Binary add.
-
#-(other) ⇒ Numo::NArray
Binary sub.
-
#-@ ⇒ Numo::SFloat
Unary minus.
-
#/(other) ⇒ Numo::NArray
Binary div.
-
#[](dim0, ..., dimL) ⇒ Numeric, Numo::SFloat
Multi-dimensional element reference.
-
#[]=(dim0, ..., dimL, val) ⇒ Numeric, ...
Multi-dimensional element assignment.
-
#abs ⇒ Numo::SFloat
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::SFloat
Unary ceil.
-
#clip(min, max) ⇒ Numo::NArray
Clip array elements by [min,max].
-
#coerce_cast(type) ⇒ nil
return NArray with cast to the type of self.
-
#copysign(other) ⇒ Numo::NArray
Binary copysign.
-
#cumprod(axis: nil, nan: false) ⇒ Numo::SFloat
cumprod of self.
-
#cumsum(axis: nil, nan: false) ⇒ Numo::SFloat
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::SFloat
Eye: Set a value to diagonal components, set 0 to non-diagonal components.
-
#fill(other) ⇒ Numo::SFloat
Fill elements with other.
-
#floor ⇒ Numo::SFloat
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::SFloat
Set logarithmic sequence of numbers to self.
-
#lt(other) ⇒ Numo::Bit
(also: #<)
Comparison lt other.
-
#map ⇒ Numo::SFloat
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::SFloat
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::SFloat
mean of self.
-
#median(axis: nil, keepdims: false, nan: false) ⇒ Numo::SFloat
median of self.
-
#min(axis: nil, keepdims: false, nan: false) ⇒ Numo::SFloat
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::SFloat
minmax of self.
-
#modf ⇒ Numo::SFloat
modf of self.
-
#mulsum(other, axis: nil, keepdims: false, nan: false) ⇒ Numo::NArray
Binary mulsum.
-
#ne(other) ⇒ Numo::Bit
Comparison ne other.
-
#nearly_eq(other) ⇒ Numo::Bit
(also: #close_to)
Comparison nearly_eq other.
-
#poly(a0, a1, ..., an) ⇒ Numo::SFloat
Calculate polynomial.
-
#prod(axis: nil, keepdims: false, nan: false) ⇒ Numo::SFloat
prod of self.
-
#ptp(axis: nil, keepdims: false, nan: false) ⇒ Numo::SFloat
ptp of self.
-
#rand([[low],high]) ⇒ Numo::SFloat
Generate uniformly distributed random numbers on self narray.
-
#rand_norm([mu,[sigma]]) ⇒ Numo::SFloat
Generates random numbers from the normal distribution on self narray using Box-Muller Transformation.
-
#reciprocal ⇒ Numo::SFloat
Unary reciprocal.
-
#rint ⇒ Numo::SFloat
Unary rint.
-
#rms(axis: nil, keepdims: false, nan: false) ⇒ Numo::SFloat
rms of self.
-
#round ⇒ Numo::SFloat
Unary round.
-
#seq([beg,[step]]) ⇒ Numo::SFloat
(also: #indgen)
Set linear sequence of numbers to self.
-
#sign ⇒ Numo::SFloat
Unary sign.
-
#signbit ⇒ Numo::Bit
Condition of signbit.
-
#sort(axis: nil, nan: false) ⇒ Numo::SFloat
sort of self.
-
#sort_index(axis: nil, nan: false) ⇒ Integer, Numo::Int
sort_index.
-
#square ⇒ Numo::SFloat
Unary square.
-
#stddev(axis: nil, keepdims: false, nan: false) ⇒ Numo::SFloat
stddev of self.
-
#store(other) ⇒ Numo::SFloat
Store elements to Numo::SFloat from other.
-
#sum(axis: nil, keepdims: false, nan: false) ⇒ Numo::SFloat
sum of self.
-
#to_a ⇒ Array
Convert self to Array.
-
#trunc ⇒ Numo::SFloat
Unary trunc.
-
#var(axis: nil, keepdims: false, nan: false) ⇒ Numo::SFloat
var of self.
Methods inherited from NArray
#==, #append, array_type, asarray, #at, byte_size, #byte_size, #byte_swapped?, #cast_to, #coerce, #column_major?, column_stack, concatenate, #concatenate, #contiguous?, #cov, debug=, #debug_info, #deg2rad, #delete, #diag, #diag_indices, diag_indices, #diagonal, #diff, #dot, #dsplit, dstack, #each_over_axis, #empty?, #expand_dims, eye, #flatten, #fliplr, #flipud, #fortran_contiguous?, #free, from_binary, #host_order?, #hsplit, hstack, #initialize, #initialize_copy, #inner, #inplace, #inplace!, #inplace?, #insert, inspect_cols, inspect_cols=, inspect_rows, inspect_rows=, #kron, linspace, logspace, #marshal_dump, #marshal_load, #ndim, #new_fill, new_like, #new_narray, #new_ones, #new_zeros, ones, #out_of_place!, #outer, parse, 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::SFloat .cast(array) ⇒ Numo::SFloat
Cast object to Numo::SFloat.
1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 |
# File 'ext/numo/narray/types/sfloat.c', line 1278
static VALUE
sfloat_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 sfloat_new_dim0(x);
}
if (RTEST(rb_obj_is_kind_of(obj,rb_cArray))) {
return sfloat_cast_array(obj);
}
if (IsNArray(obj)) {
GetNArray(obj,na);
v = nary_new(cT, NA_NDIM(na), NA_SHAPE(na));
if (NA_SIZE(na) > 0) {
sfloat_store(v,obj);
}
return v;
}
#line 41 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/cast.c"
rb_raise(nary_eCastError,"cannot cast to %s",rb_class2name(type));
return Qnil;
}
|
.[](elements) ⇒ Numo::SFloat .cast(array) ⇒ Numo::SFloat
Cast object to Numo::SFloat.
1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 |
# File 'ext/numo/narray/types/sfloat.c', line 1278
static VALUE
sfloat_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 sfloat_new_dim0(x);
}
if (RTEST(rb_obj_is_kind_of(obj,rb_cArray))) {
return sfloat_cast_array(obj);
}
if (IsNArray(obj)) {
GetNArray(obj,na);
v = nary_new(cT, NA_NDIM(na), NA_SHAPE(na));
if (NA_SIZE(na) > 0) {
sfloat_store(v,obj);
}
return v;
}
#line 41 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/cast.c"
rb_raise(nary_eCastError,"cannot cast to %s",rb_class2name(type));
return Qnil;
}
|
.maximum(*args) ⇒ Object
6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 |
# File 'ext/numo/narray/types/sfloat.c', line 6093
static VALUE
sfloat_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_sfloat_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_sfloat_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
6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 |
# File 'ext/numo/narray/types/sfloat.c', line 6176
static VALUE
sfloat_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_sfloat_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_sfloat_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.
3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 |
# File 'ext/numo/narray/types/sfloat.c', line 3009
static VALUE
sfloat_mod(VALUE self, VALUE other)
{
#line 226 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/binary.c"
VALUE klass, v;
klass = na_upcast(rb_obj_class(self),rb_obj_class(other));
if (klass==cT) {
return sfloat_mod_self(self, other);
} else {
v = rb_funcall(klass, id_cast, 1, self);
return rb_funcall(v, '%', 1, other);
}
}
|
#*(other) ⇒ Numo::NArray
Binary mul.
2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 |
# File 'ext/numo/narray/types/sfloat.c', line 2640
static VALUE
sfloat_mul(VALUE self, VALUE other)
{
#line 226 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/binary.c"
VALUE klass, v;
klass = na_upcast(rb_obj_class(self),rb_obj_class(other));
if (klass==cT) {
return sfloat_mul_self(self, other);
} else {
v = rb_funcall(klass, id_cast, 1, self);
return rb_funcall(v, '*', 1, other);
}
}
|
#**(other) ⇒ Numo::NArray
Binary power.
3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 |
# File 'ext/numo/narray/types/sfloat.c', line 3146
static VALUE
sfloat_pow(VALUE self, VALUE other)
{
#line 69 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/pow.c"
VALUE klass, v;
klass = na_upcast(rb_obj_class(self),rb_obj_class(other));
if (klass==cT) {
return sfloat_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.
2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 |
# File 'ext/numo/narray/types/sfloat.c', line 2180
static VALUE
sfloat_add(VALUE self, VALUE other)
{
#line 226 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/binary.c"
VALUE klass, v;
klass = na_upcast(rb_obj_class(self),rb_obj_class(other));
if (klass==cT) {
return sfloat_add_self(self, other);
} else {
v = rb_funcall(klass, id_cast, 1, self);
return rb_funcall(v, '+', 1, other);
}
}
|
#-(other) ⇒ Numo::NArray
Binary sub.
2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 |
# File 'ext/numo/narray/types/sfloat.c', line 2410
static VALUE
sfloat_sub(VALUE self, VALUE other)
{
#line 226 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/binary.c"
VALUE klass, v;
klass = na_upcast(rb_obj_class(self),rb_obj_class(other));
if (klass==cT) {
return sfloat_sub_self(self, other);
} else {
v = rb_funcall(klass, id_cast, 1, self);
return rb_funcall(v, '-', 1, other);
}
}
|
#-@ ⇒ Numo::SFloat
Unary minus.
3236 3237 3238 3239 3240 3241 3242 3243 3244 |
# File 'ext/numo/narray/types/sfloat.c', line 3236
static VALUE
sfloat_minus(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{cT,0}};
ndfunc_arg_out_t aout[1] = {{cT,0}};
ndfunc_t ndf = {iter_sfloat_minus, FULL_LOOP, 1,1, ain,aout};
return na_ndloop(&ndf, 1, self);
}
|
#/(other) ⇒ Numo::NArray
Binary div.
2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 |
# File 'ext/numo/narray/types/sfloat.c', line 2870
static VALUE
sfloat_div(VALUE self, VALUE other)
{
#line 226 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/binary.c"
VALUE klass, v;
klass = na_upcast(rb_obj_class(self),rb_obj_class(other));
if (klass==cT) {
return sfloat_div_self(self, other);
} else {
v = rb_funcall(klass, id_cast, 1, self);
return rb_funcall(v, '/', 1, other);
}
}
|
#[](dim0, ..., dimL) ⇒ Numeric, Numo::SFloat
Multi-dimensional element reference.
1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 |
# File 'ext/numo/narray/types/sfloat.c', line 1320
static VALUE
sfloat_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.
1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 |
# File 'ext/numo/narray/types/sfloat.c', line 1347
static VALUE
sfloat_aset(int argc, VALUE *argv, VALUE self)
{
int nd;
size_t pos;
char *ptr;
VALUE a;
dtype x;
argc--;
if (argc==0) {
sfloat_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);
sfloat_store(a, argv[argc]);
} else {
x = sfloat_extract_data(argv[argc]);
ptr = na_get_pointer_for_read_write(self) + pos;
*(dtype*)ptr = x;
}
}
return argv[argc];
}
|
#abs ⇒ Numo::SFloat
abs of self.
1957 1958 1959 1960 1961 1962 1963 1964 1965 |
# File 'ext/numo/narray/types/sfloat.c', line 1957
static VALUE
sfloat_abs(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{cT,0}};
ndfunc_arg_out_t aout[1] = {{cRT,0}};
ndfunc_t ndf = { iter_sfloat_abs, FULL_LOOP, 1, 1, ain, aout };
return na_ndloop(&ndf, 1, self);
}
|
#allocate ⇒ Object
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 168 169 170 171 |
# File 'ext/numo/narray/types/sfloat.c', line 143
static VALUE
sfloat_allocate(VALUE self)
{
narray_t *na;
char *ptr;
GetNArray(self,na);
switch(NA_TYPE(na)) {
case NARRAY_DATA_T:
ptr = NA_DATA_PTR(na);
if (na->size > 0 && ptr == NULL) {
ptr = xmalloc(sizeof(dtype) * na->size);
#line 22 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/allocate.c"
NA_DATA_PTR(na) = ptr;
}
break;
case NARRAY_VIEW_T:
rb_funcall(NA_VIEW_DATA(na), rb_intern("allocate"), 0);
break;
case NARRAY_FILEMAP_T:
//ptr = ((narray_filemap_t*)na)->ptr;
// to be implemented
default:
rb_bug("invalid narray type : %d",NA_TYPE(na));
}
return self;
}
|
#argmax(axis: nil, nan: false) ⇒ Integer, Numo::Int
Index of the maximum value.
5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 |
# File 'ext/numo/narray/types/sfloat.c', line 5811
static VALUE
sfloat_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_sfloat_argmax_arg64;
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_sfloat_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_sfloat_argmax_arg32;
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_sfloat_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.
5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 |
# File 'ext/numo/narray/types/sfloat.c', line 5942
static VALUE
sfloat_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_sfloat_argmin_arg64;
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_sfloat_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_sfloat_argmin_arg32;
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_sfloat_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::SFloat
Unary ceil.
3915 3916 3917 3918 3919 3920 3921 3922 3923 |
# File 'ext/numo/narray/types/sfloat.c', line 3915
static VALUE
sfloat_ceil(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{cT,0}};
ndfunc_arg_out_t aout[1] = {{cT,0}};
ndfunc_t ndf = {iter_sfloat_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.
4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 |
# File 'ext/numo/narray/types/sfloat.c', line 4641
static VALUE
sfloat_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_sfloat_clip_min, STRIDE_LOOP, 2, 1, ain, aout };
ndfunc_t ndf_max = { iter_sfloat_clip_max, STRIDE_LOOP, 2, 1, ain, aout };
ndfunc_t ndf_both = { iter_sfloat_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.
1381 1382 1383 1384 1385 |
# File 'ext/numo/narray/types/sfloat.c', line 1381
static VALUE
sfloat_coerce_cast(VALUE self, VALUE type)
{
return Qnil;
}
|
#copysign(other) ⇒ Numo::NArray
Binary copysign.
4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 |
# File 'ext/numo/narray/types/sfloat.c', line 4215
static VALUE
sfloat_copysign(VALUE self, VALUE other)
{
#line 226 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/binary.c"
VALUE klass, v;
klass = na_upcast(rb_obj_class(self),rb_obj_class(other));
if (klass==cT) {
return sfloat_copysign_self(self, other);
} else {
v = rb_funcall(klass, id_cast, 1, self);
return rb_funcall(v, id_copysign, 1, other);
}
}
|
#cumprod(axis: nil, nan: false) ⇒ Numo::SFloat
cumprod of self.
6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 |
# File 'ext/numo/narray/types/sfloat.c', line 6335
static VALUE
sfloat_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_sfloat_cumprod, STRIDE_LOOP|NDF_FLAT_REDUCE|NDF_CUM,
2, 1, ain, aout };
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_sfloat_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::SFloat
cumsum of self.
6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 |
# File 'ext/numo/narray/types/sfloat.c', line 6260
static VALUE
sfloat_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_sfloat_cumsum, STRIDE_LOOP|NDF_FLAT_REDUCE|NDF_CUM,
2, 1, ain, aout };
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_sfloat_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.
3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 |
# File 'ext/numo/narray/types/sfloat.c', line 3066
static VALUE
sfloat_divmod(VALUE self, VALUE other)
{
#line 50 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/binary2.c"
VALUE klass, v;
klass = na_upcast(rb_obj_class(self),rb_obj_class(other));
if (klass==cT) {
return sfloat_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| ... }
,
1644 1645 1646 1647 1648 1649 1650 1651 1652 |
# File 'ext/numo/narray/types/sfloat.c', line 1644
static VALUE
sfloat_each(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{Qnil,0}};
ndfunc_t ndf = {iter_sfloat_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,...| ... }
,
1799 1800 1801 1802 1803 1804 1805 1806 1807 |
# File 'ext/numo/narray/types/sfloat.c', line 1799
static VALUE
sfloat_each_with_index(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{Qnil,0}};
ndfunc_t ndf = {iter_sfloat_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.
3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 |
# File 'ext/numo/narray/types/sfloat.c', line 3542
static VALUE
sfloat_eq(VALUE self, VALUE other)
{
#line 46 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/cond_binary.c"
VALUE klass, v;
klass = na_upcast(rb_obj_class(self),rb_obj_class(other));
if (klass==cT) {
return sfloat_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.
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'ext/numo/narray/types/sfloat.c', line 182
static VALUE
sfloat_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::SFloat
Eye: Set a value to diagonal components, set 0 to non-diagonal components.
6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 |
# File 'ext/numo/narray/types/sfloat.c', line 6699
static VALUE
sfloat_eye(int argc, VALUE *argv, VALUE self)
{
ndfunc_arg_in_t ain[1] = {{OVERWRITE,2}};
ndfunc_t ndf = {iter_sfloat_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::SFloat
Fill elements with other.
1462 1463 1464 1465 1466 1467 1468 1469 1470 |
# File 'ext/numo/narray/types/sfloat.c', line 1462
static VALUE
sfloat_fill(VALUE self, VALUE val)
{
ndfunc_arg_in_t ain[2] = {{OVERWRITE,0},{sym_option}};
ndfunc_t ndf = { iter_sfloat_fill, FULL_LOOP, 2, 0, ain, 0 };
na_ndloop(&ndf, 2, self, val);
return self;
}
|
#floor ⇒ Numo::SFloat
Unary floor.
3747 3748 3749 3750 3751 3752 3753 3754 3755 |
# File 'ext/numo/narray/types/sfloat.c', line 3747
static VALUE
sfloat_floor(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{cT,0}};
ndfunc_arg_out_t aout[1] = {{cT,0}};
ndfunc_t ndf = {iter_sfloat_floor, FULL_LOOP, 1,1, ain,aout};
return na_ndloop(&ndf, 1, self);
}
|
#format(format) ⇒ Numo::RObject
Format elements into strings.
1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 |
# File 'ext/numo/narray/types/sfloat.c', line 1522
static VALUE
sfloat_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_sfloat_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.
1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 |
# File 'ext/numo/narray/types/sfloat.c', line 1573
static VALUE
sfloat_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_sfloat_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.
4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 |
# File 'ext/numo/narray/types/sfloat.c', line 4414
static VALUE
sfloat_ge(VALUE self, VALUE other)
{
#line 46 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/cond_binary.c"
VALUE klass, v;
klass = na_upcast(rb_obj_class(self),rb_obj_class(other));
if (klass==cT) {
return sfloat_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.
4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 |
# File 'ext/numo/narray/types/sfloat.c', line 4357
static VALUE
sfloat_gt(VALUE self, VALUE other)
{
#line 46 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/cond_binary.c"
VALUE klass, v;
klass = na_upcast(rb_obj_class(self),rb_obj_class(other));
if (klass==cT) {
return sfloat_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.
1600 1601 1602 1603 1604 |
# File 'ext/numo/narray/types/sfloat.c', line 1600
static VALUE
sfloat_inspect(VALUE ary)
{
return na_ndloop_inspect(ary, iter_sfloat_inspect, Qnil);
}
|
#isfinite ⇒ Numo::Bit
Condition of isfinite.
4895 4896 4897 4898 4899 4900 4901 4902 4903 |
# File 'ext/numo/narray/types/sfloat.c', line 4895
static VALUE
sfloat_isfinite(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{cT,0}};
ndfunc_arg_out_t aout[1] = {{numo_cBit,0}};
ndfunc_t ndf = { iter_sfloat_isfinite, FULL_LOOP, 1, 1, ain, aout };
return na_ndloop(&ndf, 1, self);
}
|
#isinf ⇒ Numo::Bit
Condition of isinf.
4751 4752 4753 4754 4755 4756 4757 4758 4759 |
# File 'ext/numo/narray/types/sfloat.c', line 4751
static VALUE
sfloat_isinf(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{cT,0}};
ndfunc_arg_out_t aout[1] = {{numo_cBit,0}};
ndfunc_t ndf = { iter_sfloat_isinf, FULL_LOOP, 1, 1, ain, aout };
return na_ndloop(&ndf, 1, self);
}
|
#isnan ⇒ Numo::Bit
Condition of isnan.
4703 4704 4705 4706 4707 4708 4709 4710 4711 |
# File 'ext/numo/narray/types/sfloat.c', line 4703
static VALUE
sfloat_isnan(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{cT,0}};
ndfunc_arg_out_t aout[1] = {{numo_cBit,0}};
ndfunc_t ndf = { iter_sfloat_isnan, FULL_LOOP, 1, 1, ain, aout };
return na_ndloop(&ndf, 1, self);
}
|
#isneginf ⇒ Numo::Bit
Condition of isneginf.
4847 4848 4849 4850 4851 4852 4853 4854 4855 |
# File 'ext/numo/narray/types/sfloat.c', line 4847
static VALUE
sfloat_isneginf(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{cT,0}};
ndfunc_arg_out_t aout[1] = {{numo_cBit,0}};
ndfunc_t ndf = { iter_sfloat_isneginf, FULL_LOOP, 1, 1, ain, aout };
return na_ndloop(&ndf, 1, self);
}
|
#isposinf ⇒ Numo::Bit
Condition of isposinf.
4799 4800 4801 4802 4803 4804 4805 4806 4807 |
# File 'ext/numo/narray/types/sfloat.c', line 4799
static VALUE
sfloat_isposinf(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{cT,0}};
ndfunc_arg_out_t aout[1] = {{numo_cBit,0}};
ndfunc_t ndf = { iter_sfloat_isposinf, FULL_LOOP, 1, 1, ain, aout };
return na_ndloop(&ndf, 1, self);
}
|
#le(other) ⇒ Numo::Bit Also known as: <=
Comparison le other.
4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 |
# File 'ext/numo/narray/types/sfloat.c', line 4528
static VALUE
sfloat_le(VALUE self, VALUE other)
{
#line 46 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/cond_binary.c"
VALUE klass, v;
klass = na_upcast(rb_obj_class(self),rb_obj_class(other));
if (klass==cT) {
return sfloat_le_self(self, other);
} else {
v = rb_funcall(klass, id_cast, 1, self);
return rb_funcall(v, id_le, 1, other);
}
}
|
#logseq(beg, step, [base]) ⇒ Numo::SFloat
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.
6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 |
# File 'ext/numo/narray/types/sfloat.c', line 6636
static VALUE
sfloat_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_sfloat_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.
4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 |
# File 'ext/numo/narray/types/sfloat.c', line 4471
static VALUE
sfloat_lt(VALUE self, VALUE other)
{
#line 46 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/cond_binary.c"
VALUE klass, v;
klass = na_upcast(rb_obj_class(self),rb_obj_class(other));
if (klass==cT) {
return sfloat_lt_self(self, other);
} else {
v = rb_funcall(klass, id_cast, 1, self);
return rb_funcall(v, id_lt, 1, other);
}
}
|
#map ⇒ Numo::SFloat
Unary map.
1728 1729 1730 1731 1732 1733 1734 1735 1736 |
# File 'ext/numo/narray/types/sfloat.c', line 1728
static VALUE
sfloat_map(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{cT,0}};
ndfunc_arg_out_t aout[1] = {{cT,0}};
ndfunc_t ndf = {iter_sfloat_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,...| ... }
,
1896 1897 1898 1899 1900 1901 1902 1903 1904 |
# File 'ext/numo/narray/types/sfloat.c', line 1896
static VALUE
sfloat_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_sfloat_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::SFloat
max of self.
5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 |
# File 'ext/numo/narray/types/sfloat.c', line 5358
static VALUE
sfloat_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_sfloat_max, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE, 2, 1, ain, aout };
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_sfloat_max_nan);
#line 42 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum.c"
v = na_ndloop(&ndf, 2, self, reduce);
return sfloat_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.
5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 |
# File 'ext/numo/narray/types/sfloat.c', line 5539
static VALUE
sfloat_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_sfloat_max_index_index64;
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_sfloat_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_sfloat_max_index_index32;
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_sfloat_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::SFloat
mean of self.
5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 |
# File 'ext/numo/narray/types/sfloat.c', line 5063
static VALUE
sfloat_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_sfloat_mean, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE, 2, 1, ain, aout };
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_sfloat_mean_nan);
#line 42 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum.c"
v = na_ndloop(&ndf, 2, self, reduce);
return sfloat_extract(v);
#line 48 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum.c"
}
|
#median(axis: nil, keepdims: false, nan: false) ⇒ Numo::SFloat
median of self.
8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 |
# File 'ext/numo/narray/types/sfloat.c', line 8235
static VALUE
sfloat_median(int argc, VALUE *argv, VALUE self)
{
VALUE v, reduce;
ndfunc_arg_in_t ain[2] = {{OVERWRITE,0},{sym_reduce,0}};
ndfunc_arg_out_t aout[1] = {{INT2FIX(0),0}};
ndfunc_t ndf = {0, NDF_HAS_LOOP|NDF_FLAT_REDUCE, 2,1, ain,aout};
self = na_copy(self); // as temporary buffer
ndf.func = iter_sfloat_median_ignan;
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_sfloat_median_prnan);
#line 63 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/median.c"
v = na_ndloop(&ndf, 2, self, reduce);
return sfloat_extract(v);
}
|
#min(axis: nil, keepdims: false, nan: false) ⇒ Numo::SFloat
min of self.
5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 |
# File 'ext/numo/narray/types/sfloat.c', line 5299
static VALUE
sfloat_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_sfloat_min, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE, 2, 1, ain, aout };
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_sfloat_min_nan);
#line 42 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum.c"
v = na_ndloop(&ndf, 2, self, reduce);
return sfloat_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.
5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 |
# File 'ext/numo/narray/types/sfloat.c', line 5677
static VALUE
sfloat_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_sfloat_min_index_index64;
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_sfloat_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_sfloat_min_index_index32;
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_sfloat_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::SFloat
minmax of self.
6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 |
# File 'ext/numo/narray/types/sfloat.c', line 6020
static VALUE
sfloat_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_sfloat_minmax, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE|NDF_EXTRACT, 2,2, ain,aout};
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_sfloat_minmax_nan);
#line 45 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/minmax.c"
return na_ndloop(&ndf, 2, self, reduce);
}
|
#modf ⇒ Numo::SFloat
modf of self.
4306 4307 4308 4309 4310 4311 4312 4313 4314 |
# File 'ext/numo/narray/types/sfloat.c', line 4306
static VALUE
sfloat_modf(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{cT,0}};
ndfunc_arg_out_t aout[2] = {{cT,0},{cT,0}};
ndfunc_t ndf = {iter_sfloat_modf, STRIDE_LOOP, 1,2, ain,aout};
return na_ndloop(&ndf, 1, self);
}
|
#mulsum(other, axis: nil, keepdims: false, nan: false) ⇒ Numo::NArray
Binary mulsum.
6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 |
# File 'ext/numo/narray/types/sfloat.c', line 6462
static VALUE
sfloat_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 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum_binary.c"
klass = na_upcast(rb_obj_class(self),rb_obj_class(argv[0]));
if (klass==cT) {
return sfloat_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.
3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 |
# File 'ext/numo/narray/types/sfloat.c', line 3599
static VALUE
sfloat_ne(VALUE self, VALUE other)
{
#line 46 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/cond_binary.c"
VALUE klass, v;
klass = na_upcast(rb_obj_class(self),rb_obj_class(other));
if (klass==cT) {
return sfloat_ne_self(self, other);
} else {
v = rb_funcall(klass, id_cast, 1, self);
return rb_funcall(v, id_ne, 1, other);
}
}
|
#nearly_eq(other) ⇒ Numo::Bit Also known as: close_to
Comparison nearly_eq other.
3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 |
# File 'ext/numo/narray/types/sfloat.c', line 3656
static VALUE
sfloat_nearly_eq(VALUE self, VALUE other)
{
#line 46 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/cond_binary.c"
VALUE klass, v;
klass = na_upcast(rb_obj_class(self),rb_obj_class(other));
if (klass==cT) {
return sfloat_nearly_eq_self(self, other);
} else {
v = rb_funcall(klass, id_cast, 1, self);
return rb_funcall(v, id_nearly_eq, 1, other);
}
}
|
#poly(a0, a1, ..., an) ⇒ Numo::SFloat
Calculate polynomial.
x.poly(a0,a1,a2,...,an) = a0 + a1*x + a2*x**2 + ... + an*x**n
6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 |
# File 'ext/numo/narray/types/sfloat.c', line 6989
static VALUE
sfloat_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_sfloat_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 sfloat_extract(v);
}
|
#prod(axis: nil, keepdims: false, nan: false) ⇒ Numo::SFloat
prod of self.
5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 |
# File 'ext/numo/narray/types/sfloat.c', line 5004
static VALUE
sfloat_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_sfloat_prod, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE, 2, 1, ain, aout };
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_sfloat_prod_nan);
#line 42 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum.c"
v = na_ndloop(&ndf, 2, self, reduce);
return sfloat_extract(v);
#line 48 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum.c"
}
|
#ptp(axis: nil, keepdims: false, nan: false) ⇒ Numo::SFloat
ptp of self.
5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 |
# File 'ext/numo/narray/types/sfloat.c', line 5417
static VALUE
sfloat_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_sfloat_ptp, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE, 2, 1, ain, aout };
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_sfloat_ptp_nan);
#line 42 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum.c"
v = na_ndloop(&ndf, 2, self, reduce);
return sfloat_extract(v);
#line 48 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum.c"
}
|
#rand([[low],high]) ⇒ Numo::SFloat
Generate uniformly distributed random numbers on self narray.
6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 |
# File 'ext/numo/narray/types/sfloat.c', line 6815
static VALUE
sfloat_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_sfloat_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;
}
|
#rand_norm([mu,[sigma]]) ⇒ Numo::SFloat
Generates random numbers from the normal distribution on self narray using Box-Muller Transformation.
6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 |
# File 'ext/numo/narray/types/sfloat.c', line 6938
static VALUE
sfloat_rand_norm(int argc, VALUE *args, VALUE self)
{
int n;
randn_opt_t g;
VALUE v1=Qnil, v2=Qnil;
ndfunc_arg_in_t ain[1] = {{OVERWRITE,0}};
ndfunc_t ndf = {iter_sfloat_rand_norm, FULL_LOOP, 1,0, ain,0};
n = rb_scan_args(argc, args, "02", &v1, &v2);
if (n == 0) {
g.mu = m_zero;
} else {
g.mu = m_num_to_data(v1);
}
if (n == 2) {
g.sigma = NUM2DBL(v2);
} else {
g.sigma = 1;
}
na_ndloop3(&ndf, &g, 1, self);
return self;
}
|
#reciprocal ⇒ Numo::SFloat
Unary reciprocal.
3320 3321 3322 3323 3324 3325 3326 3327 3328 |
# File 'ext/numo/narray/types/sfloat.c', line 3320
static VALUE
sfloat_reciprocal(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{cT,0}};
ndfunc_arg_out_t aout[1] = {{cT,0}};
ndfunc_t ndf = {iter_sfloat_reciprocal, FULL_LOOP, 1,1, ain,aout};
return na_ndloop(&ndf, 1, self);
}
|
#rint ⇒ Numo::SFloat
Unary rint.
4083 4084 4085 4086 4087 4088 4089 4090 4091 |
# File 'ext/numo/narray/types/sfloat.c', line 4083
static VALUE
sfloat_rint(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{cT,0}};
ndfunc_arg_out_t aout[1] = {{cT,0}};
ndfunc_t ndf = {iter_sfloat_rint, FULL_LOOP, 1,1, ain,aout};
return na_ndloop(&ndf, 1, self);
}
|
#rms(axis: nil, keepdims: false, nan: false) ⇒ Numo::SFloat
rms of self.
5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 |
# File 'ext/numo/narray/types/sfloat.c', line 5240
static VALUE
sfloat_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_sfloat_rms, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE, 2, 1, ain, aout };
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_sfloat_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::SFloat
Unary round.
3831 3832 3833 3834 3835 3836 3837 3838 3839 |
# File 'ext/numo/narray/types/sfloat.c', line 3831
static VALUE
sfloat_round(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{cT,0}};
ndfunc_arg_out_t aout[1] = {{cT,0}};
ndfunc_t ndf = {iter_sfloat_round, FULL_LOOP, 1,1, ain,aout};
return na_ndloop(&ndf, 1, self);
}
|
#seq([beg,[step]]) ⇒ Numo::SFloat 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.
6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 |
# File 'ext/numo/narray/types/sfloat.c', line 6549
static VALUE
sfloat_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_sfloat_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::SFloat
Unary sign.
3404 3405 3406 3407 3408 3409 3410 3411 3412 |
# File 'ext/numo/narray/types/sfloat.c', line 3404
static VALUE
sfloat_sign(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{cT,0}};
ndfunc_arg_out_t aout[1] = {{cT,0}};
ndfunc_t ndf = {iter_sfloat_sign, FULL_LOOP, 1,1, ain,aout};
return na_ndloop(&ndf, 1, self);
}
|
#signbit ⇒ Numo::Bit
Condition of signbit.
4270 4271 4272 4273 4274 4275 4276 4277 4278 |
# File 'ext/numo/narray/types/sfloat.c', line 4270
static VALUE
sfloat_signbit(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{cT,0}};
ndfunc_arg_out_t aout[1] = {{numo_cBit,0}};
ndfunc_t ndf = { iter_sfloat_signbit, FULL_LOOP, 1, 1, ain, aout };
return na_ndloop(&ndf, 1, self);
}
|
#sort(axis: nil, nan: false) ⇒ Numo::SFloat
sort of self.
7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 |
# File 'ext/numo/narray/types/sfloat.c', line 7479
static VALUE
sfloat_sort(int argc, VALUE *argv, VALUE self)
{
VALUE reduce;
ndfunc_arg_in_t ain[2] = {{OVERWRITE,0},{sym_reduce,0}};
ndfunc_t ndf = {0, NDF_HAS_LOOP|NDF_FLAT_REDUCE, 2,0, ain,0};
if (!TEST_INPLACE(self)) {
self = na_copy(self);
}
ndf.func = iter_sfloat_sort_ignan;
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_sfloat_sort_prnan);
#line 45 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/sort.c"
na_ndloop(&ndf, 2, self, reduce);
return self;
}
|
#sort_index(axis: nil, nan: false) ⇒ Integer, Numo::Int
sort_index. Returns an index array of sort result.
8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 |
# File 'ext/numo/narray/types/sfloat.c', line 8115
static VALUE
sfloat_sort_index(int argc, VALUE *argv, VALUE self)
{
size_t size;
narray_t *na;
VALUE idx, tmp, reduce, res;
char *buf;
ndfunc_arg_in_t ain[3] = {{cT,0},{0,0},{sym_reduce,0}};
ndfunc_arg_out_t aout[1] = {{0,0,0}};
ndfunc_t ndf = {0, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE|NDF_CUM, 3,1, ain,aout};
GetNArray(self,na);
if (na->ndim==0) {
return INT2FIX(0);
}
if (na->size > (~(u_int32_t)0)) {
ain[1].type =
aout[0].type = numo_cInt64;
idx = nary_new(numo_cInt64, na->ndim, na->shape);
ndf.func = sfloat_index64_qsort_ignan;
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf,
sfloat_index64_qsort_prnan);
#line 87 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/sort_index.c"
} else {
ain[1].type =
aout[0].type = numo_cInt32;
idx = nary_new(numo_cInt32, na->ndim, na->shape);
ndf.func = sfloat_index32_qsort_ignan;
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf,
sfloat_index32_qsort_prnan);
#line 99 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/sort_index.c"
}
rb_funcall(idx, rb_intern("seq"), 0);
size = na->size*sizeof(void*); // max capa
buf = rb_alloc_tmp_buffer(&tmp, size);
res = na_ndloop3(&ndf, buf, 3, self, idx, reduce);
rb_free_tmp_buffer(&tmp);
return res;
}
|
#square ⇒ Numo::SFloat
Unary square.
3488 3489 3490 3491 3492 3493 3494 3495 3496 |
# File 'ext/numo/narray/types/sfloat.c', line 3488
static VALUE
sfloat_square(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{cT,0}};
ndfunc_arg_out_t aout[1] = {{cT,0}};
ndfunc_t ndf = {iter_sfloat_square, FULL_LOOP, 1,1, ain,aout};
return na_ndloop(&ndf, 1, self);
}
|
#stddev(axis: nil, keepdims: false, nan: false) ⇒ Numo::SFloat
stddev of self.
5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 |
# File 'ext/numo/narray/types/sfloat.c', line 5122
static VALUE
sfloat_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_sfloat_stddev, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE, 2, 1, ain, aout };
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_sfloat_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::SFloat
Store elements to Numo::SFloat from other.
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 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 |
# File 'ext/numo/narray/types/sfloat.c', line 1026
static VALUE
sfloat_store(VALUE self, VALUE obj)
{
VALUE r, klass;
klass = rb_obj_class(obj);
if (klass==numo_cSFloat) {
sfloat_store_sfloat(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) {
sfloat_store_numeric(self,obj);
return self;
}
#line 19 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/store.c"
if (klass==numo_cBit) {
sfloat_store_bit(self,obj);
return self;
}
#line 19 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/store.c"
if (klass==numo_cDFloat) {
sfloat_store_dfloat(self,obj);
return self;
}
#line 19 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/store.c"
if (klass==numo_cInt64) {
sfloat_store_int64(self,obj);
return self;
}
#line 19 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/store.c"
if (klass==numo_cInt32) {
sfloat_store_int32(self,obj);
return self;
}
#line 19 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/store.c"
if (klass==numo_cInt16) {
sfloat_store_int16(self,obj);
return self;
}
#line 19 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/store.c"
if (klass==numo_cInt8) {
sfloat_store_int8(self,obj);
return self;
}
#line 19 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/store.c"
if (klass==numo_cUInt64) {
sfloat_store_uint64(self,obj);
return self;
}
#line 19 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/store.c"
if (klass==numo_cUInt32) {
sfloat_store_uint32(self,obj);
return self;
}
#line 19 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/store.c"
if (klass==numo_cUInt16) {
sfloat_store_uint16(self,obj);
return self;
}
#line 19 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/store.c"
if (klass==numo_cUInt8) {
sfloat_store_uint8(self,obj);
return self;
}
#line 19 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/store.c"
if (klass==numo_cRObject) {
sfloat_store_robject(self,obj);
return self;
}
#line 19 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/store.c"
if (klass==rb_cArray) {
sfloat_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) {
sfloat_store(self,r);
return self;
}
}
#line 36 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/store.c"
rb_raise(nary_eCastError, "unknown conversion from %s to %s",
rb_class2name(rb_obj_class(obj)),
rb_class2name(rb_obj_class(self)));
return self;
}
|
#sum(axis: nil, keepdims: false, nan: false) ⇒ Numo::SFloat
sum of self.
4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 |
# File 'ext/numo/narray/types/sfloat.c', line 4945
static VALUE
sfloat_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_sfloat_sum, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE, 2, 1, ain, aout };
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_sfloat_sum_nan);
#line 42 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum.c"
v = na_ndloop(&ndf, 2, self, reduce);
return sfloat_extract(v);
#line 48 "/home/masa/numo/numo-narray/ext/numo/narray/gen/tmpl/accum.c"
}
|
#to_a ⇒ Array
Convert self to Array.
1422 1423 1424 1425 1426 1427 1428 1429 |
# File 'ext/numo/narray/types/sfloat.c', line 1422
static VALUE
sfloat_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_sfloat_to_a, FULL_LOOP_NIP, 3, 1, ain, aout };
return na_ndloop_cast_narray_to_rarray(&ndf, self, Qnil);
}
|
#trunc ⇒ Numo::SFloat
Unary trunc.
3999 4000 4001 4002 4003 4004 4005 4006 4007 |
# File 'ext/numo/narray/types/sfloat.c', line 3999
static VALUE
sfloat_trunc(VALUE self)
{
ndfunc_arg_in_t ain[1] = {{cT,0}};
ndfunc_arg_out_t aout[1] = {{cT,0}};
ndfunc_t ndf = {iter_sfloat_trunc, FULL_LOOP, 1,1, ain,aout};
return na_ndloop(&ndf, 1, self);
}
|
#var(axis: nil, keepdims: false, nan: false) ⇒ Numo::SFloat
var of self.
5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 |
# File 'ext/numo/narray/types/sfloat.c', line 5181
static VALUE
sfloat_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_sfloat_var, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE, 2, 1, ain, aout };
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_sfloat_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);
}
|