get_elements: Subset Non-connected Regions

View source: R/RcppExports.R

get_elementsR Documentation

Subset Non-connected Regions

Description

Replicates the subset functionality of a matrix in R.

Usage

get_elements(x, row_ind, col_ind)

Arguments

x

A matrix of dimensions M x N

row_ind

A unsigned int vec that contains the row indices within [0,M-1].

col_ind

A unsigned int vec that contains the column indices within [0,N-1].

Value

A vec with each element listed according to index specification.

Author(s)

JJB

Examples

# Generate a Matrix
m = matrix(1:12, nrow = 4)

# Select Non-connect regions
row_index = c(1, 2, 1)
col_index = c(2, 2, 3)

# Subset in R
m[cbind(row_index, col_index)]

# Subset with Armadillo
get_elements(m, row_index - 1, col_index - 1)

coatless/r-to-armadillo documentation built on Nov. 16, 2023, 5:32 a.m.