Example #1
0
        public void ToArray2D()
        {
            MatrixD m = new MatrixD(3, 4, rowMajor, MatrixOrder.RowMajor);

              double[,] array = m.ToArray2D();
              Assert.AreEqual(3, array.GetLength(0));
              Assert.AreEqual(4, array.GetLength(1));
              for (int i = 0; i < 3; i++)
            for (int j = 0; j < 4; j++)
              Assert.AreEqual(i * 4 + j + 1, array[i, j]);

              array = (double[,]) m;
              Assert.AreEqual(3, array.GetLength(0));
              Assert.AreEqual(4, array.GetLength(1));
              for (int i = 0; i < 3; i++)
            for (int j = 0; j < 4; j++)
              Assert.AreEqual(i * 4 + j + 1, array[i, j]);

              m = null;
              array = (double[,]) m;
              Assert.IsNull(array);
        }