Beispiel #1
0
        public static BoolMatrix Parse(string text)
        {
            var rows   = text.Split("\n");
            var matrix = new BoolMatrix(rows.Length);

            for (int i = 0; i < rows.Length; i++)
            {
                var values = rows[i].Trim().Split(" ");
                if (values.Length != rows.Length)
                {
                    throw new ArgumentException("Rows and columns don't match");
                }
                for (int j = 0; j < values.Length; j++)
                {
                    bool value;
                    switch (values[j])
                    {
                    case "0":
                        value = false;
                        break;

                    case "1":
                        value = true;
                        break;

                    default:
                        throw new ArgumentException("Invalid character in input");
                    }
                    matrix[i, j] = value;
                }
            }
            return(matrix);
        }
        public void Setup()
        {
            _matrix = new BoolMatrix(Size);

            var random = new Random();

            for (int i = 0; i < Size / 2; i++)
            {
                _matrix[random.Next(0, Size), random.Next(0, Size)] = true;
            }
        }
 public void Setup()
 {
     _matrix = new BoolMatrix(Size);
     for (int i = 0; i < Size; i++)
     {
         for (int j = 0; i < Size; i++)
         {
             _matrix[i, j] = true;
         }
     }
 }
 public void Setup()
 {
     _matrix = new BoolMatrix(Size);
 }