示例#1
0
文件: LU.cs 项目: rakot/rawr
        public unsafe void BSolveUUnit(int col, double *c)
#endif
        {
            int i, k;

            LP.Zero(c, size);
            for (i = 0; ; i++)
            {
                if (Q[i] == col)
                {
                    col = i;
                    break;
                }
            }
            //c[col] = 1.0;

            /*for (i = 0; i < size; i++)
             * {
             *  c[i] = b[Q[i]]; // shuffle Q
             * }*/

            if (U[col * size + col] != 0)
            {
                c[col] = 1.0 / U[col * size + col];
                for (i = col + 1; i < size; i++)
                {
                    c[i] -= c[col] * U[col * size + i];
                }
            }
            else
            {
                return;
            }
            //else c[col] = 0; // value underspecified

            for (k = col + 1; k < size; k++)
            {
                if (U[k * size + k] != 0 && Math.Abs(c[k]) > 0.000001)
                {
                    c[k] /= U[k * size + k];
                    for (i = k + 1; i < size; i++)
                    {
                        c[i] -= c[k] * U[k * size + i];
                    }
                }
                else
                {
                    c[k] = 0;  // value underspecified
                }
            }
        }