Name

SPVM::R::NDArray::Long - N-Dimensional Array of long Type.

Description

R::NDArray::Long class in SPVM represents n-dimensional array of long type.

Usage

use R::NDArray::Long;

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

Super Class

R::NDArray

Field

data

method data : long[] ();

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

Class Methods

new

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

Creates a new R::NDArray::Long given the options $options and returns it.

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

Instance Methods

create_default_data

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

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

The default data is created by the following code.

my $default_data = new long[$length];

Exceptions:

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

elem_to_string

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

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

The string is created by the following code.

my $string = (string)$data->[$data_index];

elem_assign

method elem_assign : void ($dist_data : long[], $dist_data_index : int, $src_data : long[], $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 : long[], $dist_data_index : int, $src_data : long[], $src_data_index : int);

Same as "elem_assign" method.

elem_cmp

method elem_cmp : int ($a_data : long[], $a_data_index : int, $b_data : long[], $b_data_index : int);

Compares the element $a_data at index $a_data_index and the element $b_data at index $b_data_index using the comparison operator <=> and returns the result.

elem_is_na

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

Checks if an element represets NA.

Always returns 0.

clone

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

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

slice

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

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

to_int_ndarray

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

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

Each element is converted by the following code.

my $ret_elem = (int)$elem;

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.

Each element is converted by the following code.

my $ret_elem = (float)$elem;

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.

Each element is converted by the following code.

my $ret_elem = (double)$elem;

See Also

Copyright & License

Copyright (c) 2024 Yuki Kimoto

MIT License