Example #1
0
File: JACLSH.cs Project: chexia/CF
 /* 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);
                                                                     }
                                                                 }
                                                             }
                                                         });
 }
Example #2
0
File: JACLSH.cs Project: chexia/CF
        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);
        }