00_binary_operators: Matrix Array Multiplication

Description Usage Arguments Details Value See Also Examples

Description

Multiplication on GeomArray and MatrixArray objects.

These functions call the Transformation Functions.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#simple matrix-array multiplication
## S4 method for signature 'MatrixArray,MatrixArray'
x %*% y
## S4 method for signature 'MatrixArray,matrix'
x %*% y
## S4 method for signature 'matrix,MatrixArray'
x %*% y

#pre-multiplication
#(with right-side data objects)
a %*[% b
a %*{% b
a %*|% b

#post-multiplication
#(with left-side data objects)
a %]*% b
a %}*% b
a %|*% b

a %*||% b
a %||*% b

Arguments

a, b

In simple matrix-array multiplication, matrices or MatrixArray(s).

In pre-multiplication, a is the transformation object and b is the data object.
In post-multiplication, a is the data object and b is the transformation object.

The transformation object should be a matrix or MatrixArray.

The data object should a matrix, GeomObject, GeomArray or MatrixArray.
Except for row-wise and col-wise functions (with the vertical bars), where the data object should be a matrix.

x, y

Same as a and b.

Details

The operators are designed for matrix array multiplication.
But can also be used to transform GeomObject(s) and GeomArray(s).

If there are two matrix arrays, each with ten matrices of the same size:
And they are multiplied using the %*% operator, then each pair of matrices is multiplied using matrix multiplication, and a new matrix array is returned, of length ten.

It's possible to use a single matrix, in which case, its handled the same as a matrix array of length one.
Each pair of matrices needs to be conformable.
And if the lengths of the matrix arrays are different, then one matrix array is recycled.
(But currently, the length longer one needs to a multiple of the length shorter one).

Often these operators can be used to apply transformation matrices to data.
In which case, the transformation matrices will often have one more row or column than the data.

With the right-pad operator %*[%, an extra row of ones is rbinded to the right hand matrices before multiplication, and strips it off the result. Likewise, with the left-pad operator %]*%, an extra column of ones is cbinded to the left hand matrices before multiplication, and then strips it off.
The padded operators can also used on GeomObject(s), including GeomArray(s).

There are a number of variations on this approach.

In cartesian-based matrix array multiplication, the resulting object is the product over the cartesian set of both matrix arrays.
If the matrix arrays have length 10 and 20, then the resulting matrix array will have length 200, not 20.

The %*{% and %}*% operators perform cartesian matrix array multiplication, using a right or left data object, respectively.
These call the vt3.gmultc.pre and vt3.gmultc.post functions, which provide some more information.

The %*|% and %|*% operators, perform column-wise and row-wise matrix array multiplication, with right or left padding.
The data object, which should be a matrix, is handled as a MatrixArray of padded column or row vectors.
The double bar operators are the same, except that the don't pad the operands.

In post-multiplication (but not pre-multiplication) with two or more transformations and left-padding of the left-most matrix array, we need to put all the transformations in parentheses, otherwise the result after the first multiplication will be non-conformable with the subsequent multiplications.

Value

Column-wise and row-wise operators return a single matrix.

All other operators should return a GeomArray or MatrixArray.

Note that the recycling order, is subject to change.

See Also

MatrixArray

Pre-Multiplication Transformation Matrices

Post-Multiplication Transformation Matrices

vt3.testplot, vt3.testplot3

Examples

1
2
3
4
5
6
########################################
#refer to:
#Pre-Multiplication or Post-Multiplication
#for better examples
########################################
vt3.testplot (SQUARE %]*% brot2 (pi / 8) )

vectools documentation built on June 7, 2021, 9:08 a.m.