y2 = y.transpose().times(y);
} else {
y2.assign(y.transpose().times(y), Functions.PLUS);
}
}
r2 = new CholeskyDecomposition(y2);
// step 2, compute B
int ncols = 0;
for (File file : partsOfA) {
MatrixWritable m = new MatrixWritable();
final DataInputStream in = new DataInputStream(new FileInputStream(file));
try {
m.readFields(in);
} finally {
in.close();
}
Matrix aI = m.get();
ncols = Math.max(ncols, aI.columnSize());
Matrix omega = new RandomTrinaryMatrix(seed, aI.numCols(), internalDimension, false);
for (int j = 0; j < aI.numCols(); j += columnsPerSlice) {
Matrix yI = aI.times(omega);
Matrix aIJ = aI.viewPart(0, aI.rowSize(), j, Math.min(columnsPerSlice, aI.columnSize() - j));
Matrix bIJ = r2.solveRight(yI).transpose().times(aIJ);
addToSavedCopy(bFile(tmpDir, j), bIJ);
}
}
// step 3, compute BB', L and SVD(L)
Matrix b2 = new DenseMatrix(internalDimension, internalDimension);
MatrixWritable bTmp = new MatrixWritable();
for (int j = 0; j < ncols; j += columnsPerSlice) {
if (bFile(tmpDir, j).exists()) {
final DataInputStream in = new DataInputStream(new FileInputStream(bFile(tmpDir, j)));
try {
bTmp.readFields(in);
} finally {
in.close();
}
b2.assign(bTmp.get().times(bTmp.get().transpose()), Functions.PLUS);
}
}
l2 = new CholeskyDecomposition(b2);
svd = new SingularValueDecomposition(l2.getL());
}