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()
          Instantiates a new bit vector utils.
 
Method Summary
static int[] denormalizeVector(cern.colt.bitvector.BitVector[] weights)
          Denormalize vector.
static cern.colt.bitvector.BitVector[] discretizeIntVector(int[] buff, int bitSteps)
          Discretize int vector.
static cern.colt.bitvector.BitVector getRandomVector(int s)
           
static int hamming(cern.colt.bitvector.BitVector addr, cern.colt.bitvector.BitVector hardLoc)
          Calculates the Hamming distances between two address.
static cern.colt.bitvector.BitVector multiplyVectors(cern.colt.bitvector.BitVector a, cern.colt.bitvector.BitVector b)
          Multiply vectors.
static cern.colt.bitvector.BitVector noisyVector(cern.colt.bitvector.BitVector original, int noise)
          Returns a noisyVector
static cern.colt.bitvector.BitVector normalizeVector(int[] buff)
          Normalize vector.
static cern.colt.bitvector.BitVector substractVectors(cern.colt.bitvector.BitVector a, cern.colt.bitvector.BitVector b)
          Substract vectors.
static int[] subtractVectors(int[] a, cern.colt.bitvector.BitVector v)
          Subtracts vectors.
static int[] sumVectors(int[] accum, cern.colt.bitvector.BitVector v)
          Adds BitVector v to int[] accum, first converting the bits of v with value 0 to -1.
static int[] sumVectors(int[] accum, int[] vector)
          Sum 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()
Instantiates a new bit vector utils.

Method Detail

getRandomVector

public static cern.colt.bitvector.BitVector getRandomVector(int s)
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 addr,
                          cern.colt.bitvector.BitVector hardLoc)
Calculates the Hamming distances between two address.

Parameters:
addr - the addr
hardLoc - the hard loc
Returns:
the Hamming distances

noisyVector

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

Parameters:
original - original vector
noise - number of noisy bits to introduce
Returns:
new vector based in the original with at most noise bits changed

sumVectors

public static int[] sumVectors(int[] accum,
                               cern.colt.bitvector.BitVector v)
Adds BitVector v to int[] accum, first converting the bits of v with value 0 to -1. BitVector v is not modified.

Parameters:
accum - the accumulation array.
v - the vector to add
Returns:
accum

substractVectors

public static cern.colt.bitvector.BitVector substractVectors(cern.colt.bitvector.BitVector a,
                                                             cern.colt.bitvector.BitVector b)
Substract vectors.

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

subtractVectors

public static int[] subtractVectors(int[] a,
                                    cern.colt.bitvector.BitVector v)
Subtracts vectors.

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

sumVectors

public static int[] sumVectors(int[] accum,
                               int[] vector)
Sum 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[]

normalizeVector

public static cern.colt.bitvector.BitVector normalizeVector(int[] buff)
Normalize vector.

Parameters:
buff - the buff
Returns:
the bit vector

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

discretizeIntVector

public static cern.colt.bitvector.BitVector[] discretizeIntVector(int[] buff,
                                                                  int bitSteps)
Discretize int vector.

Parameters:
buff - the buff
bitSteps - the bit steps
Returns:
the bit vector[]

denormalizeVector

public static int[] denormalizeVector(cern.colt.bitvector.BitVector[] weights)
Denormalize vector.

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