dcrossprod: Diagonal of the Cross-Product of a Matrix

View source: R/miscUtils.R

dcrossprodR Documentation

Diagonal of the Cross-Product of a Matrix

Description

Return the diagonal of the cross-product t(X) %*% X for a given matrix X. As is well-known the cross-product is computed by the single argument of crossprod; however we often have to compute only the diagonal of the cross-product. For instance, the variance of a kriging predition may have to be computed without formin the covariance.

Usage

dcrossprod(X)

Arguments

X

A numeric matrix.

Details

Several methods can be used to compute the result in R (using apply, ...). To our best knowledge the method used here is the most efficient in general framework.

Value

The diagonal vector of crossprod(X).

Author(s)

Thanks to Clément Walter for comparisons and the suggested code.


libKriging/dolka documentation built on April 14, 2022, 7:17 a.m.