/// <summary>
        /// Computes the I.
        /// </summary>
        /// <returns>The I</returns>
        public Matrix Integrate()
        {
            if (MatrixPool == null)
            {
                MatrixPool = new MatrixPool();
            }


            if (XiPointCount < 1 || EtaPointCount < 1 || GammaPointCount < 1)
            {
                throw new NotSupportedException();
            }

            double a1 = A1, a2 = A2;

            var f1 = F1;
            var f2 = F2;

            var g1 = G1;
            var g2 = G2;

            var vk = GaussPoints.GetGaussianValues(GammaPointCount);
            var wk = GaussPoints.GetGaussianWeights(GammaPointCount);

            var vj = GaussPoints.GetGaussianValues(EtaPointCount);
            var wj = GaussPoints.GetGaussianWeights(EtaPointCount);

            var vi = GaussPoints.GetGaussianValues(XiPointCount);
            var wi = GaussPoints.GetGaussianWeights(XiPointCount);

            Matrix I = null;//we do not know dimensions yet!

            for (var k = 0; k < GammaPointCount; k++)
            {
                var    gammaK = (a2 - a1) / 2 * vk[k] + (a2 + a1) / 2;
                Matrix phi    = null;// = new Matrix(H, W);

                for (var j = 0; j < EtaPointCount; j++)
                {
                    var    noj  = (f2(gammaK) - f1(gammaK)) / 2 * vj[j] + (f2(gammaK) + f1(gammaK)) / 2;
                    Matrix beta = null;//= new Matrix(H, W);

                    for (var i = 0; i < XiPointCount; i++)
                    {
                        var xii = (g2(noj, gammaK) - g1(noj, gammaK)) / 2 * vi[i] + (g2(noj, gammaK) + g1(noj, gammaK)) / 2;

                        var val = H.GetMatrix(xii, noj, gammaK);

                        //initiate I, phi and beta
                        if (beta == null)
                        {
                            beta =
                                //new Matrix(val.RowCount, val.ColumnCount);
                                MatrixPool.Allocate(val.RowCount, val.ColumnCount);
                        }

                        if (phi == null)
                        {
                            phi =
                                //new Matrix(val.RowCount, val.ColumnCount);
                                MatrixPool.Allocate(val.RowCount, val.ColumnCount);
                        }

                        if (I == null)
                        {
                            I =
                                //new Matrix(val.RowCount, val.ColumnCount);
                                MatrixPool.Allocate(val.RowCount, val.ColumnCount);
                        }

                        var valSc = (g2(noj, gammaK) - g1(noj, gammaK)) / 2 * wi[i];
                        //beta += val;
                        beta.AddToThis(val, valSc);

                        val.ReturnToPool();
                    }

                    var phiSc = (f2(gammaK) - f1(gammaK)) / 2 * wj[j];
                    phi.AddToThis(beta, phiSc);

                    beta.ReturnToPool();
                }

                var iSc = (a2 - a1) / 2 * wk[k];

                I.AddToThis(phi, iSc);

                phi.ReturnToPool();
                //I += (a2 - a1) / 2 * wk[k] * phi;
            }

            return(I);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Computes the I.
        /// </summary>
        /// <returns>The I</returns>
        public Matrix Integrate()
        {
            if (XiPointCount < 1 || EtaPointCount < 1 || GammaPointCount < 1)
            {
                throw new NotSupportedException();
            }

            double a1 = A1, a2 = A2;

            var f1 = F1;
            var f2 = F2;

            var g1 = G1;
            var g2 = G2;

            var vk = GaussPoints.GetGaussianValues(GammaPointCount);
            var wk = GaussPoints.GetGaussianWeights(GammaPointCount);

            var vj = GaussPoints.GetGaussianValues(EtaPointCount);
            var wj = GaussPoints.GetGaussianWeights(EtaPointCount);

            var vi = GaussPoints.GetGaussianValues(XiPointCount);
            var wi = GaussPoints.GetGaussianWeights(XiPointCount);

            Matrix I = null;//we do not know dimensions yet!

            for (var k = 0; k < GammaPointCount; k++)
            {
                var    gammaK = (a2 - a1) / 2 * vk[k] + (a2 + a1) / 2;
                Matrix phi    = null;// = new Matrix(H, W);

                for (var j = 0; j < EtaPointCount; j++)
                {
                    var    noj  = (f2(gammaK) - f1(gammaK)) / 2 * vj[j] + (f2(gammaK) + f1(gammaK)) / 2;
                    Matrix beta = null;//= new Matrix(H, W);

                    for (var i = 0; i < XiPointCount; i++)
                    {
                        var xii = (g2(noj, gammaK) - g1(noj, gammaK)) / 2 * vi[i] + (g2(noj, gammaK) + g1(noj, gammaK)) / 2;

                        var val = H.GetMatrix(xii, noj, gammaK);

                        //initiate I, phi and beta
                        if (beta == null)
                        {
                            beta = new Matrix(val.RowCount, val.ColumnCount);
                        }

                        if (phi == null)
                        {
                            phi = new Matrix(val.RowCount, val.ColumnCount);
                        }

                        if (I == null)
                        {
                            I = new Matrix(val.RowCount, val.ColumnCount);
                        }


                        val.MultiplyByConstant((g2(noj, gammaK) - g1(noj, gammaK)) / 2 * wi[i]);
                        beta += val;
                    }

                    phi += (f2(gammaK) - f1(gammaK)) / 2 * wj[j] * beta;
                }

                I += (a2 - a1) / 2 * wk[k] * phi;
            }

            return(I);
        }