I faced with two actual implementations of the same problem, and need some help to find which one is correct.
Let K be an non-square $m \times n$ matrix (a product of two eigenvalues vectors), B an $m \times n$ matrix, and $\lambda$ an regularization term $\lambda \in \mathbb{R}$. The solution of the equation:
$(K+\lambda) x = B$
can be given by $x = K^{-1} B$, correct?
How are the following matlab implementations related?
x = pinv(K + lambda)*B
and
x = K ./ (K + lambda)
thanks in advance
The properly formed linear system is $$ \left( \mathbf{K} + \lambda \, \mathbf{I}_{n} \right) x = B $$ Define the matrix $$ \mathbf{A} = \mathbf{K} + \lambda\, \mathbf{I}_{n} $$ and the solution vector can be expressed in terms of the pseudoinverse $$ x = \mathbf{A}^{+} B $$ which is encapsulated by the MATLAB function
pinv.If the matrix $\mathbf{A}$ were nonsingular (square, full rank), you could solve it with
x = B./AThe pseudoinverse will always work, and will be the only choice if the target matrix is not square, or rank deficient. It will also provide the most accurate answer when the matrix is nonsingular and poorly conditioned.
In the special case of the square, nonsingular, well-conditioned matrix, use the
./construct.