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

non-square matrix.
This commit is contained in:
Davis King 2015-06-18 17:42:43 -04:00
parent 3286a0a342
commit c9c3fa17b5
1 changed files with 3 additions and 0 deletions

View File

@ -57,6 +57,9 @@ list _max_cost_assignment (
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
// double to integer.
const double scale = (std::numeric_limits<dlib::int64>::max()/1000)/max(abs(cost));