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 - Porting R language Features

Description

R class is a port of the R language features.

WARNINGS:Tests are not yet done. All of method and field definitions in all classes will be changed.

Usage

Math Examples

use R;
use R::OP::Double as DOP;
use R::OP::Matrix::Double as DMOP;

# Scalar
my $sca1 = R->double([3.0]);

# Vector
my $vec1 = R->double([1.0, 2.0]);
my $vec2 = R->double([3.0, 4.0]);

# Addition
my $add = DOP->add($vec1, $vec2);

# Subtruction
my $sub = DOP->sub($vec1, $vec2);

# Scalar multiplication
my $scamul = DOP->scamul($sca1, $vec1);

# Innner product
my $inner_vec1_vec2 = DOP->inner($vec1, vec2);

# Absolute
my $abs_vec1 = DOP->abs($vec1);
my $abs_vec2 = DOP->abs($vec2);

# Cosine for angle
my $cos = DOP->div($inner_vec1_vec2, DOP->mul($abs_vec1, $abs_vec2));

# Matrix and liner conversion
my $mat1 = DMOP->matrix_by_row(
  [1, 0,
   0, 1], 2, 2
);
my $ret_vec = DMOP->mul($mat1, $vec1);
$ret_vec->drop_dim;

Details

Column major or Row major

Column major.

Complex Numbers

Use R::NDArray::DoubleComplex, R::OP::DoubleComplex, and R::OP::Matrix::DoubleComplex.

Modules

Repository

SPVM::R - Github

Author

Yuki Kimoto kimoto.yuki@gmail.com

Copyright & License

Copyright (c) 2024 Yuki Kimoto

MIT License