Example #1
0
ScalarType eigentools::cosineMeasure(DenseMat &a,DenseMat &b)
{
    if (a.cols()!=b.cols() || a.rows()!=b.rows())
        return (ScalarType)0;
    if (a.cols()==1 || a.rows() == 1)
    {
        eigentools::ScalarType rval = a.cwiseProduct(b).array().sum();
        if (!a.norm() || !b.norm())
        {
            std::cerr<<"Norm of vector is 0\n";
            return 0;
        }
        rval /= a.norm();
        rval /= b.norm();
        return rval;
    }
    else
        return 0;
}