The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

Name

SPVM::R::OP::Double - N-Dimensional Array Operations for R::NDArray::Double

Description

The R::OP::Double class in SPVM has methods for n-dimensional array operations for R::NDArray::Double.

Usage

  use R::OP::Double as DOP;
  
  my $ndarray_scalar = DOP->c((double)1);
  
  my $ndarray_vector = DOP->c([(double)1, 2, 3]);
  
  my $ndarray = DOP->c([(double)1, 2, 3, 4, 5, 6], [3, 2]);
  
  my $ndarray2 = DOP->c($ndarray);

Class Methods

c

static method c : R::NDArray::Double ($data : object of Double|double[]|R::NDArray::Double, $dim : int[] = undef);

add

static method add : R::NDArray::Double ($x_ndarray : R::NDArray::Double, $y_ndarray : R::NDArray::Double);

Creates a new R::NDArray::Double object for a return value, performs addition + operation on each element of the n-dimensional array $x_ndarray and $y_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

The n-dimensional array $y_ndarray must be defined. Otherwise, an exception is thrown.

The dim field of $x_ndarray must be equal to the dim field of $y_ndarray. Otherwise, an exception is thrown.

sub

static method sub : R::NDArray::Double ($x_ndarray : R::NDArray::Double, $y_ndarray : R::NDArray::Double);

Creates a new R::NDArray::Double object for a return value, performs subtraction - operation on each element of the n-dimensional array $x_ndarray and $y_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

The n-dimensional array $y_ndarray must be defined. Otherwise, an exception is thrown.

The dim field of $x_ndarray must be equal to the dim field of $y_ndarray. Otherwise, an exception is thrown.

mul

static method mul : R::NDArray::Double ($x_ndarray : R::NDArray::Double, $y_ndarray : R::NDArray::Double);

Creates a new R::NDArray::Double object for a return value, performs multiplication * operation on each element of the n-dimensional array $x_ndarray and $y_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

The n-dimensional array $y_ndarray must be defined. Otherwise, an exception is thrown.

The dim field of $x_ndarray must be equal to the dim field of $y_ndarray. Otherwise, an exception is thrown.

scamul

static method scamul : R::NDArray::Double ($x_ndarray : R::NDArray::Double, $scalar_ndarray : R::NDArray::Double);

Creates a new R::NDArray::Double object for a return value, performs multiplication * operation on each element of the n-dimensional array $x_ndarray, and sets each element of the new n-dimensional array and the n-dimensional array $scalar_ndarray at data index 0 to the each operation result, and returns the new n-dimensional array.

Exceptions:

The n-dimensional array $scalar_ndarray must be defined. Otherwise, an exception is thrown.

The n-dmension array $scalar_ndarray must be a scalar.

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

div

static method div : R::NDArray::Double ($x_ndarray : R::NDArray::Double, $y_ndarray : R::NDArray::Double);

Creates a new R::NDArray::Double object for a return value, performs division / operation on each element of the n-dimensional array $x_ndarray and $y_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

The n-dimensional array $y_ndarray must be defined. Otherwise, an exception is thrown.

The dim field of $x_ndarray must be equal to the dim field of $y_ndarray. Otherwise, an exception is thrown.

scadiv

static method scadiv : R::NDArray::Double ($x_ndarray : R::NDArray::Double, $scalar_ndarray : R::NDArray::Double);

Creates a new R::NDArray::Double object for a return value, performs division / operations on the n-dimensional array $scalar_ndarray at data index 0 and each element of the n-dimensional array $x_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array.

Exceptions:

The n-dimensional array $scalar_ndarray must be defined. Otherwise, an exception is thrown.

The n-dmension array $scalar_ndarray must be a scalar.

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

neg

static method neg : R::NDArray::Double ($x_ndarray : R::NDArray::Double);

Creates a new R::NDArray::Double object for a return value, performs negation - operation on each element of the n-dimensional array $x_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

abs

static method abs : R::NDArray::Double ($x_ndarray : R::NDArray::Double);

Creates a new R::NDArray::Double object for a return value, performs Math#fabs method on each element of the n-dimensional array $x_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

eq

