void svd_solve_sym(float[,] a, out Vector3 sigma, ref float[,] v)
{
// assuming that A is symmetric: can optimize all operations for
// the upper right triagonal
float[,] vtav = new float[3, 3];
Array.Copy(a, vtav, a.Length);
// assuming V is identity: you can also pass a matrix the rotations
// should be applied to
// U is not computed
for (int i = 0; i < 5; ++i)
{
svd_rotate(ref vtav, ref v, 0, 1);
svd_rotate(ref vtav, ref v, 0, 2);
svd_rotate(ref vtav, ref v, 1, 2);
}
sigma = new Vector3(vtav[0, 0], vtav[1, 1], vtav[2, 2]);
}