Class: Numo::DFloat

Inherits:
NArray show all
Defined in:
ext/numo/narray/src/t_dfloat.c,
ext/numo/narray/src/t_dfloat.c

Overview

Double precision floating point number (64-bit float) N-dimensional array class.

Defined Under Namespace

Modules: Math

Constant Summary collapse

UPCAST =

Upcasting rules of DFloat.

hCast
ELEMENT_BIT_SIZE =

Element size of DFloat in bits.

INT2FIX(sizeof(dtype) * 8)
ELEMENT_BYTE_SIZE =

Element size of DFloat in bytes.

INT2FIX(sizeof(dtype))
CONTIGUOUS_STRIDE =

Stride size of contiguous DFloat array.

INT2FIX(sizeof(dtype))
EPSILON =

Machine epsilon of DFloat.

M_EPSILON
MAX =

The largest representable value of DFloat.

M_MAX
MIN =

The smallest representable value of DFloat.

M_MIN

Constants inherited from NArray

NArray::ALTERNATIVE, NArray::VERSION

Class Method Summary collapse

Instance Method Summary collapse

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::DFloat

Cast object to Numo::DFloat.

Parameters:

  • elements (Numeric, Array)
  • array (Array)

Returns:

.cast(array) ⇒ Numo::DFloat

Cast object to Numo::DFloat.

Parameters:

  • elements (Numeric, Array)
  • array (Array)

Returns:

.maximum(a1, a2, nan: false) ⇒ Numo::DFloat

Element-wise maximum of two arrays.

Parameters:

  • a1 (Numo::NArray, Numeric)

    The array to be compared.

  • a2 (Numo::NArray, Numeric)

    The array to be compared.

  • nan (Boolean) (defaults to: false)

    If true, apply NaN-aware algorithm (return NaN if exist).

Returns:

.minimum(a1, a2, nan: false) ⇒ Numo::DFloat

Element-wise minimum of two arrays.

Parameters:

  • a1 (Numo::NArray, Numeric)

    The array to be compared.

  • a2 (Numo::NArray, Numeric)

    The array to be compared.

  • nan (Boolean) (defaults to: false)

    If true, apply NaN-aware algorithm (return NaN if exist).

Returns:

Instance Method Details

#%(other) ⇒ Numo::NArray

Binary mod.

Returns self % other.

Parameters:

Returns:

#*(other) ⇒ Numo::NArray

Binary mul.

Returns self * other.

Parameters:

Returns:

#**(other) ⇒ Numo::NArray Also known as: pow

Binary power.

Returns self to the other-th power.

Parameters:

Returns:

#+(other) ⇒ Numo::NArray

Binary add.

Returns self + other.

Parameters:

Returns:

#-(other) ⇒ Numo::NArray

Binary sub.

Returns self - other.

Parameters:

Returns:

#-@Numo::DFloat

Unary minus.

Returns minus of self.

Returns:

#/(other) ⇒ Numo::NArray

Binary div.

Returns self / other.

Parameters:

Returns:

#[](dim0, ..., dimL) ⇒ Numeric, Numo::DFloat

Multi-dimensional element reference.

Returns an element or NArray view.

Parameters:

Returns:

See Also:

#[]=(dim0, ..., dimL, val) ⇒ Numeric, ...

Multi-dimensional element assignment.

Returns ‘val` (last argument).

Parameters:

Returns:

  • (Numeric, Numo::NArray, Array)

    returns ‘val` (last argument).

See Also:

#absNumo::DFloat

abs of self.

Returns abs of self.

Returns:

#allocateObject



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
376
377
# File 'ext/numo/narray/src/t_dfloat.c', line 351

static VALUE dfloat_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.

Examples:

a = Numo::NArray[3,4,1,2]
a.argmax  #=> 1

b = Numo::NArray[[3,4,1],[2,0,5]]
b.argmax                       #=> 5
b.argmax(axis:1)               #=> [1, 2]
b.argmax(axis:0)               #=> [0, 0, 1]
b.at(b.argmax(axis:0), 0..-1)  #=> [3, 4, 5]

Returns the result indices.

