public override Factor Copy() { SymbolicDot dot = base.Copy() as SymbolicDot; dot.vectorNameA = this.vectorNameA; dot.vectorNameB = this.vectorNameB; return(dot); }
public override Operand EvaluationStep(Context context) { if (factorList.Count == 0) { return(scalar); } Operand operand = base.EvaluationStep(context); if (operand != null) { return(operand); } for (int i = 0; i < factorList.Count; i++) { Factor factor = factorList[i]; if (factor.exponent == 0) { factorList.RemoveAt(i); return(this); } } for (int i = 0; i < factorList.Count; i++) { SymbolicDot dot = factorList[i] as SymbolicDot; if (dot != null && string.Compare(dot.vectorNameA, dot.vectorNameB) > 0) { string name = dot.vectorNameA; dot.vectorNameA = dot.vectorNameB; dot.vectorNameB = name; return(this); } } for (int i = 0; i < factorList.Count; i++) { Factor factorA = factorList[i]; for (int j = i + 1; j < factorList.Count; j++) { Factor factorB = factorList[j]; if (factorA.Matches(factorB)) { factorList.RemoveAt(j); factorA.exponent += factorB.exponent; return(this); } } } for (int i = 0; i < factorList.Count - 1; i++) { Factor factorA = factorList[i]; Factor factorB = factorList[i + 1]; if (string.Compare(factorA.SortKey(), factorB.SortKey()) > 0) { factorList[i] = factorB; factorList[i + 1] = factorA; return(this); } } return(null); }