示例#1
0
        public void mainFunctions(int _countColumn, int _n, double[] _arrayX, double[] _arrayY, double[] _findAnswerValues)
        {
            double[] sumPowTemp = new double[_n + 4];

            double[] sumMulTempCp = new double[_n];

            CountSum countSum = new CountSum();

            countSum.sumPowerX(sumPowTemp, _arrayX, _countColumn, _n);

            //Console.WriteLine("sumPowTemp");
            //for (int i = 0; i < sumPowTemp.Length; i++)
            //{
            //    Console.WriteLine(sumPowTemp[i]);
            //}

            countSum.multXY(sumMulTempCp, _arrayX, _arrayY, _countColumn, _n);

            //Console.WriteLine("sumMulTempCp");
            //for (int i = 0; i < sumMulTempCp.Length; i++)
            //{
            //    Console.WriteLine(sumMulTempCp[i]);
            //}

            //=============================================================================

            double[,] mainMassive = new double[_n, _n];

            assignmentMainMassive(mainMassive, sumPowTemp, _n);

            //Console.WriteLine("mainMassive");
            //for (int i = 0; i < _n; i++)
            //{
            //    for (int j = 0; j < _n; j++)
            //    {
            //        Console.Write(mainMassive[i, j] + " ");
            //    }
            //    Console.WriteLine();
            //}

            double[] freeVar = new double[_n];
            for (int i = 0; i < _n; i++)
            {
                freeVar[i] = sumMulTempCp[i];
                //Console.WriteLine(freeVar[i]);
            }

            MethodGaussa methodGaussa = new MethodGaussa();

            methodGaussa.Kramer(_n, mainMassive, freeVar, _findAnswerValues);
            //Console.WriteLine(" _findAnswerValues");
            //for (int i = 0; i < _findAnswerValues.Length; i++)
            //{
            //    Console.WriteLine(_findAnswerValues[i]);
            //}
        }
示例#2
0
        public double findR(double[] _array, double[] _calcArray, int _size)
        {
            double[] sqError = new double[_size];
            int      j       = 0;

            for (int i = 0; i < _size; i++)
            {
                sqError[j] = (_array[i] - _calcArray[j]) * (_array[i] - _calcArray[j]);
                //Console.WriteLine(sqError[j]);
                j++;
            }
            double sum = 0;

            for (int i = 0; i < _size; i++)
            {
                sum += sqError[i];
            }
            CountSum countSum = new CountSum();

            return((countSum.sumY(_array, _size) - sum) / countSum.sumY(_array, _size));
        }