Learn R Programming

far (version 0.6-7)

orthonormalization: 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)

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.

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

Author

J. Damon

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.

Examples

Run this code
  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)

Run the code above in your browser using DataLab