public PluckerSignMatrixDistribution(long sampleSize, int dimensions) { Matrix <double> mask = Matrix <double> .Build.Dense(5, 5, 1); mask[2, 0] = 0; mask[3, 0] = 0; mask[3, 1] = 0; for (long i = sampleSize; i > 0; i--) { Ngon ngon = Program.generateRandomNgon(dimensions); PluckerMatrix plucker = new PluckerMatrix(ngon); SignMatrix signMatrix = new SignMatrix(plucker, mask); SignMatrix fullKey = similarFullMatrix.Keys.FirstOrDefault(m => m.Equals(signMatrix)); if (fullKey == null) { similarFullMatrix.Add(signMatrix, new List <Ngon>()); fullKey = signMatrix; } similarFullMatrix[fullKey].Add(ngon); ReducedSignMatrix2 reducedKey = similarReducedMatrix.Keys.FirstOrDefault(m => m.Equals(signMatrix.getReduced2(mask))); if (reducedKey == null) { similarReducedMatrix.Add(signMatrix.getReduced2(mask), new List <Ngon>()); reducedKey = signMatrix.getReduced2(mask); } similarReducedMatrix[reducedKey].Add(ngon); if (i % (sampleSize / 100) == 0) { Console.Write("\rCreating sign matrix table: {0}% ", i / (sampleSize / 100)); } } }
public PluckerAndProjectionMatricesDistribution(long sampleSize, int dimensions) { for (long i = sampleSize; i > 0; i--) { Ngon ngon = Program.generateRandomNgon(dimensions); #region Plucker PluckerMatrix plucker = new PluckerMatrix(ngon); SignMatrix pluckerSign = new SignMatrix(plucker); SignMatrix fullPluckerKey = similarPluckerFullMatrix.Keys.FirstOrDefault(m => m.Equals(pluckerSign)); if (fullPluckerKey == null) { similarPluckerFullMatrix.Add(pluckerSign, new List <Ngon>()); fullPluckerKey = pluckerSign; } similarPluckerFullMatrix[fullPluckerKey].Add(ngon); ReducedSignMatrix reducedPluckerKey = similarReducedMatrix.Keys.FirstOrDefault(m => m.Equals(pluckerSign.getReduced())); if (reducedPluckerKey == null) { similarReducedMatrix.Add(pluckerSign.getReduced(), new List <Ngon>()); reducedPluckerKey = pluckerSign.getReduced(); } similarReducedMatrix[reducedPluckerKey].Add(ngon); #endregion #region Projection ProjectionMatrix projection = new ProjectionMatrix(ngon); SignMatrix projectionSign = new SignMatrix(projection); SignMatrix fullProjectionKey = similarProjectionFullMatrix.Keys.FirstOrDefault(m => m.Equals(projectionSign)); if (fullProjectionKey == null) { similarProjectionFullMatrix.Add(projectionSign, new List <Ngon>()); fullProjectionKey = projectionSign; } similarProjectionFullMatrix[fullProjectionKey].Add(ngon); #endregion SignMatrix fullMatrixKey = matrixMap.Keys.FirstOrDefault(m => m.Equals(pluckerSign)); if (fullMatrixKey == null) { matrixMap.Add(pluckerSign, new Dictionary <SignMatrix, int>()); fullMatrixKey = pluckerSign; } SignMatrix projectionResult = matrixMap[fullMatrixKey].Keys.FirstOrDefault(m => m.Equals(projectionSign)); if (projectionResult == null) { matrixMap[fullMatrixKey].Add(projectionSign, 0); projectionResult = projectionSign; } matrixMap[fullMatrixKey][projectionResult]++; if (i % (sampleSize / 100) == 0) { Console.Write("\rCreating sign matrix table: {0}% ", i / (sampleSize / 100)); } } }