Storage and methods for CPU vector data.
Data is held in an external pointer.
new()
cpuvecR6$new(size = 0, type = "double")
size
The length of the vector.
type
Storage type for the vector. Should be one of 'int', 'float', or 'double'.
Class initializer. See also ?cpuvec
.
resize()
cpuvecR6$resize(size)
size
The new length.
Change the length of the vector object.
inherit()
cpuvecR6$inherit(data)
data
R vector.
Set the data in the cpuvec object to point to the array in 'data'. See
also ?as_cpuvec
.
dupe()
cpuvecR6$dupe()
Duplicate the vector in a deep copy.
info()
cpuvecR6$info()
Print one-line information about the vector.
print()
cpuvecR6$print(ndigits = 4)
ndigits
Number of decimal digits to print.
Print the data.
fill_zero()
cpuvecR6$fill_zero()
Fill all entries with zero.
fill_val()
cpuvecR6$fill_val(v)
v
Value to set all entries to.
Fill all entries with supplied value.
fill_linspace()
cpuvecR6$fill_linspace(start, stop)
start, stop
Beginning/end of the linear spacing.
Fill the vector (column-wise) with linearly-spaced values.
scale()
cpuvecR6$scale(s)
s
Value to scale all entries by.
Scale all entries by the supplied value.
pow()
cpuvecR6$pow(s)
p
Value to raise all entries to.
Exponentiate all entries by the supplied value.
rev()
cpuvecR6$rev()
Reverse rows.
sum()
cpuvecR6$sum()
Sum the vector.
Returns the sum.
min()
cpuvecR6$min()
Finds the minimum value of the vector.
Returns the min.
max()
cpuvecR6$max()
Finds the maximum value of the vector.
Returns the max.
get()
cpuvecR6$get(i)
i
Index (0-based).
Get element from the vector.
set()
cpuvecR6$set(i, v)
i
Index (0-based).
v
Value.
Set element of the vector.
size()
cpuvecR6$size()
Returns length of the vector.
data_ptr()
cpuvecR6$data_ptr()
Returns the external pointer data. For developers only.
get_type()
cpuvecR6$get_type()
Returns the integer code for the underlying storage type. For developers only.
get_type_str()
cpuvecR6$get_type_str()
Returns the string code for the underlying storage type. For developers only.
get_class()
cpuvecR6$get_class()
Returns the integer code the class type, in this case CLASS_VEC.
to_robj()
cpuvecR6$to_robj()
Returns an R vector containing a copy of the class data.
from_robj()
cpuvecR6$from_robj(robj)
robj
R vector.
Copies the values of the input to the class data. See also ?as_cpuvec
.
clone()
The objects of this class are cloneable with this method.
cpuvecR6$clone(deep = FALSE)
deep
Whether to make a deep clone.