quadratic_form {ForeCA} | R Documentation |
Computes quadratic form x' A x
Description
quadratic_form
computes the quadratic form for an
matrix
and an
-dimensional vector
, i.e., a wrapper for
t(x) %*% A %*% x
.
fill_symmetric
and quadratic_form
work with
real and complex valued matrices/vectors.
fill_hermitian
fills up the lower triangular part (NA
)
of an upper triangular matrix to its
Hermitian (symmetric if real matrix) version, such that it satisfies
, where
is the complex
conjugate of
. If the matrix is real-valued this makes it
simply symmetric.
Note that the input matrix must have a real-valued diagonal and
NA
s in the lower triangular part.
Usage
quadratic_form(mat, vec)
fill_hermitian(mat)
Arguments
mat |
numeric; |
vec |
numeric; |
Value
A real/complex value .
Examples
## Not run:
set.seed(1)
AA <- matrix(1:4, ncol = 2)
bb <- matrix(rnorm(2))
t(bb) %*% AA %*% bb
quadratic_form(AA, bb)
## End(Not run)
AA <- matrix(1:16, ncol = 4)
AA[lower.tri(AA)] <- NA
AA
fill_hermitian(AA)
[Package ForeCA version 0.2.7 Index]