Parameters:

  • nan (Boolean) (defaults to: false)

    If true, apply NaN-aware algorithm (return NaN posision if exist).

  • axis (Numeric, Array, Range) (defaults to: nil)

    Finds maximum values along the axis and returns **indices along the axis**.

Returns:

  • (Integer, Numo::Int)

    returns the result indices.

See Also:

#argmin(axis: nil, nan: false) ⇒ Integer, Numo::Int

Index of the minimum value.

Examples:

a = Numo::NArray[3,4,1,2]
a.argmin  #=> 2

b = Numo::NArray[[3,4,1],[2,0,5]]
b.argmin                       #=> 4
b.argmin(axis:1)               #=> [2, 1]
b.argmin(axis:0)               #=> [1, 1, 0]
b.at(b.argmin(axis:0), 0..-1)  #=> [2, 0, 1]

Returns the result indices.

Parameters:

  • nan (Boolean) (defaults to: false)

    If true, apply NaN-aware algorithm (return NaN posision if exist).

  • axis (Numeric, Array, Range) (defaults to: nil)

    Finds minimum values along the axis and returns **indices along the axis**.

Returns:

  • (Integer, Numo::Int)

    returns the result indices.

See Also:

#ceilNumo::DFloat

Unary ceil.

Returns ceil of self.

Returns:

#clip(min, max) ⇒ Numo::NArray

Clip array elements by [min,max]. If either of min or max is nil, one side is clipped.

Examples:

a = Numo::Int32.new(10).seq
# => Numo::Int32#shape=[10]
# [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

a.clip(1,8)
# => Numo::Int32#shape=[10]
# [1, 1, 2, 3, 4, 5, 6, 7, 8, 8]

a.inplace.clip(3,6)
a
# => Numo::Int32#shape=[10]
# [3, 3, 3, 3, 4, 5, 6, 6, 6, 6]

b = Numo::Int32.new(10).seq
# => Numo::Int32#shape=[10]
# [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

b.clip([3,4,1,1,1,4,4,4,4,4], 8)
# => Numo::Int32#shape=[10]
# [3, 4, 2, 3, 4, 5, 6, 7, 8, 8]

Returns result of clip.

Parameters:

Returns:

#coerce_cast(type) ⇒ nil

Return NArray with cast to the type of self.

Returns:

  • (nil)

#copysign(other) ⇒ Numo::NArray

Binary copysign.

Returns self copysign other.

Parameters:

Returns:

#cumprod(axis: nil, nan: false) ⇒ Numo::DFloat

cumprod of self.

Returns cumprod of self.

Parameters:

  • axis (Numeric, Array, Range) (defaults to: nil)

    Performs cumprod along the axis.

  • nan (Boolean) (defaults to: false)

    If true, apply NaN-aware algorithm (avoid NaN if exists).

Returns:

#cumsum(axis: nil, nan: false) ⇒ Numo::DFloat

cumsum of self.

Returns cumsum of self.

Parameters:

  • axis (Numeric, Array, Range) (defaults to: nil)

    Performs cumsum along the axis.

  • nan (Boolean) (defaults to: false)

    If true, apply NaN-aware algorithm (avoid NaN if exists).

Returns:

#divmod(other) ⇒ Numo::NArray

Binary divmod.

Returns divmod of self and other.

Parameters:

Returns:

#each {|x| ... } ⇒ Numo::NArray

Calls the given block once for each element in self, passing that element as a parameter. For a block ‘{|x| … }`,

Returns self.

Yield Parameters:

  • x (Numeric)

    an element of NArray.

Returns:

See Also:

#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,…| … }`,

Returns self.

Yield Parameters:

  • x (Numeric)

    an element

  • i,j,... (Integer)

    multitimensional indices

Returns:

See Also:

#eq(other) ⇒ Numo::Bit

Comparison eq other.

Returns result of self eq other.

Parameters:

Returns:

#extractNumeric, Numo::NArray

Extract an element only if self is a dimensionless NArray.

Returns Extract element value as Ruby Object if self is a dimensionless NArray, otherwise returns self.

Returns:

  • (Numeric, Numo::NArray)

    Extract element value as Ruby Object if self is a dimensionless NArray, otherwise returns self.

#eye([element,offset]) ⇒ Numo::DFloat

