EKG_Project.IO.XMLConverter.stringToVector C# (CSharp) Method

stringToVector() public method

public stringToVector ( string input ) : Vector
input string
return Vector
        public Vector<double> stringToVector(string input)
        {
            double[] digits = input
                              .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                              .Select(digit => double.Parse(digit))
                              .ToArray();
            Vector<double> vector = Vector<double>.Build.Dense(digits.Length);
            vector.SetValues(digits);
            return vector;
        }

Usage Example

        public void Load()
        {
            R_Peaks_Data basicData = new R_Peaks_Data();
            XMLConverter converter = new XMLConverter(analysisName);

            XmlDocument file = new XmlDocument();
            string fileName = analysisName + "_Data.xml";
            file.Load(System.IO.Path.Combine(directory, fileName));

            XmlNodeList modules = file.SelectNodes("EKG/module");

            string moduleName = this.GetType().Name;
            moduleName = moduleName.Replace("_Data_Worker", "");

            foreach (XmlNode module in modules)
            {
                if (module.Attributes["name"].Value == moduleName)
                {
                    List<Tuple<string, Vector<double>>> RPeaks = new List<Tuple<string, Vector<double>>>();
                    XmlNodeList rPeaks = module.SelectNodes("RPeaks");
                    foreach (XmlNode rPeak in rPeaks)
                    {
                        XmlNode lead = rPeak["lead"];
                        string readLead = lead.InnerText;

                        XmlNode indices = rPeak["indices"];
                        string readIndices = indices.InnerText;
                        Vector<double> readDigits = converter.stringToVector(readIndices);

                        Tuple<string, Vector<double>> readRPeak = Tuple.Create(readLead, readDigits);
                        RPeaks.Add(readRPeak);
                    }
                    basicData.RPeaks = RPeaks;

                    List<Tuple<string, Vector<double>>> RRInterval = new List<Tuple<string, Vector<double>>>();
                    XmlNodeList intervals = module.SelectNodes("RRInterval");
                    foreach (XmlNode interval in intervals)
                    {
                        XmlNode lead = interval["lead"];
                        string readLead = lead.InnerText;

                        XmlNode samples = interval["intervals"];
                        string readSamples = samples.InnerText;
                        Vector<double> readDigits = converter.stringToVector(readSamples);

                        Tuple<string, Vector<double>> readInterval = Tuple.Create(readLead, readDigits);
                        RRInterval.Add(readInterval);
                    }
                    basicData.RRInterval = RRInterval;
                }
            }
            this.Data = basicData;
        }
All Usage Examples Of EKG_Project.IO.XMLConverter::stringToVector