示例#1
0
        /// <summary>Covert a String to a Summation.</summary>
        public static Org.Apache.Hadoop.Examples.PI.Math.Summation ValueOf(string s)
        {
            int i = 1;
            int j = s.IndexOf("; ", i);

            if (j < 0)
            {
                throw new ArgumentException("i=" + i + ", j=" + j + " < 0, s=" + s);
            }
            ArithmeticProgression N = ArithmeticProgression.ValueOf(Sharpen.Runtime.Substring
                                                                        (s, i, j));

            i = j + 2;
            j = s.IndexOf("]", i);
            if (j < 0)
            {
                throw new ArgumentException("i=" + i + ", j=" + j + " < 0, s=" + s);
            }
            ArithmeticProgression E = ArithmeticProgression.ValueOf(Sharpen.Runtime.Substring
                                                                        (s, i, j));

            Org.Apache.Hadoop.Examples.PI.Math.Summation sigma = new Org.Apache.Hadoop.Examples.PI.Math.Summation
                                                                     (N, E);
            i = j + 1;
            if (s.Length > i)
            {
                string value = Util.ParseStringVariable("value", Sharpen.Runtime.Substring(s, i));
                sigma.SetValue(value.IndexOf('.') < 0 ? double.LongBitsToDouble(long.Parse(value)
                                                                                ) : double.ParseDouble(value));
            }
            return(sigma);
        }
示例#2
0
 /// <summary>Constructor</summary>
 public Summation(ArithmeticProgression N, ArithmeticProgression E)
 {
     if (N.GetSteps() != E.GetSteps())
     {
         throw new ArgumentException("N.getSteps() != E.getSteps()," + "\n  N.getSteps()="
                                     + N.GetSteps() + ", N=" + N + "\n  E.getSteps()=" + E.GetSteps() + ", E=" + E);
     }
     this.N = N;
     this.E = E;
 }
示例#3
0
        private static TestSummation.Summation2 NewSummation(long @base, long range, long
                                                             delta)
        {
            ArithmeticProgression N = new ArithmeticProgression('n', @base + 3, delta, @base
                                                                + 3 + range);
            ArithmeticProgression E = new ArithmeticProgression('e', @base + range, -delta, @base
                                                                );

            return(new TestSummation.Summation2(N, E));
        }
示例#4
0
 internal Summation2(ArithmeticProgression N, ArithmeticProgression E)
     : base(N, E)
 {
 }