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::Matrix::DoubleComplex - Matrix Operations for R::NDArray::DoubleComplex

Description

R::OP::Matrix::DoubleComplex class in SPVM has methods for matrix operations for R::NDArray::DoubleComplex.

Usage

  use R::OP::Matrix::DoubleComplex as MDCOP;
  
  # $nrow * $ncol matrix. data field is [1+10i, 2+20i, 3+30i, 4+40i, 5+50i, 6+60i] by column major order.
  my $nrow = 3;
  my $ncol = 2;
  my $ndarray = MDCOP->matrix([(double)1,10,  2,20,  3,30,  4,40,  5,50,  6,60], $nrow, $ncol);

See also Matrix Examples.

Class Methods

matrix

static method matrix : R::NDArray::DoubleComplex ($data : object of double[]|Complex_2d[]|R::NDArray::DoubleComplex, $nrow : int, $ncol : int);

Creates a new R::NDArray::DoubleComplex object that represents a matrix given the data $data, the row numers $nrow, and the column numbers $ncol, and returns the new object.

This method calls R::OP::DoubleComplex#c method.

  my $ret_ndarray = R::OP::DoubleComplex->c($data, [$nrow, $ncol]);

Exceptions:

Exceptions thrown by R::OP::DoubleComplex#c method could be thrown.

matrix_byrow

static method matrix_byrow : R::NDArray::DoubleComplex ($data : object of double[]|Complex_2d[]|R::NDArray::DoubleComplex, $nrow : int, $ncol : int);

Same as "matrix" method, but the input data $data is interpreted as column major order.

Exceptions:

Exceptions thrown by "matrix" method could be thrown.

cbind

static method cbind : R::NDArray::DoubleComplex ($x_ndarray : R::NDArray::DoubleComplex, $y_ndarray : R::NDArray::DoubleComplex);

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

rbind

static method rbind : R::NDArray::DoubleComplex ($x_ndarray : R::NDArray::DoubleComplex, $y_ndarray : R::NDArray::DoubleComplex);

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

diag

static method diag : R::NDArray::DoubleComplex ($x_ndarray : R::NDArray::DoubleComplex);

Creates a R::NDArray::DoubleComplex object that represents a diagonal matrix given a n-dimensional array $x_ndarray that is a vector with diagonal values, and returns the new object.

The row numbers and column numbers of the new object is equal to the value of length field of $x_ndarray.

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.

slice_diag

static method slice_diag : R::NDArray::DoubleComplex ($x_ndarray : R::NDArray::DoubleComplex);

Creates a new R::NDArray::DoubleComplex, sets its data to the diagonal values of the n-dimension array $x_ndarray that is a matrix, and returns the new object.

The value of length field of the new object is equal to the row numbers of $x_ndarray.

Exceptions:

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

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

identity

static method identity : R::NDArray::DoubleComplex ($nrow : int);

Creates a new R::NDArray::DoubleComplex object that represets an identity matrix given the row numbers $nrow, and returns the new object.

Exceptions:

The row numbers $nrow must be greater than 0. Otherwise, an exception is thrown.

mul

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

Performs a matrix multiplication on the n-dimension array $x_ndarray that is a matrix and the n-dimension array $y_ndarray that is a matrix.

And creates a new R::NDArray::DoubleComplex object with the result, and returns the new object.

Exceptions:

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

The n-dimensional array $x_ndarray must be a matrix. 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 matrix. Otherwise, an exception is thrown.

The column numbers of the matrix $x_ndarray must be equal to the row numbers of the matrix $y_ndarray. Otherwise, an exception is thrown.

t

static method t : R::NDArray::DoubleComplex ($x_ndarray : R::NDArray::DoubleComplex);

Performs a matrix transpose on the n-dimension array $x_ndarray that is a matrix, creates a new R::NDArray::DoubleComplex object with the result, and returns the new object.

Excetpions:

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

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

det

static method det : R::NDArray::DoubleComplex ($x_ndarray : R::NDArray::DoubleComplex);

Calculates the determinant of the n-dimension array $x_ndarray that is a matrix, creates a new R::NDArray::DoubleComplex object with the result, and returns the new object.

The new object is a scalar.

Exceptions:

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

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

solve

static method solve : R::NDArray::DoubleComplex ($x_ndarray : R::NDArray::DoubleComplex);

Calculates the inverse of the n-dimension array $x_ndarray that is a matrix, creates a new R::NDArray::DoubleComplex object with the result, and returns the new object.

Exceptions:

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

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

The determinant of the n-dimensional array $x_ndarray that is a matrix must not be equal to 0. Otherwise, an exception is thrown.

eigen

static method eigen : R::NDArray::Hash ($x_ndarray : R::NDArray::DoubleComplex);

Finds the eigenvectors and eigenvalues of the n-dimension array $x_ndarray that is a matrix, and creates a new two R::NDArray::DoubleComplex object for each results.

And creates a new R::NDArray::Hash object, sets the value of key "vectors" to the new object that has the eigenvectors, sets the value of key "values" to the new object that has the eigenvalues. Note that these vectores and values are complex numbers even if the result is able to be represented by real numbers.

And returns the new R::NDArray::Hash.

Exceptions:

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

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

See Also

Copyright & License

Copyright (c) 2024 Yuki Kimoto

MIT License