You can edit almost every page by Creating an account and confirming your email.

n-Dimensional rotation matrix generation algorithm

From EverybodyWiki Bios & Wiki


High-dimensional spaces frequently occur in mathematics and the sciences, for example, N-dimensional feature space, which presents input signals of a neural network or a collection of N-dimensional parameters for multidimensional data analysis. Rotation is one of the rigid transformations in geometrical space that preserves the length of vectors and can be presented using matrix operations like Y = M.X, where X and Y are input and output vectors respectively, and M is the rotation matrix.

Definition of the task

Let's say that we have two n-dimensional vectors X and Y, having the same dimension, X, Y RN. We want to obtain a rotation matrix M that satisfies the equation

Yx=MX

where Yx has the same norm as X and the same direction as Y, i.e. Yx=X (cosYx,Y=1).

Algorithms for generation of n-dimensional rotation matrix

Descriptions of three algorithms for the generation of an n-dimensional rotation matrix, which rotates a given n-dimensional vector X to the direction of a given n-dimensional vector Y, are given below.

Using rotation in coordinate plane of basis, defined by given vectors

One of the possibilities to generate rotation matrix M is to change the basis and to create a matrix that rotates vector X in the coordinate plane in which lie the two given vectors. This algorithm includes the following sequence of operations:

  • Obtain two orthogonal vectors in the plane in which lie the two given vectors using the Gramm-Schmidt procedure.
  • Enlarge this 2-dimensional basis to an N-dimensional basis B2, in which given vectors X, Y are transformed to X и Y.
  • Create a Givens matrix G(1,2,θ) for RN, which performs rotation of X in coordinate plane x1,x2 to the direction of vector Y.
  • Obtain rotation matrix M as M=P1G(1,2,θ)P where P is the transformation matrix from the initial basis B to the constructed basis B2.

Using Householder reflection

Another way to generate a rotation matrix M is to use Householder reflection. If X and Y are vectors with the same norm, there exists an orthogonal symmetric matrix P such that Y=PX where P=I2WWT and W=XY/XY. Matrix P is a matrix of reflection (not a rotation) because det P = –1 (which gives the name to the method). That’s why to obtain a matrix of rotation M, for which det M = 1, two subsequent reflections have to be performed. The matrix of rotation can be obtained as a multiplication of two matrices of reflection P1 and P2 as M=P1P2.

Using rotation of given vectors to the direction of one of coordinate axes

The third way to generate a rotation matrix M is to use rotation of given vectors to the direction of one of the coordinate axes (i.e. axis x1). This algorithm (named NRMG algorithm) includes the following sequence of operations:

  • Obtain rotation matrix Mx, which rotates given vector X to the direction of axis x1.
  • Obtain rotation matrix My, which rotates given vector Y to the direction of axis x1.
  • Obtain rotation matrix M, as a multiplication of Mx by the inverse matrix of My given as:
M=My1Mx=MyTMx

As it can be seen in the description above, the base operation of the NRMG algorithm is rotation of an n-dimensional vector to the direction of one of the coordinate axes (i.e. axis x1).

Rotation of n-dimensional vector to the direction of axis x1

Rotation of a given n-dimensional vector to the direction of one of the coordinate axes (i.e. axis x1) can be performed by n − 1 subsequent rotations in coordinate planes (xnk, xnk+1), k = 1,…,n − 1 using multiplications by Givens matrices G(nk,nk+1,θnk), where coefficients S = sin(θnk) and C = cos(θnk) are calculated as follows:

{sin(θnk)=xnk+1xnk2+xnk+12,cos(θnk)=xnkxnk2+xnk+12,xnk2+xnk+12>0sin(θnk)=0,cos(θnk)=1,xnk2+xnk+12=0

After every rotation, we get a vector that is orthogonal to the coordinate axis xnk+1 in the current coordinate plane (xnk, xnk+1). Thus subsequent rotations in coordinate planes (xnk, xnk+1), k = 1,…,n − 1 give a vector that is orthogonal to all coordinate axes except x1. Rotation matrix Mx is obtained as a multiplication of Givens matrices G(nk,nk+1,θnk), k=1,,n1, as follows:

Mx=k=1n1G(nk,nk+1,θnk)

The length rX=X of given vector X and angles of rotation θ1 , ... , θn−1 in the equation above are in reality coordinates of vector X, presented in hyperspherical coordinate system as XS = [rX, −θ1 , ... , −θn−1 ]T. Angles of rotation are included with a negative sign, because rotation of a given vector to the direction of the coordinate axis x1 calculates angles from the vector to the coordinate axes, while presentation of the vector in hyperspherical coordinate system calculates opposite direction angles – from axes to vector.

The advantage of using Givens rotations for rotation of an n-dimensional vector to the direction of one of the coordinate axes is that rotations in coordinate planes can easily be parallelised. This way the number of subsequent rotations in coordinate planes (i.e. the number of matrix multiplications) can be reduced to log2(n) regardless of the fact that the total number of rotations in coordinate planes will remain equal to n1.

Notes

The time complexity of the algorithms described above depends on the "density" of given vectors X and Y. Like for the task of QR decomposition, for "dense" vectors Householder Reflection can be the most efficient, while for vectors that have many zero elements, the NRMG algorithm (which uses Givens rotations) can be more efficient than the other two.

References

  • H.G. Golub, J.M. Ortega, 1993, Scientific Computing and Introduction with Parallel Computing, Academic Press, Inc., San Diego
  • G. A. Korn, T.M. Korn, 1961, Mathematical Handbook for Scientists and Engineers (1st ed.), New York: McGraw-Hill. pp. 55–79.
  • H. Friedberg, A. Insel, L. Spence, 1997, Linear Algebra (3rd ed), Prentice Hall.
  • M. Cosnard, Y. Robert. Complexity of parallel QR factorization. J. ACM 33, 4 (August 1986), 712–723. DOI=10.1145/6490.214102, 1986
  • A. H. Sameh, D. J. Kuck. On Stable Parallel Linear System Solvers. J. ACM 25, 1 (January 1978), 81–91. DOI= http://dx.doi.org/10.1145/322047.322054, 1978
  • N. J. Higham, 1996, Accuracy and Stability of Numerical Algorithms, SIAM, Philadelfia
  • G. W.Steward, 1976, The economical storage of plane rotations, Numer. Math, 25, 2 1976, 137–139
  • N. K. Bose, 1985, Multidimensional Systems Theory: Progress, Directions, and Open Problems. D.Reidel Publishing Co., Dordrecht, The Netherland
  • A. S. Householder, 1958, “Unitary triangularization of a nonsimetric matrix”, J. ACM 5, 339–342, 1958
  • E. Anderson, 2000, “Discontinuous Plane Rotations and the Symmetric Eigenvalue Problem” LAPACK Working Note 150, University of Tennessee, UT-CS-00-454, December 4, 2000. page 2
  • Zhelezov O. I. N-dimensional Rotation Matrix Generation Algorithm, American Journal of Computational and Applied Mathematics, Vol. 7 No. 2, 2017, pp. 51–57. doi: 10.5923/j.ajcam.20170702.04.


This article "N-Dimensional rotation matrix generation algorithm" is from Wikipedia. The list of its authors can be seen in its historical. Articles copied from Draft Namespace on Wikipedia could be seen on the Draft Namespace of Wikipedia and not main one.