public int CompareTo(object obj) { ReducedSignMatrix2 other = (ReducedSignMatrix2)obj; if (this.data.Length > other.data.Length) { return(1); } if (this.data.Length < other.data.Length) { return(-1); } for (int i = 0; i < this.data.Length; i++) { for (int j = 0; j < this.data.Length; j++) { if (this.data[i][j] == other.data[i][j]) { continue; } if (this.data[i][j] > other.data[i][j]) { return(-1); } if (this.data[i][j] < other.data[i][j]) { return(1); } } } return(0); }
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 MultipleReducedMatricesDistribution(int dimensions = 5) { db = new NgonDatabase(dimensions); Matrix <double> mask = Matrix <double> .Build.Dense(dimensions, dimensions, 1); if (dimensions == 5) { mask[3, 0] = 0; mask[3, 1] = 0; mask[4, 1] = 0; } if (dimensions == 4) { mask[2, 0] = 0; mask[3, 2] = 0; } foreach (SignMatrix matrix in db.PluckerSignMatrices) { var reduced1 = matrix.getReduced(); var reduced2 = matrix.getReduced2(mask); ReducedSignMatrix reduced1Key = similarReducedMatrix.Keys.FirstOrDefault(m => m.Equals(reduced1)); if (reduced1Key == null) { similarReducedMatrix.Add(reduced1, new List <ReducedSignMatrix2>()); reduced1Key = reduced1; } ReducedSignMatrix2 reduced2Key = similarReduced2Matrix.Keys.FirstOrDefault(m => m.Equals(reduced2)); if (reduced2Key == null) { similarReducedMatrix[reduced1Key].Add(reduced2); similarReduced2Matrix.Add(reduced2, new List <SignMatrix>()); reduced2Key = reduced2; } similarReduced2Matrix[reduced2Key].Add(matrix); } }