Eye: Set a value to diagonal components, set 0 to non-diagonal components.

Returns eye of self.

Parameters:

  • element (Numeric)

    Diagonal element to be stored. Default is 1.

  • offset (Integer)

    Diagonal offset from the main diagonal. The default is 0. k>0 for diagonals above the main diagonal, and k<0 for diagonals below the main diagonal.

Returns:

#fill(other) ⇒ Numo::DFloat

Fill elements with other.

Returns self.

Parameters:

  • other (Numeric)

Returns:

#floorNumo::DFloat

Unary floor.

Returns floor of self.

Returns:

#format(format) ⇒ Numo::RObject

Format elements into strings.

Returns array of formatted strings.

Parameters:

  • format (String)

Returns:

#format_to_a(format) ⇒ Array

Format elements into strings.

Returns array of formatted strings.

Parameters:

  • format (String)

Returns:

  • (Array)

    array of formatted strings.

#ge(other) ⇒ Numo::Bit Also known as: >=

Comparison ge other.

Returns result of self ge other.

Parameters:

Returns:

#gt(other) ⇒ Numo::Bit Also known as: >

Comparison gt other.

Returns result of self gt other.

Parameters:

Returns:

#inspectString

Returns a string containing a human-readable representation of NArray.

Returns:

  • (String)

#isfiniteNumo::Bit

Condition of isfinite.

Returns Condition of isfinite.

Returns:

#isinfNumo::Bit

Condition of isinf.

Returns Condition of isinf.

Returns:

#isnanNumo::Bit

Condition of isnan.

Returns Condition of isnan.

Returns:

#isneginfNumo::Bit

Condition of isneginf.

Returns Condition of isneginf.

Returns:

#isposinfNumo::Bit

Condition of isposinf.

Returns Condition of isposinf.

Returns:

#kahan_sum(axis: nil, keepdims: false, nan: false) ⇒ Numo::DFloat

kahan_sum of self.

Returns result of kahan_sum.

Parameters:

  • nan (Boolean) (defaults to: false)

    If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).

  • axis (Numeric, Array, Range) (defaults to: nil)

    Performs kahan_sum along the axis.

  • keepdims (Boolean) (defaults to: false)

    If true, the reduced axes are left in the result array as dimensions with size one.

Returns:

#le(other) ⇒ Numo::Bit Also known as: <=

Comparison le other.

Returns result of self le other.

Parameters:

Returns:

#logseq(beg, step, [base]) ⇒ Numo::DFloat

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.

Examples:

Numo::DFloat.new(5).logseq(4,-1,2)
# => Numo::DFloat#shape=[5]
# [16, 8, 4, 2, 1]

Numo::DComplex.new(5).logseq(0,1i*Math::PI/3,Math::E)
# => Numo::DComplex#shape=[5]
# [1+7.26156e-310i, 0.5+0.866025i, -0.5+0.866025i, -1+1.22465e-16i, ...]

Returns self.

Parameters:

  • beg (Numeric)

    The beginning of sequence.

  • step (Numeric)

    The step of sequence.

  • base (Numeric)

    The base of log space. (default=10)

Returns:

#lt(other) ⇒ Numo::Bit Also known as: <

Comparison lt other.

Returns result of self lt other.

Parameters:

Returns:

#mapNumo::DFloat

Unary map.

Returns map of self.

Returns:

#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,…| … }`,

Returns mapped array.

Yield Parameters:

  • x (Numeric)

    an element

  • i,j,... (Integer)

    multitimensional indices

Returns:

See Also:

#max(axis: nil, keepdims: false, nan: false) ⇒ Numo::DFloat

max of self.

Returns result of max.

Parameters:

  • nan (Boolean) (defaults to: false)

    If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).

  • axis (Numeric, Array, Range) (defaults to: nil)

    Performs max along the axis.

  • keepdims (Boolean) (defaults to: false)

    If true, the reduced axes are left in the result array as dimensions with size one.

Returns:

#max_index(axis: nil, nan: false) ⇒ Integer, Numo::Int

Index of the maximum value.

Examples:

a = Numo::NArray[3,4,1,2]
a.max_index  #=> 1

