Matrix sortedMatrix;
if (matrix instanceof SparseMatrix)
sortedMatrix = new SparseRowMaskedMatrix(
(SparseMatrix) matrix, reordering);
else
sortedMatrix = new RowMaskedMatrix(matrix, reordering);
LOGGER.info("Computing the spectral cut");
// Compute the index at which the best cut can be made based on the
// reordered data matrix and rho values.
int cutIndex = computeCut(
sortedMatrix, sortedRho, pSum, matrixRowSums);
leftReordering = Arrays.copyOfRange(reordering, 0, cutIndex);
rightReordering = Arrays.copyOfRange(
reordering, cutIndex, reordering.length);
// Create the split permuted matricies.
if (matrix instanceof SparseMatrix) {
leftSplit = new SparseRowMaskedMatrix((SparseMatrix) matrix,
leftReordering);
rightSplit = new SparseRowMaskedMatrix((SparseMatrix) matrix,
rightReordering);
} else {
leftSplit = new RowMaskedMatrix(matrix, leftReordering);
rightSplit = new RowMaskedMatrix(matrix, rightReordering);
}
}