/usr/include/dlib/svm/multiclass_tools.h is in libdlib-dev 18.18-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | // Copyright (C) 2010 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#ifndef DLIB_MULTICLASS_TOoLS_Hh_
#define DLIB_MULTICLASS_TOoLS_Hh_
#include "multiclass_tools_abstract.h"
#include <vector>
#include <set>
#include "../unordered_pair.h"
namespace dlib
{
// ----------------------------------------------------------------------------------------
template <typename label_type>
std::vector<label_type> select_all_distinct_labels (
const std::vector<label_type>& labels
)
{
std::set<label_type> temp;
temp.insert(labels.begin(), labels.end());
return std::vector<label_type>(temp.begin(), temp.end());
}
// ----------------------------------------------------------------------------------------
template <typename label_type, typename U>
std::vector<unordered_pair<label_type> > find_missing_pairs (
const std::map<unordered_pair<label_type>,U>& bdfs
)
{
typedef std::map<unordered_pair<label_type>,U> map_type;
// find all the labels
std::set<label_type> temp;
for (typename map_type::const_iterator i = bdfs.begin(); i != bdfs.end(); ++i)
{
temp.insert(i->first.first);
temp.insert(i->first.second);
}
std::vector<unordered_pair<label_type> > missing_pairs;
// now make sure all label pairs are present
typename std::set<label_type>::const_iterator i, j;
for (i = temp.begin(); i != temp.end(); ++i)
{
for (j = i, ++j; j != temp.end(); ++j)
{
const unordered_pair<label_type> p(*i, *j);
if (bdfs.count(p) == 0)
missing_pairs.push_back(p);
}
}
return missing_pairs;
}
// ----------------------------------------------------------------------------------------
}
#endif // DLIB_MULTICLASS_TOoLS_Hh_
|