// pca.getEigenvectors().times(pca.selectionMatrixOfWeakEigenvectors());
Matrix weakEigenvectors = pcares.getWeakEigenvectors();
// Matrix strongEigenvectors =
// pca.getEigenvectors().times(pca.selectionMatrixOfStrongEigenvectors());
Matrix strongEigenvectors = pcares.getStrongEigenvectors();
Vector centroid = centroidDV.getColumnVector();
// TODO: what if we don't have any weak eigenvectors?
if(weakEigenvectors.getColumnDimensionality() == 0) {
sol = new CorrelationAnalysisSolution<V>(null, db, strongEigenvectors, weakEigenvectors, pcares.similarityMatrix(), centroid);
}
else {
Matrix transposedWeakEigenvectors = weakEigenvectors.transpose();
if(logger.isDebugging()) {
StringBuilder log = new StringBuilder();
log.append("Strong Eigenvectors:\n");
log.append(FormatUtil.format(pcares.getEigenvectors().times(pcares.selectionMatrixOfStrongEigenvectors()), NF)).append('\n');
log.append("Transposed weak Eigenvectors:\n");
log.append(FormatUtil.format(transposedWeakEigenvectors, NF)).append('\n');
log.append("Eigenvalues:\n");
log.append(FormatUtil.format(pcares.getEigenvalues(), " , ", 2));
logger.debugFine(log.toString());
}
Vector B = transposedWeakEigenvectors.times(centroid);
if(logger.isDebugging()) {
StringBuilder log = new StringBuilder();
log.append("Centroid:\n").append(centroid).append('\n');
log.append("tEV * Centroid\n");
log.append(B);
logger.debugFine(log.toString());
}
// +1 == + B.getColumnDimensionality()
Matrix gaussJordan = new Matrix(transposedWeakEigenvectors.getRowDimensionality(), transposedWeakEigenvectors.getColumnDimensionality() + 1);
gaussJordan.setMatrix(0, transposedWeakEigenvectors.getRowDimensionality() - 1, 0, transposedWeakEigenvectors.getColumnDimensionality() - 1, transposedWeakEigenvectors);
gaussJordan.setColumnVector(transposedWeakEigenvectors.getColumnDimensionality(), B);
if(logger.isDebuggingFiner()) {
logger.debugFiner("Gauss-Jordan-Elimination of " + FormatUtil.format(gaussJordan, NF));
}
double[][] a = new double[transposedWeakEigenvectors.getRowDimensionality()][transposedWeakEigenvectors.getColumnDimensionality()];
double[][] we = transposedWeakEigenvectors.getArrayRef();
double[] b = B.getArrayRef();
System.arraycopy(we, 0, a, 0, transposedWeakEigenvectors.getRowDimensionality());
LinearEquationSystem lq = new LinearEquationSystem(a, b);
lq.solveByTotalPivotSearch();