public void Add(LinearEquation a) { if (a.size == n + 1) { listofcoef.Add(a); } else { throw new ArgumentException(); } }
public override bool Equals(object obj) { LinearEquation a = (LinearEquation)obj; for (int i = 0; i < size; i++) { if (Math.Abs(listofcoef[i] - a[i]) > 0.000000001) { return(false); //17 } } return(true); }
public static LinearEquation operator -(LinearEquation a, LinearEquation b) { LinearEquation a1 = new LinearEquation(a.listofcoef); for (int i = 0; i < a.size; i++) { a1[i] = a[i]; } for (int i = 0; i < Math.Min(a.size, b.size); i++) { a1[i] -= b.listofcoef[i]; } return(new LinearEquation(a1)); }
public void StepConvert() { int step; int j; double step1, step2; for (int i = 0; i < size; i++) { j = i; if (listofcoef[i][j] == 0) { while (listofcoef[i][j] == 0 && j < n) { j++; } step = 1; while (i + step < size && listofcoef[i + step][j] == 0) { step++; } if (i + step == size) { return; } LinearEquation c = new LinearEquation(listofcoef[i]); c = listofcoef[i]; listofcoef[i] = listofcoef[i + step]; listofcoef[i + step] = c; } for (int k = i + 1; k < size; k++) { step1 = listofcoef[i][j]; step2 = listofcoef[k][j]; listofcoef[k] *= step1; listofcoef[k] -= listofcoef[i] * step2; } } }