Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

Qrot

Rotation Matrix to Specific Direction


Description

Construct the p x p rotation matrix that rotates the unit vector (1,0,....0), i.e., the x_1-axis, onto (1,1,1,...1)/sqrt(p), or more generally to u / ||u|| (u :=unit.image).

Usage

Qrot(p, transpose = FALSE, unit.image = rep(1, p))

Arguments

p

integer; the dimension (of the vectors involved).

transpose

logical indicating if the transposed matrix is to returned.

unit.image

numeric vector of length p onto which the unit vector should be rotated; defaults to “the diagonal” prop. to(1,1,1,...,1).

Details

The qr decomposition is used for a Gram-Schmitt basis orthogonalization.

Value

p x p orthogonal matrix which rotates (1,0,...,0) onto a vector proportional to unit.image.

Author(s)

Martin Maechler

See Also

qr, matrix (and vector) multiplication, %*%.

Examples

Q <- Qrot(6)
zapsmall(crossprod(Q)) # 6 x 6 unity <==> Q'Q = I  <==> Q orthogonal

if(require("MASS")) {
  Qt <- Qrot(6, transpose = TRUE)
  stopifnot(all.equal(Qt, t(Q)))
  fractions(Qt ^2) # --> 1/6  1/30  etc, in an almost lower-triagonal matrix
}

robustX

'eXtra' / 'eXperimental' Functionality for Robust Statistics

v1.2-4
GPL (>= 2)
Authors
Werner Stahel, Martin Maechler [aut, cre] (<https://orcid.org/0000-0002-8685-9910>) and potentially others
Initial release
2019-02-25

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.