I noticed that array division gives different results in Matlab and Julia.
Matlab:
>[1 2 2]\[2 2 2]
ans =
0 0 0
1 1 1
0 0 0
Julia:
>[1 2 2]\[2 2 2]
3×3 Array{Float64,2}:
0.222222 0.222222 0.222222
0.444444 0.444444 0.444444
0.444444 0.444444 0.444444
They must be using different least-squares algorithms. From the documentation, though, it seems that both procedures use QR decomposition. Why do they give different outputs?
Matlab: (from 'help \')
If A is an M-by-N matrix with M < or > N and B is a column vector with M components, or a matrix with several such columns, then X = A\B is the solution in the least squares sense to the under- or overdetermined system of equations A*X = B. The effective rank, K, of A is determined from the QR decomposition with pivoting. A solution X is computed which has at most K nonzero components per column. If K < N this will usually not be the same solution as PINV(A)*B. A\EYE(SIZE(A)) produces a generalized inverse of A.
Julia (from '? \')
\ (A, B)
Matrix division using a polyalgorithm. For input matrices A and B, the result X is such that A*X == B when A is square. The solver that is used depends upon the structure of A. If A is upper or lower triangular (or diagonal), no factorization of A is required and the system is solved with either forward or backward substitution. For non-triangular square matrices, an LU factorization is used.
For rectangular A the result is the minimum-norm least squares solution computed by a pivoted QR factorization of A and a rank estimate of A based on the R factor.
When A is sparse, a similar polyalgorithm is used. For indefinite matrices, the LDLt factorization does not use pivoting during the numerical factorization and therefore the procedure can fail even for invertible matrices.