R: Matrix crossproduct envolving the duplication matrix

dupl.cross {fastmatrix} | R Documentation

## Matrix crossproduct envolving the duplication matrix

### Description

Given the order of two duplication matrices and matrix `x`, this function performs the operation: \bold{Y} = \bold{D}_n^T\bold{X}\bold{D}_k, where \bold{D}_n and \bold{D}_k are duplication matrices of order n and k, respectively.

### Usage

    dupl.cross(n = 1, k = n, x = NULL)

### Arguments

`n` | order of the duplication matrix used pre-multiplying `x`.
`k` | order of the duplication matrix used post-multiplying `x`. By default `k = n` is used.
`x` | numeric matrix, this argument is required.

### Details

This function calls `dupl.prod` to performs the matrix multiplications required but without forming any duplication matrices.

### See Also

`dupl.prod`

### Examples

    D2 <- duplication(n = 2, matrix = TRUE)
    D3 <- duplication(n = 3, matrix = TRUE)
    x <- matrix(1, nrow = 9, ncol = 4)
    y <- t(D3) %*% x %*% D2

    z <- dupl.cross(n = 3, k = 2, x) # D2 and D3 are not stored
    all(z == y) # matrices y and z are equal!

    x <- matrix(1, nrow = 9, ncol = 9)
    z <- dupl.cross(n = 3, x = x) # same matrix is used to pre- and post-multiplying x
    z # print result

[Package fastmatrix version 0.4-1 Index]