numl.Math.LinearAlgebra.Matrix.Parse C# (CSharp) Метод

Parse() публичный статический Метод

Parses a string containing MATLAB style Matrix syntax, i.e. "[[1, 2, 3]; [3, 4, 5]]"
public static Parse ( string text ) : Matrix
text string Input string to parse.
Результат Matrix
        public static Matrix Parse(string text)
        {
            string[] arrs = text.Split(new char[] { '[', ';', ']', '\r', '\n', '\t' }, StringSplitOptions.RemoveEmptyEntries)
                                .Where(w => !string.IsNullOrWhiteSpace(w)).ToArray();

            int rows = arrs.Length;

            double[][] result = new double[rows][];

            for (int i = 0; i < rows; i++)
                result[i] = arrs[i].Trim().Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries)
                                    .Select(s => double.Parse(s.Trim())).ToArray();

            return new Matrix(result);
        }