Name

SPVM::R::NDArray::Int - N-Dimensional Array of int Type.

Description

R::NDArray::Int class in SPVM represents n-dimensional array of int type.

Usage

use R::NDArray::Int;

my $ndarray = R::NDArray::Int->new({data => [(int)1, 2, 3, 4, 5, 6], dim => [3, 2]});

Super Class

R::NDArray

Field

data

method data : int[] ();

Same as R::NDArray#data method, but the return type is different.

Class Methods

static method new : R::NDArray::Int ($options : object[] = undef);

Creates a new R::NDArray::Int and returns it.

This method calls R::NDArray#init method given the options $options.

Instance Methods

create_default_data

method create_default_data : int[] ($length : int = 0);

Creates a default data given the length $length and returns it.

elem_to_string

method elem_to_string : string ($data : int[], $data_index : int);

Converts an element $data at index $data_index to a string and returns it.

elem_assign

method elem_assign : void ($dist_data : int[], $dist_data_index : int, $src_data : int[], $src_data_index : int);

Assigns the element $src_data at index $src_data_index to the element $dist_data at index $dist_data_index.

elem_clone

method elem_clone : void ($dist_data : int[], $dist_data_index : int, $src_data : int[], $src_data_index : int);

Copies the element $src_data at index $src_data_indext to the element $dist_data at index $dist_data_index.

elem_cmp

method elem_cmp : int ($data : int[], $a_data_index : int, $b_data_index : int);

Compares the element $data at index $a_data_index and the element $data at index $b_data_index and returns the result.

elem_is_na

method elem_is_na : int ($data : byte[], $data_index : int);

Checks if an element represets NA.

Returns 0.

clone

method clone : R::NDArray::Int ($shallow : int = 0);

Same as R::NDArray#clone method, but the return type is different.

slice

method slice : R::NDArray::Int ($asix_indexes_product : R::NDArray::Int[]);

Same as R::NDArray#slice method, but the return type is different.

to_byte_ndarray

method to_byte_ndarray : R::NDArray::Byte ();

Converts this n-dimensional array to a n-dimensional array of R::NDArray::Byte and returns it.

to_short_ndarray

method to_short_ndarray : R::NDArray::Short ();

Converts this n-dimensional array to a n-dimensional array of R::NDArray::Short and returns it.

to_long_ndarray

method to_long_ndarray : R::NDArray::Long ();

Converts this n-dimensional array to a n-dimensional array of R::NDArray::Long and returns it.

to_float_ndarray

method to_float_ndarray : R::NDArray::Float ();

Converts this n-dimensional array to a n-dimensional array of R::NDArray::Float and returns it.

to_double_ndarray

method to_double_ndarray : R::NDArray::Double ();

Converts this n-dimensional array to a n-dimensional array of R::NDArray::Double and returns it.

to_indexes

method to_indexes : R::NDArray::Int ();

Creates a list of indexes whose elements are true values, convert it to an N-dimensional array that is a vector, and return it.

For example, [0, 1, 0, 1, 1] is converted to [1, 3, 4].

Exceptions:

This n-dimensional array must be a vector. Otherwise an exception is thrown.

Copyright & License

Copyright (c) 2024 Yuki Kimoto

MIT License