ru.sscc.util.data
Class DoubleContainer

java.lang.Object
  |
  +--ru.sscc.util.data.RealContainer
        |
        +--ru.sscc.util.data.DoubleContainer

public final class DoubleContainer
extends RealContainer

An implementation of RealContainer based on double[] type vector.

See Also:
Serialized Form

Fields inherited from class ru.sscc.util.data.RealContainer
CANT_MOVE_VECTOR
 
Constructor Summary
DoubleContainer(double[] data)
          Constructor.
DoubleContainer(int size)
          Constructor.
 
Method Summary
 double add(int index, double value)
          Adds the value to the container's entry.
 void addVector(int index1, int step1, int index2, int step2, double factor, int count)
          Operation vector1 += factor * vector2 upon the vectors stored in the container.
 void assign(int index1, int step1, int index2, int step2, int count)
          Assignment vector1 = vector2 when both vectors are stored in the container.
 java.lang.Object clone()
          Clones the container.
 double get(int index)
          Gets the value of a container entry.
 java.lang.Object getData()
          Returns the data container encapsulated in the object (instance of the double[] type).
 RealPointer getPointer()
          Gets a pointer to the beginning of the container with the unit increment.
 RealVector getVector(int index, int step, int count)
          Creates a vector within the container.
 int indexOfNormMax(int index, int step, int count)
          Calculates the index of the first entry having the maximum module for the vector stored in the container.
 void moveVector(RealVector vector, int newStartIndex)
          Moves the starting index of vector created upon this container to a new location in the container.
 double mul(int index, double value)
          Multiplies the container's entry by the value.
 void multiply(int index, int step, double value, int count)
          Multiplies the vector posed in the container on a value.
 RealContainer newContainer(int size)
          Creates a new container of the same type with the required size.
 double normalize(int index, int step, double value, int count)
          Multiplies the vector posed in the container on a value and calculates its sum-norm.
 double normMax(int index, int step, int count)
          Calculates the maximum modules norm of the vector stored in the container.
 double normSum(int index, int step, int count)
          Calculates the sum of modules norm of the vector stored in the container.
 double postProduct(int index1, int step1, int index2, int step2, int count)
          Calculates an inner product of two vectors distributed within the container with post-increment of starting indices.
 double postProduct(int index, int step, RealPointer vec, int count)
          Calculates an inner product of two vectors with post-increment of starting indices.
 double preProduct(int index1, int step1, int index2, int step2, int count)
          Calculates an inner product of two vectors distributed within the container with pre-increment of starting indices.
 double preProduct(int index, int step, RealPointer vec, int count)
          Calculates an inner product of two vectors with pre-increment of starting indices.
 double relativeAccuracy()
          Returns the relative accuracy: the RealMath.DBL_EPSILON value.
 void resize(int newSize)
          Changes size of the container to a new size.
 void rotate(double cos, double sin, int index1, int step1, int index2, int step2, int count)
          Rotates two container's vectors with the Givens rotataion by the formulas v1' = v1*cos(a) + v2*sin(a), v2' = -v1*sin(a) + v2*cos(a).
 double set(int index, double value)
          Sets the value of a container entry.
 int size()
          Gets the container size.
 void swap(int index1, int step1, int index2, int step2, int count)
          Swaps entries of vector1 with corresponding entries of vector2 for the vectors stored in the container.
 double weightedNormMax(int index, int step, RealPointer weight, int count)
          Calculates the weighted maximum modules norm of the vector stored in the container.
 double weightedNormSum(int index, int step, RealPointer weight, int count)
          Calculates the weighted sum of modules norm of the vector stored in the container.
 double weightedProduct(int index1, int step1, int index2, int step2, RealPointer weight, int count)
          Calculates a weighted inner product of two vectors distributed within the container.
 
Methods inherited from class ru.sscc.util.data.RealContainer
by, ensureSize, getPointer, getVector, shiftVector
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DoubleContainer

