Storage and methods for CPU matrix data.
Data is held in an external pointer.
new()
cpumatR6$new(nrows = 0, ncols = 0, type = "double")
nrows, ncols
The dimension of the matrix.
type
Storage type for the matrix. Should be one of 'int', 'float', or 'double'.
Class initializer. See also ?cpumat
.
resize()
cpumatR6$resize(nrows, ncols)
nrows, ncols
The new dimension.
Change the dimension of the matrix object.
inherit()
cpumatR6$inherit(data)
data
R matrix.
Set the data in the cpumat object to point to the array in 'data'. See
also ?as_cpumat
.
dupe()
cpumatR6$dupe()
Duplicate the matrix in a deep copy.
info()
cpumatR6$info()
Print one-line information about the matrix.
print()
cpumatR6$print(ndigits = 4)
ndigits
Number of decimal digits to print.
Print the data.
fill_zero()
cpumatR6$fill_zero()
Fill all entries with zero.
fill_val()
cpumatR6$fill_val(v)
v
Value to set all entries to.
Fill all entries with supplied value.
fill_linspace()
cpumatR6$fill_linspace(start, stop)
start, stop
Beginning/end of the linear spacing.
Fill the matrix (column-wise) with linearly-spaced values.
fill_eye()
cpumatR6$fill_eye()
Fill diagonal values to 1 and non-diagonal values to 0.
fill_diag()
cpumatR6$fill_diag(v)
v
A cpuvec object.
Set diagonal entries of the matrix to those in the vector. If the vector is smaller than the matrix diagonal, the vector will recycle until the matrix diagonal is filled.
fill_runif()
cpumatR6$fill_runif(seed, min = 0, max = 1)
seed
Seed for the generator. Can be left blank.
min, max
Parameters for the generator.
Fill the matrix with random unifmorm data.
fill_rnorm()
cpumatR6$fill_rnorm(seed, mean = 0, sd = 1)
seed
Seed for the generator. Can be left blank.
mean, sd
Parameters for the generator.
Fill the matrix with random normal data.
diag()
cpumatR6$diag(v)
v
A cpuvec object.
Get diagonal entries of the matrix.
antidiag()
cpumatR6$antidiag(v)
v
A cpuvec object.
Get anti-diagonal entries of the matrix.
scale()
cpumatR6$scale(s)
s
Value to scale all entries by.
Scale all entries by the supplied value.
rev_rows()
cpumatR6$rev_rows()
Reverse rows.
rev_cols()
cpumatR6$rev_cols()
Reverse columns.
get()
cpumatR6$get(i, j)
i, j
Indices (0-based).
Get element from the matrix.
set()
cpumatR6$set(i, j, v)
i, j
Indices (0-based).
v
Value.
Set element of the matrix.
get_row()
cpumatR6$get_row(i, v)
i
Index (0-based).
v
A cpuvec object.
Get the specified row.
get_col()
cpumatR6$get_col(j, v)
j
Index (0-based).
v
A cpuvec object.
Get the specified column.
dim()
cpumatR6$dim()
Returns number of rows and columns of the matrix.
nrows()
cpumatR6$nrows()
Returns number of rows of the matrix.
ncols()
cpumatR6$ncols()
Returns number of columns of the matrix.
data_ptr()
cpumatR6$data_ptr()
Returns the external pointer data. For developers only.
get_type()
cpumatR6$get_type()
Returns the integer code for the underlying storage type. For developers only.
get_type_str()
cpumatR6$get_type_str()
Returns the string code for the underlying storage type. For developers only.
get_class()
cpumatR6$get_class()
Returns the integer code the class type, in this case CLASS_MAT.
to_robj()
cpumatR6$to_robj()
Returns an R matrix containing a copy of the class data.
from_robj()
cpumatR6$from_robj(robj)
robj
R matrix.
Copies the values of the input to the class data. See also ?as_cpumat
.
clone()
The objects of this class are cloneable with this method.
cpumatR6$clone(deep = FALSE)
deep
Whether to make a deep clone.