Exemplo n.º 1
0
 static public bool SetIntegral(IIntegral integral)
 {
     try
     {
         _integral = integral;
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Exemplo n.º 2
0
 public IntegralTesterBehavior(IBindingContext context, Func <double, double> reference, double initial, double relTol, double absTol)
     : base(context)
 {
     _biasing   = context.GetState <IBiasingSimulationState>();
     _method    = context.GetState <IIntegrationMethod>();
     _time      = context.GetState <ITimeSimulationState>();
     _integral  = _method.CreateIntegral();
     _reference = reference;
     _initial   = initial;
     _relTol    = relTol;
     _absTol    = absTol;
 }
Exemplo n.º 3
0
        public Form1()
        {
            // Ініціалізуємо змінні
            InitializeComponent();
            a = 0;
            b = 0;
            h = 0;

            rectanglesMethod = new RectanglesMethod();
            trapezoidMethod  = new TrapezoidMethod();
            simpsonMethod    = new SimpsonMethod();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Factory method on algorithm strategy.
        /// </summary>
        /// <param name="parameter">Clicked algorithm identifier.</param>
        private async void ExecuteChangeAlgorithmCommand(object parameter)
        {
            var param = Convert.ToInt16(parameter);

            if (param == 0x01)
            {
                _calculator = new RectangleRuleIntegral();
            }
            else if (param == 0x02)
            {
                _calculator = new TableRuleIntegral();
            }
            else
            {
                _calculator = new SimpsonsRuleIntegral();
            }
        }
Exemplo n.º 5
0
        public void Write(SmartPointer ptr, IIntegral value)
        {
            IIntegral val = value;

            if (ptr.Length != value.Length)
            {
                val = value.CastTo(Int.BestFit((int)ptr.Length));
            }

            try
            {
                Write(ptr.Address, val.ToBinary());
            }
            catch
            {
                throw;
            }
        }
Exemplo n.º 6
0
        private void buttonIntegrate_Click(object sender, EventArgs e)
        {
            a = (double)numericA.Value;
            b = (double)numericB.Value;
            h = (double)numericH.Value;

            if (radioButtonRectangles.Checked)
            {
                integral = new IntegralRectangles();
            }
            else if (radioButtonTrapezoid.Checked)
            {
                integral = new IntegralTrapezoid();
            }
            else if (radioButtonSimpson.Checked)
            {
                integral = new IntegralSimpson();
            }

            label4.Text = "" + integral.Integrate(a, b, h);
        }
Exemplo n.º 7
0
        public IIntegral CastTo(IIntegral tout)
        {
            IIntegral result = tout;

            byte[] value = new byte[result.Length];
            byte[] bin   = ToBinary();

            for (int i = 0; i < result.Length; i++)
            {
                if (i < bin.Length)
                {
                    value[i] = bin[i];
                }
                else
                {
                    value[i] = 0;
                }
            }

            result.FromBinary(value);
            return(result);
        }