Name

SPVM::R::OP::FloatComplex - N-Dimensional Array Operations for R::NDArray::FloatComplex

Description

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

Usage

use R::OP::FloatComplex as FCOP;

# 1+10i
my $ndarray_scalar = FCOP->c([(float)1,10]);

# 1+10i, 2+20i, 3+30i
my $ndarray_vector = FCOP->c([(float)1,10,  2,20,  3,30]);

my $ndarray = FCOP->c([(float)1,10,  2,20,  3,30,  4,40,  5,50,  6,60], [3, 2]);

my $ndarray2 = FCOP->c($ndarray);

Class Methods

c

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

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

Implemetation:

If $data is defined and the type of $data is float[], it is interpreted as pairs of a real number and a complex number and is converted to an array of Complex_2f, $data is set to the array.

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

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

Exceptions:

The length of pairs \$data must be an even number if the type of \$data is float[]. Othrewise, an exception is thrown.

The type of the data $data must be float[], Complex_2f[] or R::NDArray::FloatComplex.

add

static method add : R::NDArray::FloatComplex ($x_ndarray : R::NDArray::FloatComplex, $y_ndarray : R::NDArray::FloatComplex);

Creates a new R::NDArray::FloatComplex object of the same dimensions as the n-dimensional array $x_ndarray for a return value, performs Math#caddf method on each element of the n-dimensional array $x_ndarray and $y_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array.

$y_ndarray allows to be a scalar. In that case, each element used in the operation is the element at index 0.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

The n-dimensional array $y_ndarray must be defined. Otherwise, an exception is thrown.

The dimensions of $x_ndarray must be equal to the dimensions of $y_ndarray if $y_ndarray is not a scalar. Otherwise, an exception is thrown.

sub

static method sub : R::NDArray::FloatComplex ($x_ndarray : R::NDArray::FloatComplex, $y_ndarray : R::NDArray::FloatComplex);

Creates a new R::NDArray::FloatComplex object of the same dimensions as the n-dimensional array $x_ndarray for a return value, performs Math#csubf method on each element of the n-dimensional array $x_ndarray and $y_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array.

$y_ndarray allows to be a scalar. In that case, each element used in the operation is the element at index 0.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

The n-dimensional array $y_ndarray must be defined. Otherwise, an exception is thrown.

The dimensions of $x_ndarray must be equal to the dimensions of $y_ndarray if $y_ndarray is not a scalar. Otherwise, an exception is thrown.

mul

static method mul : R::NDArray::FloatComplex ($x_ndarray : R::NDArray::FloatComplex, $y_ndarray : R::NDArray::FloatComplex);

Creates a new R::NDArray::FloatComplex object of the same dimensions as the n-dimensional array $x_ndarray for a return value, performs Math#cmulf method on each element of the n-dimensional array $x_ndarray and $y_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array.

$y_ndarray allows to be a scalar. In that case, each element used in the operation is the element at index 0.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

The n-dimensional array $y_ndarray must be defined. Otherwise, an exception is thrown.

The dimensions of $x_ndarray must be equal to the dimensions of $y_ndarray if $y_ndarray is not a scalar. Otherwise, an exception is thrown.

div

static method div : R::NDArray::FloatComplex ($x_ndarray : R::NDArray::FloatComplex, $y_ndarray : R::NDArray::FloatComplex);

Creates a new R::NDArray::FloatComplex object of the same dimensions as the n-dimensional array $x_ndarray for a return value, performs Math#cdivf method on each element of the n-dimensional array $x_ndarray and $y_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array.

$y_ndarray allows to be a scalar. In that case, each element used in the operation is the element at index 0.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

The n-dimensional array $y_ndarray must be defined. Otherwise, an exception is thrown.

The dimensions of $x_ndarray must be equal to the dimensions of $y_ndarray if $y_ndarray is not a scalar. Otherwise, an exception is thrown.

neg

static method neg : R::NDArray::FloatComplex ($x_ndarray : R::NDArray::FloatComplex);

Creates a new R::NDArray::FloatComplex object of the same dimensions as the n-dimensional array $x_ndarray for a return value, performs Math#cnegf method on each element of the n-dimensional array $x_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array. Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

