Let $\Phi \in R^{N \times n}$, $N > n$, with $\Phi$ having linearly independent columns.
I have to solve a lot of linear systems of the form $$ (\Phi^\top D_i \Phi) x = \Phi^\top b_i, $$ where $D_i \in R^{N \times N}$ is a different strictly positive definite diagonal matrix and $b_i \in R^N$ a different RHS for every system but the matrix $\Phi$ stays constant.
Is there any way to precompute some factorization such that the linear system is fast to solve every iteration? I stumbled upon this "solution": Prefactoring to solve many similar linear systems, but it doesn't seem to work:
>> Phi = randn(100,10);
>> D = diag(randn(100,1));
>> [Q, R] = qr(Phi, 0);
>> norm(inv(Phi'*D*Phi) - inv(R) * Q' * inv(D) * Q * inv(R)')
ans =
5.8901
Unfortunately, this answer will be negative: 1.) The mismatch is expected, because the current approach is mathematically inconsistent. 2.) While it may be possible to fix it, I don't know how.
The usual calculation, as in the link you provided, is \begin{align} \Phi^T D \Phi x &= b \tag{*} \\ R^T Q^T D Q R x &= b \\ Q^T D Q R x &= R^{-T} b \\ D Q R x &= Q (R^{-T} b) \tag{**} \\ Q R x &= D^{-1} (Q (R^{-T} b)) \\ R x &= Q^T (D^{-1} (Q (R^{-T} b))) \\ x &= R^{-1} (Q^T (D^{-1} (Q (R^{-T} b)))) \end{align} However, (**) was false: $Q$ only has a left inverse ($Q^T Q = {}$ the identity) not a right inverse ($Q Q^T \not= {}$ the identity) when $Q R$ is the reduced factorization of $\Phi \in \mathbb{R}^{N \times n}$ with $N > n$. This can be substantiated by numerical evidence (MATLAB):
Okay: Back to (mathematical) square one. Let's investigate the solvability of (*).
I don't know how to prove this, however, numerical tests in MATLAB suggest that the probability of having $y$ in the column space of $\Phi$ is is extremely low.
Numerical results:
Discussion: Among $10\,000$ pairs of $(\Phi, D, b)$, there was not one for which $y = D^{-1} \Phi^{-T} b$ was in the column space of $\Phi$ (represented by the fact that
any_consistent_Phiwasfalse()).Last comment: I suppose we could compute the least-squares solution of $\Phi x = y$ satisfying $\Phi^T \Phi x = \Phi^T y$. However, this seems strange to me -- assuming (*) is full rank, why compute a least-squares solution? (The
any_low_rank_PhiDPhivariable in the above numerical test returnedfalse(), which means that all $10\,000$ matrices were full rank... so if there are any non-full-rank matrices $\Phi^T D \Phi$, they happen very infrequently.)