public void Mul()//DataGridView dt, DataGridView dt1, DataGridView dt2, DataGridView dt3,DataGridView dt4)
        {
            Function = MulFunction;
            ListUnion();
            TransformationOfLists();
            CreatedListsForMultiple();
            List <double> X1 = new List <double>();
            List <double> X2 = new List <double>();

            for (int k = 0; k < X.Count; k++)
            {
                X1.Add(X[k]);
                X2.Add(X[k]);
            }

            List <double> KD = new List <double>();
            List <double> KU = new List <double>();
            List <double> MD = new List <double>();
            List <double> MU = new List <double>();

            //foreach (var V in X)
            //{
            //    dt4.Rows.Add(V.ToString());
            //}
            for (int i = 0; i < X.Count - 1; i++)
            {
                if (Math.Round(KoefLFIDown[i][0], 6) != 0 && Math.Round(KoefLFIDown[i][1], 6) != 0)
                {
                    K1 = KoefLFIDown[i][0]; K2 = KoefLFIDown[i][1]; M1 = KoefLFIDown[i][2]; M2 = KoefLFIDown[i][3];
                    List <double> ListD = new List <double>()
                    {
                        ExtremePointForParabola()
                    };
                    LFI LinFuncIntD = new LFI(1, X[i], X[i + 1], ListD, ParabolaFunction, DerivativeParabolaFunction);
                    LinFuncIntD.BuildLFI();
                    //LinFuncIntD.PaintLFI(chart);
                    for (int j = 1; j < LinFuncIntD.X.Count - 1; j++)
                    {
                        X1.Add(Math.Round(LinFuncIntD.X[j], 10));
                    }
                    for (int j = 0; j < LinFuncIntD.KDown.Count; j++)
                    {
                        KD.Add(LinFuncIntD.KDown[j]);
                        MD.Add(LinFuncIntD.MDown[j]);
                    }
                }
                else
                {
                    K1 = KoefLFIDown[i][0]; K2 = KoefLFIDown[i][1]; M1 = KoefLFIDown[i][2]; M2 = KoefLFIDown[i][3];
                    KD.Add(CreateMulK());
                    MD.Add(CreateMulM());
                }
                //---------------------------------------------------------------------------------------------------------//
                if (Math.Round(KoefLFIUp[i][0], 6) != 0 && Math.Round(KoefLFIUp[i][1], 6) != 0)
                {
                    K1 = KoefLFIUp[i][0]; K2 = KoefLFIUp[i][1]; M1 = KoefLFIUp[i][2]; M2 = KoefLFIUp[i][3];
                    List <double> ListU = new List <double>()
                    {
                        ExtremePointForParabola()
                    };
                    LFI LinFuncIntU = new LFI(1, X[i], X[i + 1], ListU, ParabolaFunction, DerivativeParabolaFunction);
                    LinFuncIntU.BuildLFI();
                    for (int j = 1; j < LinFuncIntU.X.Count - 1; j++)
                    {
                        X2.Add(Math.Round(LinFuncIntU.X[j], 10));
                    }
                    for (int j = 0; j < LinFuncIntU.KUp.Count; j++)
                    {
                        KU.Add(LinFuncIntU.KUp[j]);
                        MU.Add(LinFuncIntU.MUp[j]);
                    }
                }
                else
                {
                    K1 = KoefLFIUp[i][0]; K2 = KoefLFIUp[i][1]; M1 = KoefLFIUp[i][2]; M2 = KoefLFIUp[i][3];
                    KU.Add(CreateMulK());
                    MU.Add(CreateMulM());
                }
            }

            X1.Sort();
            X2.Sort();


            X.Clear();
            //List<double> NewX = new List<double>();
            X = X1.Union(X2).ToList();
            //X = X.Distinct().ToList();
            X.Sort();
            //for (int k = 0; k < X1.Count; k++)
            //{
            //    dt.Rows.Add(X1[k].ToString());
            //}

            //for (int k = 0; k < X2.Count; k++)
            //{
            //    dt1.Rows.Add(X2[k].ToString());
            //}
            //for (int k = 0; k < X.Count; k++)
            //{
            //    dt2.Rows.Add(X[k].ToString());
            //}

            for (int i = 0; i < X.Count - 1; i++)
            {
                for (int j1 = 0; j1 < X1.Count - 1; j1++)
                {
                    if (X[i] >= X1[j1] && X[i + 1] <= X1[j1 + 1])
                    {
                        KDown.Add(KD[j1]);
                        MDown.Add(MD[j1]);
                    }
                }
                for (int j2 = 0; j2 < X2.Count - 1; j2++)
                {
                    if (X[i] >= X2[j2] && X[i + 1] <= X2[j2 + 1])
                    {
                        KUp.Add(KU[j2]);
                        MUp.Add(MU[j2]);
                    }
                }
            }
            CreatedFLists();
            //for (int k = 0; k < KU.Count; k++)
            //{
            //    dt3.Rows.Add(KU[k].ToString(), MU[k].ToString());//,KDown[k].ToString(), MDown[k].ToString());
            //}
        }
