Name

SPVM::R::NDArray::DoubleComplex - N-Dimensional Array of Double Complex Type.

Description

R::NDArray::DoubleComplex class in SPVM represents n-dimensional array of float complex Complex_2d type.

Usage

use R::NDArray::DoubleComplex;
use Math;

my $data = [
  Math->complex(1, 0),
  Math->complex(2, 0),
  Math->complex(3, 0),
  Math->complex(4, 0),
  Math->complex(5, 0),
  Math->complex(6, 0)
];

my $ndarray = R::NDArray::DoubleComplex->new({data => $data, dim => [3, 2]});

Super Class

R::NDArray

Fields

data

method data : Complex_2d[] ();

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

Class Methods

new

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

Creates a new R::NDArray::DoubleComplex 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 : Complex_2d[] ($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 Complex_2d[$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 : Complex_2d[], $data_index : int);

Converts an element $data at index $data_index to a string such as 2+3i and returns it.

elem_assign

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

Same as "elem_assign" method.

elem_is_na

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

Checks if an element represets NA.

If the real number or the image number of the element $data at index $data_index is NaN, returns 1, otherwise returns 0.

clone

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

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

slice

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

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

to_float_complex_ndarray

method to_float_complex_ndarray : R::NDArray::FloatComplex ();

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

Each element is converted by the following code.

$ret_elem->{re} = (float)$elem->{re};
$ret_elem->{im} = (float)$elem->{im};

See Also

Copyright & License

Copyright (c) 2024 Yuki Kimoto

MIT License