A \ B 在matlab中给出了一个特殊的解决方案,而numpy.linalg.lstsq却没有.
A = [1 2 0; 0 4 3];
b = [8; 18];
c_mldivide = A \ b
c_mldivide =
0
4
0.66666666666667
c_lstsq = np.linalg.lstsq([[1 ,2, 0],[0, 4, 3]],[[8],[18]])
print c_lstsq
c_lstsq = (array([[ 0.91803279],
[ 3.54098361],
[ 1.27868852]]), array([], dtype=float64), 2, array([ 5.27316304,1.48113184]))
Run Code Online (Sandbox Code Playgroud)
A \ Bmatlab 中的mldivide如何提供特殊的解决方案?