FromPackedArray() public method

Take the values of thie matrix from a packed array.
public FromPackedArray ( double array, int index ) : int
array double The packed array to read the matrix from.
index int The index to begin reading at in the array.
return int
Ejemplo n.º 1
0
        public void PackedArray2()
        {
            double[] data   = { 1.0, 2.0, 3.0, 4.0 };
            var      matrix = new Matrix(1, 4);

            matrix.FromPackedArray(data, 0);
            Assert.AreEqual(1.0, matrix[0, 0]);
            Assert.AreEqual(2.0, matrix[0, 1]);
            Assert.AreEqual(3.0, matrix[0, 2]);
        }
Ejemplo n.º 2
0
        public void PackedArray()
        {
            double[][] matrixData =
            {
                new[] { 1.0, 2.0 },
                new[] { 3.0, 4.0 }
            };
            var matrix = new Matrix(matrixData);

            double[] matrixData2 = matrix.ToPackedArray();
            Assert.AreEqual(4, matrixData2.Length);
            Assert.AreEqual(1.0, matrix[0, 0]);
            Assert.AreEqual(2.0, matrix[0, 1]);
            Assert.AreEqual(3.0, matrix[1, 0]);
            Assert.AreEqual(4.0, matrix[1, 1]);

            var matrix2 = new Matrix(2, 2);

            matrix2.FromPackedArray(matrixData2, 0);
            Assert.IsTrue(matrix.Equals(matrix2));
        }
 public void PackedArray2()
 {
     double[] data = {1.0, 2.0, 3.0, 4.0};
     var matrix = new Matrix(1, 4);
     matrix.FromPackedArray(data, 0);
     Assert.AreEqual(1.0, matrix[0, 0]);
     Assert.AreEqual(2.0, matrix[0, 1]);
     Assert.AreEqual(3.0, matrix[0, 2]);
 }
        public void PackedArray()
        {
            double[][] matrixData = {
                                        new[] {1.0, 2.0},
                                        new[] {3.0, 4.0}
                                    };
            var matrix = new Matrix(matrixData);
            double[] matrixData2 = matrix.ToPackedArray();
            Assert.AreEqual(4, matrixData2.Length);
            Assert.AreEqual(1.0, matrix[0, 0]);
            Assert.AreEqual(2.0, matrix[0, 1]);
            Assert.AreEqual(3.0, matrix[1, 0]);
            Assert.AreEqual(4.0, matrix[1, 1]);

            var matrix2 = new Matrix(2, 2);
            matrix2.FromPackedArray(matrixData2, 0);
            Assert.IsTrue(matrix.Equals(matrix2));
        }