Method lu
of package Matrix
works fine for square matrices. However, I can't see why there is that square开发者_JS百科
restriction. How can I perform LU decomposition on a rectangular matrix?
You can embed it into a identity matrix:
[ a11 a12 a13 ]
[ a21 a22 a23 ]
[ 0 0 1 ]
LU decomposition is for square matrices only. You may want to check Wikipedia for a refreshing.
Non-square matricies mean different things.
If it has more rows than columns (more equations than unknowns), it means you need a least squares approximation. You can pre-multiply both sides by the transpose of A and use LU decomp on that. The result is the least squares "best" solution.
If it has fewer rows than columns (more unknowns than equations), you need Singular Value Decomposition (SVD). It'll give you the best solution and the null space as well.
精彩评论