#include "Utils.h"
+#include <iostream>
+#include <stdexcept>
using namespace suanzi;
using namespace cv;
+using namespace std;
double distance_cosine(const Eigen::VectorXd& u, const Eigen::VectorXd& v)
{
+ if (u.dot(u) * v.dot(v) == 0){
+ throw overflow_error("zero vector for cosine distance");
+ }
return (1 - u.dot(v) / std::sqrt(u.dot(u) * v.dot(v)));
}