Encog.Persist.EncogFileSection.ParseMatrix C# (CSharp) Method

ParseMatrix() public static method

Parse a matrix from a name-value collection of params.
public static ParseMatrix ( String>.IDictionary paras, String name ) : Matrix
paras String>.IDictionary The name-value pairs.
name String The name to parse.
return Matrix
        public static Matrix ParseMatrix(IDictionary<String, String> paras,
                                         String name)
        {
            if (!paras.ContainsKey(name))
            {
                throw new PersistError("Missing property: " + name);
            }

            String line = paras[name];

            double[] d = NumberList.FromList(CSVFormat.EgFormat, line);
            var rows = (int) d[0];
            var cols = (int) d[1];

            var result = new Matrix(rows, cols);

            int index = 2;
            for (int r = 0; r < rows; r++)
            {
                for (int c = 0; c < cols; c++)
                {
                    result[r, c] = d[index++];
                }
            }

            return result;
        }