[英]Getting all possible Linear Combinations of a matrix R
suppose I have the following augmented matrix假设我有以下增广矩阵
100 100 0 100
325 0 500 500
In equation terms:在等式方面:
c1(100) + c2(100) + c3(0) = 100
c1(325) + c2(0) + c3(500) = 500
I cannot change the final column.我无法更改最后一列。 How do I find all possible linear combinations?如何找到所有可能的线性组合? The obvious solution is c2 = 1 and c3 = 1. But how do I get it in a systemic manner?显而易见的解决方案是 c2 = 1 和 c3 = 1。但是我如何以系统的方式得到它?
I tried using rref in the pracma package but I get我尝试在 pracma 包中使用 rref 但我得到了
1 0 1.538462 1.5384615
0 1 -1.538462 -0.5384615
I really can't have any fraction values.我真的不能有任何分数值。
Any advice?有什么建议吗?
This is an underdetermined system of linear equations.这是一个欠定的线性方程组。 You can get all its solutions with the help of the Moore-Penrose inverse of A
.借助A
的 Moore-Penrose 逆,您可以得到它的所有解。 Let Ainv
be the Moore-Penrose inverse of A
.让Ainv
是的Moore-Penrose逆A
。 Then all solutions of A %*% x = b
are given by Ainv %*% b + (I - Ainv %*% A) %*% w
where I
is the identity matrix and w
is any vector.然后A %*% x = b
所有解都由Ainv %*% b + (I - Ainv %*% A) %*% w
,其中I
是单位矩阵, w
是任何向量。
A <- rbind(c(100,100,0), c(325,0,500))
b <- c(100,500)
Ainv <- MASS::ginv(A)
w <- c(1,2,3) # arbitrary
one_solution <- Ainv %*% b + (diag(3L) - Ainv %*% A) %*% w
A %*% one_solution
# [,1]
# [1,] 100
# [2,] 500
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.