X-Git-Url: http://47.100.26.94:8080/?a=blobdiff_plain;f=src%2Fhungarian.cpp;h=fffb1f3758050696180adad79baba1e650b9395d;hb=be96459d3e098508417f07ed0e1952b6e05215c4;hp=7c1d8dad45447bd0c89d7e4a40810f3b90960f7c;hpb=48adce31a0ffdb3757ee1be8a63ce7e769e87deb;p=trackerpp.git diff --git a/src/hungarian.cpp b/src/hungarian.cpp index 7c1d8da..fffb1f3 100644 --- a/src/hungarian.cpp +++ b/src/hungarian.cpp @@ -57,6 +57,11 @@ int linear_sum_assignment(const MatrixXi& cost_matrix, VectorXi& row_ind, Vector { // The algorithm expects more columns than rows in the cost matrix. MatrixXi correct_matrix = cost_matrix; + if (cost_matrix.cols() == 0 || cost_matrix.rows() == 0){ + row_ind = VectorXi::Zero(0); + col_ind = VectorXi::Zero(0); + return 0; + } bool is_transposed = false; if (cost_matrix.cols() < cost_matrix.rows()){ cout << "cols < rows, transpose." << endl; @@ -302,14 +307,3 @@ int step_six(Hungary& state) return 4; } -//////////////////////////////////////////////////////////////////////////////// -double distance_cosine(const VectorXd& u, const VectorXd& v) -{ - return (1 - u.dot(v) / std::sqrt(u.dot(u) * v.dot(v))); -} - -double distance_euclidean(const VectorXd& u, const VectorXd& v) -{ - VectorXd d = u - v; - return std::sqrt(d.dot(d)); -}