Пример #1
0
        /**
         * <p>
         * Linear solver which uses QR pivot decomposition.  These solvers can handle singular systems
         * and should never fail.  For singular systems, the solution might not be as accurate as a
         * pseudo inverse that uses SVD.
         * </p>
         *
         * <p>
         * For singular systems there are multiple correct solutions.  The optimal 2-norm solution is the
         * solution vector with the minimal 2-norm and is unique.  If the optimal solution is not computed
         * then the basic solution is returned.  See {@link org.ejml.dense.row.linsol.qr.BaseLinearSolverQrp_FDRM}
         * for details.  There is only a runtime difference for small matrices, 2-norm solution is slower.
         * </p>
         *
         * <p>
         * Two different solvers are available.  Compute Q will compute the Q matrix once then use it multiple times.
         * If the solution for a single vector is being found then this should be set to false.  If the pseudo inverse
         * is being found or the solution matrix has more than one columns AND solve is being called numerous multiples
         * times then this should be set to true.
         * </p>
         *
         * @param computeNorm2 true to compute the minimum 2-norm solution for singular systems. Try true.
         * @param computeQ Should it precompute Q or use house holder.  Try false;
         * @return Pseudo inverse type solver using QR with column pivots.
         */
        public static LinearSolverDense <FMatrixRMaj> leastSquaresQrPivot(bool computeNorm2, bool computeQ)
        {
            QRColPivDecompositionHouseholderColumn_FDRM decomposition =
                new QRColPivDecompositionHouseholderColumn_FDRM();

            if (computeQ)
            {
                return(new SolvePseudoInverseQrp_FDRM(decomposition, computeNorm2));
            }
            else
            {
                return(new LinearSolverQrpHouseCol_FDRM(decomposition, computeNorm2));
            }
        }
 public LinearSolverQrpHouseCol_FDRM(QRColPivDecompositionHouseholderColumn_FDRM decomposition,
                                     bool norm2Solution)
     : base(decomposition, norm2Solution)
 {
     this.decomposition = decomposition;
 }