orthonormalization: Orthonormalization of a set of a matrix

View source: R/orthonormalization.R

orthonormalizationR Documentation

Orthonormalization of a set of a matrix

Description

Gram-Schmidt orthogonalization of a matrix considering its columns as vectors. Normalization is provided as will.

Usage

orthonormalization(u, basis=TRUE, norm=TRUE)

Arguments

u

a matrix (n x p) representing n different vectors in a n dimensional space

basis

does the returned matrix have to be a basis

norm

does the returned vectors have to be normed

Details

This is a simple application of the Gram-Schmidt algorithm of orthogonalization (please note that this process was presented first by Laplace).

The user provides a set of vector (structured in a matrix) and the function calculate a orthogonal basis of the same space. If desired, the returned basis can be normed, or/and completed to cover the hole space.

If the number of vectors in u is greater than the dimension of the space (that is if n > p), only the first p columns are taken into account to computed the result. A warning is also provided.

The only assumption made on u is that the span space is of size min(n,p). In other words, there must be no colinearities in the initial set of vector.

Value

The orthogonalized matrix obtained from u where the vector are arranged in columns.

If basis is set to TRUE, the returned matrix is squared.

Author(s)

J. Damon

Examples

  mat1 <- matrix(c(1,0,1,1,1,0),nrow=3,ncol=2)
  orth1 <- orthonormalization(mat1, basis=FALSE, norm=FALSE)
  orth2 <- orthonormalization(mat1, basis=FALSE, norm=TRUE)
  orth3 <- orthonormalization(mat1, basis=TRUE, norm=TRUE)
  crossprod(orth1)
  crossprod(orth2)
  crossprod(orth3)

Looping027/far documentation built on Aug. 15, 2022, 7:15 a.m.