static method eq : R::NDArray::Double ($x_ndarray : R::NDArray::Double, $y_ndarray : R::NDArray::Double);

Creates a new R::NDArray::Double object for a return value, performs numeric comparison == operation on each element of the n-dimensional array $x_ndarray and $y_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

The n-dimensional array $y_ndarray must be defined. Otherwise, an exception is thrown.

The dim field of $x_ndarray must be equal to the dim field of $y_ndarray. Otherwise, an exception is thrown.

ne

static method ne : R::NDArray::Int ($x_ndarray : R::NDArray::Double, $y_ndarray : R::NDArray::Double);

Creates a new R::NDArray::Int object for a return value, performs numeric comparison != operation on each element of the n-dimensional array $x_ndarray and $y_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

The n-dimensional array $y_ndarray must be defined. Otherwise, an exception is thrown.

The dim field of $x_ndarray must be equal to the dim field of $y_ndarray. Otherwise, an exception is thrown.

gt

static method gt : R::NDArray::Int ($x_ndarray : R::NDArray::Double, $y_ndarray : R::NDArray::Double);

Creates a new R::NDArray::Int object for a return value, performs numeric comparison > operation on each element of the n-dimensional array $x_ndarray and $y_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

The n-dimensional array $y_ndarray must be defined. Otherwise, an exception is thrown.

The dim field of $x_ndarray must be equal to the dim field of $y_ndarray. Otherwise, an exception is thrown.

ge

static method ge : R::NDArray::Int ($x_ndarray : R::NDArray::Double, $y_ndarray : R::NDArray::Double);

Creates a new R::NDArray::Int object for a return value, performs numeric comparison >= operation on each element of the n-dimensional array $x_ndarray and $y_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

The n-dimensional array $y_ndarray must be defined. Otherwise, an exception is thrown.

The dim field of $x_ndarray must be equal to the dim field of $y_ndarray. Otherwise, an exception is thrown.

lt

static method lt : R::NDArray::Int ($x_ndarray : R::NDArray::Double, $y_ndarray : R::NDArray::Double);

Creates a new R::NDArray::Int object for a return value, performs numeric comparison < operation on each element of the n-dimensional array $x_ndarray and $y_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

The n-dimensional array $y_ndarray must be defined. Otherwise, an exception is thrown.

The dim field of $x_ndarray must be equal to the dim field of $y_ndarray. Otherwise, an exception is thrown.

le

static method le : R::NDArray::Int ($x_ndarray : R::NDArray::Double, $y_ndarray : R::NDArray::Double);

Creates a new R::NDArray::Int object for a return value, performs numeric comparison <= operation on each element of the n-dimensional array $x_ndarray and $y_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

The n-dimensional array $y_ndarray must be defined. Otherwise, an exception is thrown.

The dim field of $x_ndarray must be equal to the dim field of $y_ndarray. Otherwise, an exception is thrown.

rep

static method rep : R::NDArray::Double ($x_ndarray : R::NDArray::Double, $times : int);

rep_length

static method rep_length : R::NDArray::Double ($x_ndarray : R::NDArray::Double, $length : int);

seq

static method seq : R::NDArray::Double ($begin : double, $end : double, $by : double = 1);

seq_length

static method seq_length : R::NDArray::Double ($begin : double, $end : double, $length : int);

sin

static method sin : R::NDArray::Double ($x_ndarray : R::NDArray::Double);

Creates a new R::NDArray::Double object for a return value, performs Math#sin method on each element of the n-dimensional array $x_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

cos

static method cos : R::NDArray::Double ($x_ndarray : R::NDArray::Double);

tan

static method tan : R::NDArray::Double ($x_ndarray : R::NDArray::Double);

sinh

static method sinh : R::NDArray::Double ($x_ndarray : R::NDArray::Double);

cosh

static method cosh : R::NDArray::Double ($x_ndarray : R::NDArray::Double);

tanh

static method tanh : R::NDArray::Double ($x_ndarray : R::NDArray::Double);

acos

static method acos : R::NDArray::Double ($x_ndarray : R::NDArray::Double);

asin

static method asin : R::NDArray::Double ($x_ndarray : R::NDArray::Double);

