multiply_arrays: Multiply arrays based on dimension-names, using recycling

Description Usage Arguments Value

View source: R/multiply_arrays.R

Description

Given two arrays with a full set of named dimension-names that match in a proper fashion, this function will create the product of them based on matching dimension-names. If necessary, an intermediate step will be performed to properly align the arrays. If one array has fewer dimensions than the other, then the product will be performed by recycling of vectors.

Usage

1
multiply_arrays(.arr1, .arr2, keep_shape = FALSE)

Arguments

.arr1

The first array in the product, if .arr2 has the same size (but not necessarily the same shape), the result will be given in the shape of .arr1. The case where .arr1 is a single number (dimensionless) will be treated as an exception, in which case that single number will be multiplied with .arr2.

.arr2

The second array in the product. The case where .arr2 is a single number (dimensionless) will be treated as an exception, in which case that single number will be multiplied with .arr1.

keep_shape

A logic argument, default value FALSE that only is used when recycling is needed in order to perform the product. If the shape of the resulting array doesn't matter, then the default will avoid an extra permutation at the end of the computation.

Value

When .arr1 and .arr2 have the same size, the result will be the product of them in the shape of .arr1. If one of them has fewer dimensions than the other, then recycling will be performed and the result will be given in the shape of the largest one. It is allowed to have as an exception the case where one (or both) of the array-arguments is a single number (dimensionless), in which case a standard product will be performed.


LAJordanger/leanRcoding documentation built on Feb. 27, 2020, 4:42 p.m.