Mean squared error of a matrix factorization of the form \(A = wdh\) is given by $$\frac{\sum_{i,j}{(A - wdh)^2}}{ij}$$ where \(i\) and \(j\) are the number of rows and columns in \(A\).
Thus, this function simply calculates the cross-product of \(wh\) or \(wdh\) (if \(d\) is specified),
subtracts that from \(A\), squares the result, and calculates the mean of all values.
If no diagonal scaling vector is present in the model, input d = rep(1, k) where k is the rank of the model.
Parallelization. Calculation of mean squared error is performed in parallel across columns in A using the number of threads set by setRcppMLthreads.
By default, all available threads are used, see getRcppMLthreads.