bop: Bloc Operation in Place

View source: R/RcppExports.R

bopR Documentation

Bloc Operation in Place

Description

src array is added (if sop=="+=") to dst[...] or any other manipulation is made according to sop parameter Both arrays are supposed to be of type 'double' The operation is done 'in place' without new memory allocation for dst src is reshaped and possibly replicated to fit the designated block of dst. mv can be:

  • a 1 or 3 component vector describing the block: 1-margin number of dst, 2-offset, 3-length if only the margin is present than offest is 0 and length is the total length of this margin

  • a matrix of indexes. Its column number must be equal to the length(dim(dst))) each row of this matrix is a multidimensional index in dst array.

sop is one off: "=" (copy src to dst[]), "+=", "-=", "*=", "/="

Usage

bop(dst, mv, sop, src)

Arguments

dst

A numeric array, destination

mv

An integer vector or matrix, describe margins to operate on

sop

A string, describes an operator to apply

src

A numeric array, source (may be replicated to fit the size of dst)

Value

None

Examples

a=matrix(1, 3, 3) # 3x3 matrix of 1's
b=1:3
bop(a, 2, "+=", b) # a += b, here b will be repeated
a
#      [,1] [,2] [,3]
# [1,]    2    2    2
# [2,]    3    3    3
# [3,]    4    4    4

multbxxc documentation built on June 27, 2024, 1:06 a.m.