edu.memphis.ccrg.lida.episodicmemory.sdm
Class BitVectorUtils

java.lang.Object
  extended by edu.memphis.ccrg.lida.episodicmemory.sdm.BitVectorUtils

public class BitVectorUtils
extends java.lang.Object

Utilities for BitVector

Author:
Javier Snaider

Constructor Summary
BitVectorUtils()
           
 
Method Summary
static cern.colt.bitvector.BitVector getComplement(cern.colt.bitvector.BitVector a)
          Gets the complement of a bit vector.
static cern.colt.bitvector.BitVector getNoisyVector(cern.colt.bitvector.BitVector original, int noise)
          Returns a noisy BitVector
static cern.colt.bitvector.BitVector getNormalizedVector(int[] buff)
          Gets a normalized vector.
static cern.colt.bitvector.BitVector getRandomVector(int s)
          Returns a random BitVector of specified size
static int[] getVectorSum(int[] accum, cern.colt.bitvector.BitVector v)
          Adds a BitVector to an accumulation array.
static int[] getVectorSum(int[] accum, int[] vector)
          Sums specified vectors.
static int hamming(cern.colt.bitvector.BitVector vector1, cern.colt.bitvector.BitVector vector2)
          Calculates the Hamming distances between two BitVector addresses.
static cern.colt.bitvector.BitVector multiplyVectors(cern.colt.bitvector.BitVector a, cern.colt.bitvector.BitVector b)
          Multiply vectors.
static int[] vectorToBipolar(cern.colt.bitvector.BitVector v)
          Vector to bipolar.
static int[] vectorToBipolar(int[] accum, cern.colt.bitvector.BitVector v)
          Vector to bipolar.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BitVectorUtils

public BitVectorUtils()
Method Detail

getRandomVector

public static cern.colt.bitvector.BitVector getRandomVector(int s)
Returns a random BitVector of specified size

Parameters:
s - the size of the new vector
Returns:
a new random vector of size s.

hamming

public static int hamming(cern.colt.bitvector.BitVector vector1,
                          cern.colt.bitvector.BitVector vector2)
Calculates the Hamming distances between two BitVector addresses.

Parameters:
vector1 - the first BitVector
vector2 - the second BitVector
Returns:
the Hamming distances

getNoisyVector

public static cern.colt.bitvector.BitVector getNoisyVector(cern.colt.bitvector.BitVector original,
                                                           int noise)
Returns a noisy BitVector

Parameters:
original - original BitVector
noise - number of noisy bits to introduce
Returns:
a new vector which differs from the original by at most 'noise' bits

getVectorSum

public static int[] getVectorSum(int[] accum,
                                 cern.colt.bitvector.BitVector v)
Adds a BitVector to an accumulation array. The bits of the BitVector are first converted to either 0 to -1. The BitVector is not modified.

Parameters:
accum - the accumulation array.
v - the vector to be added
Returns:
the new accumulation array

getVectorSum

public static int[] getVectorSum(int[] accum,
                                 int[] vector)
Sums specified vectors.

Parameters:
accum - the accum
vector - the vector
Returns:
the int[]

vectorToBipolar

public static int[] vectorToBipolar(int[] accum,
                                    cern.colt.bitvector.BitVector v)
Vector to bipolar.

Parameters:
accum - the accum
v - the v
Returns:
the int[]

vectorToBipolar

public static int[] vectorToBipolar(cern.colt.bitvector.BitVector v)
Vector to bipolar.

Parameters:
v - the v
Returns:
the int[]

getNormalizedVector

public static cern.colt.bitvector.BitVector getNormalizedVector(int[] buff)
Gets a normalized vector.

Parameters:
buff - a int[] vector
Returns:
new normalized BitVector

multiplyVectors

public static cern.colt.bitvector.BitVector multiplyVectors(cern.colt.bitvector.BitVector a,
                                                            cern.colt.bitvector.BitVector b)
Multiply vectors.

Parameters:
a - the a
b - the b
Returns:
the bit vector

getComplement

public static cern.colt.bitvector.BitVector getComplement(cern.colt.bitvector.BitVector a)
Gets the complement of a bit vector.

Parameters:
a - the input bit vector
Returns:
the complement of the input bit vector