public DoubleContainer(double[] data)
Constructor.
Parameters:
data - a data container

DoubleContainer

public DoubleContainer(int size)
Constructor.
Parameters:
size - a container size
Method Detail

size

public int size()
Gets the container size.
Overrides:
size in class RealContainer

resize

public void resize(int newSize)
Changes size of the container to a new size. The old container contents is copied to the new one.
Overrides:
resize in class RealContainer

newContainer

public RealContainer newContainer(int size)
Creates a new container of the same type with the required size.
Overrides:
newContainer in class RealContainer

get

public double get(int index)
Gets the value of a container entry.
Overrides:
get in class RealContainer
Parameters:
index - an entry position in the container
Returns:
an entry value at the required position

set

public double set(int index,
                  double value)
Sets the value of a container entry.
Overrides:
set in class RealContainer
Parameters:
index - an entry position in the container
value - a value to set
Returns:
the set value

add

public double add(int index,
                  double value)
Adds the value to the container's entry.
Overrides:
add in class RealContainer
Parameters:
index - the entry position in the container
value - the value to add
Returns:
the result of addition

mul

public double mul(int index,
                  double value)
Multiplies the container's entry by the value.
Overrides:
mul in class RealContainer
Parameters:
index - the entry position in the container
value - the value to multiply
Returns:
the result of multiplication

getPointer

public RealPointer getPointer()
Gets a pointer to the beginning of the container with the unit increment.
Overrides:
getPointer in class RealContainer
Returns:
RealPointer object

getVector

public RealVector getVector(int index,
                            int step,
                            int count)
Creates a vector within the container.
Overrides:
getVector in class RealContainer
Parameters:
index - a starting index in the container
step - an increment step in the container
count - a size of the vector

moveVector

public void moveVector(RealVector vector,
                       int newStartIndex)
Moves the starting index of vector created upon this container to a new location in the container. In attempt to move an alien vector, the IllegalArgumentException will be thrown.
Overrides:
moveVector in class RealContainer
Parameters:
vector - the vector to be moved to
newStartIndex - the new starting index

clone

public java.lang.Object clone()
Clones the container.
Overrides:
clone in class RealContainer
Returns:
clone of this container

getData

public java.lang.Object getData()
Returns the data container encapsulated in the object (instance of the double[] type).
Overrides:
getData in class RealContainer

relativeAccuracy

public double relativeAccuracy()
Returns the relative accuracy: the RealMath.DBL_EPSILON value.
Overrides:
relativeAccuracy in class RealContainer

assign

public void assign(int index1,
                   int step1,
                   int index2,
                   int step2,
                   int count)
Assignment vector1 = vector2 when both vectors are stored in the container.
Overrides:
assign in class RealContainer
Parameters:
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 - vector's size

multiply

public void multiply(int index,
                     int step,
                     double value,
                     int count)
Multiplies the vector posed in the container on a value.
Overrides:
multiply in class RealContainer
Parameters:
index - the starting index for the vector
step - the increment step for the vector
value - the multiple
count - the vector length

normalize

public double normalize(int index,
                        int step,
                        double value,
                        int count)
Multiplies the vector posed in the container on a value and calculates its sum-norm.
Overrides:
normalize in class RealContainer
Parameters:
index - the starting index for the vector
step - the increment step for the vector
value - the multiple
count - the vector length
the - sum of modules norm after the multiplication

addVector

public void addVector(int index1,
                      int step1,
                      int index2,
                      int step2,
                      double factor,
                      int count)
Operation vector1 += factor * vector2 upon the vectors stored in the container.
Overrides:
addVector in class RealContainer
Parameters:
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
factor - a multiplier
count - a vector size

postProduct

public double postProduct(int index1,
                          int step1,
                          int index2,
                          int step2,
                          int count)
Calculates an inner product of two vectors distributed within the container with post-increment of starting indices.
Overrides:
postProduct in class RealContainer
Parameters:
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

