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);
        }
예제 #2
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);
        }
예제 #3
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);
        }