Storage and methods for CPU matrix data.

Details

Data is held in an external pointer.

Methods

Public methods


Method new()

Usage

cpumatR6$new(nrows = 0, ncols = 0, type = "double")

Arguments

nrows, ncols

The dimension of the matrix.

type

Storage type for the matrix. Should be one of 'int', 'float', or 'double'.

Details

Class initializer. See also ?cpumat.


Method resize()

Usage

cpumatR6$resize(nrows, ncols)

Arguments

nrows, ncols

The new dimension.

Details

Change the dimension of the matrix object.


Method inherit()

Usage

cpumatR6$inherit(data)

Arguments

data

R matrix.

Details

Set the data in the cpumat object to point to the array in 'data'. See also ?as_cpumat.


Method dupe()

Usage

cpumatR6$dupe()

Details

Duplicate the matrix in a deep copy.


Method info()

Usage

cpumatR6$info()

Details

Print one-line information about the matrix.


Method print()

Usage

cpumatR6$print(ndigits = 4)

Arguments

ndigits

Number of decimal digits to print.

Details

Print the data.


Method fill_zero()

Usage

cpumatR6$fill_zero()

Details

Fill all entries with zero.


Method fill_val()

Usage

cpumatR6$fill_val(v)

Arguments

v

Value to set all entries to.

Details

Fill all entries with supplied value.


Method fill_linspace()

Usage

cpumatR6$fill_linspace(start, stop)

Arguments

start, stop

Beginning/end of the linear spacing.

Details

Fill the matrix (column-wise) with linearly-spaced values.


Method fill_eye()

Usage

cpumatR6$fill_eye()

Details

Fill diagonal values to 1 and non-diagonal values to 0.


Method fill_diag()

Usage

cpumatR6$fill_diag(v)

Arguments

v

A cpuvec object.

Details

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.


Method fill_runif()

Usage

cpumatR6$fill_runif(seed, min = 0, max = 1)

Arguments

seed

Seed for the generator. Can be left blank.

min, max

Parameters for the generator.

Details

Fill the matrix with random unifmorm data.


Method fill_rnorm()

Usage

cpumatR6$fill_rnorm(seed, mean = 0, sd = 1)

Arguments

seed

Seed for the generator. Can be left blank.

mean, sd

Parameters for the generator.

Details

Fill the matrix with random normal data.


Method diag()

Usage

cpumatR6$diag(v)

Arguments

v

A cpuvec object.

Details

Get diagonal entries of the matrix.


Method antidiag()

Usage

cpumatR6$antidiag(v)

Arguments

v

A cpuvec object.

Details

Get anti-diagonal entries of the matrix.


Method scale()

Usage

cpumatR6$scale(s)

Arguments

s

Value to scale all entries by.

Details

Scale all entries by the supplied value.


Method rev_rows()

Usage

cpumatR6$rev_rows()

Details

Reverse rows.


Method rev_cols()

Usage

cpumatR6$rev_cols()

Details

Reverse columns.


Method get()

Usage

cpumatR6$get(i, j)

Arguments

i, j

Indices (0-based).

Details

Get element from the matrix.


Method set()

Usage

cpumatR6$set(i, j, v)

Arguments

i, j

Indices (0-based).

v

Value.

Details

Set element of the matrix.


Method get_row()

Usage

cpumatR6$get_row(i, v)

Arguments

i

Index (0-based).

v

A cpuvec object.

Details

Get the specified row.


Method get_col()

Usage

cpumatR6$get_col(j, v)

Arguments

j

Index (0-based).

v

A cpuvec object.

Details

Get the specified column.


Method dim()

Usage

cpumatR6$dim()

Details

Returns number of rows and columns of the matrix.


Method nrows()

Usage

cpumatR6$nrows()

Details

Returns number of rows of the matrix.


Method ncols()

Usage

cpumatR6$ncols()

Details

Returns number of columns of the matrix.


Method data_ptr()

Usage

cpumatR6$data_ptr()

Details

Returns the external pointer data. For developers only.


Method get_type()

Usage

cpumatR6$get_type()

Details

Returns the integer code for the underlying storage type. For developers only.


Method get_type_str()

Usage

cpumatR6$get_type_str()

Details

Returns the string code for the underlying storage type. For developers only.


Method get_class()

Usage

cpumatR6$get_class()

Details

Returns the integer code the class type, in this case CLASS_MAT.


Method to_robj()

Usage

cpumatR6$to_robj()

Details

Returns an R matrix containing a copy of the class data.


Method from_robj()

Usage

cpumatR6$from_robj(robj)

Arguments

robj

R matrix.

Details

Copies the values of the input to the class data. See also ?as_cpumat.


Method clone()

The objects of this class are cloneable with this method.

Usage

cpumatR6$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.