One Modification which Increases Performance of N-Dimensional Rotation Matrix Generation Algorithm

— This article presents one modification of algorithm for generation of n-dimensional rotation matrix M, which rotates given n-dimensional vector X to the direction of given n-dimensional vector Y. Algorithm, named


I. INTRODUCTION
High-dimensional spaces frequently occur in mathematics and the sciences, in example n-dimensional feature space, which presents input signals of neural network or collection of n-dimensional parameters for multidimensional data analysis.Rotation is one of rigid transformations in geometrical space, which preserves length of vectors and can be presented using matrix operation like Y = M.X , where X and Y are input and output vector respectively, and M is rotation matrix.This article proposes one modification of n-dimensional rotation matrix generation algorithm, which increases performance if some of corresponding components of the two given vectors are equal.

II. SHORT DESCRIPTION OF ALGORITHMS FOR N-DIMENSIONAL ROTATION MATRIX GENERATION
Let's say that we have two n-dimensional vectors X and Y, having the same dimension, X, Y  R n .We want to obtain a rotation matrix M that satisfies the equation.X .M Y ~ (1) where Y ~ has the same norm as X and the same direction as Y, i.e.

X Y ~ and
One of possibilities to generate rotation matrix M is to rotate given vectors in two-dimensional subspace, generated by vectors and map it back to R n as follows [4], [19]: that have the same norm.Then P=uu T +vv T is a projection onto the space, generated by X and Y, and Q=I -uu T -vv T is a projection onto the n-2 dimensional complementment subspace.So the rotation just has to take place on the range of P.This rotation has to be performed in R 2 .Then result is mapped back to R n by [a,b] T au+bv.So matrix of rotation, which rotates X to the direction of Y is calculated as follows: Another way to generate rotation matrix M is to use Householder Reflection [5], [11], [18], [19].If u and v are vectors with the same norm, in example obtained from input vectors X and Y as . Matrix P is matrix of reflection (not a rotation) because det P = -1, (which gives the name to method) that's why to obtain matrix of rotation M, for which det M = 1, have to be performed two subsequent reflections.Matrix of rotation can be obtained as multiplication of two matrices of reflection P1 and P2 as M = P1.P2 .The third way to generate rotation matrix M is to use rotation of given vectors to the direction of one of coordinate axes (i.e.axis 1 x  ).Algorithm, named N- dimensional Rotation Matrix Generation Algorithm (NRMG algorithm) [1] includes the following sequence of operations: 1) Obtaining rotation matrix MX, which rotates given vector X to the direction of axis 1 x  as follows: 2) Obtaining rotation matrix MY, which rotates given vector Y to the direction of axis using ( 3) and ( 4). 3) Obtaining rotation matrix M as multiplication of MX by inverse matrix of MY given as M=MX -1.

III. DEFINITION OF THE TASK
Let's say that we have two n-dimensional vectors X and Y, having the same dimension and the same norm, X, Y  R n , X Y  and let's some of their corresponding components xi and yi are equal: xi=yi if iK{1,…n}.We want to obtain a rotation matrix M that satisfies the equation.

X . M Y 
(5) As it can be seen from this definition, proposed modification of NRMG algorithm needs the two given vectors X and Y to have the same norm, while the original NRMG algorithm [20] do not.

IV. DESCRIPTION OF MODIFIED NRMG ALGORITHM
Modified NRMG (MNRMG) algorithm for generation of N-dimensional rotation matrix M is NRMG algorithm [1], which uses rotations in coordinate planes only in subspace V, that is spanned by the unit vectors of axes, on which components of given vectors X и Y are not equal.
MNRMG algorithm contains the following operations: 1) Comparing corresponding components of the two given vectors X и Y and obtaining vector , which consist of indexes of components that are not equal.2) Obtaining rotation matrix MX , which rotates projection of given vector X in subspace V to the direction of one of axes, having indexes in w  (i.e. the first one) 3) Obtaining rotation matrix MY, which rotates projection of given vector Y in subspace V to the direction of the same axis as for projection of X. 4) Obtaining rotation matrix M, which rotates given vector X to the direction of given vector Y as multiplication of matrix MX and inverse matrix of MY , as follows: Multiplication of vector by matrix MX or by matrix MY do not change vector's components, which indexes are not in vector of indexes w  .Thus the length Lw of the vector w  defines the number of rotations in coordinate planes (base operations of algorithm, described below), which coefficients have to be calculated to obtain searched matrix M. Below operations of proposed algorithm will be described subsequently

COMPARING CORRESPONDING COMPONENTS OF THE TWO GIVEN VECTORS X И Y AND OBTAINING VECTOR, WHICH CONTAINS INDEXES OF COMPONENTS THAT ARE NOT EQUAL
To obtain vector w  , which contains indexes of corresponding components of the two given vectors X and Y, that are not equal, have to be performed subsequent comparing of corresponding components of X and Y. Indexes of components, that are not equal, are saved subsequently in vector .In example vectors X2=[0 2 3 0] Т and Y2=[0 3 2 0] T , obtained from vectors X and Y, given above, belongs to subspace VR4.It is easy to see that X2 and Y2 are projections of vectors X and Y onto subspace V.

OBTAINING ROTATION MATRICES MX AND MY, WHICH ROTATES PROJECTIONS OF GIVEN VECTORS X AND Y IN V TO THE DIRECTION OF ONE OF AXES, HAVING INDEXES IN (I.E. THE FIRST ONE)
Rotation of projection of given vector X in V to the direction of the first of coordinate axes, having indexes in w  can be performed by subsequent multiplications by Givens matrices [8] as follow:  are components of vector w

VI.
CONCLUSION In this article we proposes one modification of NRMG algorithm for generation of n-dimensional rotation matrix M, which rotates given n-dimensional vector X to the direction of given vector Y having the same dimension and the same norm.Modification decreases the number of base operations to 2(Lw-1) where Lw is the number of corresponding components of given vectors, that are not equal.Thus when the two given vectors X and Y have significant number of corresponding components that are equal, Modified NRMG algorithm can be more effective than existing algorithms, shortly described above.It is important to note, that no one of algorithms for n-dimensional matrix generation, described in p.2 do not provide possibility to decrease needed calculations when exists some linear or non-linear dependence between given vectors X and Y. Proposed modification of NRMG algorithm provides decreasing of needed calculations using that NRMG algorithm consists of sequence of identical operationsmultiplications of vector by Givens matrices.If some of corresponding components of given vectors are equal, they are not changed, which decreases the number of needed base operations.
3 are indexes of second and third components, that are not equal.The length Lw of vector w  is equal to the number of different corresponding components of vectors X и Y. Vectors, that have zero values of components, which indexes are not in w  , generates subspace VR n journal of Chemistry, Mathematics and Physics (IJCMP) [Vol-2, Issue-2, Mar-Apr, 2018] https://dx.doi.org/10.22161/ijcmp.2

Fig. 2 .
Fig. 2 Schema for rotation of vector X to the direction of first of axes, having indexes in w If calculation uses parallel execution of two-dimensional rotations[4],[16] (named Accelerated Rotation AR in[20]) matrices Mx and My are calculated as multiplication of log2Lw matrices of stages for which coefficients Cwk and Swk are calculated using(9).The proposed modification of NRMG algorithm avoids execution of base operations for vector's components, which indexes are not in vector w .In example let's we have two 8dimensional vectors X and Y, that have two equal components, i.e. x3=y3 and x6=y6, Then schema, which perform rotation of X to the direction of Y using MNRMG algorithm and AR will look as follows: