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::Byte - N-Dimensional Array Operations for R::NDArray::Byte

Description

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

Usage

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

Class Methods

c

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

Creates a new R::NDArray::Byte object given the data $data and the dimensions $dim.

Implemetation:

If $data is defined and the type of $data is Byte, $data is set to [(byte)$data-(Byte)]>.

If $data is defined and the type of $data is R::NDArray::Byte, $dim is set to $data->(R::NDArray::Byte)->dim unless $dim is defined and $data is set to $data->(R::NDArray::Byte)->data.

And this method calls R::NDArray::Byte#new method given $dim and $data.

Exceptions:

The type of the data $data must be Byte, byte[], or R::NDArray::Byte if defined. Othrewise, an exception is thrown.

rep

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

Same as R::OP#rep method, but the return type is different.

rep_length

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

Same as R::OP#rep_length method, but the return type is different.

seq

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

Creates a R::NDArray::Byte object from $bigin to $end at intervals of $by.

Exceptions:

$by must not be 0. Otherwise, an exception is thrown.

If $by is greater than 0 and $end is not greater than or equal to $begin, an exception is thrown.

If $by is less than 0 and $end Is not greater than or equal to $begin, an exception is thrown.

See Also

Copyright & License

Copyright (c) 2024 Yuki Kimoto

MIT License