Class VArray

java.lang.Object
  extended by VArray

public class VArray
extends java.lang.Object

A wrapper of a bit array related to the random variables in a Bayesian network.


Field Summary
(package private)  boolean[] array
          Bit array.
(package private)  BayesNet bayesNet
          Target Bayesian network.
 
Constructor Summary
VArray(BayesNet bn)
          Initializes all bits as false.
VArray(BayesNet bn, boolean b)
          Initializes all bits as b.
VArray(BayesNet bn, Variable v)
          Sets true to the bits corresponding to the variables included in the CPT at which the variable v appears.
 
Method Summary
 VArray copy()
          Returns a copy of this object.
 boolean get(int i)
          Returns the i-th element of the bit array.
 boolean[] getArray()
           
 void intersect(VArray va)
          Takes the bit-wise intersection of the bit array and va.
static VArray intersect(VArray va1, VArray va2)
          Returns the bit-wise exclusive OR of va1 and va2.
 void set(int i, boolean b)
          Sets the i-th element of the bit array as b.
 void setAll(boolean b)
          Sets all elements of the bit array as b.
 void setArray(boolean[] a)
          Makes a deep copy of a to the bit array.
 int size()
          Returns the size of the bit array.
 java.lang.String toString()
          Returns a string representation of the bit array.
 void union(VArray va)
          Takes the bit-wise union of the bit array and va.
static VArray union(VArray va1, VArray va2)
          Returns the bit-wise union of va1 and va2.
 void xor(VArray va)
          Takes the bit-wise exclusive OR of the bit array and va.
static VArray xor(VArray va1, VArray va2)
          Returns the bit-wise exclusive OR of va1 and va2.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

bayesNet

BayesNet bayesNet
Target Bayesian network.


array

boolean[] array
Bit array.

Constructor Detail

VArray

VArray(BayesNet bn,
       boolean b)
Initializes all bits as b.

Parameters:
b - initial value for the bit array.

VArray

VArray(BayesNet bn)
Initializes all bits as false.

Parameters:
bn - a Bayesian network

VArray

VArray(BayesNet bn,
       Variable v)
Sets true to the bits corresponding to the variables included in the CPT at which the variable v appears.

Parameters:
bn - a Bayesian network
Method Detail

getArray

public boolean[] getArray()

setArray

public void setArray(boolean[] a)
              throws B2PException
Makes a deep copy of a to the bit array.

Throws:
B2PException

copy

public VArray copy()
            throws B2PException
Returns a copy of this object.

Throws:
B2PException

get

public boolean get(int i)
Returns the i-th element of the bit array.


set

public void set(int i,
                boolean b)
Sets the i-th element of the bit array as b.


setAll

public void setAll(boolean b)
Sets all elements of the bit array as b.


size

public int size()
Returns the size of the bit array.


toString

public java.lang.String toString()
Returns a string representation of the bit array.

Overrides:
toString in class java.lang.Object

intersect

public void intersect(VArray va)
               throws B2PException
Takes the bit-wise intersection of the bit array and va.

Throws:
B2PException

union

public void union(VArray va)
           throws B2PException
Takes the bit-wise union of the bit array and va.

Throws:
B2PException

xor

public void xor(VArray va)
         throws B2PException
Takes the bit-wise exclusive OR of the bit array and va.

Throws:
B2PException

intersect

public static VArray intersect(VArray va1,
                               VArray va2)
                        throws B2PException
Returns the bit-wise exclusive OR of va1 and va2.

Throws:
B2PException

union

public static VArray union(VArray va1,
                           VArray va2)
                    throws B2PException
Returns the bit-wise union of va1 and va2.

Throws:
B2PException

xor

public static VArray xor(VArray va1,
                         VArray va2)
                  throws B2PException
Returns the bit-wise exclusive OR of va1 and va2.

Throws:
B2PException