我知道solve函数可以解决Ax=b问题。但是我想要一个函数来解x的xA=b?有可用的功能吗?
顺便说一句,它应该像Matlab的分水岭那样工作:
x = B/A solves the system of linear equations x*A = B for x. The matrices A and B must contain the same number of columns. MATLAB® displays a warning message if A is badly scaled or nearly singular, but performs the calculation regardless.
If A is a scalar, then B/A is equivalent to B./A.
If A is a square n-by-n matrix and B is a matrix with n columns, then x = B/A is a solution to the equation x*A = B, if it exists.
If A is a rectangular m-by-n matrix with m ~= n, and B is a matrix with n columns, then x = B/A returns a least-squares solution of the system of equations x*A = B.发布于 2014-05-20 07:12:14
基于矩阵求逆的方法:
如果xA = b,那么x*A* inv(A) =b* inv(A) <=> x=b* inv(A) <=>,那么在opencv中有:
void mrdivide(const cv::Mat &A, const cv::Mat &b, cv::Mat &x) {
x = b * A.inv();
}但是,由于矩阵反演的成本很高,从数值方法的角度来看,这是不可取的。此外,它只能解不超定义的线性方程组,且系统矩阵A必须是可逆的。
基于矩阵移位的方法:
因为我们有xA = b,所以(xA)^T = b^T <=> A*T^T= b^T,所以我们可以使用cv::解题(A.T(),b.t(),x),x.t()是这样的结果:
void mrdivide(const cv::Mat &A, const cv::Mat &b, cv::Mat &x) {
cv::solve(A.t(), b.t(), x);
cv::transpose(x,x);
}这是一般的和推荐的解决方案。它提供了solve()所提供的所有功能。
https://stackoverflow.com/questions/23749932
复制相似问题