Compute the cosine of the angle between a vector and a subspace

Description

cosangle1 returns the cosine of the angle between a vector vecs and the subspace spanned by the columns of the matrix mat. For cosangle, vecs can be a matrix, in which case cosangle1 is called for each column in vecs.

Usage

cosangle(mat, vecs)
cosangle1(mat, vec)

Arguments

mat A matrix the provides the basis for a subspace
vecs A vector with the same number of rows as mat, or a matrix with the same number of rows as mat
vec A vector with the same number of rows as mat

Details

cosangle1 computes the cosine of the angle between vec and the orthogonal projection of vec onto the column space of mat. cosangle repeats this computation for each column of vecs.

Value

cosangle1 returns a single value and cosangle returns a vector.

Author(s)

Sanford Weisberg <sandy@stat.umn.edu>


[Package Contents]