LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
qrf_independent_rows.m
1function keep = qrf_independent_rows(A, tol)
2% QRF_INDEPENDENT_ROWS Indices of a maximal independent subset of A's rows.
3%
4% KEEP = QRF_INDEPENDENT_ROWS(A) selects by column-pivoted QR of A', so the
5% retained rows are the numerically best-conditioned independent set rather
6% than simply the first ones encountered.
7%
8% The QRF equality block is heavily redundant, carrying about twice as many
9% rows as its rank, and both quadprog (MATLAB) and SLSQP (Python) degrade on
10% the rank-deficient system. Dropping dependent rows changes no feasible
11% point: they are exact linear combinations of the retained ones. This is the
12% MATLAB counterpart of qrf_noblo_common.independent_rows.
13
14if isempty(A)
15 keep = zeros(0,1);
16 return
17end
18[~, R, P] = qr(full(A)', 0);
19d = abs(diag(R));
20if isempty(d)
21 keep = zeros(0,1);
22 return
23end
24if nargin < 2 || isempty(tol)
25 tol = max(size(A)) * eps * d(1);
26end
27keep = sort(P(1:sum(d > tol)));
28keep = keep(:);
29end
Definition Station.m:245