Exemple #1
0
 public JACCF(JACMatrix utilMat, bool usingLSH = true, int r = 10, int b = 20, bool norm = true)
 {
     this.utilMat = utilMat;
     if (norm)
         utilMat.normalize();
     if (usingLSH)
         this.myLSH = new JACLSH(utilMat, r, b, this);
 }
Exemple #2
0
 public static JACMatrix makeUtilMat(int rowNum, int colNum, string inputFilePath, int rowPos = 2, int colPos = 0, int valPos = 1)
 {
     List<double[]> points = new List<double[]>();
     LogEnum logenum = new LogEnum(inputFilePath);
     foreach (string line in logenum)
     {
         string[] tokens = line.Split(new char[] { '\t' });
         double[] point = new double[3];
         point[0] = Double.Parse(tokens[rowPos]);
         point[1] = Double.Parse(tokens[colPos]);
         if (valPos == -1)
             point[2] = Double.Parse(tokens[3]) / Double.Parse(tokens[2]);
         else
             point[2] = Double.Parse(tokens[valPos]);
         points.Add(point);
     }
     JACMatrix utilMat = new JACMatrix(rowNum, colNum, points);
     return utilMat;
 }
Exemple #3
0
 /* produces signature matrix from original matrix, for compression purposes
  * @arguments: takes in the original matrix
  */
 private void compSigMatEntries(JACMatrix utilMat)
 {
     int[] bandArr = new int[b];
     for (int i = 0; i < b; i++)
         bandArr[i] = i;
     Parallel.For<Dictionary<int, Dictionary<int, int>>>(0, b,
                                                         () => new Dictionary<int, Dictionary<int, int>>(),
                                                         (bandInd, foo, sigMatLocal) =>
                                                         {
                                                             sigMatLocal[bandInd] = new Dictionary<int, int>();
                                                             int[][] currBandRandVec = compRandVec(utilMat.GetLength(0));
                                                             for (int col = 0; col < this.numSets; col++)
                                                             {
                                                                 string tmpHash = "";
                                                                 for (int vecInd = 0; vecInd < r; vecInd++)
                                                                 {
                                                                     double result = 0;
                                                                     for (int row = 0; row < utilMat.GetLength(0); row++)
                                                                     {
                                                                         int realRow = currBandRandVec[vecInd][row];
                                                                         if (utilMat.get(realRow, col) == 1)
                                                                             result = realRow;
                                                                         break;
                                                                     }
                                                                     tmpHash += result;
                                                                 }
                                                                 int hashCode = tmpHash.GetHashCode();
                                                                 sigMatLocal[bandInd].Add(col, hashCode);
                                                             }
                                                             return sigMatLocal;
                                                         },
                                                         (sigMatLocal) =>
                                                         {
                                                             foreach (int bandInd in sigMatLocal.Keys)
                                                             {
                                                                 foreach (int colInd in sigMatLocal[bandInd].Keys)
                                                                 {
                                                                     lock (this.sigMat)
                                                                     {
                                                                         this.sigMat[bandInd].Add(colInd, sigMatLocal[bandInd][colInd]);
                                                                     }
                                                                     lock (this.revSigMat)
                                                                     {
                                                                         this.revSigMat[bandInd].Add(sigMatLocal[bandInd][colInd], colInd);
                                                                     }
                                                                 }
                                                             }
                                                         });
 }
Exemple #4
0
        private Dictionary<int, int>[] sigMat; //gets hash value from column

        #endregion Fields

        #region Constructors

        public JACLSH(JACMatrix utilMat, int r, int b, JACCF filter)
        {
            this.filter = filter;
            this.numSets = utilMat.GetLength(1);
            this.r = r;
            this.b = b;
            sigMat = new Dictionary<int, int>[b];
            revSigMat = new MultiDictionary<int, int>[b];
            for (int bandInd = 0; bandInd < b; bandInd++)
            {
                sigMat[bandInd] = new Dictionary<int, int>();
                revSigMat[bandInd] = new MultiDictionary<int, int>(true);
            }
            compSigMatEntries(utilMat);
        }