mlr.orthogonalize | R Documentation |
Decomposing a collection of vectors into parallel and orthogonal components with respect to the subspace spanned by columns of a reference matrix.
mlr.orthogonalize(X, Z, normalize = FALSE, tolerance = .Machine$double.eps^0.5)
X |
Matrix whose columns form the subspace, with respect to which we want to orthogonalize columns of |
Z |
Matrix whose columns we want to orthogonalize with respect to the subpsace spanned by columns of |
normalize |
Boolean flag, indicating whether the orthogonal component of |
tolerance |
If unnormalized projection of a column of |
Current implementation uses Singular Value Decomposition (svd
) of X
to form an orthonormal basis from columns of X
to facilitate the projection process.
A matrix of same dimensions as Z
is returned, with each column containing the orthogonal component of the corresponding column of Z
. Parallel components are attached as parallel
attribute.
Alireza S. Mahani, Mansour T.A. Sharabiani
Link to a draft paper, documenting the supporting mathematical framework, will be provided in the next release.
K <- 10 N <- 100 Ko <- 5 X <- matrix(runif(N*K), ncol = K) Z <- matrix(runif(N*Ko), ncol = Ko) ret <- mlr.orthogonalize(X = X, Z = Z, normalize = FALSE) orthogonal <- ret parallel <- attr(ret, "parallel") Z.rec <- parallel + orthogonal # check that parallel and orthogonal components add up to Z cat("check 1:", all.equal(as.numeric(Z.rec), as.numeric(Z)), "\n") # check that inner product of orthogonal columns and X columns are zero cat("check 2:", all.equal(t(orthogonal) %*% X, matrix(0, nrow = Ko, ncol = K)), "\n")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.