b = Numo::NArray[[3,4,1],[2,0,5]]
b.max_index             #=> 5
b.max_index(axis:1)     #=> [1, 5]
b.max_index(axis:0)     #=> [0, 1, 5]
b[b.max_index(axis:0)]  #=> [3, 4, 5]

Returns result indices.

Parameters:

  • nan (Boolean) (defaults to: false)

    If true, apply NaN-aware algorithm (return NaN posision if exist).

  • axis (Numeric, Array, Range) (defaults to: nil)

    Finds maximum values along the axis and returns **flat 1-d indices**.

Returns:

  • (Integer, Numo::Int)

    returns result indices.

See Also:

#mean(axis: nil, keepdims: false, nan: false) ⇒ Numo::DFloat

mean of self.

Returns result of mean.

Parameters:

  • axis (Numeric, Array, Range) (defaults to: nil)

    Performs mean along the axis.

  • keepdims (Boolean) (defaults to: false)

    If true, the reduced axes are left in the result array as dimensions with size one.

  • nan (Boolean) (defaults to: false)

    If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or return NaN for min/max etc).

Returns:

#median(axis: nil, keepdims: false, nan: false) ⇒ Numo::DFloat

median of self.

Parameters:

  • nan (Boolean) (defaults to: false)

    (keyword) If true, propagete NaN. If false, ignore NaN.

  • axis (Numeric, Array, Range) (defaults to: nil)

    Finds median along the axis.

  • keepdims (Boolean) (defaults to: false)

    If true, the reduced axes are left in the result array as dimensions with size one.

Returns:

#min(axis: nil, keepdims: false, nan: false) ⇒ Numo::DFloat

min of self.

Returns result of min.

Parameters:

  • nan (Boolean) (defaults to: false)

    If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).

  • axis (Numeric, Array, Range) (defaults to: nil)

    Performs min along the axis.

  • keepdims (Boolean) (defaults to: false)

    If true, the reduced axes are left in the result array as dimensions with size one.

Returns:

#min_index(axis: nil, nan: false) ⇒ Integer, Numo::Int

Index of the minimum value.

Examples:

a = Numo::NArray[3,4,1,2]
a.min_index  #=> 2

b = Numo::NArray[[3,4,1],[2,0,5]]
b.min_index             #=> 4
b.min_index(axis:1)     #=> [2, 4]
b.min_index(axis:0)     #=> [3, 4, 2]
b[b.min_index(axis:0)]  #=> [2, 0, 1]

Returns result indices.

Parameters:

  • nan (Boolean) (defaults to: false)

    If true, apply NaN-aware algorithm (return NaN posision if exist).

  • axis (Numeric, Array, Range) (defaults to: nil)

    Finds minimum values along the axis and returns **flat 1-d indices**.

Returns:

  • (Integer, Numo::Int)

    returns result indices.

See Also:

#minmax(axis: nil, keepdims: false, nan: false) ⇒ Numo::DFloat

minmax of self.

Returns min and max of self.

Parameters:

  • nan (Boolean) (defaults to: false)

    If true, apply NaN-aware algorithm (return NaN if exist).

  • axis (Numeric, Array, Range) (defaults to: nil)

    Finds min-max along the axis.

  • keepdims (Boolean) (defaults to: false)

    (keyword) If true, the reduced axes are left in the result array as dimensions with size one.

Returns:

#modfNumo::DFloat

modf of self.

Returns modf of self.

Returns:

#mulsum(other, axis: nil, keepdims: false, nan: false) ⇒ Numo::NArray

Binary mulsum.

Returns mulsum of self and other.

Parameters:

  • other (Numo::NArray, Numeric)
  • axis (Numeric, Array, Range) (defaults to: nil)

    Performs mulsum along the axis.

  • keepdims (Boolean) (defaults to: false)

    (keyword) If true, the reduced axes are left in the result array as dimensions with size one.

  • nan (Boolean) (defaults to: false)

    (keyword) If true, apply NaN-aware algorithm (avoid NaN if exists).

Returns:

#ne(other) ⇒ Numo::Bit

Comparison ne other.

Returns result of self ne other.

Parameters:

Returns:

