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

Description

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

Usage

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

Class Methods

c

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

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

Implemetation:

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

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

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

Exceptions:

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

rep

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

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

rep_length

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

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

seq

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

Creates a R::NDArray::Short 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