BinaryMatrix GenerateHWithIdentity(BinaryMatrix H) { BinaryMatrix HWithIdentity = new BinaryMatrix(H.RowAmount, H.ColumnAmount + H.RowAmount); for (int y = 0; y < H.RowAmount; y++) { for (int x = 0; x < H.ColumnAmount; x++) { HWithIdentity.Set(y, x, H.Get(y, x)); } } for (int y = 0; y < H.RowAmount; y++) { int n = 0; for (int x = H.ColumnAmount; x < H.ColumnAmount + H.RowAmount; x++) { HWithIdentity.Set(y, x, y == n); n++; } } return(HWithIdentity); }
BinaryMatrix GenerateHMatrix(int rowsAmount, int columnsAmount) { BinaryMatrix H = new BinaryMatrix(rowsAmount, columnsAmount); int column = 0; for (int i = 1; i <= Math.Pow(2, rowsAmount); i++) { Binary binary = new Binary(i, H.RowAmount); if (binary.CountOnes() >= 2) { for (int row = 0; row < rowsAmount; row++) { H.Set(row, column, binary[row]); } column++; } if (column >= H.ColumnAmount) { break; } } return(H); }