postProduct

public double postProduct(int index,
                          int step,
                          RealPointer vec,
                          int count)
Calculates an inner product of two vectors with post-increment of starting indices. The first vector is situated within the container and the second one is presented by a RealPointer.
Overrides:
postProduct in class RealContainer
Parameters:
index - a starting index for the first vector
step - an increment step for the first vector
vec - a pointer to the second vector
count - a vectors length

preProduct

public double preProduct(int index1,
                         int step1,
                         int index2,
                         int step2,
                         int count)
Calculates an inner product of two vectors distributed within the container with pre-increment of starting indices.
Overrides:
preProduct in class RealContainer
Parameters:
index1 - an index before the first vector
step1 - an increment step for the first vector
index2 - an index before the second vector
step2 - an increment step for the second vector
count - a vectors length

preProduct

public double preProduct(int index,
                         int step,
                         RealPointer vec,
                         int count)
Calculates an inner product of two vectors with pre-increment of starting indices. The first vector is situated within the container and the second one is represented by a RealPointer.
Overrides:
preProduct in class RealContainer
Parameters:
index - an index before the first vector
step - an increment step for the first vector
vec - a pointer to an entry before the second vector
count - a vectors length

weightedProduct

public double weightedProduct(int index1,
                              int step1,
                              int index2,
                              int step2,
                              RealPointer weight,
                              int count)
Calculates a weighted inner product of two vectors distributed within the container.
Overrides:
weightedProduct in class RealContainer
Parameters:
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
weight - a weight vector (may be equal to null)
count - a vectors length

indexOfNormMax

public int indexOfNormMax(int index,
                          int step,
                          int count)
Calculates the index of the first entry having the maximum module for the vector stored in the container. If vector length is nonpositive, (-1) is returned.
Overrides:
indexOfNormMax in class RealContainer
Parameters:
index - the starting index
step - the increment step
count - the vector size
Returns:
the index of entry having the maximum module

normMax

public double normMax(int index,
                      int step,
                      int count)
Calculates the maximum modules norm of the vector stored in the container.
Overrides:
normMax in class RealContainer
Parameters:
index - the starting index
step - the increment step
count - the vector size
Returns:
the max-norm

normSum

public double normSum(int index,
                      int step,
                      int count)
Calculates the sum of modules norm of the vector stored in the container.
Overrides:
normSum in class RealContainer
Parameters:
index - the starting index
step - the increment step
count - the vector size
Returns:
the sum-norm

weightedNormMax

public double weightedNormMax(int index,
                              int step,
                              RealPointer weight,
                              int count)
Calculates the weighted maximum modules norm of the vector stored in the container.
Overrides:
weightedNormMax in class RealContainer
Parameters:
index - the starting index
step - the increment step
weight - the weight vector (may be equal to null)
count - the vector size
Returns:
the weighted max-norm

weightedNormSum

public double weightedNormSum(int index,
                              int step,
                              RealPointer weight,
                              int count)
Calculates the weighted sum of modules norm of the vector stored in the container.
Overrides:
weightedNormSum in class RealContainer
Parameters:
index - the starting index
step - the increment step
weight - the weight vector (may be equal to null)
count - the vector size
Returns:
the weighted sum-norm

rotate

public void rotate(double cos,
                   double sin,
                   int index1,
                   int step1,
                   int index2,
                   int step2,
                   int count)
Rotates two container's vectors with the Givens rotataion by the formulas v1' = v1*cos(a) + v2*sin(a), v2' = -v1*sin(a) + v2*cos(a).
Overrides:
rotate in class RealContainer
Parameters:
cos - a cosine of the rotaion angle a
sin - a sine of the rotatin angle a
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

swap

public void swap(int index1,
                 int step1,
                 int index2,
                 int step2,
                 int count)
Swaps entries of vector1 with corresponding entries of vector2 for the vectors stored in the container.
Overrides:
swap in class RealContainer
Parameters:
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 vector size