Commit c1343f07 authored by Davis King's avatar Davis King

Switched the sparse vectors all over to unsigned integral keys and changed

the definition of what is officially a sparse vector to say that unsigned
integral keys are required.  Having this requirement is nice because it creates
a simple correspondence between dense vector index values and sparse vector keys.
The previous sparse vector definition was just excessively generic.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%403523
parent 6ed74b7a
......@@ -916,7 +916,7 @@ namespace dlib
else
{
// first compute w = cscale*alpha*w
for (typename std::map<long,scalar_type>::iterator i = w.begin(); i != w.end(); ++i)
for (typename std::map<unsigned long,scalar_type>::iterator i = w.begin(); i != w.end(); ++i)
{
i->second *= cscale*alpha;
}
......@@ -935,7 +935,7 @@ namespace dlib
kernel_type kernel;
std::map<long,scalar_type> w;
std::map<unsigned long,scalar_type> w;
scalar_type alpha;
......
......@@ -16,7 +16,7 @@ namespace dlib
In dlib, sparse vectors are represented using the container objects
in the C++ STL. In particular, a sparse vector is any container that
contains a sorted range of std::pair<key, scalar_value> objects where:
- key is any type that can serve as a unique index or identifier (e.g. unsigned long)
- key is an unsigned integral type
- scalar_value is float, double, or long double
So examples of valid sparse vectors are:
......
......@@ -106,8 +106,8 @@ namespace
template <typename K>
double dist (
const K& k,
std::map<long,double> a,
std::map<long,double> b
std::map<unsigned long,double> a,
std::map<unsigned long,double> b
)
/*!
ensures
......@@ -357,7 +357,7 @@ namespace
)
/*!
requires
- kernel_type::sample_type == a std::map<long,double>
- kernel_type::sample_type == a std::map<unsigned long,double>
- kernel_type == a kernel that just computes a dot product
between its inputs. I.e. a linear kernel
ensures
......@@ -536,7 +536,7 @@ namespace
)
/*!
requires
- kernel_type::sample_type == a std::map<long,double>
- kernel_type::sample_type == a std::map<unsigned long,double>
- kernel_type == a kernel that just computes a dot product
between its inputs + some constant. I.e. a linear kernel
wrapped by offset_kernel
......@@ -553,7 +553,7 @@ namespace
sample_type temp, temp2, temp3;
std::map<long,double> val, val2;
std::map<unsigned long,double> val, val2;
const double b = std::sqrt(k.offset);
......@@ -674,10 +674,10 @@ namespace
test_kcentroid_with_offset_linear_kernel<offset_kernel<linear_kernel<matrix<double,4,1> > > >();
test_kcentroid_with_linear_kernel<unopt_linear_kernel<matrix<double,5,1> > >();
test_kcentroid_with_offset_linear_kernel<offset_kernel<unopt_linear_kernel<matrix<double,4,1> > > >();
test_kcentroid_with_sparse_linear_kernel<sparse_linear_kernel<std::map<long,double> > >();
test_kcentroid_with_offset_sparse_linear_kernel<offset_kernel<sparse_linear_kernel<std::map<long,double> > > >();
test_kcentroid_with_sparse_linear_kernel<unopt_sparse_linear_kernel<std::map<long,double> > >();
test_kcentroid_with_offset_sparse_linear_kernel<offset_kernel<unopt_sparse_linear_kernel<std::map<long,double> > > >();
test_kcentroid_with_sparse_linear_kernel<sparse_linear_kernel<std::map<unsigned long,double> > >();
test_kcentroid_with_offset_sparse_linear_kernel<offset_kernel<sparse_linear_kernel<std::map<unsigned long,double> > > >();
test_kcentroid_with_sparse_linear_kernel<unopt_sparse_linear_kernel<std::map<unsigned long,double> > >();
test_kcentroid_with_offset_sparse_linear_kernel<offset_kernel<unopt_sparse_linear_kernel<std::map<unsigned long,double> > > >();
}
} a;
......
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