for (int v = 0; v < dim; v++) {
final double[] evec = covMatDec.getEigenvector(v).toArray();
covMatEigenvectors.setColumn(v, evec);
}
final RealMatrix tmpMatrix = covMatEigenvectors.transpose();
// Scale each eigenvector by the square root of its eigenvalue.
for (int row = 0; row < dim; row++) {
final double factor = FastMath.sqrt(covMatEigenvalues[row]);
for (int col = 0; col < dim; col++) {