}
b[i] = sum;
}
final DoubleMatrix1D mb = new DoubleMatrix1D(b);
DoubleMatrix2D ma = getAMatrix(f, invSigmaSqr);
for (i = 0; i < dim; i++) {
if (lambda[i] > 0.0) {
final DoubleMatrix2D d = getDiffMatrix(sizes, differenceOrder[i], i);
ma = (DoubleMatrix2D) _algebra.add(ma, _algebra.scale(d, lambda[i]));
}
}
final DecompositionResult decmp = _decomposition.evaluate(ma);
final DoubleMatrix1D w = decmp.solve(mb);
final DoubleMatrix2D covar = decmp.solve(DoubleMatrixUtils.getIdentityMatrix2D(m));
double chiSq = 0;
for (i = 0; i < n; i++) {
double temp = 0;
for (k = 0; k < m; k++) {
temp += w.getEntry(k) * f[k][i];
}
chiSq += FunctionUtils.square(y.get(i) - temp) * invSigmaSqr[i];
}
return new GeneralizedLeastSquareResults<>(basisFunctions, chiSq, w, covar);