atan

static method atan : R::NDArray::Double ($x_ndarray : R::NDArray::Double);

asinh

static method asinh : R::NDArray::Double ($x_ndarray : R::NDArray::Double);

acosh

static method acosh : R::NDArray::Double ($x_ndarray : R::NDArray::Double);

atanh

static method atanh : R::NDArray::Double ($x_ndarray : R::NDArray::Double);

exp

static method exp : R::NDArray::Double ($x_ndarray : R::NDArray::Double);

expm1

static method expm1 : R::NDArray::Double ($x_ndarray : R::NDArray::Double);

log

static method log : R::NDArray::Double ($x_ndarray : R::NDArray::Double);

logb

static method logb : R::NDArray::Double ($x_ndarray : R::NDArray::Double);

log2

static method log2 : R::NDArray::Double ($x_ndarray : R::NDArray::Double);

log10

static method log10 : R::NDArray::Double ($x_ndarray : R::NDArray::Double);

sqrt

static method sqrt : R::NDArray::Double ($x_ndarray : R::NDArray::Double);

isinf

static method isinf : R::NDArray::Int ($x_ndarray : R::NDArray::Double);

is_infinite

static method is_infinite : R::NDArray::Int ($x_ndarray : R::NDArray::Double);

is_finite

static method is_finite : R::NDArray::Int ($x_ndarray : R::NDArray::Double);

isnan

static method isnan : R::NDArray::Int ($x_ndarray : R::NDArray::Double);

is_nan

static method is_nan : R::NDArray::Int ($x_ndarray : R::NDArray::Double);

pow

static method pow : R::NDArray::Double ($x_ndarray : R::NDArray::Double, $y_ndarray : R::NDArray::Double);

atan2

static method atan2 : R::NDArray::Double ($y_ndarray : R::NDArray::Double, $x_ndarray : R::NDArray::Double);

modf

static method modf : R::NDArray::Double ($x_ndarray : R::NDArray::Double, $intpart_ndarray_ref : R::NDArray::Double[]);

ceil

static method ceil : R::NDArray::Double ($x_ndarray : R::NDArray::Double);

ceiling

static method ceiling : R::NDArray::Double ($x_ndarray : R::NDArray::Double);

floor

static method floor : R::NDArray::Double ($x_ndarray : R::NDArray::Double);

round

static method round : R::NDArray::Double ($x_ndarray : R::NDArray::Double);

lround

static method lround : R::NDArray::Long ($x_ndarray : R::NDArray::Double);

remainder

static method remainder : R::NDArray::Double ($x_ndarray : R::NDArray::Double, $y_ndarray : R::NDArray::Double);

fmod

static method fmod : R::NDArray::Double ($x_ndarray : R::NDArray::Double, $y_ndarray : R::NDArray::Double);

sum

static method sum : R::NDArray::Double ($x_ndarray : R::NDArray::Double);

cumsum

static method cumsum : R::NDArray::Double ($x_ndarray : R::NDArray::Double);

prod

static method prod : R::NDArray::Double ($x_ndarray : R::NDArray::Double);

cumprod

static method cumprod : R::NDArray::Double ($x_ndarray : R::NDArray::Double);

diff

static method diff : R::NDArray::Double ($x_ndarray : R::NDArray::Double);

max

static method max : R::NDArray::Double ($x_ndarray : R::NDArray::Double);

min

static method min : R::NDArray::Double ($x_ndarray : R::NDArray::Double);

mean

static method mean : R::NDArray::Double ($x_ndarray : R::NDArray::Double);

dot

static method dot : R::NDArray::Double ($x_ndarray : R::NDArray::Double, $y_ndarray : R::NDArray::Double);

cross

static method cross : R::NDArray::Double ($x_ndarray : R::NDArray::Double, $y_ndarray : R::NDArray::Double);

outer

static method outer : R::NDArray::Double ($x_ndarray : R::NDArray::Double, $y_ndarray : R::NDArray::Double);

pi

static method pi : R::NDArray::Double ();

See Also

Copyright & License

Copyright (c) 2024 Yuki Kimoto

MIT License