#nearly_eq(other) ⇒ Numo::Bit Also known as: close_to

Comparison nearly_eq other.

Returns result of self nearly_eq other.

Parameters:

Returns:

  • (Numo::Bit)

    result of self nearly_eq other.

#poly(a0, a1, ..., an) ⇒ Numo::DFloat

Calculate polynomial.

`x.poly(a0,a1,a2,...,an) = a0 + a1*x + a2*x**2 + ... + an*x**n`

Parameters:

Returns:

#prod(axis: nil, keepdims: false, nan: false) ⇒ Numo::DFloat

prod of self.

Returns result of prod.

Parameters:

  • nan (Boolean) (defaults to: false)

    If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).

  • axis (Numeric, Array, Range) (defaults to: nil)

    Performs prod along the axis.

  • keepdims (Boolean) (defaults to: false)

    If true, the reduced axes are left in the result array as dimensions with size one.

Returns:

#ptp(axis: nil, keepdims: false, nan: false) ⇒ Numo::DFloat

ptp of self.

Returns result of ptp.

Parameters:

  • nan (Boolean) (defaults to: false)

    If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).

  • axis (Numeric, Array, Range) (defaults to: nil)

    Performs ptp along the axis.

  • keepdims (Boolean) (defaults to: false)

    If true, the reduced axes are left in the result array as dimensions with size one.

Returns:

#rand([[low],high]) ⇒ Numo::DFloat

Generate uniformly distributed random numbers on self narray.

Examples:

Numo::DFloat.new(6).rand
# => Numo::DFloat#shape=[6]
# [0.0617545, 0.373067, 0.794815, 0.201042, 0.116041, 0.344032]

Numo::DComplex.new(6).rand(5+5i)
# => Numo::DComplex#shape=[6]
# [2.69974+3.68908i, 0.825443+0.254414i, 0.540323+0.34354i, 4.52061+2.39322i, ...]

Numo::Int32.new(6).rand(2,5)
# => Numo::Int32#shape=[6]
# [4, 3, 3, 2, 4, 2]

Returns self.

Parameters:

  • low (Numeric)

    lower inclusive boundary of random numbers. (default=0)

  • high (Numeric)

    upper exclusive boundary of random numbers. (default=1 or 1+1i for complex types)

Returns:

#rand_norm([mu,[sigma]]) ⇒ Numo::DFloat

Generates random numbers from the normal distribution on self narray using Box-Muller Transformation.

Examples:

Numo::DFloat.new(5,5).rand_norm
# => Numo::DFloat#shape=[5,5]
# [[-0.581255, -0.168354, 0.586895, -0.595142, -0.802802],
#  [-0.326106, 0.282922, 1.68427, 0.918499, -0.0485384],
#  [-0.464453, -0.992194, 0.413794, -0.60717, -0.699695],
#  [-1.64168, 0.48676, -0.875871, -1.43275, 0.812172],
#  [-0.209975, -0.103612, -0.878617, -1.42495, 1.0968]]

Numo::DFloat.new(5,5).rand_norm(10,0.1)
# => Numo::DFloat#shape=[5,5]
# [[9.9019, 9.90339, 10.0826, 9.98384, 9.72861],
#  [9.81507, 10.0272, 9.91445, 10.0568, 9.88923],
#  [10.0234, 9.97874, 9.96011, 9.9006, 9.99964],
#  [10.0186, 9.94598, 9.92236, 9.99811, 9.97003],
#  [9.79266, 9.95044, 9.95212, 9.93692, 10.2027]]

Numo::DComplex.new(3,3).rand_norm(5+5i)
# => Numo::DComplex#shape=[3,3]
# [[5.84303+4.40052i, 4.00984+6.08982i, 5.10979+5.13215i],
#  [4.26477+3.99655i, 4.90052+5.00763i, 4.46607+2.3444i],
#  [4.5528+7.11003i, 5.62117+6.69094i, 5.05443+5.35133i]]

Returns self.

Parameters:

  • mu (Numeric)

    mean of normal distribution. (default=0)

  • sigma (Numeric)

    standard deviation of normal distribution. (default=1)

Returns:

#reciprocalNumo::DFloat

Unary reciprocal.

Returns reciprocal of self.

