sumsymouter: Compute Quadratic Forms in 3D Arrays

View source: R/linalg.R

sumsymouterR Documentation

Compute Quadratic Forms in 3D Arrays

Description

Calculates certain quadratic forms of 3D arrays.

Usage

  sumsymouter(x, w = NULL, distinct = TRUE)

Arguments

x

Three-dimensional array (class array) or sparse three-dimensional array (class sparse3Darray).

w

Matrix or sparse matrix.

distinct

Logical value indicating whether to exclude diagonal contributions. See Details.

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.

Value

A square matrix with numeric or complex values.

Author(s)

\adrian

.

See Also

sumouter

Examples

   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)

spatstat.sparse documentation built on May 21, 2026, 9:07 a.m.