Exemplo n.º 1
0
IGL_INLINE void igl::polar_svd3x3_avx(const Eigen::Matrix<T, 3*8, 3>& A, Eigen::Matrix<T, 3*8, 3> &R)
{
    // should be caught at compile time, but just to be 150% sure:
    assert(A.rows() == 3*8 && A.cols() == 3);

    Eigen::Matrix<T, 3*8, 3> U, Vt;
    Eigen::Matrix<T, 3*8, 1> S;
    svd3x3_avx(A, U, S, Vt);

    for (int k=0; k<8; k++)
    {
        R.block(3*k, 0, 3, 3) = U.block(3*k, 0, 3, 3) * Vt.block(3*k, 0, 3, 3).transpose();
    }

    // test:
    for (int k=0; k<8; k++)
    {
        Eigen::Matrix3f Apart = A.block(3*k, 0, 3, 3);
        Eigen::Matrix3f Rpart;
        polar_svd3x3(Apart, Rpart);

        Eigen::Matrix3f Rpart_SSE = R.block(3*k, 0, 3, 3);
        Eigen::Matrix3f diff = Rpart - Rpart_SSE;
        float diffNorm = diff.norm();
        if (abs(diffNorm) > 0.001)
        {
            printf("Huh: diffNorm = %15f (k = %i)\n", diffNorm, k);
        }

        // Unused
        //int hu = 1;
    }
    // eof test
}