Encog.MathUtil.Matrices.Matrix.CreateRowMatrix C# (CSharp) Method

CreateRowMatrix() public static method

Create a matrix that is a single row.
public static CreateRowMatrix ( double input ) : Matrix
input double A 1D array to make the matrix from.
return Matrix
        public static Matrix CreateRowMatrix(double[] input)
        {
            var d = new double[1][];

            d[0] = new double[input.Length];

            for (int i = 0; i < input.Length; i++)
            {
                d[0][i] = input[i];
            }

            return new Matrix(d);
        }

Usage Example

        public void Bipolar2Double()
        {
            // test a 1x4
            bool[]   boolData1    = { true, false, true, false };
            double[] checkData1   = { 1, -1, 1, -1 };
            Matrix   matrix1      = Matrix.CreateRowMatrix(BiPolarUtil.Bipolar2double(boolData1));
            Matrix   checkMatrix1 = Matrix.CreateRowMatrix(checkData1);

            Assert.IsTrue(matrix1.Equals(checkMatrix1));

            // test a 2x2
            bool[][] boolData2 =
            {
                new[] { true,  false },
                new[] { false, true  }
            };
            double[][] checkData2 =
            {
                new[] {  1.0, -1.0 },
                new[] { -1.0,  1.0 }
            };
            var matrix2      = new Matrix(BiPolarUtil.Bipolar2double(boolData2));
            var checkMatrix2 = new Matrix(checkData2);

            Assert.IsTrue(matrix2.Equals(checkMatrix2));
        }
All Usage Examples Of Encog.MathUtil.Matrices.Matrix::CreateRowMatrix