Sponsoring The Perl Toolchain Summit 2025: Help make this important event another success Learn more

# Copyright (c) 2024 Yuki Kimoto
# MIT License
class R::OP::AnyObject {
version_from R;
use R::OP;
use R::NDArray::AnyObject;
# Class Methods
static method c : R::NDArray::AnyObject ($data : object of object[]|R::NDArray::AnyObject, $dim : int[] = undef) {
if ($data) {
if ($data is_type object[]) {
# Do nothing
}
elsif ($data is_type R::NDArray::AnyObject) {
unless ($dim) {
$dim = $data->(R::NDArray::AnyObject)->dim;
}
$data = $data->(R::NDArray::AnyObject)->data;
}
else {
die "The type of the data \$data must be object[] or R::NDArray::AnyObject.";
}
}
my $ndarray = R::NDArray::AnyObject->new({dim => $dim, data => $data});
return $ndarray;
}
}