Commit c9c3fa17 authored by Davis King's avatar Davis King

Made max_cost_assignment() give an error if you incorrectly give it a

non-square matrix.
parent 3286a0a3
...@@ -57,6 +57,9 @@ list _max_cost_assignment ( ...@@ -57,6 +57,9 @@ list _max_cost_assignment (
const matrix<double>& cost const matrix<double>& cost
) )
{ {
if (cost.nr() != cost.nc())
throw dlib::error("The input matrix must be square.");
// max_cost_assignment() only works with integer matrices, so convert from // max_cost_assignment() only works with integer matrices, so convert from
// double to integer. // double to integer.
const double scale = (std::numeric_limits<dlib::int64>::max()/1000)/max(abs(cost)); const double scale = (std::numeric_limits<dlib::int64>::max()/1000)/max(abs(cost));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment