private void Swap(LinearEquation a, LinearEquation b) { LinearEquation temp = new LinearEquation(a); b.Copy(a); temp.Copy(b); }
public void Add(LinearEquation a) { if (a.Size == n + 1) { system.Add(a); } else { throw new ArgumentException(); } }
public int Size => system.Count; // Возвращает кол-во элементов в списке public void Add(LinearEquation a) // Добавляем уравнение в систему { if (a.Size == n + 1) { system.Add(a); } else { throw new ArgumentException(); } }
public void Add(LinearEquation a) { if (a.Degree == n + 1) { system.Add(a); } else { throw new IndexOutOfRangeException(); } }
public void InitializationWithArray() { const int n = 3; double[] k = new double[n] { 1, 2, 3 }; LinearEquation a = new Task2.LinearEquation(k); Assert.AreEqual(a[0], 2); }
public override bool Equals(object obj) { LinearEquation a = (LinearEquation)obj; for (int i = 0; i < Size; i++) { if (Math.Abs(this[i] - a[i]) > 1e-9) { return(false); } } return(true); }
public static LinearEquation operator -(LinearEquation Fpol, LinearEquation Spol) { LinearEquation result = new LinearEquation(); if (Fpol.Degree > Spol.Degree) { result.coef = Spol.coef.Concat(Enumerable.Repeat(0.0, Fpol.Degree - Spol.Degree).ToList()).ToList(); result.coef = Fpol.coef.Zip(result.coef, (x, y) => x - y).ToList(); } else { result.coef = Fpol.coef.Concat(Enumerable.Repeat(0.0, Spol.Degree - Fpol.Degree).ToList()).ToList(); result.coef = Spol.coef.Zip(result.coef, (x, y) => y - x).ToList(); } return(result); }
static void Main(string[] args) { int n = 3; LinearEquation a = new LinearEquation("5.2,6.89,5"); SystemOfLinearEquation s = new SystemOfLinearEquation(n); s.Add(new LinearEquation("3.0, 2.0,-4.0, 3.0")); s.Add(new LinearEquation("2.0, 3.0, 3.0, 15.0")); s.Add(new LinearEquation("5.0, -3, 1.0, 14.0")); s.SteppingUp(); double[] solve = s.SolveSystem(); Console.WriteLine(s.ToString()); for (int i = 0; i < solve.Length; i++) { Console.WriteLine(@"x{0}={1}", i + 1, solve[i]); } }
public override bool Equals(Object obj) { LinearEquation temp = (LinearEquation)obj; bool res = true; if (this.Degree != temp.Degree) { res = false; } else { for (int i = 0; i < this.Degree + 1; i++) { if (this[i] != temp.Degree) { res = false; } } } return(res); }
public void CopyTo(LinearEquation a) { a.coefficients = coefficients.ToList(); }
public void CopyTo(LinearEquation a) { a.indexes = indexes.ToList(); }