|
JavaView® v2.12 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--jv.vecmath.P_Vector
|
+--jv.vecmath.PiVector
Linear algebra class for an array of integers with variable length.
| Field Summary | |
int[] |
m_data
Data array containing the components of the vector. |
| Constructor Summary | |
PiVector()
Constructor, should only be used by experts, usually call PiVector(int aSize). |
|
PiVector(int aSize)
Constructor creating a vector with given dimension. |
|
PiVector(int[] x)
Constructs a vector having same length and given initial data as given array. |
|
PiVector(int x,
int y)
Constructs a vector of length 2 and given initial data. |
|
PiVector(int x,
int y,
int z)
Constructs a vector of length 3 and given initial data. |
|
PiVector(int x,
int y,
int z,
int w)
Constructs a vector of length 4 and given initial data. |
|
| Method Summary | |
void |
add(int val)
Add argument to each component of vector. |
void |
add(PiVector m)
Sum with argument vector this = this+m. |
void |
add(PiVector m1,
PiVector m2)
Sum of argument vectors this = m1+m2. |
int |
addEntry(int val)
Add another entry at the end of the vector and increment size of vector. |
void |
blend(int a,
PiVector v,
int b,
PiVector w)
Interpolate between two vectors with given weights. |
void |
blendBase(PiVector v,
int b,
PiVector w)
Interpolate between two vectors with given weights. |
static PiVector |
blendNew(int a,
PiVector v,
int b,
PiVector w)
Create a new vector this = a*v + b*w. |
int |
changeValue(int oldValue,
int newValue)
Change all occurrence of value oldValue to newValue COMPARE: changeValue(int, int, int) return number of changed positions |
int |
changeValue(int usedSize,
int oldValue,
int newValue)
Change occurrence of value oldValue to newValue on first 'usedSize' positions difference to method changeValue(int, int): sometime we use vectors where only the first entries are used. |
java.lang.Object |
clone()
Duplicate vector and data array. |
void |
copy(int[] anArray,
int aSize)
Copy a integer array into a vector, and do not adjust size of dest vector. |
boolean |
copy(int destInd,
PiVector dataSrc,
int srcInd,
int size)
Copy part of a vector into a vector, and adjust size of dest vector only it is too small. |
void |
copy(PiVector v)
Copy a vector into a vector, and do not adjust size of dest vector. |
static boolean |
copy(PiVector[] dataDest,
int destInd,
PiVector[] dataSrc,
int srcInd,
int size)
Copies some vectors of a given array of vectors into an existing destination array. |
void |
copyArray(PiVector v)
Copy data array of source vector into this vector, and do not adjust size of dest vector. |
static PiVector[] |
copyNew(int[][] data)
Create an new array with copies of all doubles of a given 2-dimensional array of numbers. |
static PiVector |
copyNew(PiVector v)
Create a new vector as clone of argument vector. |
static PiVector[] |
copyNew(PiVector[] data)
Create an new array with copies of all vectors of a given array of vectors. |
static PiVector[] |
copyNew(PiVector[] data,
int size)
Create an new array with copies of the first 'size' vectors of a given array of vectors. |
int |
dist(PiVector v)
Euclidean distance dist = |this-v|. |
int |
dot(PiVector v)
Compute scalar product with argument vector. |
static int |
dot(PiVector v,
PiVector w)
Scalar product of two vectors. |
boolean |
equals(int[] list)
Compare vector with list of integers and return false if different
array lengths or a different entry.
|
boolean |
equals(PiVector vec)
Determines whether another vector is equal to this vector. |
int[] |
getEntries()
Return a copy of content of vector as array of integers. |
static int[][] |
getEntries(PiVector[] vArr)
Return content of array of vectors as matrix of integers. |
int |
getEntry(int ind)
Get the component of a vector. |
int |
getFirstEntry()
Get the first component of a vector. |
int |
getIndexOf(int aValue)
Find index of first occurrence of value 'aValue' in vector. |
int |
getLastEntry()
Get the last component of a vector. |
static int |
getSameSize(PiVector[] vecArray,
int numUsed)
Check of all vectors in array of vector have same length. |
int |
getSize()
Return size of vector, i.e. number of entries in data array. |
boolean |
hasUniqueEntries()
Check, whether all entrys of this vector are different. |
int |
indexOfAbsMax()
Find component in vector with maximal absolute value. |
int |
indexOfAbsMin()
Find component in vector with minimal absolute value. |
int |
indexOfMax()
Find component in vector with maximal value. |
int |
indexOfMin()
Find component in vector with minimal value. |
void |
invert()
Invert order of all entries, i.e. the first entry becomes the last entry. |
void |
invert(int usedSize)
Invert order of the first 'usedSize' entries, i.e. the first entry becomes the 'usedSize-1' entry. |
void |
leftMultMatrix(PdMatrix m)
Multiply vector with matrix this = m*this.
|
void |
leftMultMatrix(PdMatrix m,
PiVector v)
Multiply vector with matrix this = m*v.
|
int |
length()
Get euclidean length of vector. |
int |
max()
Find maximum value in vector. |
static boolean |
max(PiVector max,
PiVector[] aVecArray,
int arrayLength)
Find the maximum of an array of vectors in each component. |
double |
maxAbs()
Find maximal absolute value of component in vector. |
int |
min()
Find minimal value of component in vector. |
static boolean |
min(PiVector min,
PiVector[] aVecArray,
int arrayLength)
Find the minimum of an array of vectors in each component. |
void |
multScalar(int scalar)
Multiply vector with scalar this = scalar*this. |
void |
multScalar(PiVector v,
int scalar)
Multiply argument vector with scalar this = scalar*v. |
boolean |
normalize()
Normalize vector to unit length. |
void |
normalize(PiVector v)
Set vector to normalized argument vector. |
static PiVector[] |
realloc(PiVector[] data,
int arraySize)
Allocate an array of vectors, where all vectors have the same dimension. |
static PiVector[] |
realloc(PiVector[] data,
int arraySize,
int vectorSize)
Allocate an array of vectors, where all vectors have the same dimension. |
void |
rightMultMatrix(PdMatrix m)
Multiply vector with matrix this = this*m.
|
void |
rightMultMatrix(PiVector v,
PdMatrix m)
Multiply vector with matrix this = v*m.
|
void |
set(int x)
Assign value to vector, and set size of vector to 1. |
void |
set(int[] x)
Assign values of vector, and adjust length of vector if different from length of array. |
void |
set(int[] x,
int len)
Assign first values of array to vector, and adjust length of vector if different from argument len. |
void |
set(int[] x,
int from,
int len)
Assign 'len' values of array starting at 'from' to vector, and adjust length of vector if different from argument len. |
void |
set(int x,
int y)
Assign value to vector, and set size of vector to 2. |
void |
set(int x,
int y,
int z)
Assign value to vector, and set size of vector to 3. |
void |
set(int x,
int y,
int z,
int w)
Assign value to vector, and set size of vector to 4. |
void |
set(PiVector x,
int from,
int len)
Assign 'len' values of array starting at 'from' to vector, and adjust length of vector if different from argument len. |
void |
setConstant(int aValue)
Set all entries to a constant value. |
static void |
setConstant(PiVector[] aVecArray,
int aValue)
Set all components of all vectors of an array to a constant. |
static void |
setConstant(PiVector[] aVecArray,
int[] data)
Set all vectors of an array equal to a given vector. |
static void |
setConstant(PiVector[] aVecArray,
PiVector aVector)
Set all vectors of an array equal to a given vector. |
static void |
setConstant(PiVector v,
int aValue)
Set all entries to a constant value. |
void |
setEntry(int ind,
int value)
Assign value to component of vector, and possibly enlarge vector if too small. |
void |
setFirstEntry(int value)
Set the first component of a vector. |
void |
setLastEntry(int value)
Set the last component of a vector. |
void |
setLength(int aLength)
Set euclidean length of vector. |
int |
setSize(int aSize)
Set dimension of vector, i.e. length of its data array. |
void |
shift(int num)
Shift components in cyclic order within the array. |
void |
sort()
Sort entries of this PiVector by size. |
void |
sort(PiVector vecOut)
Fill OutVector with sorted entries of this PiVector. |
int |
sqrDist(PiVector v)
Square of euclidean distance sqrDist = |this-v|^2. |
int |
sqrLength()
Get square of euclidean length of vector. |
void |
sub(PiVector m)
Difference with argument vector this = this-m. |
void |
sub(PiVector m1,
PiVector m2)
|
static PiVector |
subNew(PiVector m1,
PiVector m2)
Create a new vector as difference of argument vectors new = m1-m2. |
java.lang.String |
toShortString()
Create a single-line string representation of the vector components and attributes. |
java.lang.String |
toString()
Create a multi-line string representation with detailed information about all instance variables. |
| Methods inherited from class jv.vecmath.P_Vector |
clearTag, clone, clone, copy, getBits, getName, hasTag, setName, setTag |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public int[] m_data
| Constructor Detail |
public PiVector()
public PiVector(int aSize)
public PiVector(int x,
int y)
public PiVector(int x,
int y,
int z)
public PiVector(int x,
int y,
int z,
int w)
public PiVector(int[] x)
| Method Detail |
public java.lang.Object clone()
copyNew(PiVector).copyNew(PiVector)public static int[][] getEntries(PiVector[] vArr)
vArr - Array of vectors
public static final PiVector[] realloc(PiVector[] data,
int arraySize,
int vectorSize)
data!=null then as most as possible of the content of
existing vectors is copied into (possibly reused) vectors of the
reallocated array.
If requested array size is 0 then method returns an array of length 0.
data - possibly empty array of vectorsarraySize - number of vectors in new arrayvectorSize - dimension of vectors in new arrayrealloc(PiVector [], int)
public static final PiVector[] realloc(PiVector[] data,
int arraySize)
data!=null then as most as possible of the
existing vectors are reused in the reallocated array.
If requested array size is 0 then method returns an array of length 0.
data - possibly empty array of vectorsarraySize - number of vectors in new arrayrealloc(PiVector [], int, int)public static PiVector[] copyNew(int[][] data)
data - 2-dimensional array of numberscopyNew(PiVector [], int),
copy(PiVector [], int, PiVector [], int, int)public static PiVector[] copyNew(PiVector[] data)
data - array of vectorscopyNew(PiVector [], int),
copy(PiVector [], int, PiVector [], int, int)
public static PiVector[] copyNew(PiVector[] data,
int size)
data - array of vectorssize - number of copied vectors of arraycopyNew(PiVector []),
copy(PiVector [], int, PiVector [], int, int)
public static boolean copy(PiVector[] dataDest,
int destInd,
PiVector[] dataSrc,
int srcInd,
int size)
for (int i=0; iDestination array must be large enough, i.e. dataDest.length >= destInd+size.
- Parameters:
dataDest- destination array of vectorsdestInd- index of first destination vector in dataDestdataSrc- source array of vectorssrcInd- index of first source vector in dataSrc used for copyingsize- number of copied vectors of array- Returns:
trueif destination array is large enough- See Also:
copy(PiVector)
public static int getSameSize(PiVector[] vecArray,
int numUsed)
public static final boolean min(PiVector min,
PiVector[] aVecArray,
int arrayLength)
min - computed minimumaVecArray - array of vectorsarrayLength - number of used vectors of arraymax(PiVector, PiVector [], int)
public static final boolean max(PiVector max,
PiVector[] aVecArray,
int arrayLength)
max - computed maximumaVecArray - array of vectorsarrayLength - number of used vectors of arraymin(PiVector, PiVector [], int)
public static void setConstant(PiVector[] aVecArray,
int aValue)
public static void setConstant(PiVector[] aVecArray,
int[] data)
public static void setConstant(PiVector[] aVecArray,
PiVector aVector)
public static void setConstant(PiVector v,
int aValue)
public void setConstant(int aValue)
public int getSize()
public int setSize(int aSize)
new - number of components of vectorpublic int[] getEntries()
public int getEntry(int ind)
public void setEntry(int ind,
int value)
ind - index of component to modifyvalue - new value of componentpublic int getFirstEntry()
public void setFirstEntry(int value)
value - new value of first componentpublic int getLastEntry()
public void setLastEntry(int value)
value - new value of last componentpublic int addEntry(int val)
value - to be added
public void set(PiVector x,
int from,
int len)
public void set(int[] x,
int from,
int len)
public void set(int[] x,
int len)
public void set(int[] x)
public void set(int x)
public void set(int x,
int y)
public void set(int x,
int y,
int z)
public void set(int x,
int y,
int z,
int w)
public int getIndexOf(int aValue)
public int changeValue(int usedSize,
int oldValue,
int newValue)
public int changeValue(int oldValue,
int newValue)
public void shift(int num)
num - number of positions each component is shiftedinvert()public void invert(int usedSize)
invert()public void invert()
invert(int)public void add(int val)
public void add(PiVector m)
this = this+m.
public void add(PiVector m1,
PiVector m2)
this = m1+m2.public void sub(PiVector m)
this = this-m.
public void sub(PiVector m1,
PiVector m2)
public static PiVector subNew(PiVector m1,
PiVector m2)
new = m1-m2.public static PiVector copyNew(PiVector v)
v - source vector to clone
public boolean copy(int destInd,
PiVector dataSrc,
int srcInd,
int size)
copy(PiVector)public void copy(PiVector v)
v - source vector to copycopy(int,PiVector,int,int)public void copyArray(PiVector v)
#copy(PdVector) this method does not
invoke the copy method of the superclass.
If destination vector is empty then allocated space of size of source vector.
If source and destination vectors have different size then use the mininum
of both sizes for copying. If destination vector is bigger than source then reset
the additional entries in destination vector with 0.v - source vector to copycopy(PiVector)
public void copy(int[] anArray,
int aSize)
copy(int, PiVector, int, int)public void multScalar(int scalar)
this = scalar*this.
public void multScalar(PiVector v,
int scalar)
this = scalar*v.public void leftMultMatrix(PdMatrix m)
this = m*this.
Matrix must be square and of same size than vector.
Method does not change size of 'this'!
public void leftMultMatrix(PdMatrix m,
PiVector v)
this = m*v.
Matrix need not be square.
Method modifies size of vector to number of row of matrix.public void rightMultMatrix(PdMatrix m)
this = this*m.
Matrix must be square and of same size than vector.
Method does not change size of 'this'!
public void rightMultMatrix(PiVector v,
PdMatrix m)
this = v*m.
Matrix need not be square.
Method modifies size of vector to number of columns of matrix.
public static int dot(PiVector v,
PiVector w)
public int dot(PiVector v)
public int sqrLength()
public int length()
public boolean normalize()
public void normalize(PiVector v)
public void setLength(int aLength)
public static PiVector blendNew(int a,
PiVector v,
int b,
PiVector w)
this = a*v + b*w.blend(int, PiVector, int, PiVector),
blendBase(PiVector, int, PiVector)
public void blend(int a,
PiVector v,
int b,
PiVector w)
this = v*a + w*b.
If result vector 'this' is empty then its size is set to length of vector v,
otherwise interpolation is done up to length of result vector.v - first vectora - weight of vector vw - second vectorb - weight of vector wblendBase(PiVector, int, PiVector),
blendNew(int, PiVector, int, PiVector)
public void blendBase(PiVector v,
int b,
PiVector w)
this = v + w*b.
If result vector 'this' is empty then its size is set to length of vector v,
otherwise interpolation is done up to length of result vector.v - first vectorw - second vectorb - weight of vector wblend(int, PiVector, int, PiVector),
blendNew(int, PiVector, int, PiVector)public int dist(PiVector v)
dist = |this-v|.public int sqrDist(PiVector v)
sqrDist = |this-v|^2.public int max()
min(),
indexOfMax(),
indexOfAbsMax()public double maxAbs()
min(),
indexOfMax(),
indexOfAbsMax()public int min()
max(),
indexOfMin(),
indexOfAbsMin()public int indexOfAbsMax()
max(),
indexOfMax()public int indexOfAbsMin()
min(),
indexOfMin()public int indexOfMax()
indexOfAbsMax()public int indexOfMin()
indexOfAbsMin()public boolean hasUniqueEntries()
public void sort(PiVector vecOut)
public void sort()
public boolean equals(int[] list)
false if different
array lengths or a different entry.
Determines whether a list of integers is equal to data of this vector.
The result is true if both arrays have same length and
equal components. Result is also true if argument vector
is null and this vector has no entries.
- Parameters:
list - the list of integers to compare with- Returns:
true if the objects are the same; false otherwise.
public boolean equals(PiVector vec)
true if both vectors have same length and
equal components. Result is also true if argument vector
is null and this vector has no entries.vec - the vector to compare withtrue if the objects are the same; false otherwise.public java.lang.String toString()
toString in class P_VectortoShortString()public java.lang.String toShortString()
toString()
|
JavaView® v2.12 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||