Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.87 KB | None | 0 0
  1. struct PhasePoint
  2. {
  3.     List<double> x;
  4.  
  5.     PhasePoint(List<double x) {
  6.         this.x = x;
  7.     }
  8.     PhasePoint(params double[] x) {
  9.         this.x = x.ToList();
  10.     }
  11.  
  12.     static PhasePoint opeartor+(PhasePoint p1, PhasePoint p2) {
  13.         if (p1.x.Lenght != p2.x.Lenght)
  14.             throw new InvalidOperationException("Phase points must have same dimension!");
  15.  
  16.         var result_x = new List<double>();
  17.         for (int i = 0; i < p1.x.Length; i++)
  18.             result_x.Add(p1.x.[i] + p2.x.[i]);
  19.         return new PhasePoint(result_x);
  20.     }
  21.     //аналогично реализуешь остальные операторы
  22. }
  23.  
  24. //потом в коде метода используешь PhasePoint так же как обычный double
  25.  
  26. public List<SolvingPoint> Met(DelegateFunc.Func func,double h,double x0, double xk) ->
  27. public List<SolvingPoint> Met(DelegateFunc.Func func,PhasePoint h,PhasePoint x0, PhasePoint xk)
  28. etc.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement