Documentation of 'jv.vecmath.PbVector' Java class
PbVector ("JavaView Reference Manual")
"JavaView? v5.03.003"
jv.vecmath

Class PbVector

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable


    public class PbVector
    extends P_Vector
    implements java.lang.Cloneable
    Linear algebra class for an array of booleans with variable length.
    See Also:
    Serialized Form
    Author:
    Matthias Nieser
    Version:
    06.02.08, 1.10 revised (kp) Moved to jv.vecmath from dev.number.
    13.06.07, 1.00 created (mn) Created from PiVector.
    00.00.97, 1.00 created (kp) Original class jv.vecmath.PiVector.
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      boolean[] m_data
      Data array containing the components of the vector.
    • Constructor Summary

      Constructors 
      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.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      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.
      • Methods inherited from class java.lang.Object

        getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • m_data

        public boolean[] 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

      • PbVector

        public PbVector()
        Construct vector with zero size.
      • PbVector

        public PbVector(int aSize)
        Constructor creating a vector with given dimension.
      • PbVector

        public PbVector(boolean x)
        Constructs a vector of length 1 and given initial data.
      • PbVector

        public PbVector(boolean x,
                        boolean y)
        Constructs a vector of length 2 and given initial data.
      • PbVector

        public PbVector(boolean x,
                        boolean y,
                        boolean z)
        Constructs a vector of length 3 and given initial data.
      • PbVector

        public PbVector(boolean x,
                        boolean y,
                        boolean z,
                        boolean w)
        Constructs a vector of length 4 and given initial data.
      • PbVector

        public PbVector(boolean[] x)
        Constructs a vector having same length and given initial data as given array.
    • Method Detail

      • clone

        public java.lang.Object clone()
        Clone object and all instance variables. Similar like copyNew(PbVector) but this clone() method is consistent with possible subclasses while copyNew() explicitly creates a new PbVector.
        Overrides:
        clone in class P_Vector
        See Also:
        copyNew(PbVector)
      • getEntries

        public static boolean[][] getEntries(PbVector[] vArr)
        Return content of array of vectors as matrix of boolean.
        Parameters:
        vArr - Array of vectors
        Returns:
        2-dimensional matrix of boolean
      • alloc

        public static PbVector[][] 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 array
        sizeJ - number of columns in row[i] in new array
        vectorSize - dimension of vectors in new array
      • realloc

        public static PbVector[] realloc(PbVector[] data,
                                         int arraySize,
                                         int vectorSize)
        Allocate an array of vectors, where all vectors have the same dimension. If argument 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.

        Parameters:
        data - possibly empty array of vectors
        arraySize - number of vectors in new array
        vectorSize - dimension of vectors in new array
        Version:
        26.12.99, 1.10 revised (kp) Use System.arraycopy internally.
      • realloc

        public static PbVector[] realloc(PbVector[] data,
                                         int arraySize)
        Allocate an array of vectors. If argument 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.

        Parameters:
        data - possibly empty array of vectors
        arraySize - number of vectors in new array
        Version:
        26.12.99, 1.10 revised (kp) Use System.arraycopy internally.
      • copyNew

        public static PbVector[] copyNew(boolean[][] data)
        Create an new array with copies of all booleans 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
      • copyNew

        public static PbVector[] copyNew(PbVector[] 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
      • copyNew

        public static PbVector[] copyNew(PbVector[] 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 vectors
        size - number of copied vectors of array
        Returns:
        new array with number of vectors equal to argument 'size'
        See Also:
        copyNew(PbVector [])
      • copy

        public 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. All vectors in source and destination array must exist already.
         
         for (int i=0; i<size; i++)
            dataDest[destInd+i].copy(dataSrc[srcInd+i]);
         
        Destination array must be large enough, i.e. dataDest.length >= destInd+size.
        Parameters:
        dataDest - destination array of vectors
        destInd - index of first destination vector in dataDest
        dataSrc - source array of vectors
        srcInd - index of first source vector in dataSrc used for copying
        size - number of copied vectors of array
        Returns:
        true if destination array is large enough
        See Also:
        copy(PbVector)
      • getSameSize

        public static int getSameSize(PbVector[] vecArray,
                                      int numUsed)
        Check of all vectors in array of vector have same length.
        Returns:
        same length, or -1 if different or no entries.
      • setConstant

        public static void setConstant(PbVector[] vecArr,
                                       boolean aValue)
        Set all components of all vectors of an array to a constant.
      • setConstant

        public static void setConstant(PbVector[] vecArr,
                                       boolean[] data)
        Set all vectors of an array equal to a given vector. All vectors of argument array must have same length.
      • setConstant

        public static void setConstant(PbVector[] vecArr,
                                       PbVector aVector)
        Set all vectors of an array equal to a given vector. All vectors of argument array must have same length.
      • setConstant

        public static void setConstant(PbVector v,
                                       boolean aValue)
        Set all entries to a constant value.
      • setConstant

        public static void setConstant(boolean[] v,
                                       boolean aValue)
        Set all entries to a constant value.
      • setConstant

        public void setConstant(boolean aValue)
        Set all entries to a constant value.
      • getSize

        public int getSize()
        Get dimension of vector, i.e. length of its data array.
      • setSize

        public int setSize(int aSize)
        Set dimension of vector, i.e. length of its data array.
        Parameters:
        aSize - new number of components of vector
        Returns:
        new number of components of vector
      • getEntries

        public boolean[] getEntries()
        Return a copy of the content of vector as array of booleans.
      • getEntry

        public boolean getEntry(int ind)
        Get the component of a vector.
      • setEntry

        public void setEntry(int ind,
                             boolean value)
        Assign value to component of vector, and possibly enlarge vector if too small.
        Parameters:
        ind - index of component.
        value - new value of component.
        Version:
        29.09.99, 1.10 revised (kp) Check for m_data==null. 13.09.99, 1.10 revised (kp) setSize allocated one entry too few.
      • getFirstEntry

        public boolean getFirstEntry()
        Get the first component of a vector.
        Returns:
        value of the first component.
      • setFirstEntry

        public void setFirstEntry(boolean value)
        Set the first component of a vector.
        Parameters:
        value - new value of first component
        Version:
        25.07.00 created (kp)
      • getLastEntry

        public boolean getLastEntry()
        Get the last component of a vector.
        Returns:
        value of the last component.
      • setLastEntry

        public void setLastEntry(boolean value)
        Set the last component of a vector.
        Parameters:
        value - new value of last component
        Version:
        25.07.00 created (kp)
      • addEntry

        public int addEntry(boolean 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.
      • set

        public 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.
      • set

        public 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.
      • set

        public void set(boolean[] x,
                        int len)
        Assign first values of boolean array to vector, and adjust length of vector if different from argument len.
      • set

        public void set(boolean[] x)
        Assign values of boolean array to vector, and adjust length of vector if different from length of array.
      • set

        public void set(boolean x)
        Assign value to vector, and increase size of vector if necessary.
      • set

        public void set(boolean x,
                        boolean y)
        Assign value to vector, and increase size of vector if necessary.
      • set

        public void set(boolean x,
                        boolean y,
                        boolean z)
        Assign value to vector, and increase size of vector if necessary.
      • set

        public void set(boolean x,
                        boolean y,
                        boolean z,
                        boolean w)
        Assign value to vector, and increase size of vector if necessary.
      • invert

        public void invert(int usedSize)
        Invert order of the first 'usedSize' entries, i.e. the first entry becomes the 'usedSize-1' entry.
        See Also:
        invert()
      • invert

        public void invert()
        Invert order of all entries, i.e. the first entry becomes the last entry.
        See Also:
        invert(int)
      • invertEntries

        public void invertEntries()
        Set all entries e to (not e).
      • and

        public void and(PbVector v)
        Apply the 'AND' operation component-wise to the entries of this and v and store the results in this.
        Author:
        Felix Kaelberer
        Version:
        06.02.2011, 1.00 created (fk)
      • or

        public void or(PbVector v)
        Apply the 'OR' operation component-wise to the entries of this and v and store the results in this.
        Author:
        Felix Kaelberer
        Version:
        06.02.2011, 1.00 created (fk)
      • xor

        public void xor(PbVector v)
        Apply the 'XOR' operation component-wise to the entries of this and v and store the results in this.
        Author:
        Felix Kaelberer
        Version:
        06.02.2011, 1.00 created (fk)
      • countValue

        public int countValue(boolean b)
        Count the entries that have the same value as b.
        Author:
        Felix Kaelberer
        Version:
        05.04.2011, 1.00 created (fk)
      • copyNew

        public static PbVector copyNew(PbVector v)
        Create a new vector as clone of argument vector.
        Parameters:
        v - source vector to clone
      • copy

        public 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.
        See Also:
        copy(PbVector)
        Version:
        26.12.99, 1.10 revised (kp) Use System.arraycopy internally.
      • copy

        public void copy(PbVector 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,PbVector,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(PbVector v)
        Copy data array of source vector into this vector, and do not adjust size of dest vector. In contrast to 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.
        Parameters:
        v - source vector to copy
        See Also:
        copy(PbVector)
        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(boolean[] anArray,
                         int aSize)
        Copy a boolean array into a vector, and do not adjust size of dest 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 mininum of both sizes. If destination vector is bigger than source then reset the additional entries in destination vector with 0.
        See Also:
        copy(int,PbVector,int,int)
        Version:
        04.02.05, 1.20 revised (kp) Better sync with copy(PbVector).
        26.12.99, 1.10 revised (kp) Use System.arraycopy internally.
        25.08.99, 1.05 revised (ur) Set size if 'this' is empty.
      • copy

        public 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. If destination vector is empty then allocated space of size of source array. If parameter size and length of destination vectors are different then use the minimum of both sizes. If destination vector is bigger than argument size then reset the additional entries in destination vector with 0.
        Parameters:
        anArray - array of booleans
        srcPos - first position in array used for copying
        aSize - number of entries to copy.
        Version:
        26.12.99, 1.10 revised (kp) Use System.arraycopy internally.
      • countTrueEntries

        public int countTrueEntries()
        Count number of entries with state = true.
      • blend

        public void blend(double a,
                          PbVector v,
                          double b,
                          PbVector w)
        Interpolate between two vectors with given weights. Uses this = v, if a>=b, or else this = w. 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:
        a - weight of first vector
        v - first vector
        b - weight of second vector
        w - second vector
        See Also:
        blendNew(double, PbVector, double, PbVector)
      • indexOf

        public int indexOf(boolean value)
        Computes the index i of the first entry of vector with v[i]==value.
        Returns:
        Index of the first entry of vector with v[i]==value or -1 if value is smaller than minimum value of vector.
      • equals

        public boolean equals(boolean[] list)
        Compare vector with list of booleans and return 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.
        Parameters:
        list - the list of booleans to compare with
        Returns:
        true if the objects are the same; false otherwise.
      • equals

        public boolean equals(java.lang.Object obj)
        Determines whether another vector or array of booleans is equal to this vector.
        Overrides:
        equals in class java.lang.Object
        Since:
        JavaView 3.62.012
        See Also:
        equals(boolean[]), equals(PbVector), Object.equals(java.lang.Object)
      • equals

        public boolean equals(PbVector v)
        Determines whether another vector is equal to this vector. The result is 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.
        Parameters:
        v - the vector to compare with
        Returns:
        true if the objects are the same; false otherwise.
      • toString

        public java.lang.String toString()
        Create a multi-line string representation of the vector with detailed information about all instance variables.
        Overrides:
        toString in class P_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.
"JavaView? v5.03.003"

"

The software JavaView? is copyright protected. All Rights Reserved.
"

Ads help maintain this website.