Exemplo n.º 1
0
        public override /**/ double quality()
        {
            return(SpecializedOps_ZDRM.qualityTriangular(decomposer._getT()));
        }

        /**
         * <p>
         * Using the decomposition, finds the value of 'X' in the linear equation below:<br>
         *
         * A*x = b<br>
         *
         * where A has dimension of n by n, x and b are n by m dimension.
         * </p>
         * <p>
         * *Note* that 'b' and 'x' can be the same matrix instance.
         * </p>
         *
         * @param B A matrix that is n by m.  Not modified.
         * @param X An n by m matrix where the solution is writen to.  Modified.
         */
        public override void solve(ZMatrixRMaj B, ZMatrixRMaj X)
        {
            UtilEjml.checkReshapeSolve(numRows, numCols, B, X);

            int numCols2 = B.numCols;

            double[] dataB = B.data;
            double[] dataX = X.data;

            if (decomposer.isLower())
            {
                for (int j = 0; j < numCols2; j++)
                {
                    for (int i = 0; i < n; i++)
                    {
                        vv[i * 2]     = dataB[(i * numCols2 + j) * 2];
                        vv[i * 2 + 1] = dataB[(i * numCols2 + j) * 2 + 1];
                    }
                    solveInternalL();
                    for (int i = 0; i < n; i++)
                    {
                        dataX[(i * numCols2 + j) * 2]     = vv[i * 2];
                        dataX[(i * numCols2 + j) * 2 + 1] = vv[i * 2 + 1];
                    }
                }
            }
            else
            {
                throw new SystemException("Implement");
            }
        }
        override public void solve(ZMatrixRMaj B, ZMatrixRMaj X)
        {
            UtilEjml.checkReshapeSolve(numRows, numCols, B, X);

            int bnumCols = B.numCols;
            int bstride  = B.RowStride;

            double[] dataB = B.data;
            double[] dataX = X.data;

            double[] vv = decomp._getVV();

            //        for( int j = 0; j < numCols; j++ ) {
            //            for( int i = 0; i < this.numCols; i++ ) vv[i] = dataB[i*numCols+j];
            //            decomp._solveVectorInternal(vv);
            //            for( int i = 0; i < this.numCols; i++ ) dataX[i*numCols+j] = vv[i];
            //        }
            for (int j = 0; j < bnumCols; j++)
            {
                int index = j * 2;
                for (int i = 0; i < numRows; i++, index += bstride)
                {
                    vv[i * 2]     = dataB[index];
                    vv[i * 2 + 1] = dataB[index + 1];
                }
                decomp._solveVectorInternal(vv);
                index = j * 2;
                for (int i = 0; i < numRows; i++, index += bstride)
                {
                    dataX[index]     = vv[i * 2];
                    dataX[index + 1] = vv[i * 2 + 1];
                }
            }
        }