abs

static method abs : R::NDArray::FloatSPVM::R::NDArray::Float ($x_ndarray : R::NDArray::FloatComplex);

Creates a new R::NDArray::Float object of the same dimensions as the n-dimensional array $x_ndarray for a return value, performs Math#cabsf method on each element of the n-dimensional array $x_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array. Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

re

static method re : R::NDArray::FloatSPVM::R::NDArray::Float ($x_ndarray : R::NDArray::FloatComplex);

Creates a new R::NDArray::Float object of the same dimensions as the n-dimensional array $x_ndarray for a return value, gets the real number on each element of the n-dimensional array $x_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

im

static method im : R::NDArray::FloatSPVM::R::NDArray::Float ($x_ndarray : R::NDArray::FloatComplex);

Creates a new R::NDArray::Float object of the same dimensions as the n-dimensional array $x_ndarray for a return value, gets the image number on each element of the n-dimensional array $x_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

i

static method i : R::NDArray::FloatComplex ();

Creates a new R::NDArray::FloatComplex object of the dimensions [1] for a return value, sets the element of the new n-dimensional array to the return value of Math->complex(0, 1), and returns the new n-dimensional array.

conj

static method conj : R::NDArray::FloatComplex ($x_ndarray : R::NDArray::FloatComplex);

Creates a new R::NDArray::FloatComplex object of the same dimensions as the n-dimensional array $x_ndarray for a return value, performs Math#conjf method on each element of the n-dimensional array $x_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array. Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

arg

static method arg : R::NDArray::FloatSPVM::R::NDArray::Float ($x_ndarray : R::NDArray::FloatComplex);

Creates a new R::NDArray::Float object of the same dimensions as the n-dimensional array $x_ndarray for a return value, performs Math#cargf method on each element of the n-dimensional array $x_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array. Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

eq

static method eq : R::NDArray::Int ($x_ndarray : R::NDArray::FloatComplex, $y_ndarray : R::NDArray::FloatComplex);

Creates a new R::NDArray::Int object of the same dimensions as the n-dimensional array $x_ndarray for a return value, performs AND operation && on the results of numeric comparison == operation on the real number and image number of each element of the n-dimensional array $x_ndarray and $y_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

The n-dimensional array $y_ndarray must be defined. Otherwise, an exception is thrown.

The dimensions of $x_ndarray must be equal to the dimensions of $y_ndarray. Otherwise, an exception is thrown.

ne

static method ne : R::NDArray::Int ($x_ndarray : R::NDArray::FloatComplex, $y_ndarray : R::NDArray::FloatComplex);

Creates a new R::NDArray::Int object of the same dimensions as the n-dimensional array $x_ndarray for a return value, performs NOT operation ! on the reust of AND operation && on the results of numeric comparison == operation on the real number and image number of each element of the n-dimensional array $x_ndarray and $y_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

The n-dimensional array $y_ndarray must be defined. Otherwise, an exception is thrown.

The dimensions of $x_ndarray must be equal to the dimensions of $y_ndarray. Otherwise, an exception is thrown.

rep

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

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

rep_length

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

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

sin

static method sin : R::NDArray::FloatComplex ($x_ndarray : R::NDArray::FloatComplex);

Creates a new R::NDArray::FloatComplex object of the same dimensions as the n-dimensional array $x_ndarray for a return value, performs Math#csinf method on each element of the n-dimensional array $x_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array. Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

cos

static method cos : R::NDArray::FloatComplex ($x_ndarray : R::NDArray::FloatComplex);

Creates a new R::NDArray::FloatComplex object of the same dimensions as the n-dimensional array $x_ndarray for a return value, performs Math#ccosf method on each element of the n-dimensional array $x_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array. Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

tan

static method tan : R::NDArray::FloatComplex ($x_ndarray : R::NDArray::FloatComplex);

Creates a new R::NDArray::FloatComplex object of the same dimensions as the n-dimensional array $x_ndarray for a return value, performs Math#ctanf method on each element of the n-dimensional array $x_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array. Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

sinh

