|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ru.sscc.util.data.RealVector
An abstract implementation of a real data vector distributed within a real data container by the regular manner (for example, with the fixed distance between neighbouring entries). The vector entries are accessed via a zero based index. An imlementation of this class must allow an index to be out of the vector bounds if the corresponding entry in the container exists. Methods for the assignment, the calculation of vector sum, inner product, and various vector norms are implemented.
Field Summary | |
protected int |
index
The starting index of the vector entry in the container. |
int |
length
A length of the vector (a number of its entries). |
protected int |
step
The vector's increment step. |
Constructor Summary | |
protected |
RealVector(int length,
int index,
int step)
Constructor. |
Method Summary | |
abstract double |
add(int index,
double value)
Adds the value to the vector entry. |
void |
addVector(RealVector vec,
double factor)
Adds RealVector vector multiplied by factor. |
void |
addVector(RealVector vec,
double factor,
int count)
Adds count values from the RealVector vector
multiplied by factor. |
void |
assign(double value)
Assigns a value to the vector. |
void |
assign(double value,
int count)
Assigns a value to the first count entries of the vector. |
void |
assign(RealVector vec)
Assigns values from RealVector vector. |
void |
assign(RealVector vec,
double factor)
Assigns RealVector vector multiplied by a factor. |
void |
assign(RealVector vec,
double factor,
int count)
Assigns count values of RealVector vector multiplied
by a factor. |
void |
assign(RealVector vec,
int count)
Assigns count values from RealVector vector. |
static RealVector |
by(java.lang.Object obj)
Static service method which creates RealVector upon an
object convertable to it (double[], float[],
RealContainer , or RealVector instance). |
static RealVector |
by(java.lang.Object obj,
java.lang.Object ref)
Static service method which tests obj object to be float[] or double[] instance and ref object to be short[] or int[] instance and creates RealVector
based on all container entries referenced by ref object. |
void |
ensureLength(int length)
Tests a vector length to be not less that specified length and throws the IllegalArgumentException if not. |
abstract double |
get(int index)
Gets the value of a vector entry. |
abstract RealPointer |
getPointer()
Gets a pointer to the beginning of the real data vector with the unit increment. |
RealPointer |
getPointer(int index,
int step)
Gets a pointer and resets it for the sequential access to vector entries starting from the index position with the step increment. |
protected int |
inc(int s)
Calculates a complete increment step in a subvector as a product of the vector's and subvector's increments. |
int |
indexOfNormMax()
Calculates the index of the first vector's entry having the maximum module. |
int |
indexOfNormMax(int count)
Calculates the index of the first vector's entry having the maximum module between the first count vector entries. |
double |
innerProduct(RealVector vec)
Calculates an inner product of the vector by another RealVector vector. |
double |
innerProduct(RealVector vec,
int count)
Calculates an inner product of first count entries the vector by another RealVector vector. |
abstract double |
mul(int index,
double value)
Multiplies the vector entry by the value. |
void |
multiply(double value)
Multiplies the vector by a value. |
void |
multiply(double value,
int count)
Multiplies the first count entries of the vector by a value. |
double |
norm()
Calculates the euqlidian norm of the vector. |
double |
norm(int count)
Calculates the euqlidian norm of the first count vector entries. |
double |
normMax()
Calculates the maximum modules norm. |
double |
normMax(int count)
Calculates the max-norm of the first count vector entries. |
double |
normSum()
Calculates a sum of modules norm. |
double |
normSum(int count)
Calculates the sum-norm of the first count vector entries. |
protected int |
pos(int i)
Calculates the complete index of a vector entry in the container by its index in the vector. |
abstract double |
set(int index,
double value)
Sets the value of a vector entry. |
abstract RealVector |
subvector(int index,
int step,
int length)
Creates a subvector within the real data vector. |
void |
swap(int i,
int j)
Swaps i-th and j-th vector's values without testing of indices correctness. |
double |
weightedNorm(RealVector weight)
Calculates the weighted euqlidian norm of the vector (if the weight vector is null, the calculated norm will be unweighted). |
double |
weightedNorm(RealVector weight,
int count)
Calculates the weighted euqlidian norm of the first count entries of the vector (if the weight vector is null, the calculated norm will be unweighted). |
double |
weightedNormMax(RealVector weight)
Calculates the weighted maximum modules norm (if the weight vector is null, the calculated norm will be unweighted). |
double |
weightedNormMax(RealVector weight,
int count)
Calculates the weighted max-norm of the first count vector entries (if the weight vector is null, the calculated norm will be unweighted). |
double |
weightedNormSum(RealVector weight)
Calculates a weighted sum of modules norm (if the weight vector is null, the calculated norm will be unweighted). |
double |
weightedNormSum(RealVector weight,
int count)
Calculates the weighted sum-norm of the first count vector entries (if the weight vector is null, the calculated norm will be unweighted). |
double |
weightedProduct(RealVector vec,
RealVector weight)
Calculates a weighted inner product of the vector by another RealVector vector (if a weight vector is
null, the calculated inner product will be unweighted). |
double |
weightedProduct(RealVector vec,
RealVector weight,
int count)
Calculates a weighted inner product of the first count entries of the vector by another RealVector vector (if a weight vector is
null, the calculated inner product will be unweighted). |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public final int length
protected int index
protected final int step
Constructor Detail |
protected RealVector(int length, int index, int step)
length
- a vector length (a number of entries)index
- a first vector entry indexstep
- an increment stepMethod Detail |
public abstract double get(int index)
index
- an entry position in the vectorpublic abstract double set(int index, double value)
index
- an entry position in the vectorvalue
- a value to setpublic abstract double add(int index, double value)
index
- the entry position in the containervalue
- the value to addpublic abstract double mul(int index, double value)
index
- the entry position in the containervalue
- the value to multiplypublic abstract RealPointer getPointer()
public final RealPointer getPointer(int index, int step)
index
- a starting index in the vectorstep
- an increment step in the vectorpublic abstract RealVector subvector(int index, int step, int length)
index
- a starting index in the vectorstep
- an increment step in the vectorlength
- a length of the subvectorpublic static RealVector by(java.lang.Object obj)
RealVector
upon an
object convertable to it (double[], float[],
RealContainer
, or RealVector
instance).
In the last case the same object will be returned.public static RealVector by(java.lang.Object obj, java.lang.Object ref)
RealVector
based on all container entries referenced by ref object.obj
- a data container (float[] or double[]
instance)ref
- a reference vector (short[] or int[]
instance)public final void ensureLength(int length)
length
- a minimum length neededpublic final void swap(int i, int j)
public final void assign(double value)
value
- a value to assignpublic final void assign(double value, int count)
value
- a value to assigncount
- a number of entries to assignpublic final void assign(RealVector vec)
RealVector
vector.vec
- source vectorpublic final void assign(RealVector vec, int count)
RealVector
vector.vec
- source vectorcount
- a number of entries to assignpublic final void assign(RealVector vec, double factor)
RealVector
vector multiplied by a factor.vec
- a source vectorfactor
- a value to multiplypublic final void assign(RealVector vec, double factor, int count)
RealVector
vector multiplied
by a factor.vec
- a source vectorfactor
- a value to multiplycount
- a number of entries to assignpublic final void addVector(RealVector vec, double factor)
RealVector
vector multiplied by factor.vec
- a vector to be addedfactor
- a multiplierpublic final void addVector(RealVector vec, double factor, int count)
RealVector
vector
multiplied by factor.vec
- a vector to be addedfactor
- a multipliercount
- a number of entries to addpublic final void multiply(double value)
value
- a value to multiplypublic final void multiply(double value, int count)
value
- a value to multiplycount
- a number of entries to multiplypublic final double innerProduct(RealVector vec)
RealVector
vector.vec
- a vector to multiplypublic final double innerProduct(RealVector vec, int count)
RealVector
vector.vec
- a vector to multiplycount
- a number of entriespublic final double weightedProduct(RealVector vec, RealVector weight)
RealVector
vector (if a weight vector is
null, the calculated inner product will be unweighted).vec
- a vector to multiplyweight
- a weight vectorpublic final double weightedProduct(RealVector vec, RealVector weight, int count)
RealVector
vector (if a weight vector is
null, the calculated inner product will be unweighted).vec
- a vector to multiplyweight
- a weight vectorcount
- a number of entriespublic final double norm()
public final double norm(int count)
count
- the number of entriespublic final double normMax()
public final double normMax(int count)
count
- the number of entriespublic final double normSum()
public final double normSum(int count)
count
- the number of entriespublic final int indexOfNormMax()
public final int indexOfNormMax(int count)
count
- the number of entriespublic final double weightedNorm(RealVector weight)
weight
- the weight vectorpublic final double weightedNorm(RealVector weight, int count)
weight
- the weight vectorcount
- the number of entriespublic final double weightedNormMax(RealVector weight)
weight
- the weight vectorpublic final double weightedNormMax(RealVector weight, int count)
weight
- the weight vectorcount
- the number of entriespublic final double weightedNormSum(RealVector weight)
weight
- the weight vectorpublic final double weightedNormSum(RealVector weight, int count)
weight
- the weight vectorcount
- the number of entriesprotected final int inc(int s)
s
- an increment step in the subvectorprotected final int pos(int i)
i
- an entry index in the vector
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |