/// <summary> /// 以文本行初始化。 /// </summary> /// <param name="line"></param> /// <returns></returns> public IBlockItem Init(string line) { //throw new NotImplementedException(); // MatrixLine this1 = new MatrixLine(); this.Row = int.Parse(line.Substring(1, 5)); this.Col = int.Parse(line.Substring(7, 5)); int i = 0, cur = 0; while (line.Length > (cur = 13 + i * 22)) { MatrixUnit u = new MatrixUnit(); string s = line.Substring(cur, cur + 21 > line.Length ? line.Length - cur : 21); if (s == " " || s == " " || s == " " || s.Trim() == "") { i++; } else { u.Row = this.Row; u.Col = this.Col + (i++); u.Val = double.Parse(line.Substring(cur, cur + 21 > line.Length ? line.Length - cur : 21)); this.MatrixUnits.Add(u); } } return(this); }
/// <summary> /// 解析矩阵行。 /// </summary> /// <param name="line"></param> /// <returns></returns> public static MatrixLine ParseLine(string line) { MatrixLine b = new MatrixLine(); b.Row = int.Parse(line.Substring(1, 5)); b.Col = int.Parse(line.Substring(7, 5)); int i = 0, cur; while (line.Length > (cur = 13 + (i++) * 22)) { MatrixUnit u = new MatrixUnit(); u.Row = b.Row; u.Col = b.Col + i; u.Val = double.Parse(line.Substring(cur, 21)); b.MatrixUnits.Add(u); } return(b); }