jv.vecmath
Class PiVector
- java.lang.Object
-
- jv.vecmath.P_Vector
-
- jv.vecmath.PiVector
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable
- Direct Known Subclasses:
- PgEdgeStar, PgFaceStar
public class PiVector extends P_Vector implements java.lang.Cloneable
Linear algebra class for an array of integers with variable length.- See Also:
- Serialized Form
- Author:
- Konrad Polthier
- Version:
- 24.08.09, 1.96 revised (fk) New method average().
08.07.06, 1.95 revised (kp) Method clone() implemented to replace copyNew() when used by subclasses.
06.07.04, 1.90 revised (ep) New static methodadjustSizes.
28.01.02, 1.80 revised (ep) Implement cloneable interface.
08.11.00, 1.70 revised (kp) Replace string formatting routines of Fmt with PuString.
29.08.00, 1.60 revised (ur) Sort methods and hasUniqueEntries method added.
29.08.97, 1.50 revised (kp) Many additional methods from PdVector added.
00.00.97, 1.00 created (kp)
-
-
Field Summary
Fields Modifier and Type Field and Description int[]m_dataData array containing the components of the vector.
-
Constructor Summary
Constructors Constructor and Description PiVector()Construct vector with zero size.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
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description voidadd(int val)Add a value to each component of the vector.voidadd(int factor, PiVector v)Addfactor*vtothis.voidadd(PiVector m)Sum with argument vectorthis = this+m.voidadd(PiVector m1, PiVector m2)Sum of argument vectorsthis = m1+m2.intaddEntry(int val)Add another entry at the end of the vector and increment size of vector.static booleanadjustSizes(PiVector[] dataDest, int destInd, PiVector[] dataSrc, int srcInd, int size)Adjusts the sizes of vectors in destination array to match the sizes of vectors in source array.static PiVector[][]alloc(int sizeI, int sizeJ, int vectorSize)Allocate a new array of vectors, where all vectors have the same dimension.doubleaverage()Compute the average value of all entries.voidblend(double a, PiVector v, double b, PiVector w)Interpolate between two vectors with given weights.voidblend(int a, PiVector v, int b, PiVector w)Interpolate between two vectors with given weights.voidblendBase(PiVector v, int b, PiVector w)Interpolate between two vectors with given weights.static PiVectorblendNew(int a, PiVector v, int b, PiVector w)Create a new vectorthis = a*v + b*w.intchangeValue(int oldValue, int newValue)Change all occurrence of value oldValue to newValue COMPARE: changeValue(int, int, int) return number of changed positionsintchangeValue(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.Objectclone()Clone object and all instance variables.voidconcat(PiVector piv)Concatenates another PiVector to the end of this vector.static PiVectorconcatNew(PiVector v, PiVector w)Concatenate two PiVectors into one new PiVector.booleancontains(int aValue)Returns true if this PiVector contains 'aValue'.voidcopy(int[] anArray, int aSize)Copy a integer array into a vector, and do not adjust size of destination vector.booleancopy(int destInd, PiVector dataSrc, int srcInd, int size)Copy part of the source vector into this vector, and adjust size of this vector only if it is too small.voidcopy(PiVector v)Copy a vector into a vector, and do not adjust size of dest vector.static booleancopy(PiVector[] dataDest, int destInd, PiVector[] dataSrc, int srcInd, int size)Copies some vectors of a given array of vectors into an existing destination array.voidcopyArray(PiVector v)Copy data array of source vector into this vector, and do not adjust size of destination vector.static PiVector[]copyNew(int[][] data)Create an new array with copies of all doubles of a given 2-dimensional array of numbers.static PiVectorcopyNew(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.intdist(PiVector v)Euclidean distancedist = |this-v|.intdot(PiVector v)Compute scalar product with argument vector.static intdot(PiVector v, PiVector w)Scalar product of two vectors.booleanequals(int[] list)Compare vector with list of integers and returnfalseif different array lengths or a different entry.booleanequals(java.lang.Object obj)Determines whether another vector or array of ints is equal to this vector.booleanequals(PiVector v)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.intgetEntry(int ind)Get the component of a vector.intgetFirstEntry()Get the first component of a vector.intgetIndexOf(int aValue)Find index of first occurrence of value 'aValue' in vector.intgetLastEntry()Get the last component of a vector.doublegetLength()Get Euclidean length of vector.static intgetSameSize(PiVector[] vecArr, int numUsed)Check of all vectors in array of vector have same length.intgetSize()Return size of vector, i.e. number of entries in data array.booleanhasUniqueEntries()Check, whether all entries of this vector are different.intindexOfAbsMax()Find component in vector with maximal absolute value.intindexOfAbsMin()Find component in vector with minimal absolute value.intindexOfMax()Find component in vector with maximal value.intindexOfMin()Find component in vector with minimal value.intindexOfValueInOrdering(int value)Computes the index i of the first entry of vector withv[i]>=valuein logarithmic time.PiVectorinvert()Invert order of all entries, i.e. the first entry becomes the last entry.PiVectorinvert(int usedSize)Invert order of the first 'usedSize' entries, i.e. the first entry becomes the usedSize-1 entry.voidleftMultMatrix(PdMatrix m)Multiply vector with matrixthis = m*this.voidleftMultMatrix(PdMatrix m, PiVector v)Multiply vector with matrixthis = m*v.intlength()Get Euclidean length of vector as rounded integer.intmax()Find maximum value in vector.static booleanmax(PiVector max, PiVector[] vecArr, int arrayLength)Find the maximum of an array of vectors in each component.doublemaxAbs()Find maximal absolute value of component in vector.intmin()Find minimal value of component in vector.static booleanmin(PiVector min, PiVector[] vecArr, int arrayLength)Find the minimum of an array of vectors in each component.voidmultScalar(int scalar)Multiply vector with scalarthis = scalar*this.voidmultScalar(PiVector v, int scalar)Multiply argument vector with scalarthis = scalar*v.booleannormalize()Deprecated.use PdVectorvoidnormalize(PiVector v)Deprecated.use PdVectorstatic PiVector[]realloc(PiVector[] data, int arraySize)Allocate an array of vectors.static PiVector[]realloc(PiVector[] data, int arraySize, int vectorSize)Allocate an array of vectors, where all vectors have the same dimension.voidremoveEntry(int ind)Remove an entry from the vector.voidremoveSuccessiveDuplicates()Removes all successive duplicate entries.voidrightMultMatrix(PdMatrix m)Multiply vector with matrixthis = this*m.voidrightMultMatrix(PiVector v, PdMatrix m)Multiply vector with matrixthis = v*m.voidset(int x)Assign value to vector, and set size of vector to 1.voidset(int[] x)Assign values of vector, and adjust length of vector if different from length of array.voidset(int[] x, int len)Assign first values of array to vector, and adjust length of vector if different from argument len.voidset(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.voidset(int x, int y)Assign value to vector, and set size of vector to 2.voidset(int x, int y, int z)Assign value to vector, and set size of vector to 3.voidset(int x, int y, int z, int w)Assign value to vector, and set size of vector to 4.voidset(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.voidsetConstant(int aValue)Set all entries to a constant value.static voidsetConstant(PiVector[] vecArr, int aValue)Set all components of all vectors of an array to a constant.static voidsetConstant(PiVector[] vecArr, int[] data)Set all vectors of an array equal to a given vector.static voidsetConstant(PiVector[] vecArr, PiVector aVector)Set all vectors of an array equal to a given vector.static voidsetConstant(PiVector v, int aValue)Set all entries to a constant value.voidsetEntry(int ind, int value)Assign value to component of vector, and possibly enlarge vector if too small.voidsetFirstEntry(int value)Set the first component of a vector.voidsetLastEntry(int value)Set the last component of a vector.voidsetLength(int aLength)Deprecated.use PdVectorintsetSize(int aSize)Set dimension of vector, i.e. length of its data array.voidshift(int num)Shift components in cyclic order within the array.voidsort()Sort entries of this PiVector by size.voidsort(PiVector vecOut)Fill OutVector with sorted entries of this PiVector.intsqrDist(PiVector v)Square of Euclidean distancesqrDist = |this-v|^2.intsqrLength()Get square of Euclidean length of vector.voidsub(PiVector m)Difference with argument vectorthis = this-m.voidsub(PiVector m1, PiVector m2)Difference of argument vectorsthis = m1 - m2.static PiVectorsubNew(PiVector m1, PiVector m2)Create a new vector as difference of argument vectorsnew = m1-m2.intsum()Compute the sum of all entries.java.lang.StringtoShortString()Create a single-line string representation of the vector components and attributes.java.lang.StringtoString()Create a multi-line string representation with detailed information about all instance variables.
-
-
-
Field Detail
-
m_data
public int[] m_data
Data array containing the components of the vector. Array has public access for efficiency reasons in numerical computations, although method access should be preferred. Do not modify length of array directly.
-
-
Constructor Detail
-
PiVector
public PiVector()
Construct vector with zero size.- Version:
- 27.12.01, 1.10 revised (kp) Now allocate array with zero length.
-
PiVector
public PiVector(int aSize)
Constructor creating a vector with given dimension. The length of the integer array is 'aSize', no initialization performed.
-
PiVector
public PiVector(int x, int y)Constructs a vector of length 2 and given initial data.
-
PiVector
public PiVector(int x, int y, int z)Constructs a vector of length 3 and given initial data.
-
PiVector
public PiVector(int x, int y, int z, int w)Constructs a vector of length 4 and given initial data.
-
PiVector
public PiVector(int[] x)
Constructs a vector having same length and given initial data as given array.- Version:
- 20.07.00, 1.00 created (kp).
-
-
Method Detail
-
clone
public java.lang.Object clone()
Clone object and all instance variables. Similar likecopyNew(PiVector)but this clone() method is consistent with possible subclasses while copyNew() explicitly creates a new PiVector.- Overrides:
clonein classP_Vector- See Also:
copyNew(PiVector)- Version:
- 08.07.06, 1.00 created (kp)
-
getEntries
public static int[][] getEntries(PiVector[] vArr)
Return content of array of vectors as matrix of integers.- Parameters:
vArr- Array of vectors- Returns:
- 2-dimensional matrix of integers
- Version:
- 05.07.00, 1.00 created (kp)
-
alloc
public static PiVector[][] alloc(int sizeI, int sizeJ, int vectorSize)
Allocate a new array of vectors, where all vectors have the same dimension.- Parameters:
sizeI- number of rows in new arraysizeJ- number of columns in row[i] in new arrayvectorSize- dimension of vectors in new array- See Also:
realloc(PiVector [], int, int)- Version:
- 12.12.06, 1.10 revised (ur) Bug fixed.
27.11.06, 1.00 revised (kp)
-
realloc
public static final PiVector[] realloc(PiVector[] data, int arraySize, int vectorSize)
Allocate an array of vectors, where all vectors have the same dimension. If argumentdata!=nullthen 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.
- Parameters:
data- possibly empty array of vectorsarraySize- number of vectors in new arrayvectorSize- dimension of vectors in new array- See Also:
realloc(PiVector [], int)- Version:
- 26.12.99, 1.10 revised (kp) Use System.arraycopy internally.
-
realloc
public static final PiVector[] realloc(PiVector[] data, int arraySize)
Allocate an array of vectors. If argumentdata!=nullthen as most as possible of the existing vectors are reused in the reallocated array. New vectors are allocated with dimension zero.If requested array size is 0 then method returns an array of length 0.
- Parameters:
data- possibly empty array of vectorsarraySize- number of vectors in new array- See Also:
realloc(PiVector [], int, int)- Version:
- 26.12.99, 1.10 revised (kp) Use System.arraycopy internally.
-
copyNew
public static PiVector[] copyNew(int[][] data)
Create an new array with copies of all doubles of a given 2-dimensional array of numbers. Each row of argument vector is stored in a vector. Rows may have different length. A row with length zero leads to a warning message, and allocates a vector with length zero.- Parameters:
data- 2-dimensional array of numbers- Returns:
- new array with same number of vectors as rows of argument array
- See Also:
copyNew(PiVector [], int),copy(PiVector [], int, PiVector [], int, int)- Version:
- 24.07.00 1.00 created (kp)
-
copyNew
public static PiVector[] copyNew(PiVector[] data)
Create an new array with copies of all vectors of a given array of vectors. The new array contains new vectors containing the same data as the original vectors.- Parameters:
data- array of vectors- Returns:
- new array with same number of vectors as argument array
- See Also:
copyNew(PiVector [], int),copy(PiVector [], int, PiVector [], int, int)
-
copyNew
public static PiVector[] copyNew(PiVector[] data, int size)
Create an new array with copies of the first 'size' vectors of a given array of vectors. The new array contains new vectors containing the same data as the original vectors.- Parameters:
data- array of vectorssize- number of copied vectors of array- Returns:
- new array with number of vectors equal to argument 'size'
- See Also:
copyNew(PiVector []),copy(PiVector [], int, PiVector [], int, int)
-
copy
public 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.for (int i=0; i<size; i++) dataDest[destInd+i].copy(dataSrc[srcInd+i]);All vectors in source and destination array must exist already. Destination 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),adjustSizes(PiVector[], int, PiVector[], int, int)
-
adjustSizes
public static boolean adjustSizes(PiVector[] dataDest, int destInd, PiVector[] dataSrc, int srcInd, int size)
Adjusts the sizes of vectors in destination array to match the sizes of vectors in source array.for (int i=0; i<size; i++) dataDest[destInd+i].setSize(dataSrc[srcInd+i].getSize());All vectors in source and destination array must exist already. Destination array must be large enough, i.e. must have at least size
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 vector sizes of array- Returns:
trueat success- Since:
- JavaView 3.30.002
- See Also:
copy(PiVector[], int, PiVector[], int, int)- Author:
- Eike Preuss
- Version:
- 06.07.04, 1.00 created (ep).
-
getSameSize
public static int getSameSize(PiVector[] vecArr, int numUsed)
Check of all vectors in array of vector have same length.- Returns:
- same length, or -1 if different or no entries.
-
min
public static final boolean min(PiVector min, PiVector[] vecArr, int arrayLength)
Find the minimum of an array of vectors in each component. Vectors of array may have different length. Any comparison is between the resulting vector and a vector of the array is done for the common number of components.- Parameters:
min- computed minimumvecArr- array of vectorsarrayLength- number of used vectors of array- See Also:
max(PiVector, PiVector [], int)- Version:
- 08.09.00, 1.11 revised (kp) Check for vecArr.length==0.
27.12.99, 1.10 revised (kp) Allow variable length of vectors in array.
-
max
public static final boolean max(PiVector max, PiVector[] vecArr, int arrayLength)
Find the maximum of an array of vectors in each component. Vectors of array may have different length. Any comparison is between the resulting vector and a vector of the array is done for the common number of components.- Parameters:
max- computed maximumvecArr- array of vectorsarrayLength- number of used vectors of array- See Also:
min(PiVector, PiVector [], int)- Version:
- 08.09.00, 1.11 revised (kp) Check for vecArr.length==0.
27.12.99, 1.10 revised (kp) Allow variable length of vectors in array.
-
setConstant
public static void setConstant(PiVector[] vecArr, int aValue)
Set all components of all vectors of an array to a constant.- Version:
- 08.09.00, 1.11 revised (kp) Check for vecArr.length==0.
24.07.00, 1.10 revised (kp) Now call method in inner loop.
-
setConstant
public static void setConstant(PiVector[] vecArr, int[] data)
Set all vectors of an array equal to a given vector. All vectors of argument array must have same length.- Version:
- 08.09.00, 1.01 revised (kp) Check for vecArr.length==0.
24.07.00, 1.00 created (kp) From setConstant(PiVector[],PiVector).
-
setConstant
public static void setConstant(PiVector[] vecArr, PiVector aVector)
Set all vectors of an array equal to a given vector. All vectors of argument array must have same length.- Version:
- 24.07.00, 1.10 revised (kp) No calls setConstant(PiVector[],int[]).
-
setConstant
public static void setConstant(PiVector v, int aValue)
Set all entries to a constant value.
-
setConstant
public void setConstant(int aValue)
Set all entries to a constant value.
-
getSize
public int getSize()
Return size of vector, i.e. number of entries in data array.
-
setSize
public int setSize(int aSize)
Set dimension of vector, i.e. length of its data array. Existing data is copied into the new array.- Parameters:
aSize- new number of components of vector- Returns:
- new number of components of vector
-
getEntries
public int[] getEntries()
Return a copy of content of vector as array of integers.
-
getEntry
public int getEntry(int ind)
Get the component of a vector.
-
setEntry
public void setEntry(int ind, int value)Assign value to component of vector, and possibly enlarge vector if too small.- Parameters:
ind- index of component to modifyvalue- new value of component- Version:
- 29.09.99 revised (kp) Check for m_data==null. 08.09.99 revised (ep) setSize allocated one entry too few.
-
getFirstEntry
public int getFirstEntry()
Get the first component of a vector.- Returns:
- value of the first component.
-
setFirstEntry
public void setFirstEntry(int value)
Set the first component of a vector.- Parameters:
value- new value of first component- Version:
- 25.07.00 revised (kp) 25.07.00 created (kp)
-
getLastEntry
public int getLastEntry()
Get the last component of a vector.- Returns:
- value of the last component.
-
setLastEntry
public void setLastEntry(int value)
Set the last component of a vector.- Parameters:
value- new value of last component- Version:
- 25.07.00 revised (kp) 25.07.00 created (kp)
-
addEntry
public int addEntry(int val)
Add another entry at the end of the vector and increment size of vector.- Parameters:
val- value to be added- Returns:
- index of new last entry.
-
removeEntry
public void removeEntry(int ind)
Remove an entry from the vector. All successive entries will be copied.- Parameters:
ind- Index of the entry to remove.- Author:
- Matthias Nieser
- Version:
- 16.03.10, 1.00 created (mn)
-
concat
public void concat(PiVector piv)
Concatenates another PiVector to the end of this vector.- Parameters:
piv- Vector to append to this one.- Version:
- 07.08.07, 1.00 created (mn)
-
concatNew
public static PiVector concatNew(PiVector v, PiVector w)
Concatenate two PiVectors into one new PiVector.- Parameters:
v- First vectorw- Second vector- Returns:
- Concatenation of both vectors.
- Author:
- Felix Kaelberer
- Version:
- 27.02.08, 2.00 revised (mn) Use copy() instead of manual copying.
29.01.08, 1.00 created (fk)
-
set
public 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.- Version:
- 22.12.99 created (kp)
-
set
public 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.- Version:
- 22.12.99 created (kp)
-
set
public void set(int[] x, int len)Assign first values of array to vector, and adjust length of vector if different from argument len.- Version:
- 22.12.99 revised (kp) Method now just calls set(double[], int, int).
29.09.99 revised (kp) Check for m_data==null.
-
set
public void set(int[] x)
Assign values of vector, and adjust length of vector if different from length of array.- Version:
- 22.12.99 revised (kp) Method now just calls set(double[], int, int).
29.09.99 revised (kp) Check for m_data==null.
-
set
public void set(int x)
Assign value to vector, and set size of vector to 1.
-
set
public void set(int x, int y)Assign value to vector, and set size of vector to 2.- Version:
- 29.09.99 revised (kp) Check for m_data==null.
-
set
public void set(int x, int y, int z)Assign value to vector, and set size of vector to 3.- Version:
- 29.09.99 revised (kp) Check for m_data==null.
-
set
public void set(int x, int y, int z, int w)Assign value to vector, and set size of vector to 4.- Version:
- 29.09.99 revised (kp) Check for m_data==null.
-
getIndexOf
public int getIndexOf(int aValue)
Find index of first occurrence of value 'aValue' in vector.- Returns:
- -1 if aValue not found
-
contains
public boolean contains(int aValue)
Returns true if this PiVector contains 'aValue'.- Version:
- 19.08.2011, 1.00 created (fk)
-
changeValue
public 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. The other entries are not used and initialized to zero. If by chance 'oldValue' is zero then these initialization would be spoiled, which is very error prone. return number of changed positions
-
changeValue
public int changeValue(int oldValue, int newValue)Change all occurrence of value oldValue to newValue COMPARE: changeValue(int, int, int) return number of changed positions
-
shift
public void shift(int num)
Shift components in cyclic order within the array. If num>0, the components will be shifted in upper direction, i.e. index i -> index i+1.- Parameters:
num- number of positions each component is shifted- See Also:
invert()- Version:
- 19.10.06, 1.20 revised (ur) Allow shifting by numbers different from +1 and -1.
07.06.06, 1.10 revised (fk) Prevent exception if array length < 2.
-
invert
public PiVector invert(int usedSize)
Invert order of the first 'usedSize' entries, i.e. the first entry becomes the usedSize-1 entry.- Parameters:
usedSize- number of used entries- Returns:
- this
- See Also:
invert()
-
invert
public PiVector invert()
Invert order of all entries, i.e. the first entry becomes the last entry.- Returns:
- this
- See Also:
invert(int)
-
add
public void add(int val)
Add a value to each component of the vector.- Parameters:
val- number to be added to each component
-
add
public void add(PiVector m)
Sum with argument vectorthis = this+m.
-
add
public void add(int factor, PiVector v)Addfactor*vtothis. If result vector 'this' is empty then its size is set to length of vector 'v'. Otherwise, 'this' and v must be of same size.- Parameters:
v- vector to add to 'this'factor- weight of vector v- See Also:
add(PiVector),add(PiVector, PiVector),blendBase(PiVector, int, PiVector),blend(int, PiVector, int, PiVector)- Author:
- Felix Kaelberer
- Version:
- 30.11.07, 1.00 created (mn) Copied from PdVector.add(double, PdVector).
-
sub
public void sub(PiVector m)
Difference with argument vectorthis = this-m.
-
subNew
public static PiVector subNew(PiVector m1, PiVector m2)
Create a new vector as difference of argument vectorsnew = m1-m2. If sizes differ then a warning is thrown and a vector of minimal common size returned.- Version:
- 05.12.00, 1.10 revised (kp) Better check of array bounds.
-
copyNew
public static PiVector copyNew(PiVector v)
Create a new vector as clone of argument vector.- Parameters:
v- source vector to clone- Version:
- 29.04.06, 1.20 revised (kp) No longer throws a warning if arg is null.
20.05.01, 1.10 revised (kp) Copy items of superclass too.
-
copy
public boolean copy(int destInd, PiVector dataSrc, int srcInd, int size)Copy part of the source vector into this vector, and adjust size of this vector only if it is too small.- See Also:
copy(PiVector)- Version:
- 26.12.99, 1.10 revised (kp) Use System.arraycopy internally.
-
copy
public void copy(PiVector v)
Copy a vector into a vector, and do not adjust size of dest vector. 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. If destination vector is bigger than source then reset the additional entries in destination vector with 0.- Parameters:
v- source vector to copy- See Also:
copy(int,PiVector,int,int)- Version:
- 26.12.99, 1.10 revised (kp) Use System.arraycopy internally.
25.08.99, 1.05 revised (ur) Set size if 'this' is empty.
-
copyArray
public void copyArray(PiVector v)
Copy data array of source vector into this vector, and do not adjust size of destination vector. In contrast tocopy(PiVector)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 minimum of both sizes for copying. If destination vector is bigger than source then reset the additional entries in destination vector with 0.- Parameters:
v- source vector to copy- See Also:
copy(PiVector)- Version:
- 30.12.01, 1.10 revised (kp) Resize not only when m_data==null but also m_data.length==0.
01.01.01, 1.00 revised (kp)
-
copy
public void copy(int[] anArray, int aSize)Copy a integer array into a vector, and do not adjust size of destination vector. If destination vector is empty then allocated space of size of source array. If source and destination vectors have different size then use the minimum of both sizes. If destination vector is bigger than source then reset the additional entries in destination vector with 0.- See Also:
copyArray(PiVector),copy(int, PiVector, int, int)- Version:
- 09.03.14, 2.00 revised (kp) Use same optimized code as copyArray.
26.12.99, 1.10 revised (kp) Use System.arraycopy internally.
25.08.99, 1.05 revised (ur) Set size if 'this' is empty.
-
multScalar
public void multScalar(int scalar)
Multiply vector with scalarthis = scalar*this.
-
multScalar
public void multScalar(PiVector v, int scalar)
Multiply argument vector with scalarthis = scalar*v.
-
leftMultMatrix
public void leftMultMatrix(PdMatrix m)
Multiply vector with matrixthis = m*this. Matrix must be square and of same size than vector. Method does not change size of 'this'!- Version:
- 12.03.06, 1.10 revised (kp) Used clone instead of allocate/assign.
-
leftMultMatrix
public void leftMultMatrix(PdMatrix m, PiVector v)
Multiply vector with matrixthis = m*v. Matrix need not be square. Method modifies size of vector to number of row of matrix.
-
rightMultMatrix
public void rightMultMatrix(PdMatrix m)
Multiply vector with matrixthis = this*m. Matrix must be square and of same size than vector. Method does not change size of 'this'!- Version:
- 12.03.06, 1.10 revised (kp) Used clone instead of allocate/assign.
-
rightMultMatrix
public void rightMultMatrix(PiVector v, PdMatrix m)
Multiply vector with matrixthis = v*m. Matrix need not be square. Method modifies size of vector to number of columns of matrix.
-
dot
public int dot(PiVector v)
Compute scalar product with argument vector.
-
sqrLength
public int sqrLength()
Get square of Euclidean length of vector.
-
length
public int length()
Get Euclidean length of vector as rounded integer.
-
getLength
public double getLength()
Get Euclidean length of vector.- Since:
- JavaView 3.24.003.
- Version:
- 02.06.04, 1.00 created (kp)
-
normalize
public boolean normalize()
Deprecated. use PdVectorNormalize vector to unit length.
-
normalize
public void normalize(PiVector v)
Deprecated. use PdVectorSet vector to normalized argument vector.
-
setLength
public void setLength(int aLength)
Deprecated. use PdVectorSet Euclidean length of vector.
-
blendNew
public static PiVector blendNew(int a, PiVector v, int b, PiVector w)
Create a new vectorthis = a*v + b*w.
-
blend
public void blend(int a, PiVector v, int b, PiVector w)Interpolate between two vectors with given weights. Usesthis = 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.- Parameters:
v- first vectora- weight of vector vw- second vectorb- weight of vector w- See Also:
blendBase(PiVector, int, PiVector),blendNew(int, PiVector, int, PiVector)- Author:
- Konrad Polthier
- Version:
- 16.09.98, 1.00 revised (kp)
16.09.98, 1.00 created (kp)
-
blendBase
public void blendBase(PiVector v, int b, PiVector w)
Interpolate between two vectors with given weights. Usesthis = 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.- Parameters:
v- first vectorw- second vectorb- weight of vector w- See Also:
blend(int, PiVector, int, PiVector),blendNew(int, PiVector, int, PiVector)- Author:
- Konrad Polthier
- Version:
- 16.09.98, 1.00 revised (kp)
16.09.98, 1.00 created (kp)
-
blend
public void blend(double a, PiVector v, double b, PiVector w)Interpolate between two vectors with given weights. Usesthis = 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.- Parameters:
v- first vectora- weight of vector vw- second vectorb- weight of vector w- See Also:
blendBase(PiVector, int, PiVector),blendNew(int, PiVector, int, PiVector)- Author:
- Konrad Polthier
- Version:
- 18.06.07, 1.00 created (kp) Based on original int method.
-
dist
public int dist(PiVector v)
Euclidean distancedist = |this-v|.
-
sqrDist
public int sqrDist(PiVector v)
Square of Euclidean distancesqrDist = |this-v|^2.
-
max
public int max()
Find maximum value in vector.- See Also:
min(),indexOfMax(),indexOfAbsMax()
-
maxAbs
public double maxAbs()
Find maximal absolute value of component in vector.- Returns:
- absolute value of maximal absolute component
- See Also:
min(),indexOfMax(),indexOfAbsMax()
-
min
public int min()
Find minimal value of component in vector.- Returns:
- value of minimal component
- See Also:
max(),indexOfMin(),indexOfAbsMin()
-
indexOfAbsMax
public int indexOfAbsMax()
Find component in vector with maximal absolute value.- Returns:
- index of maximal absolute component
- See Also:
max(),indexOfMax()- Version:
- 06.04.03, 1.10 revised (kp) Bug removed which led to malfunctioning
of method if negative entries.
-
indexOfAbsMin
public int indexOfAbsMin()
Find component in vector with minimal absolute value.- Returns:
- index of minimal absolute component
- See Also:
min(),indexOfMin()
-
indexOfMax
public int indexOfMax()
Find component in vector with maximal value.- Returns:
- index of maximal component
- See Also:
indexOfAbsMax()
-
indexOfMin
public int indexOfMin()
Find component in vector with minimal value.- Returns:
- index of minimal component
- See Also:
indexOfAbsMin()
-
indexOfValueInOrdering
public int indexOfValueInOrdering(int value)
Computes the index i of the first entry of vector withv[i]>=valuein logarithmic time. Vector must be sort by increasing values.- Parameters:
value- Find position of this value in order vector.- Returns:
- Index of the first entry of vector with
v[i]>=valueor -1 if value is smaller than minimum value of vector. - Version:
- 14.06.2007, 1.00 created (mn) Copied from PdVector.indexOfValueInOrdering().
-
sum
public int sum()
Compute the sum of all entries.- Author:
- Felix Kaelberer
- Version:
- 22.05.07, 1.00 created (fk)
-
average
public double average()
Compute the average value of all entries. Return 0 if this vector has no entries.- Returns:
- Average of all entries if size > 0, and 0 otherwise.
- Author:
- Felix Kaelberer
- Version:
- 24.08.09, 1.00 created (fk) created from PdVector.
-
hasUniqueEntries
public boolean hasUniqueEntries()
Check, whether all entries of this vector are different.- Version:
- 02.06.04, 1.10 revised (kp) Method did not work before.
-
sort
public void sort(PiVector vecOut)
Fill OutVector with sorted entries of this PiVector.
-
sort
public void sort()
Sort entries of this PiVector by size.
-
equals
public boolean equals(java.lang.Object obj)
Determines whether another vector or array of ints is equal to this vector.- Overrides:
equalsin classjava.lang.Object- Since:
- JavaView 3.84.027
- See Also:
equals(int[]),equals(PiVector),Object.equals(java.lang.Object)
-
equals
public boolean equals(int[] list)
Compare vector with list of integers and returnfalseif different array lengths or a different entry. Determines whether a list of integers is equal to data of this vector. The result istrueif both arrays have same length and equal components. Result is alsotrueif argument vector is null and this vector has no entries.- Parameters:
list- the list of integers to compare with- Returns:
trueif the objects are the same;falseotherwise.
-
equals
public boolean equals(PiVector v)
Determines whether another vector is equal to this vector. The result istrueif both vectors have same length and equal components. Result is alsotrueif argument vector is null and this vector has no entries.- Parameters:
v- the vector to compare with- Returns:
trueif the objects are the same;falseotherwise.
-
toString
public java.lang.String toString()
Create a multi-line string representation with detailed information about all instance variables.- Overrides:
toStringin classP_Vector- See Also:
toShortString()- Version:
- 03.06.06, 1.10 (kp) Print empty brackets instead of null if empty data array.
-
toShortString
public java.lang.String toShortString()
Create a single-line string representation of the vector components and attributes.- See Also:
toString()- Version:
- 03.06.06, 1.10 (kp) Print empty brackets instead of null if empty data array.
-
removeSuccessiveDuplicates
public void removeSuccessiveDuplicates()
Removes all successive duplicate entries. Call sort() before, if you want to remove all duplicates.- Author:
- Matthias Nieser
- Version:
- 05.03.08, 1.00 created (mn)
-
-
"