public ZMatrixRMaj getQ(ZMatrixRMaj Q, bool compact)
        {
            if (compact)
            {
                Q = UtilDecompositons_ZDRM.checkIdentity(Q, numRows, minLength);
            }
            else
            {
                Q = UtilDecompositons_ZDRM.checkIdentity(Q, numRows, numRows);
            }

            for (int j = minLength - 1; j >= 0; j--)
            {
                double[] u = dataQR[j];

                double vvReal = u[j * 2];
                double vvImag = u[j * 2 + 1];

                u[j * 2]     = 1;
                u[j * 2 + 1] = 0;
                double gammaReal = gammas[j];

                QrHelperFunctions_ZDRM.rank1UpdateMultR(Q, u, 0, gammaReal, j, j, numRows, v);

                u[j * 2]     = vvReal;
                u[j * 2 + 1] = vvImag;
            }

            return(Q);
        }
示例#2
0
        public ZMatrixRMaj getLower(ZMatrixRMaj lower)
        {
            int numRows = LU.numRows;
            int numCols = LU.numRows < LU.numCols ? LU.numRows : LU.numCols;

            lower = UtilDecompositons_ZDRM.checkZerosUT(lower, numRows, numCols);

            for (int i = 0; i < numCols; i++)
            {
                lower.set(i, i, 1.0, 0.0);

                for (int j = 0; j < i; j++)
                {
                    int indexLU = LU.getIndex(i, j);
                    int indexL  = lower.getIndex(i, j);

                    double real      = LU.data[indexLU];
                    double imaginary = LU.data[indexLU + 1];

                    lower.data[indexL]     = real;
                    lower.data[indexL + 1] = imaginary;
                }
            }

            if (numRows > numCols)
            {
                for (int i = numCols; i < numRows; i++)
                {
                    for (int j = 0; j < numCols; j++)
                    {
                        int indexLU = LU.getIndex(i, j);
                        int indexL  = lower.getIndex(i, j);

                        double real      = LU.data[indexLU];
                        double imaginary = LU.data[indexLU + 1];

                        lower.data[indexL]     = real;
                        lower.data[indexL + 1] = imaginary;
                    }
                }
            }
            return(lower);
        }
        public ZMatrixRMaj getR(ZMatrixRMaj R, bool compact)
        {
            if (compact)
            {
                R = UtilDecompositons_ZDRM.checkZerosLT(R, minLength, numCols);
            }
            else
            {
                R = UtilDecompositons_ZDRM.checkZerosLT(R, numRows, numCols);
            }

            for (int j = 0; j < numCols; j++)
            {
                double[] colR = dataQR[j];
                int      l    = Math.Min(j, numRows - 1);
                for (int i = 0; i <= l; i++)
                {
                    R.set(i, j, colR[i * 2], colR[i * 2 + 1]);
                }
            }

            return(R);
        }
示例#4
0
        ZMatrixRMaj CholeskyDecomposition <ZMatrixRMaj> .getT(ZMatrixRMaj T)
        {
            // write the values to T
            if (lower)
            {
                T = UtilDecompositons_ZDRM.checkZerosUT(T, n, n);
                for (int i = 0; i < n; i++)
                {
                    int index = i * n * 2;
                    for (int j = 0; j <= i; j++)
                    {
                        T.data[index] = this.T.data[index];
                        index++;
                        T.data[index] = this.T.data[index];
                        index++;
                    }
                }
            }
            else
            {
                T = UtilDecompositons_ZDRM.checkZerosLT(T, n, n);
                for (int i = 0; i < n; i++)
                {
                    int index = (i * n + i) * 2;
                    for (int j = i; j < n; j++)
                    {
                        T.data[index] = this.T.data[index];
                        index++;
                        T.data[index] = this.T.data[index];
                        index++;
                    }
                }
            }

            return(T);
        }
示例#5
0
        public ZMatrixRMaj getUpper(ZMatrixRMaj upper)
        {
            int numRows = LU.numRows < LU.numCols ? LU.numRows : LU.numCols;
            int numCols = LU.numCols;

            upper = UtilDecompositons_ZDRM.checkZerosLT(upper, numRows, numCols);

            for (int i = 0; i < numRows; i++)
            {
                for (int j = i; j < numCols; j++)
                {
                    int indexLU = LU.getIndex(i, j);
                    int indexU  = upper.getIndex(i, j);

                    double real      = LU.data[indexLU];
                    double imaginary = LU.data[indexLU + 1];

                    upper.data[indexU]     = real;
                    upper.data[indexU + 1] = imaginary;
                }
            }

            return(upper);
        }