Returns:

#rintNumo::DFloat

Unary rint.

Returns rint of self.

Returns:

#rms(axis: nil, keepdims: false, nan: false) ⇒ Numo::DFloat

rms of self.

Returns result of rms.

Parameters:

  • axis (Numeric, Array, Range) (defaults to: nil)

    Performs rms along the axis.

  • keepdims (Boolean) (defaults to: false)

    If true, the reduced axes are left in the result array as dimensions with size one.

  • nan (Boolean) (defaults to: false)

    If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).

Returns:

#roundNumo::DFloat

Unary round.

Returns round of self.

Returns:

#seq([beg,[step]]) ⇒ Numo::DFloat 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.

Examples:

Numo::DFloat.new(6).seq(1,-0.2)
# => Numo::DFloat#shape=[6]
# [1, 0.8, 0.6, 0.4, 0.2, 0]

Numo::DComplex.new(6).seq(1,-0.2+0.2i)
# => Numo::DComplex#shape=[6]
# [1+0i, 0.8+0.2i, 0.6+0.4i, 0.4+0.6i, 0.2+0.8i, 0+1i]

Returns self.

Parameters:

  • beg (Numeric)

    beginning of sequence. (default=0)

  • step (Numeric)

    step of sequence. (default=1)

Returns:

#signNumo::DFloat

Unary sign.

Returns sign of self.

Returns:

#signbitNumo::Bit

Condition of signbit.

Returns Condition of signbit.

Returns:

#sort(axis: nil, nan: false) ⇒ Numo::DFloat

sort of self.

Examples:

Numo::DFloat[3,4,1,2].sort #=> Numo::DFloat[1,2,3,4]

Returns result of sort.

Parameters:

  • nan (Boolean) (defaults to: false)

    If true, propagete NaN. If false, ignore NaN.

  • axis (Numeric, Array, Range) (defaults to: nil)

    Performs sort along the axis.

Returns:

#sort_index(axis: nil, nan: false) ⇒ Integer, Numo::Int

sort_index. Returns an index array of sort result.

Examples:

Numo::NArray[3,4,1,2].sort_index #=> Numo::Int32[2,3,0,1]

Returns result index of sort_index.

Parameters:

  • nan (Boolean) (defaults to: false)

    If true, propagete NaN. If false, ignore NaN.

  • axis (Numeric, Array, Range) (defaults to: nil)

    Performs sort_index along the axis.

Returns:

  • (Integer, Numo::Int)

    returns result index of sort_index.

#squareNumo::DFloat

Unary square.

Returns square of self.

Returns:

#stddev(axis: nil, keepdims: false, nan: false) ⇒ Numo::DFloat

stddev of self.

Returns result of stddev.

Parameters:

  • axis (Numeric, Array, Range) (defaults to: nil)

    Performs stddev along the axis.

  • keepdims (Boolean) (defaults to: false)

    If true, the reduced axes are left in the result array as dimensions with size one.

  • nan (Boolean) (defaults to: false)

    If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).

Returns:

#store(other) ⇒ Numo::DFloat

Store elements to Numo::DFloat from other.

Returns self.

Parameters:

  • other (Object)

Returns:

#sum(axis: nil, keepdims: false, nan: false) ⇒ Numo::DFloat

sum of self.

Returns result of sum.

Parameters:

  • nan (Boolean) (defaults to: false)

    If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).

  • axis (Numeric, Array, Range) (defaults to: nil)

    Performs sum along the axis.

  • keepdims (Boolean) (defaults to: false)

    If true, the reduced axes are left in the result array as dimensions with size one.

Returns:

#to_aArray

Convert self to Array.

Returns:

  • (Array)

#truncNumo::DFloat

Unary trunc.

Returns trunc of self.

Returns:

#var(axis: nil, keepdims: false, nan: false) ⇒ Numo::DFloat

var of self.

Returns result of var.

Parameters:

  • axis (Numeric, Array, Range) (defaults to: nil)

    Performs var along the axis.

  • keepdims (Boolean) (defaults to: false)

    If true, the reduced axes are left in the result array as dimensions with size one.

  • nan (Boolean) (defaults to: false)

    If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).

Returns: