mean = mul(mean, 1./list.size());
// compute covariance matrix;
double[][] cov = new double[dim][dim];
ThreadedMatrixOperator factory = new ThreadedMatrixOperator() {
@Override
public void doLines(double[][] matrix, int from, int to) {
for(int i = from ; i < to ; i++) {
for(int j = 0 ; j < matrix.length ; j++) {
double sum = 0;
for(TrainingSample<double[]> t : list) {
sum += (t.sample[i]-mean[i]) * (t.sample[j]-mean[j]);
}
matrix[i][j] = sum/list.size();
}
}
}
};
cov = factory.getMatrix(cov);
// eigen decomposition
double[][][] eig = eig(cov);
//projectors are eigenvectors transposed