public class PbVector extends P_Vector implements java.lang.Cloneable
Modifier and Type | Field and Description |
---|---|
boolean[] |
m_data
Data array containing the components of the vector.
|
Constructor and Description |
---|
PbVector()
Construct vector with zero size.
|
PbVector(boolean x)
Constructs a vector of length 1 and given initial data.
|
PbVector(boolean[] x)
Constructs a vector having same length and given initial data as given array.
|
PbVector(boolean x,
boolean y)
Constructs a vector of length 2 and given initial data.
|
PbVector(boolean x,
boolean y,
boolean z)
Constructs a vector of length 3 and given initial data.
|
PbVector(boolean x,
boolean y,
boolean z,
boolean w)
Constructs a vector of length 4 and given initial data.
|
PbVector(int aSize)
Constructor creating a vector with given dimension.
|
Modifier and Type | Method and Description |
---|---|
int |
addEntry(boolean val)
Add another entry at the end of the vector and increment size of vector.
|
static PbVector[][] |
alloc(int sizeI,
int sizeJ,
int vectorSize)
Allocate a new array of vectors, where all vectors have the same dimension.
|
void |
and(PbVector v)
Apply the 'AND' operation component-wise to the entries of
this and
v and store the results in this . |
void |
blend(double a,
PbVector v,
double b,
PbVector w)
Interpolate between two vectors with given weights.
|
static PbVector |
blendNew(double a,
PbVector v,
double b,
PbVector w)
Create a new vector
this = a*v + b*w . |
java.lang.Object |
clone()
Clone object and all instance variables.
|
void |
copy(boolean[] anArray,
int aSize)
Copy a boolean array into a vector, and do not adjust size of dest vector.
|
void |
copy(boolean[] anArray,
int srcPos,
int aSize)
Copy part of a boolean array into a vector, and do not adjust size of dest vector.
|
boolean |
copy(int destInd,
PbVector 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.
|
void |
copy(PbVector v)
Copy a vector into a vector, and do not adjust size of dest vector.
|
static boolean |
copy(PbVector[] dataDest,
int destInd,
PbVector[] dataSrc,
int srcInd,
int size)
Copies some vectors of a given array of vectors into an existing destination array.
|
void |
copyArray(PbVector v)
Copy data array of source vector into this vector, and do not adjust size of dest vector.
|
static PbVector[] |
copyNew(boolean[][] data)
Create an new array with copies of all booleans of a given 2-dimensional array of numbers.
|
static PbVector |
copyNew(PbVector v)
Create a new vector as clone of argument vector.
|
static PbVector[] |
copyNew(PbVector[] data)
Create an new array with copies of all vectors of a given array of vectors.
|
static PbVector[] |
copyNew(PbVector[] data,
int size)
Create an new array with copies of the first 'size' vectors of a given array of vectors.
|
int |
countTrueEntries()
Count number of entries with state = true.
|
int |
countValue(boolean b)
Count the entries that have the same value as
b . |
boolean |
equals(boolean[] list)
Compare vector with list of booleans and return
false if different
array lengths or a different entry. |
boolean |
equals(java.lang.Object obj)
Determines whether another vector or array of booleans is equal to this vector.
|
boolean |
equals(PbVector v)
Determines whether another vector is equal to this vector.
|
boolean[] |
getEntries()
Return a copy of the content of vector as array of booleans.
|
static boolean[][] |
getEntries(PbVector[] vArr)
Return content of array of vectors as matrix of boolean.
|
boolean |
getEntry(int ind)
Get the component of a vector.
|
boolean |
getFirstEntry()
Get the first component of a vector.
|
boolean |
getLastEntry()
Get the last component of a vector.
|
static int |
getSameSize(PbVector[] vecArray,
int numUsed)
Check of all vectors in array of vector have same length.
|
int |
getSize()
Get dimension of vector, i.e. length of its data array.
|
int |
indexOf(boolean value)
Computes the index i of the first entry of vector with
v[i]==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 |
invertEntries()
Set all entries e to (not e).
|
void |
or(PbVector v)
Apply the 'OR' operation component-wise to the entries of
this and
v and store the results in this . |
static PbVector[] |
realloc(PbVector[] data,
int arraySize)
Allocate an array of vectors.
|
static PbVector[] |
realloc(PbVector[] data,
int arraySize,
int vectorSize)
Allocate an array of vectors, where all vectors have the same dimension.
|
void |
set(boolean x)
Assign value to vector, and increase size of vector if necessary.
|
void |
set(boolean[] x)
Assign values of boolean array to vector,
and adjust length of vector if different from length of array.
|
void |
set(boolean[] x,
int len)
Assign first values of boolean array to vector,
and adjust length of vector if different from argument len.
|
void |
set(boolean[] x,
int from,
int len)
Assign 'len' values of boolean array starting at 'from' to vector,
and adjust length of vector if different from argument len.
|
void |
set(boolean x,
boolean y)
Assign value to vector, and increase size of vector if necessary.
|
void |
set(boolean x,
boolean y,
boolean z)
Assign value to vector, and increase size of vector if necessary.
|
void |
set(boolean x,
boolean y,
boolean z,
boolean w)
Assign value to vector, and increase size of vector if necessary.
|
void |
set(PbVector 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(boolean aValue)
Set all entries to a constant value.
|
static void |
setConstant(boolean[] v,
boolean aValue)
Set all entries to a constant value.
|
static void |
setConstant(PbVector[] vecArr,
boolean aValue)
Set all components of all vectors of an array to a constant.
|
static void |
setConstant(PbVector[] vecArr,
boolean[] data)
Set all vectors of an array equal to a given vector.
|
static void |
setConstant(PbVector[] vecArr,
PbVector aVector)
Set all vectors of an array equal to a given vector.
|
static void |
setConstant(PbVector v,
boolean aValue)
Set all entries to a constant value.
|
void |
setEntry(int ind,
boolean value)
Assign value to component of vector, and possibly enlarge vector if too small.
|
void |
setFirstEntry(boolean value)
Set the first component of a vector.
|
void |
setLastEntry(boolean value)
Set the last component of a vector.
|
int |
setSize(int aSize)
Set dimension of vector, i.e. length of its data array.
|
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 of the vector
with detailed information about all instance variables.
|
void |
xor(PbVector v)
Apply the 'XOR' operation component-wise to the entries of
this and
v and store the results in this . |
public boolean[] m_data
public PbVector()
public PbVector(int aSize)
public PbVector(boolean x)
public PbVector(boolean x, boolean y)
public PbVector(boolean x, boolean y, boolean z)
public PbVector(boolean x, boolean y, boolean z, boolean w)
public PbVector(boolean[] x)
public java.lang.Object clone()
copyNew(PbVector)
but this clone() method is consistent with possible subclasses
while copyNew() explicitly creates a new PbVector.clone
in class java.lang.Object
copyNew(PbVector)
public static boolean[][] getEntries(PbVector[] vArr)
vArr
- Array of vectorspublic static PbVector[][] alloc(int sizeI, int sizeJ, int vectorSize)
sizeI
- number of rows in new arraysizeJ
- number of columns in row[i] in new arrayvectorSize
- dimension of vectors in new arraypublic static PbVector[] realloc(PbVector[] 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 arraypublic static PbVector[] realloc(PbVector[] data, int arraySize)
data!=null
then 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.
data
- possibly empty array of vectorsarraySize
- number of vectors in new arraypublic static PbVector[] copyNew(boolean[][] data)
data
- 2-dimensional array of numberspublic static PbVector[] copyNew(PbVector[] data)
data
- array of vectorspublic static PbVector[] copyNew(PbVector[] data, int size)
data
- array of vectorssize
- number of copied vectors of arraycopyNew(PbVector [])
public static boolean copy(PbVector[] dataDest, int destInd, PbVector[] dataSrc, int srcInd, int size)
for (int i=0; iDestination array must be large enough, i.e. dataDest.length >= destInd+size
.
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 arraytrue
if destination array is large enoughcopy(PbVector)
public static int getSameSize(PbVector[] vecArray, int numUsed)
public static void setConstant(PbVector[] vecArr, boolean aValue)
public static void setConstant(PbVector[] vecArr, boolean[] data)
public static void setConstant(PbVector[] vecArr, PbVector aVector)
public static void setConstant(PbVector v, boolean aValue)
public static void setConstant(boolean[] v, boolean aValue)
public void setConstant(boolean aValue)
public int getSize()
public int setSize(int aSize)
aSize
- new number of components of vectorpublic boolean[] getEntries()
public boolean getEntry(int ind)
public void setEntry(int ind, boolean value)
ind
- index of component.value
- new value of component.public boolean getFirstEntry()
public void setFirstEntry(boolean value)
value
- new value of first componentpublic boolean getLastEntry()
public void setLastEntry(boolean value)
value
- new value of last componentpublic int addEntry(boolean val)
val
- value to be addedpublic void set(PbVector x, int from, int len)
public void set(boolean[] x, int from, int len)
public void set(boolean[] x, int len)
public void set(boolean[] x)
public void set(boolean x)
public void set(boolean x, boolean y)
public void set(boolean x, boolean y, boolean z)
public void set(boolean x, boolean y, boolean z, boolean w)
public void invert(int usedSize)
invert()
public void invert()
invert(int)
public void invertEntries()
public void and(PbVector v)
this
and
v
and store the results in this
.public void or(PbVector v)
this
and
v
and store the results in this
.public void xor(PbVector v)
this
and
v
and store the results in this
.public int countValue(boolean b)
b
.public static PbVector copyNew(PbVector v)
v
- source vector to clonepublic boolean copy(int destInd, PbVector dataSrc, int srcInd, int size)
copy(PbVector)
public void copy(PbVector v)
v
- source vector to copycopy(int,PbVector,int,int)
public void copyArray(PbVector v)
copy(PbVector)
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(PbVector)
public void copy(boolean[] anArray, int aSize)
copy(int,PbVector,int,int)
public void copy(boolean[] anArray, int srcPos, int aSize)
anArray
- array of booleanssrcPos
- first position in array used for copyingaSize
- number of entries to copy.public int countTrueEntries()
public static PbVector blendNew(double a, PbVector v, double b, PbVector w)
this = a*v + b*w
.a
- weight of first vectorv
- first vectorb
- weight of second vectorw
- second vectorblend(double, PbVector, double, PbVector)
public void blend(double a, PbVector v, double b, PbVector w)
this = v, if a>=b, or this = w, else
.
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.a
- weight of first vectorv
- first vectorb
- weight of second vectorw
- second vectorblendNew(double, PbVector, double, PbVector)
public int indexOf(boolean value)
v[i]==value
.v[i]==value
or -1 if value is smaller than minimum value of vector.public boolean equals(boolean[] list)
false if different
array lengths or a different entry.
Determines whether a list of booleans 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.
list
- the list of booleans to compare withtrue
if the objects are the same; false
otherwise.public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
equals(boolean[])
,
equals(PbVector)
,
Object.equals(java.lang.Object)
public boolean equals(PbVector v)
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.v
- the vector to compare withtrue
if the objects are the same; false
otherwise.public java.lang.String toString()
toString
in class P_Vector
toShortString()
public java.lang.String toShortString()
toString()
"