Name
SPVM::R::NDArray::Time::Piece - N-Dimensional Array of Time::Piece Type.
Description
R::NDArray::Time::Piece class in SPVM represents n-dimensional array of Time::Piece
type.
Usage
my
$data
= [
Time::Piece->strptime(
"2024-01-01 00-00-00"
,
'%Y-%m-%d %H:%M:%S'
),
Time::Piece->strptime(
"2024-01-02 00-00-00"
,
'%Y-%m-%d %H:%M:%S'
),
Time::Piece->strptime(
"2024-01-03 00-00-00"
,
'%Y-%m-%d %H:%M:%S'
),
Time::Piece->strptime(
"2024-01-04 00-00-00"
,
'%Y-%m-%d %H:%M:%S'
),
Time::Piece->strptime(
"2024-01-05 00-00-00"
,
'%Y-%m-%d %H:%M:%S'
),
Time::Piece->strptime(
"2024-01-06 00-00-00"
,
'%Y-%m-%d %H:%M:%S'
),
];
my
$ndarray
= R::NDArray::Time::Piece->new({
data
=>
$data
,
dim
=> [3, 2]});
Super Class
Field
data
method data : Time::Piece[] ();
Same as R::NDArray#data method, but the return type is different.
Class Methods
new
static method new : R::NDArray::Time::Piece ($options : object[] = undef);
Creates a new R::NDArray::Time::Piece 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 : Time::Piece[] ($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 Time::Piece[
$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 : Time::Piece[], $data_index : int);
Converts an element $data at index $data_index to a string and returns it.
my
$string
= (string)
undef
;
if
(
$data
->[
$data_index
]) {
$string
=
$data
->[
$data_index
]->strftime(
"%Y-%m-%d %H:%M:%S"
);
}
elem_assign
method elem_assign : void ($dist_data : Time::Piece[], $dist_data_index : int, $src_data : Time::Piece[], $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 : Time::Piece[], $dist_data_index : int, $src_data : Time::Piece[], $src_data_index : int);
Clones the element $src_data at index $src_data_indext to the element $dist_data at index $dist_data_index.
The clone is created by the following code.
$dist_data
->[
$dist_data_index
] = (Time::Piece)
undef
;
if
(
$src_data
->[
$src_data_index
]) {
$dist_data
->[
$dist_data_index
] =
$src_data
->[
$src_data_index
]->clone;
}
elem_cmp
method elem_cmp : int ($a_data : Time::Piece[], $a_data_index : int, $b_data : Time::Piece[], $b_data_index : int);
Compares the element $a_data at index $a_data_index and the element $b_data at index $b_data_index using the following comparison code and returns the result.
my
$cmp
= 0;
if
(
$a_data
->[
$a_data_index
] &&
$b_data
->[
$b_data_index
]) {
my
$a_epoch
=
$a_data
->[
$a_data_index
]->epoch;
my
$b_epoch
=
$b_data
->[
$b_data_index
]->epoch;
$cmp
=
$a_epoch
<=>
$b_epoch
;
}
elsif
(
$a_data
->[
$a_data_index
]) {
$cmp
= 1;
}
elsif
(
$b_data
->[
$b_data_index
]) {
$cmp
= -1;
}
clone
method clone : R::NDArray::Time::Piece ($shallow : int = 0);
Same as R::NDArray#clone method, but the return type is different.
slice
method slice : R::NDArray::Time::Piece ($indexes_product : R::NDArray::Int[]);
Same as R::NDArray#slice method, but the return type is different.
See Also
Copyright & License
Copyright (c) 2024 Yuki Kimoto
MIT License