Ejemplo n.º 1
0
        // markov operation
        public void DoBackward(double t, double[] x, int right, double[] prob)
        {
            //int right;
            //if (t > maxt)
            //{
            //	right = setMaxT(t);
            //}
            //else
            //{
            //	right = PoiDist.getRightBound(lambda * t, epsi);
            //}
            double weight = PoiDist.CompProb(Lambda * t, 0, right, prob);

            Blas.Dcopy(ndim, x, xi);
            Blas.Fill(ndim, x, 0.0);
            Blas.Daxpy(ndim, prob[0], xi, x);
            for (int l = 1; l <= right; l++)
            {
                Blas.Dcopy(ndim, xi, tmp);
                DgemvNoTrans(1.0, tmp, 0.0, xi);
                Blas.Daxpy(ndim, prob[l], xi, x);
            }
            Blas.Dscal(ndim, 1.0 / weight, x);
        }
Ejemplo n.º 2
0
        public void DoSojournForward(double t, double[] f, double[] b, double[] h, int right, double[] prob, double[][] vc)
        {
            //int right;
            //if (t > maxt)
            //{
            //	right = setMaxT(t);
            //}
            //else
            //{
            //	right = PoiDist.getRightBound(lambda * t, epsi);
            //}
            double weight = PoiDist.CompProb(Lambda * t, 0, right + 1, prob);

            // forward and backward
            Blas.Fill(ndim, vc[right + 1], 0.0);
            Blas.Daxpy(ndim, prob[right + 1], b, vc[right + 1]);
            for (int l = right; l >= 1; l--)
            {
                DgemvNoTrans(1.0, vc[l + 1], 0.0, vc[l]);
                Blas.Daxpy(ndim, prob[l], b, vc[l]);
            }
            Blas.Dcopy(ndim, f, xi);
            Blas.Fill(ndim, f, 0.0);
            Blas.Daxpy(ndim, prob[0], xi, f);
            Blas.Fill(ndim * 2, h, 0.0);
            Dger(1.0, xi, vc[1], h);
            for (int l = 1; l <= right; l++)
            {
                Blas.Dcopy(ndim, xi, tmp);
                DgemvTrans(1.0, tmp, 0.0, xi);
                Blas.Daxpy(ndim, prob[l], xi, f);
                Dger(1.0, xi, vc[l + 1], h);
            }
            Blas.Dscal(ndim, 1.0 / weight, f);
            Blas.Dscal(ndim * 2, 1.0 / Lambda / weight, h);
        }