public MatrixEquation Build() { //统计列参数 List <string> paramNames = GetParamNames(); //按照此顺序重新构建方程左手边 foreach (var eqa in MatrixEquations) { eqa.ExpandObsParams(paramNames); } //分别计算 MatrixEquation added = null; foreach (var item in MatrixEquations) { if (added == null) { added = item.NormalEquation; } else { added += item.NormalEquation; } } added.Name = "NormalIterOf" + MatrixEquations.Count + "EqsOf" + PostFixName; return(added); }
/// <summary> /// 构建 /// </summary> /// <returns></returns> public MatrixEquation Build() { var meq = new MatrixEquation(new Matrix(LeftMatrix), new Matrix(RightVector), "ComEq"); if (QofRightVector != null) { meq.QofU = new Matrix(QofRightVector); } return(meq); }
public override MatrixEquationManager Read() { ObjectTableManagerReader reader = new ObjectTableManagerReader(Stream); var tables = reader.Read(); var keys = tables.Keys; List <string> names = new List <string>(); foreach (var item in keys) { var name = MatrixEquationNameBuiler.GetName(item); if (!names.Contains(name)) { names.Add(name); } } MatrixEquationManager manager = new MatrixEquationManager(); foreach (var name in names) { var leftName = MatrixEquationNameBuiler.GetLeftSideName(name); var rightName = MatrixEquationNameBuiler.GetRightSideName(name); var QOfrightName = MatrixEquationNameBuiler.GetInverseWeightNameOfRightSide(name); var left = tables.Get(leftName); var right = tables.Get(rightName); var QofRightSide = tables.Get(QOfrightName); var n = Matrix.Parse(left); var u = Matrix.Parse(right); Matrix q = null; if (QofRightSide != null) { q = Matrix.Parse(QofRightSide); } var eq = new MatrixEquation(n, u, name) { QofU = q }; manager[name] = eq; } return(manager); }
/// <summary> /// 添加 /// </summary> /// <param name="equation"></param> public void AddSubMatrix(MatrixEquation equation) { //左边 CoeffMatrixComposer.Add(equation.LeftSide); //右边 if (RightVector == null) { RightVector = equation.RightVector; } else { RightVector.AddRange(equation.RightVector); } if (equation.HasWeightOfRightSide) { QofRightVectorComposer.Add(equation.InverseWeightOfRightSide); } }
/// <summary> /// 构建消除固定参数后的新方程。 /// </summary> /// <param name="input"></param> /// <returns></returns> public MatrixEquation Build(MatrixEquation input) { var oldParams = input.ParamNames; var oldCoeff = input.LeftSide; var oldObs = input.RightSide; var fixedParams = GetFixedParams(oldParams); var fixeParamList = fixedParams.Keys.ToList(); Vector fixedVector = new Vector(fixedParams); //提取新阵 List <string> newParams = Geo.Utils.ListUtil.GetExcept <string>(oldParams, fixeParamList); SparseMatrix newCoef = BuildNewCoeff(oldCoeff, newParams); SparseMatrix fixedParamCoef = BuildNewCoeff(oldCoeff, fixeParamList); Vector fixedObs = new Matrix(fixedParamCoef) * fixedVector; Vector newObs = oldObs.Col(0) - fixedObs; WeightedVector newRight = new WeightedVector(newObs, input.QofU); MatrixEquation result = new MatrixEquation(newCoef, newRight); return(result); }
/// <summary> /// 增加方程 /// </summary> /// <param name="obj"></param> public void AddSubMatrix(MatrixEquation obj) { MatrixEquations.Add(obj); }
public override void Write(MatrixEquation product) { ObjectTableManager objects = product.GetObjectTables(); objects.WriteAsOneFile(Stream); }