in src/main/java/org/apache/datasketches/vector/decomposition/MatrixOpsImplOjAlgo.java [211:231]
private void computeSymmEigSVD(final MatrixStore<Double> A, final boolean computeVectors) {
if (evd_ == null) {
evd_ = Eigenvalue.PRIMITIVE.make(n_, true);
}
// want left singular vectors U, aka eigenvectors of AA^T -- so compute that
evd_.decompose(A.transpose().premultiply(A));
// TODO: can we only use k_ values?
final double[] ev = new double[n_];
evd_.getEigenvalues(ev, Optional.empty());
for (int i = 0; i < ev.length; ++i) {
final double val = Math.sqrt(ev[i]);
sv_[i] = val;
if (computeVectors && (val > 0)) { S_.set(i, i, 1 / val); }
}
if (computeVectors) {
S_.multiply(evd_.getV().transpose()).multiply(A, Vt_);
}
}