Learn R Programming

glmmFEL (version 1.0.5)

glmmfe_trAB: Fast trace of a matrix product

Description

Internal helper to compute \(\mathrm{tr}(A B)\) without forming A %*% B: $$\mathrm{tr}(A B) = \sum (A \circ B^\top).$$

This identity is used repeatedly in the fully exponential (FE) trace corrections (Karl, Yang, and Lohr, 2014, Appendix B), where a naive diag(A %*% B) would allocate the full product.

Usage

glmmfe_trAB(A, B)

Value

A single numeric scalar equal to tr(A %*% B).

Arguments

A, B

Numeric matrices with identical dimensions.