Library: | math |
See also: | mat2rot CPCp CPCFGalg |
Quantlet: | Jacobirot | |
Description: | Jacobirot produces an orthogonal matrix used in the Jacobi rotation. |
Usage: | Jac=Jacobirot(m,j,theta,p) | |
Input: | ||
m | scalar: determines a place in the matrix (see below) | |
j | scalar: determines a place in the matrix (see below) | |
theta | scalar: the angle of the rotation | |
p | scalar: size of the output matrix | |
Output: | ||
Jac | p x p diagonal matrix with ones on the diagonal, but with cos(theta) at Jac[m,m], -sin(theta) at Jac[m,j], sin(theta) at Jac[j,m] and cos(theta) at Jac[j,j]. |
library("math") A = #(112.01, 106.64, 52.97)~#(106.64,108.13,54.75)~#(52.97,54.75,33.86) eigv = eigsm(A[2:3,2:3]){2} ; compute eigenvectors of a submatrix theta = acos(eigv[1,1]) ; find rotation angle H = Jacobirot(2,3,theta,3)'*A*Jacobirot(2,3,theta,3) A H
Contents of A [1,] 112.01 106.64 52.97 [2,] 106.64 108.13 54.75 [3,] 52.97 54.75 33.86 Contents of H [1,] 112.01 119.03 -3.1413 [2,] 119.03 137.15 -1.4211e-14 [3,] -3.1413 -8.8818e-15 4.8393 The example shows that in H the mth and jth column is affected after applying the Jacobi rotation to A. Here, the rotation angle is chosen in a way to diagonalize the (2x2) m,jth submatrix. Of course this is the same as computing its eigenvectors.