Class: Numo::RObject
- Defined in:
- ext/numo/narray/src/t_robject.c,
ext/numo/narray/src/t_robject.c
Overview
Ruby object N-dimensional array class.
Constant Summary collapse
- UPCAST =
Upcasting rules of RObject.
hCast- ELEMENT_BIT_SIZE =
Element size of RObject in bits.
INT2FIX(sizeof(dtype) * 8)
- ELEMENT_BYTE_SIZE =
Element size of RObject in bytes.
INT2FIX(sizeof(dtype))
- CONTIGUOUS_STRIDE =
Stride size of contiguous RObject array.
INT2FIX(sizeof(dtype))
Constants inherited from NArray
NArray::ALTERNATIVE, NArray::VERSION
Class Method Summary collapse
- .[] ⇒ Object
-
.cast ⇒ Object
Cast object to Numo::RObject.
-
.maximum(a1, a2, nan: false) ⇒ Numo::RObject
Element-wise maximum of two arrays.
-
.minimum(a1, a2, nan: false) ⇒ Numo::RObject
Element-wise minimum of two arrays.
Instance Method Summary collapse
-
#%(other) ⇒ Numo::NArray
Binary mod.
-
#&(other) ⇒ Numo::NArray
Binary bit_and.
-
#*(other) ⇒ Numo::NArray
Binary mul.
-
#**(other) ⇒ Numo::NArray
(also: #pow)
Binary power.
-
#+(other) ⇒ Numo::NArray
Binary add.
-
#-(other) ⇒ Numo::NArray
Binary sub.
-
#-@ ⇒ Numo::RObject
Unary minus.
-
#/(other) ⇒ Numo::NArray
Binary div.
-
#<<(other) ⇒ Numo::NArray
Binary left_shift.
-
#>>(other) ⇒ Numo::NArray
Binary right_shift.
-
#[](dim0, ..., dimL) ⇒ Numeric, Numo::RObject
Multi-dimensional element reference.
-
#[]=(dim0, ..., dimL, val) ⇒ Numeric, ...
Multi-dimensional element assignment.
-
#^(other) ⇒ Numo::NArray
Binary bit_xor.
-
#abs ⇒ Numo::RObject
abs of self.
- #allocate ⇒ Object
-
#argmax(axis: nil, nan: false) ⇒ Integer, Numo::Int
Index of the maximum value.
-
#argmin(axis: nil, nan: false) ⇒ Integer, Numo::Int
Index of the minimum value.
-
#ceil ⇒ Numo::RObject
Unary ceil.
-
#clip(min, max) ⇒ Numo::NArray
Clip array elements by [min,max].
-
#coerce_cast(type) ⇒ nil
return NArray with cast to the type of self.
-
#cumprod(axis: nil, nan: false) ⇒ Numo::RObject
cumprod of self.
-
#cumsum(axis: nil, nan: false) ⇒ Numo::RObject
cumsum of self.
-
#divmod(other) ⇒ Numo::NArray
Binary divmod.
-
#each {|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::RObject
Eye: Set a value to diagonal components, set 0 to non-diagonal components.
-
#fill(other) ⇒ Numo::RObject
Fill elements with other.
-
#floor ⇒ Numo::RObject
Unary floor.
-
#format(format) ⇒ Numo::RObject
Format elements into strings.
-
#format_to_a(format) ⇒ Array
Format elements into strings.
-
#ge(other) ⇒ Numo::Bit
(also: #>=)
Comparison ge other.
-
#gt(other) ⇒ Numo::Bit
(also: #>)
Comparison gt other.
-
#inspect ⇒ String
Returns a string containing a human-readable representation of NArray.
-
#isfinite ⇒ Numo::Bit
Condition of isfinite.
-
#isinf ⇒ Numo::Bit
Condition of isinf.
-
#isnan ⇒ Numo::Bit
Condition of isnan.
-
#isneginf ⇒ Numo::Bit
Condition of isneginf.
-
#isposinf ⇒ Numo::Bit
Condition of isposinf.
-
#le(other) ⇒ Numo::Bit
(also: #<=)
Comparison le other.
-
#logseq(beg, step, [base]) ⇒ Numo::RObject
Set logarithmic sequence of numbers to self.
-
#lt(other) ⇒ Numo::Bit
(also: #<)
Comparison lt other.
-
#map ⇒ Numo::RObject
Unary map.
-
#map_with_index {|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::RObject
max of self.
-
#max_index(axis: nil, nan: false) ⇒ Integer, Numo::Int
Index of the maximum value.
-
#mean(axis: nil, keepdims: false, nan: false) ⇒ Numo::RObject
mean of self.
-
#min(axis: nil, keepdims: false, nan: false) ⇒ Numo::RObject
min of self.
-
#min_index(axis: nil, nan: false) ⇒ Integer, Numo::Int
Index of the minimum value.
-
#minmax(axis: nil, keepdims: false, nan: false) ⇒ Numo::RObject
minmax of self.
-
#mulsum(other, axis: nil, keepdims: false, nan: false) ⇒ Numo::NArray
Binary mulsum.
-
#ne(other) ⇒ Numo::Bit
Comparison ne other.
-
#nearly_eq(other) ⇒ Numo::Bit
(also: #close_to)
Comparison nearly_eq other.
-
#poly(a0, a1, ..., an) ⇒ Numo::RObject
Calculate polynomial.
-
#prod(axis: nil, keepdims: false, nan: false) ⇒ Numo::RObject
prod of self.
-
#ptp(axis: nil, keepdims: false, nan: false) ⇒ Numo::RObject
ptp of self.
-
#rand([[low],high]) ⇒ Numo::RObject
Generate uniformly distributed random numbers on self narray.
-
#reciprocal ⇒ Numo::RObject
Unary reciprocal.
-
#rms(axis: nil, keepdims: false, nan: false) ⇒ Numo::RObject
rms of self.
-
#round ⇒ Numo::RObject
Unary round.
-
#seq([beg,[step]]) ⇒ Numo::RObject
(also: #indgen)
Set linear sequence of numbers to self.
-
#sign ⇒ Numo::RObject
Unary sign.
-
#square ⇒ Numo::RObject
Unary square.
-
#stddev(axis: nil, keepdims: false, nan: false) ⇒ Numo::RObject
stddev of self.
-
#store(other) ⇒ Numo::RObject
Store elements to Numo::RObject from other.
-
#sum(axis: nil, keepdims: false, nan: false) ⇒ Numo::RObject
sum of self.
-
#to_a ⇒ Array
Convert self to Array.
-
#trunc ⇒ Numo::RObject
Unary trunc.
-
#var(axis: nil, keepdims: false, nan: false) ⇒ Numo::RObject
var of self.
-
#|(other) ⇒ Numo::NArray
Binary bit_or.
-
#~ ⇒ Numo::RObject
Unary bit_not.
Methods inherited from NArray
#==, 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
.[] ⇒ Object
.[](elements) ⇒ Object .cast(array) ⇒ Numo::RObject
Cast object to Numo::RObject.
.maximum(a1, a2, nan: false) ⇒ Numo::RObject
Element-wise maximum of two arrays.
.minimum(a1, a2, nan: false) ⇒ Numo::RObject
Element-wise minimum of two arrays.
Instance Method Details
#%(other) ⇒ Numo::NArray
Binary mod.
#&(other) ⇒ Numo::NArray
Binary bit_and.
#*(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::RObject
Unary minus.
#/(other) ⇒ Numo::NArray
Binary div.
#<<(other) ⇒ Numo::NArray
Binary left_shift.
#>>(other) ⇒ Numo::NArray
Binary right_shift.
#[](dim0, ..., dimL) ⇒ Numeric, Numo::RObject
Multi-dimensional element reference.
#[]=(dim0, ..., dimL, val) ⇒ Numeric, ...
Multi-dimensional element assignment.
#^(other) ⇒ Numo::NArray
Binary bit_xor.
#abs ⇒ Numo::RObject
abs of self.
#allocate ⇒ Object
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
# File 'ext/numo/narray/src/t_robject.c', line 301
static VALUE robject_allocate(VALUE self) {
narray_t* na;
char* ptr;
GetNArray(self, na);
switch (NA_TYPE(na)) {
case NARRAY_DATA_T:
ptr = NA_DATA_PTR(na);
if (na->size > 0 && ptr == NULL) {
ptr = xmalloc(sizeof(dtype) * na->size);
{
size_t i;
VALUE* a = (VALUE*)ptr;
for (i = na->size; i--;) {
*a++ = Qnil;
}
}
NA_DATA_PTR(na) = ptr;
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::RObject
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.
#cumprod(axis: nil, nan: false) ⇒ Numo::RObject
cumprod of self.
#cumsum(axis: nil, nan: false) ⇒ Numo::RObject
cumsum of self.
#divmod(other) ⇒ Numo::NArray
Binary divmod.
#each {|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::RObject
Eye: Set a value to diagonal components, set 0 to non-diagonal components.
#fill(other) ⇒ Numo::RObject
Fill elements with other.
#floor ⇒ Numo::RObject
Unary floor.
#format(format) ⇒ Numo::RObject
Format elements into strings.
#format_to_a(format) ⇒ Array
Format elements into strings.
#ge(other) ⇒ Numo::Bit Also 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::RObject
Set logarithmic sequence of numbers to self. The sequence is obtained from
`base**(beg+i*step)`
where i is 1-dimensional index. Applicable classes: DFloat, SFloat, DComplex, SCopmplex.
#lt(other) ⇒ Numo::Bit Also known as: <
Comparison lt other.
#map ⇒ Numo::RObject
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`.
#max(axis: nil, keepdims: false, nan: false) ⇒ Numo::RObject
max of self.
#max_index(axis: nil, nan: false) ⇒ Integer, Numo::Int
Index of the maximum value.
#mean(axis: nil, keepdims: false, nan: false) ⇒ Numo::RObject
mean of self.
#min(axis: nil, keepdims: false, nan: false) ⇒ Numo::RObject
min of self.
#min_index(axis: nil, nan: false) ⇒ Integer, Numo::Int
Index of the minimum value.
#minmax(axis: nil, keepdims: false, nan: false) ⇒ Numo::RObject
minmax of self.
#mulsum(other, axis: nil, keepdims: false, nan: false) ⇒ Numo::NArray
Binary mulsum.
#ne(other) ⇒ Numo::Bit
Comparison ne other.
#nearly_eq(other) ⇒ Numo::Bit Also known as: close_to
Comparison nearly_eq other.
#poly(a0, a1, ..., an) ⇒ Numo::RObject
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::RObject
prod of self.
#ptp(axis: nil, keepdims: false, nan: false) ⇒ Numo::RObject
ptp of self.
#rand([[low],high]) ⇒ Numo::RObject
Generate uniformly distributed random numbers on self narray.
#reciprocal ⇒ Numo::RObject
Unary reciprocal.
#rms(axis: nil, keepdims: false, nan: false) ⇒ Numo::RObject
rms of self.
#round ⇒ Numo::RObject
Unary round.
#seq([beg,[step]]) ⇒ Numo::RObject Also 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::RObject
Unary sign.
#square ⇒ Numo::RObject
Unary square.
#stddev(axis: nil, keepdims: false, nan: false) ⇒ Numo::RObject
stddev of self.
#store(other) ⇒ Numo::RObject
Store elements to Numo::RObject from other.
#sum(axis: nil, keepdims: false, nan: false) ⇒ Numo::RObject
sum of self.
#to_a ⇒ Array
Convert self to Array.
#trunc ⇒ Numo::RObject
Unary trunc.
#var(axis: nil, keepdims: false, nan: false) ⇒ Numo::RObject
var of self.
#|(other) ⇒ Numo::NArray
Binary bit_or.
#~ ⇒ Numo::RObject
Unary bit_not.