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 - N-Dimensional Array Operations

Description

R::OP class in SPVM has methods for operations for R::NDArray.

Usage

  use R::OP;
  use R::IO::Int as IOP;
  
  my $ndarray1 = IOP->c([1, 2, 3]);
  
  my $ndarray2 = IOP->c([3, 4, 5]);
  
  my $equals_dim = R::OP->equals_dim($ndarray1, $ndarray2);

Related Modules

Class Methods

equals_dim

static method equals_dim : int ($x_ndarray : R::NDArray, $y_ndarray : R::NDArray);

If the dimensions of $x_ndarray is equal to the dimensions of $x_ndarray, returns 1, otherwise returns 0.

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.

equals_dropped_dim

static method equals_dropped_dim : int ($x_ndarray : R::NDArray, $y_ndarray : R::NDArray);

If the dimensions of $x_ndarray on which R::Util#drop_dim method is performed is equal to the dimensions of $x_ndarray on which R::Util#drop_dim method is performed, returns 1, otherwise returns 0.

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.

rep

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

Creates a new R::NDArray object by repeating the data of $x_ndarray $times times.

The type of new object is the same as the type of $x_ndarray, and the dimensions is [$length * $times]. ($leghth is the length of $x_ndarray).

Exceptions:

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

The repeat count $times must be greater than or equal to 0. Otherwise an exception is thrown.

rep_length

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

Creates a new R::NDArray object by repeating the data of $x_ndarray up to length $length.

The type of new object is the same as the type of $x_ndarray, and the dimensions is [$length].

Exceptions:

The length $length must be greater than or equal to 0. Otherwise an exception is thrown.

The length $length must be devided by the length of the n-dimensional array $x_ndarray. Otherwise an exception is thrown.

is_na

static method is_na : R::NDArray::Int ($x_ndarray : R::NDArray);

Creates a new R::NDArray::Int object by performing R::NDArray#elem_is_na on all elements of the n-dimensional array $x_ndarray.

Exceptions:

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

See Also

Copyright & License

Copyright (c) 2024 Yuki Kimoto

MIT License