Storage and methods for CPU vector data.

Details

Data is held in an external pointer.

Methods

Public methods


Method new()

Usage

cpuvecR6$new(size = 0, type = "double")

Arguments

size

The length of the vector.

type

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

Details

Class initializer. See also ?cpuvec.


Method resize()

Usage

cpuvecR6$resize(size)

Arguments

size

The new length.

Details

Change the length of the vector object.


Method inherit()

Usage

cpuvecR6$inherit(data)

Arguments

data

R vector.

Details

Set the data in the cpuvec object to point to the array in 'data'. See also ?as_cpuvec.


Method dupe()

Usage

cpuvecR6$dupe()

Details

Duplicate the vector in a deep copy.


Method info()

Usage

cpuvecR6$info()

Details

Print one-line information about the vector.


Method print()

Usage

cpuvecR6$print(ndigits = 4)

Arguments

ndigits

Number of decimal digits to print.

Details

Print the data.


Method fill_zero()

Usage

cpuvecR6$fill_zero()

Details

Fill all entries with zero.


Method fill_val()

Usage

cpuvecR6$fill_val(v)

Arguments

v

Value to set all entries to.

Details

Fill all entries with supplied value.


Method fill_linspace()

Usage

cpuvecR6$fill_linspace(start, stop)

Arguments

start, stop

Beginning/end of the linear spacing.

Details

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


Method scale()

Usage

cpuvecR6$scale(s)

Arguments

s

Value to scale all entries by.

Details

Scale all entries by the supplied value.


Method pow()

Usage

cpuvecR6$pow(s)

Arguments

p

Value to raise all entries to.

Details

Exponentiate all entries by the supplied value.


Method rev()

Usage

cpuvecR6$rev()

Details

Reverse rows.


Method sum()

Usage

cpuvecR6$sum()

Details

Sum the vector.

Returns

Returns the sum.


Method min()

Usage

cpuvecR6$min()

Details

Finds the minimum value of the vector.

Returns

Returns the min.


Method max()

Usage

cpuvecR6$max()

Details

Finds the maximum value of the vector.

Returns

Returns the max.


Method get()

Usage

cpuvecR6$get(i)

Arguments

i

Index (0-based).

Details

Get element from the vector.


Method set()

Usage

cpuvecR6$set(i, v)

Arguments

i

Index (0-based).

v

Value.

Details

Set element of the vector.


Method size()

Usage

cpuvecR6$size()

Details

Returns length of the vector.


Method data_ptr()

Usage

cpuvecR6$data_ptr()

Details

Returns the external pointer data. For developers only.


Method get_type()

Usage

cpuvecR6$get_type()

Details

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


Method get_type_str()

Usage

cpuvecR6$get_type_str()

Details

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


Method get_class()

Usage

cpuvecR6$get_class()

Details

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


Method to_robj()

Usage

cpuvecR6$to_robj()

Details

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


Method from_robj()

Usage

cpuvecR6$from_robj(robj)

Arguments

robj

R vector.

Details

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


Method clone()

The objects of this class are cloneable with this method.

Usage

cpuvecR6$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.