ru.sscc.util
Class Rotation

java.lang.Object
  |
  +--ru.sscc.util.Rotation

public final class Rotation
extends java.lang.Object

The class provides Givens rotation by the formulas x' = x*cos(a) + y*sin(a), y' = -x*sin(a) + y*cos(a). The rotation angle a is always choosen from the interval [-p/2,p/2]. Note that rotation coefficients are uniquely reconstructed via tan(a/2) value. This fact is useful for storing of rotation coefficients in place of annuled matrix entries in rotation based factorization methods. The construction of a rotation coefficients is implemented in a number of construct methods by the efficiency reason (to provide reusing of the class instance).

The prepare() methods may be also used for constructing of rotation by already calculated tan(a/2) value or by the pair of sin(a) and cos(a) values.


Constructor Summary
Rotation()
           
 
Method Summary
 double construct(double x, double y)
          Calculates rotation coefficients in such a way to annigilate a second argument.
 void construct(RealPointer px, RealPointer py)
          Calculates rotation coefficients in such a way to annigilate an entry pointed by the second parameter and modifies pointed entries by placing the rotated value at the first entry and tan(a/2) value at the second one.
 void constructAndRotate(RealContainer data, int index1, int step1, int index2, int step2, int count)
          Calculates rotation coefficients to annigilate the beginning entry of the second vector, does the rotation on entries of both vectors with the rotate(RealContainer,int,int,int,int,int) method, and writes the tan(a/2) value to the beginning entry of the second vector.
 double cos()
          Returns the cos(a).
 void prepare(double tan)
          Prepares rotation coefficients using tan(a/2) value.
 void prepare(double sin, double cos)
          Prepares the instance by already calculated sine and cosine values.
 void rotate(RealContainer data, int index1, int step1, int index2, int step2, int count)
          Rotates entries of two vectors by the formulas x'i = xi*cos(a) + yi*sin(a), y'i = -xi*sin(a) + yi*cos(a), i=0,...,count-1.
 void rotate(RealPointer px, RealPointer py)
          Processes a rotation upon x and y entries and stores x' and y' values in places of them.
 double sin()
          Returns the sin(a).
 double tan()
          Returns the tan(a/2) value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Rotation

public Rotation()
Method Detail

construct

public double construct(double x,
                        double y)
Calculates rotation coefficients in such a way to annigilate a second argument.
Parameters:
x - a leading value
y - an annullable value
Returns:
the rotated leading value

construct

public void construct(RealPointer px,
                      RealPointer py)
Calculates rotation coefficients in such a way to annigilate an entry pointed by the second parameter and modifies pointed entries by placing the rotated value at the first entry and tan(a/2) value at the second one.
Parameters:
px - a pointer to the leading entry
py - a pointer to the annullable entry

constructAndRotate

public void constructAndRotate(RealContainer data,
                               int index1,
                               int step1,
                               int index2,
                               int step2,
                               int count)
Calculates rotation coefficients to annigilate the beginning entry of the second vector, does the rotation on entries of both vectors with the rotate(RealContainer,int,int,int,int,int) method, and writes the tan(a/2) value to the beginning entry of the second vector.
Parameters:
data - a container where the vectors are stored
index1 - a starting index for the first vector
step1 - an increment step for the first vector
index2 - a starting index for the second vector
step2 - an increment step for the second vector
count - a vectors' length (should be positive)

rotate

public final void rotate(RealContainer data,
                         int index1,
                         int step1,
                         int index2,
                         int step2,
                         int count)
Rotates entries of two vectors by the formulas x'i = xi*cos(a) + yi*sin(a), y'i = -xi*sin(a) + yi*cos(a), i=0,...,count-1.
Parameters:
data - a container where the vectors are stored
index1 - a starting index for the first vector
step1 - an increment step for the first vector
index2 - a starting index for the second vector
step2 - an increment step for the second vector
count - a vectors' length

rotate

public void rotate(RealPointer px,
                   RealPointer py)
Processes a rotation upon x and y entries and stores x' and y' values in places of them.
Parameters:
px - a pointer to x
py - a pointer to y

tan

public final double tan()
Returns the tan(a/2) value.

prepare

public void prepare(double tan)
Prepares rotation coefficients using tan(a/2) value.

sin

public final double sin()
Returns the sin(a).

cos

public final double cos()
Returns the cos(a).

prepare

public final void prepare(double sin,
                          double cos)
Prepares the instance by already calculated sine and cosine values.