static method sinh : R::NDArray::FloatComplex ($x_ndarray : R::NDArray::FloatComplex);

Creates a new R::NDArray::FloatComplex object of the same dimensions as the n-dimensional array $x_ndarray for a return value, performs Math#csinhf method on each element of the n-dimensional array $x_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

cosh

static method cosh : R::NDArray::FloatComplex ($x_ndarray : R::NDArray::FloatComplex);

Creates a new R::NDArray::FloatComplex object of the same dimensions as the n-dimensional array $x_ndarray for a return value, performs Math#ccoshf method on each element of the n-dimensional array $x_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

tanh

static method tanh : R::NDArray::FloatComplex ($x_ndarray : R::NDArray::FloatComplex);

Creates a new R::NDArray::FloatComplex object of the same dimensions as the n-dimensional array $x_ndarray for a return value, performs Math#ctanhf method on each element of the n-dimensional array $x_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

acos

static method acos : R::NDArray::FloatComplex ($x_ndarray : R::NDArray::FloatComplex);

Creates a new R::NDArray::FloatComplex object of the same dimensions as the n-dimensional array $x_ndarray for a return value, performs Math#cacosf method on each element of the n-dimensional array $x_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

asin

static method asin : R::NDArray::FloatComplex ($x_ndarray : R::NDArray::FloatComplex);

Creates a new R::NDArray::FloatComplex object of the same dimensions as the n-dimensional array $x_ndarray for a return value, performs Math#casinf method on each element of the n-dimensional array $x_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

atan

static method atan : R::NDArray::FloatComplex ($x_ndarray : R::NDArray::FloatComplex);

Creates a new R::NDArray::FloatComplex object of the same dimensions as the n-dimensional array $x_ndarray for a return value, performs Math#catanf method on each element of the n-dimensional array $x_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

asinh

static method asinh : R::NDArray::FloatComplex ($x_ndarray : R::NDArray::FloatComplex);

Creates a new R::NDArray::FloatComplex object of the same dimensions as the n-dimensional array $x_ndarray for a return value, performs Math#casinhf method on each element of the n-dimensional array $x_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

acosh

static method acosh : R::NDArray::FloatComplex ($x_ndarray : R::NDArray::FloatComplex);

Creates a new R::NDArray::FloatComplex object of the same dimensions as the n-dimensional array $x_ndarray for a return value, performs Math#cacoshf method on each element of the n-dimensional array $x_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

atanh

static method atanh : R::NDArray::FloatComplex ($x_ndarray : R::NDArray::FloatComplex);

Creates a new R::NDArray::FloatComplex object of the same dimensions as the n-dimensional array $x_ndarray for a return value, performs Math#catanhf method on each element of the n-dimensional array $x_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

exp

static method exp : R::NDArray::FloatComplex ($x_ndarray : R::NDArray::FloatComplex);

Creates a new R::NDArray::FloatComplex object of the same dimensions as the n-dimensional array $x_ndarray for a return value, performs Math#cexpf method on each element of the n-dimensional array $x_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

log

static method log : R::NDArray::FloatComplex ($x_ndarray : R::NDArray::FloatComplex);

Creates a new R::NDArray::FloatComplex object of the same dimensions as the n-dimensional array $x_ndarray for a return value, performs Math#clogf method on each element of the n-dimensional array $x_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

sqrt

static method sqrt : R::NDArray::FloatComplex ($x_ndarray : R::NDArray::FloatComplex);

Creates a new R::NDArray::FloatComplex object of the same dimensions as the n-dimensional array $x_ndarray for a return value, performs Math#csqrtf method on each element of the n-dimensional array $x_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

pow

static method pow : R::NDArray::FloatComplex ($x_ndarray : R::NDArray::FloatComplex, $y_ndarray : R::NDArray::FloatComplex);

Creates a new R::NDArray::FloatComplex object of the same dimensions as the n-dimensional array $x_ndarray for a return value, performs Math#cpowf method given each element of the n-dimensional array $x_ndarray and $y_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array.

$y_ndarray allows to be a scalar. In that case, each element used in the operation is the element at index 0.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

The n-dimensional array $y_ndarray must be defined. Otherwise, an exception is thrown.

The dimensions of $x_ndarray must be equal to the dimensions of $y_ndarray if $y_ndarray is not a scalar. Otherwise, an exception is thrown.

sum

static method sum : R::NDArray::FloatComplex ($x_ndarray : R::NDArray::FloatComplex);

Creates a new R::NDArray::FloatComplex object with the dimenstion [1] for a return value, calculates the sum of all elements of the n-dimensional array $x_ndarray, and sets the element of the new n-dimensional array to the result, and returns the new n-dimensional array.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

cumsum

static method cumsum : R::NDArray::FloatComplex ($x_ndarray : R::NDArray::FloatComplex);

Creates a new R::NDArray::FloatComplex object of the same dimensions as the n-dimensional array $x_ndarray for a return value, calculates the cumulative sum on each element of the n-dimensional array $x_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

prod

static method prod : R::NDArray::FloatComplex ($x_ndarray : R::NDArray::FloatComplex);

Creates a new R::NDArray::FloatComplex object with the dimenstion [1] for a return value, calculates the production of all elements of the n-dimensional array $x_ndarray, and sets the element of the new n-dimensional array to the result, and returns the new n-dimensional array.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

cumprod

static method cumprod : R::NDArray::FloatComplex ($x_ndarray : R::NDArray::FloatComplex);

Creates a new R::NDArray::FloatComplex object of the same dimensions as the n-dimensional array $x_ndarray for a return value, calculates the cumulative product on each element of the n-dimensional array $x_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

diff

static method diff : R::NDArray::FloatComplex ($x_ndarray : R::NDArray::FloatComplex);

Creates a new R::NDArray::FloatComplex object of the dimensions as the n-dimensional array $x_ndarray minus 1 for a return value, calculats the difference of adjacent elements of the n-dimensional array $x_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

mean

static method mean : R::NDArray::FloatComplex ($x_ndarray : R::NDArray::FloatComplex);

Creates a new R::NDArray::FloatComplex object with the dimenstion [1] for a return value, calculates the mean of all elements of the n-dimensional array $x_ndarray, and sets the element of the new n-dimensional array to the result, and returns the new n-dimensional array.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

dot

static method dot : R::NDArray::FloatComplex ($x_ndarray : R::NDArray::FloatComplex, $y_ndarray : R::NDArray::FloatComplex);

Creates a new R::NDArray::FloatComplex object of the same dimensions as the n-dimensional array $x_ndarray for a return value, performs dot product of elements of the n-dimensional array $x_ndarray and $y_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array.

The dot product in this implementation is conjugate-linear in the first variable and linear in the second variable.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

The n-dimensional array $x_ndarray must be a vector. Otherwise, an exception is thrown.

The n-dimensional array $y_ndarray must be defined. Otherwise, an exception is thrown.

The n-dimensional array $y_ndarray must be a vector. Otherwise, an exception is thrown.

The length of the n-dimensional array $x_ndarray must be equal to the length of the n-dimensional array $y_ndarray. Otherwise, an exception is thrown.

outer

static method outer : R::NDArray::FloatComplex ($x_ndarray : R::NDArray::FloatComplex, $y_ndarray : R::NDArray::FloatComplex);

Creates a new R::NDArray::FloatComplex object of the dimensions [$x_dim, $y_dim] ($x_dim is the dimensions of $x_ndarray and $y_dim is the dimensions of $y_ndarray) for a return value, performs outer product of elements of the n-dimensional array $x_ndarray and $y_ndarray, and sets each element of the new n-dimensional array to the each operation result, and returns the new n-dimensional array.

Exceptions:

The n-dimensional array $x_ndarray must be defined. Otherwise, an exception is thrown.

The n-dimensional array $x_ndarray must be a vector. Otherwise, an exception is thrown.

The n-dimensional array $y_ndarray must be defined. Otherwise, an exception is thrown.

The n-dimensional array $y_ndarray must be a vector. Otherwise, an exception is thrown.

pi

static method pi : R::NDArray::FloatComplex ();

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

See Also

Copyright & License

Copyright (c) 2024 Yuki Kimoto

MIT License