Ejemplo n.º 2
0
        //-------------------------------------------------------------------------------------------------------------------------//

        private void CreateLFIbutton_Click(object sender, EventArgs e)
        {
            int    N = Convert.ToInt32(NtextBox.Text);
            double A = Convert.ToDouble(AtextBox.Text);
            double B = Convert.ToDouble(BtextBox.Text);

            //LFI LinFuncIntQuad = new LFI(N, A, B, ListOfExtremePointsQuad, QuadraticFunction, DerivateQuadFunc);
            //LFI LinFuncIntQuadMy = new LFI(N, A, B, ListOfExtremePointsQuadMy, QuadraticFunctionMy, DerivateQuadFuncMy);
            //LFI LinFuncIntSin = new LFI(N, A, B, ListOfExtremePointsSin, Sin, DerivativeSin);
            //LFI LinFuncIntCos = new LFI(N, A, B, ListOfExtremePointsCos, Cos, DerivativeCos);
            //LFI LinFuncIntPow = new LFI(N, A, B, ListOfExtremePointsPow, Pow, DerivativePow);
            //LFI LinFuncIntLn = new LFI(N, A, B, ListOfExtremePointsLn, Ln, DerivativeLn);
            LFI LFI1 = new LFI(N, A, B, X1, ElemFunction1, DerivateFunction1);
            LFI LFI2 = new LFI(N, A, B, X2, ElemFunction2, DerivateFunction2);

            LFI1.BuildLFI();
            LFI1.PaintLFI(chart1);

            LFI2.BuildLFI();
            LFI2.PaintLFI(chart2);

            ArithmeticOperation Sum = new ArithmeticOperation(LFI1.X, LFI1.KUp, LFI1.KDown, LFI1.MUp, LFI1.MDown,
                                                              LFI2.X, LFI2.KUp, LFI2.KDown, LFI2.MUp, LFI2.MDown, LFI1.ElemFunction, LFI2.ElemFunction);

            Sum.Sum();
            Sum.PaintOperation(chart3);
            Sum.Norma();
            Sum.Width();
            //Sum.PaintLists(dgvSuma);
            //Sum.FunctionalNorm(dgvSumNorm);
            //Sum.FunctionalWidth(dgvSumWidth);

            ArithmeticOperation Sub = new ArithmeticOperation(LFI1.X, LFI1.KUp, LFI1.KDown, LFI1.MUp, LFI1.MDown,
                                                              LFI2.X, LFI2.KUp, LFI2.KDown, LFI2.MUp, LFI2.MDown, LFI1.ElemFunction, LFI2.ElemFunction);

            Sub.Sub();
            Sub.PaintOperation(chart4);
            Sub.Norma();
            Sub.Width();
            //Sub.PaintLists(dgvSub);
            //Sub.FunctionalNorm(dgvSubNorm);
            //Sub.FunctionalWidth(dgvSubWidth);

            //ArithmeticOperation Mul = new ArithmeticOperation(LinFuncIntQuad.X, LinFuncIntQuad.KUp, LinFuncIntQuad.KDown, LinFuncIntQuad.MUp, LinFuncIntQuad.MDown,
            // LinFuncIntLn.X, LinFuncIntLn.KUp, LinFuncIntLn.KDown, LinFuncIntLn.MUp, LinFuncIntLn.MDown, LinFuncIntQuad.ElemFunction, LinFuncIntLn.ElemFunction);
            //Mul.Mul();
            //Mul.PaintOperation(chart5);
            //Mul.Norma();
            //Mul.Width();
            //Mul.FunctionalNorm(dgvMulNorm);
            //Mul.FunctionalWidth(dgvMulWidth);
            //Mul.PaintLists(dgvMul);

            AgregateOperation Ag = new AgregateOperation(LFI1.X, LFI1.KUp, LFI1.KDown, LFI1.MUp, LFI1.MDown,
                                                         LFI2.X, LFI1.ElemFunction, LFI2.ElemFunction, DerivateFunction2);

            // ++          AgregateOperation Ag = new AgregateOperation(LinFuncIntQuad.X, LinFuncIntQuad.KUp, LinFuncIntQuad.KDown, LinFuncIntQuad.MUp, LinFuncIntQuad.MDown,
            //LinFuncIntPow.X, QuadraticFunction, PowMy, DerivativePowMy);

            //             AgregateOperation Ag = new AgregateOperation(LinFuncIntQuad.X, LinFuncIntQuad.KUp, LinFuncIntQuad.KDown, LinFuncIntQuad.MUp, LinFuncIntQuad.MDown,
            //ListOfExtremePointsCos, QuadraticFunction, Cos, DerivativeCos);


            Ag.Agregate();
            Ag.PaintOperation(chart5);
            //Sub.Norma();
            //Sub.Width();
            //Sub.PaintLists(dgvSub);
            //Sub.FunctionalNorm(dgvSubNorm);
            //Sub.FunctionalWidth(dgvSubWidth);
        }