| sumsymouter | R Documentation |
Calculates certain quadratic forms of 3D arrays.
sumsymouter(x, w = NULL, distinct = TRUE)
x |
Three-dimensional array (class |
w |
Matrix or sparse matrix. |
distinct |
Logical value indicating whether to exclude diagonal contributions. See Details. |
Given a three-dimensional matrix or sparse matrix x
and a matrix or sparse matrix w,
this function computes the matrix M with entries
M_{i,j} = \sum_k \sum_m w_{k,m} x_{i, k, m} x_{j, m, k}
,
the weighted sum of symmetric outer products of x
with weights w.
If distinct=TRUE (the default), terms with k=m are
omitted from the sum. If distinct=FALSE they are included.
The array x should have dimensions
p \times n \times n
and the matrix w should have dimensions n \times n
if it is given.
The result M is a p \times p square matrix.
If w is missing or NULL, all weights are taken to be 1.
Entries in x and w may be integer, numeric, complex
or logical values.
The result is a symmetric matrix if w is a symmetric matrix,
or if w is missing or NULL. Otherwise it is not
guaranteed to be symmetric.
A square matrix with numeric or complex values.
.
sumouter
d <- c(2, 3, 3)
n <- prod(d)
v <- ifelse(runif(n) < 0.6, 0, round(runif(n), 1))
x <- array(v, dim=d)
w <- outer(1:3, 1:3)
sumsymouter(x, w)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.