Class: Numo::SFloat
- Defined in:
- ext/numo/narray/src/t_sfloat.c,
ext/numo/narray/src/t_sfloat.c
Overview
Single precision floating point number (32-bit float) N-dimensional array class.
Defined Under Namespace
Modules: Math
Constant Summary collapse
- UPCAST =
Upcasting rules of SFloat.
hCast- ELEMENT_BIT_SIZE =
Element size of SFloat in bits.
INT2FIX(sizeof(dtype) * 8)
- ELEMENT_BYTE_SIZE =
Element size of SFloat in bytes.
INT2FIX(sizeof(dtype))
- CONTIGUOUS_STRIDE =
Stride size of contiguous SFloat array.
INT2FIX(sizeof(dtype))
- EPSILON =
Machine epsilon of SFloat
M_EPSILON- MAX =
The largest respresentable value of SFloat
M_MAX- MIN =
The smallest respresentable value of SFloat
M_MIN
Constants inherited from NArray
NArray::ALTERNATIVE, NArray::VERSION
Class Method Summary collapse
-
.[](elements) ⇒ Numo::SFloat
Cast object to Numo::SFloat.
-
.cast(array) ⇒ Numo::SFloat
Cast object to Numo::SFloat.
-
.maximum(a1, a2, nan: false) ⇒ Numo::SFloat
Element-wise maximum of two arrays.
-
.minimum(a1, a2, nan: false) ⇒ Numo::SFloat
Element-wise minimum of two arrays.
Instance Method Summary collapse
-
#%(other) ⇒ Numo::NArray
Binary mod.
-
#*(other) ⇒ Numo::NArray
Binary mul.
-
#**(other) ⇒ Numo::NArray
(also: #pow)
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 {|x| ... } ⇒ Numo::NArray
Calls the given block once for each element in self, passing that element as a parameter.
-
#each_with_index {|x, i,j,...| ... } ⇒ 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 {|x, i,j,...| ... } ⇒ 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
#==, alternative?, #append, #argsort, array_type, asarray, #at, byte_size, #byte_size, #byte_swapped?, #cast_to, #coerce, #column_major?, column_stack, concatenate, #concatenate, #contiguous?, #cov, debug=, #debug_info, #deg2rad, #delete, #diag, #diag_indices, diag_indices, #diagonal, #diff, #dot, #dsplit, dstack, #each_over_axis, #empty?, #expand_dims, eye, #flatten, #fliplr, #flipud, #fortran_contiguous?, #free, from_binary, #host_order?, #hsplit, hstack, #initialize, #initialize_copy, #inner, #inplace, #inplace!, #inplace?, #insert, inspect_cols, inspect_cols=, inspect_rows, inspect_rows=, #kron, linspace, logspace, #marshal_dump, #marshal_load, #ndim, #new_fill, new_like, #new_narray, #new_ones, #new_zeros, ones, #out_of_place!, #outer, parse, #percentile, profile, profile=, #rad2deg, #repeat, #reshape, #reshape!, #reverse, #rot90, #row_major?, #shape, #size, #split, #store_binary, #swap_byte, #swapaxes, #tile, #to_binary, #to_c, #to_f, #to_host, #to_i, #to_network, #to_swapped, #to_vacs, #trace, #transpose, #tril, #tril!, #tril_indices, tril_indices, #triu, #triu!, #triu_indices, triu_indices, upcast, #view, #vsplit, vstack, zeros
Constructor Details
This class inherits a constructor from Numo::NArray
Class Method Details
.[](elements) ⇒ Numo::SFloat
Cast object to Numo::SFloat.
.cast(array) ⇒ Numo::SFloat
Cast object to Numo::SFloat.
.maximum(a1, a2, nan: false) ⇒ Numo::SFloat
Element-wise maximum of two arrays.
.minimum(a1, a2, nan: false) ⇒ Numo::SFloat
Element-wise minimum of two arrays.
Instance Method Details
#%(other) ⇒ Numo::NArray
Binary mod.
#*(other) ⇒ Numo::NArray
Binary mul.
#**(other) ⇒ Numo::NArray Also known as: pow
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
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 |
# File 'ext/numo/narray/src/t_sfloat.c', line 349
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);
NA_DATA_PTR(na) = ptr;
NA_DATA_OWNED(na) = TRUE;
}
break;
case NARRAY_VIEW_T:
rb_funcall(NA_VIEW_DATA(na), rb_intern("allocate"), 0);
break;
case NARRAY_FILEMAP_T:
// ptr = ((narray_filemap_t*)na)->ptr;
// to be implemented
default:
rb_bug("invalid narray type : %d", NA_TYPE(na));
}
return self;
}
|
#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]. If either of min or max is nil, one side is clipped.
#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 {|x| ... } ⇒ Numo::NArray
Calls the given block once for each element in self, passing that element as a parameter. For a block ‘{|x| … }`,
#each_with_index {|x, i,j,...| ... } ⇒ 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,…| … }`,
#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 known as: >=
Comparison ge other.
#gt(other) ⇒ Numo::Bit Also known as: >
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 known as: <=
Comparison le 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.
#lt(other) ⇒ Numo::Bit Also known as: <
Comparison lt other.
#map ⇒ Numo::SFloat
Unary map.
#map_with_index {|x, i,j,...| ... } ⇒ 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,…| … }`,
#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 known as: close_to
Comparison nearly_eq other.
#poly(a0, a1, ..., an) ⇒ Numo::SFloat
Calculate polynomial.
`x.poly(a0,a1,a2,...,an) = a0 + a1*x + a2*x**2 + ... + an*x**n`
#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 known as: indgen
Set linear sequence of numbers to self. The sequence is obtained from
beg+i*step
where i is 1-dimensional index.
#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. Returns an index array of sort result.
#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.