/**
         * <p>
         * Solves for x in the following equation:<br>
         * <br>
         * A*x = b
         * </p>
         *
         * <p>
         * If the system could not be solved then false is returned.  If it returns true
         * that just means the algorithm finished operating, but the results could still be bad
         * because 'A' is singular or nearly singular.
         * </p>
         *
         * <p>
         * If repeat calls to solve are being made then one should consider using {@link LinearSolverFactory_ZDRM}
         * instead.
         * </p>
         *
         * <p>
         * It is ok for 'b' and 'x' to be the same matrix.
         * </p>
         *
         * @param a A matrix that is m by n. Not modified.
         * @param b A matrix that is n by k. Not modified.
         * @param x A matrix that is m by k. Modified.
         * @return true if it could invert the matrix false if it could not.
         */
        public static bool solve(ZMatrixRMaj a, ZMatrixRMaj b, ZMatrixRMaj x)
        {
            LinearSolverDense <ZMatrixRMaj> solver;

            if (a.numCols == a.numRows)
            {
                solver = LinearSolverFactory_ZDRM.lu(a.numRows);
            }
            else
            {
                solver = LinearSolverFactory_ZDRM.qr(a.numRows, a.numCols);
            }

            // make sure the inputs 'a' and 'b' are not modified
            solver = new LinearSolverSafe <ZMatrixRMaj>(solver);

            if (!solver.setA(a))
            {
                return(false);
            }

            solver.solve(b, x);
            return(true);
        }