Exemple #1
0
 public void ModifyAll <U, V>(U[,] array, V[,] array2, Func <T, U, V, T> converter)
 {
     if (array.GetLength(0) != Length0)
     {
         throw new ArgumentException("array.GetLength(0) (" + array.GetLength(0) + ") != this.Length0 (" + this.Length0 + ")");
     }
     if (array.GetLength(1) != Length1)
     {
         throw new ArgumentException("array.GetLength(1) (" + array.GetLength(1) + ") != this.Length1 (" + this.Length1 + ")");
     }
     if (array2.GetLength(0) != Length0)
     {
         throw new ArgumentException("array2.GetLength(0) (" + array2.GetLength(0) + ") != this.Length0 (" + this.Length0 + ")");
     }
     if (array2.GetLength(1) != Length1)
     {
         throw new ArgumentException("array2.GetLength(1) (" + array2.GetLength(1) + ") != this.Length1 (" + this.Length1 + ")");
     }
     for (int i = 0; i < Length0; i++)
     {
         for (int j = 0; j < Length1; j++)
         {
             this[i, j] = converter(this[i, j], array[i, j], array2[i, j]);
         }
     }
 }
Exemple #2
0
 static void check <T, U, V>(T[,] a, U b, V[,] result)
 {
     if (rows(a) != rows(result) || cols(a) != cols(result))
     {
         throw new DimensionMismatchException("result");
     }
 }
Exemple #3
0
 public void ForEach <U, V>(U[,] array, V[,] array2, Action <T, U, V> action)
 {
     if (array.GetLength(0) != Length0)
     {
         throw new ArgumentException("array.GetLength(0) (" + array.GetLength(0) + ") != this.Length0 (" + this.Length0 + ")");
     }
     if (array.GetLength(1) != Length1)
     {
         throw new ArgumentException("array.GetLength(1) (" + array.GetLength(1) + ") != this.Length1 (" + this.Length1 + ")");
     }
     if (array2.GetLength(0) != Length0)
     {
         throw new ArgumentException("array2.GetLength(0) (" + array2.GetLength(0) + ") != this.Length0 (" + this.Length0 + ")");
     }
     if (array2.GetLength(1) != Length1)
     {
         throw new ArgumentException("array2.GetLength(1) (" + array2.GetLength(1) + ") != this.Length1 (" + this.Length1 + ")");
     }
     for (int i = 0; i < Length0; i++)
     {
         for (int j = 0; j < Length1; j++)
         {
             action(this[i, j], array[i, j], array2[i, j]);
         }
     }
 }
Exemple #4
0
 static void check <T, U, V>(int d, T a, U[,] b, V[,] result)
 {
     if (rows(b) != rows(result) || cols(b) != cols(result))
     {
         throw new DimensionMismatchException("result");
     }
 }
Exemple #5
0
 public Form1()
 {
     InitializeComponent();
     DoubleBuffered  = true;
     pos_arr         = new V[shapes, frames];
     pos_arr[0, 0].y = 150;
     pos_arr[1, 0].y = 160;
     vel_arr         = new V[shapes, frames];
     timer1.Interval = (int)(1000 * dt);
 }
        public SquareDictionary(IEnumerable <Tuple <Square <K1, K2>, V> > dictionary)
        {
            IEnumerable <Square <K1, K2> > squares = dictionary.Select(p => p.Item1);

            xDimension = squares.ToIndexIntervalDictinary(s => s.XInterval.Elements());
            yDimension = squares.ToIndexIntervalDictinary(s => s.YInterval.Elements());

            values = new V[xDimension.Count, yDimension.Count];
            used   = new bool[xDimension.Count, yDimension.Count];

            foreach (var item in dictionary)
            {
                Add(item.Item1, item.Item2);
            }
        }
Exemple #7
0
 static void check <T, U, V>(VectorType d, T[] a, U[,] b, V[,] result)
 {
     if (d == 0)
     {
         if (cols(b) != rows(a))
         {
             throw new DimensionMismatchException("b");
         }
     }
     else
     {
         if (rows(b) != rows(a))
         {
             throw new DimensionMismatchException("b");
         }
     }
     if (rows(b) != rows(result) || cols(b) != cols(result))
     {
         throw new DimensionMismatchException("result");
     }
 }
Exemple #8
0
 public Table(R[] rows, C[] columns)
 {
     this.rows    = rows;
     this.columns = columns;
     values       = new V[rows.Length, columns.Length];
 }