quadform function

Fast quadratic form computation

Fast quadratic form computation

Fast computation of a quadratic form t(x)Mxt(x) * M * x.

quadform(x, M, invertM = FALSE, transposex = FALSE)

Arguments

  • x: A matrix with dimensions n*k.
  • M: A matrix with dimenions n*n. If it is to be inverted then the matrix should be symmetric and positive difinite (no check is done for this)
  • invertM: A logical. If set to TRUE then M will be inverted before computations (defaults to FALSE)
  • transposex: A logical. Should the matrix be transposed before computations (defaults to FALSE).

Returns

A matrix with dimensions k * k giving the quadratic form

Author(s)

Claus Ekstrom claus@rprimer.dk

  • Maintainer: Claus Thorn Ekstrøm
  • License: GPL-2
  • Last published: 2023-08-20