mirror of https://github.com/davisking/dlib.git
merged
This commit is contained in:
commit
fdf2a45448
|
@ -62,6 +62,7 @@
|
|||
- std::string
|
||||
- std::wstring
|
||||
- std::vector
|
||||
- std::deque
|
||||
- std::map
|
||||
- std::set
|
||||
- std::pair
|
||||
|
@ -79,6 +80,7 @@
|
|||
- std::string
|
||||
- std::wstring
|
||||
- std::vector
|
||||
- std::deque
|
||||
- std::map
|
||||
- std::set
|
||||
- std::pair
|
||||
|
@ -143,6 +145,7 @@
|
|||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <deque>
|
||||
#include <complex>
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
@ -652,6 +655,18 @@ namespace dlib
|
|||
std::istream& in
|
||||
);
|
||||
|
||||
template <typename T, typename alloc>
|
||||
void serialize (
|
||||
const std::deque<T,alloc>& item,
|
||||
std::ostream& out
|
||||
);
|
||||
|
||||
template <typename T, typename alloc>
|
||||
void deserialize (
|
||||
std::deque<T,alloc>& item,
|
||||
std::istream& in
|
||||
);
|
||||
|
||||
inline void serialize (
|
||||
const std::string& item,
|
||||
std::ostream& out
|
||||
|
@ -1035,6 +1050,44 @@ namespace dlib
|
|||
{ throw serialization_error(e.info + "\n while deserializing object of type std::vector"); }
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
template <typename T, typename alloc>
|
||||
void serialize (
|
||||
const std::deque<T,alloc>& item,
|
||||
std::ostream& out
|
||||
)
|
||||
{
|
||||
try
|
||||
{
|
||||
const unsigned long size = static_cast<unsigned long>(item.size());
|
||||
|
||||
serialize(size,out);
|
||||
for (unsigned long i = 0; i < item.size(); ++i)
|
||||
serialize(item[i],out);
|
||||
}
|
||||
catch (serialization_error& e)
|
||||
{ throw serialization_error(e.info + "\n while serializing object of type std::deque"); }
|
||||
}
|
||||
|
||||
template <typename T, typename alloc>
|
||||
void deserialize (
|
||||
std::deque<T, alloc>& item,
|
||||
std::istream& in
|
||||
)
|
||||
{
|
||||
try
|
||||
{
|
||||
unsigned long size;
|
||||
deserialize(size,in);
|
||||
item.resize(size);
|
||||
for (unsigned long i = 0; i < size; ++i)
|
||||
deserialize(item[i],in);
|
||||
}
|
||||
catch (serialization_error& e)
|
||||
{ throw serialization_error(e.info + "\n while deserializing object of type std::deque"); }
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
inline void serialize (
|
||||
|
|
|
@ -151,6 +151,51 @@ namespace dlib
|
|||
matrix<double,2,1> w;
|
||||
double residual_squared;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
template <
|
||||
typename T
|
||||
>
|
||||
double probability_gradient_less_than (
|
||||
const T& container,
|
||||
double thresh
|
||||
)
|
||||
{
|
||||
running_gradient g;
|
||||
for(auto&& v : container)
|
||||
g.add(v);
|
||||
|
||||
// make sure requires clause is not broken
|
||||
DLIB_ASSERT(g.current_n() > 2,
|
||||
"\t double probability_gradient_less_than()"
|
||||
<< "\n\t You need more than 2 elements in the given container to call this function."
|
||||
);
|
||||
return g.probability_gradient_less_than(thresh);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T
|
||||
>
|
||||
double probability_gradient_greater_than (
|
||||
const T& container,
|
||||
double thresh
|
||||
)
|
||||
{
|
||||
running_gradient g;
|
||||
for(auto&& v : container)
|
||||
g.add(v);
|
||||
|
||||
// make sure requires clause is not broken
|
||||
DLIB_ASSERT(g.current_n() > 2,
|
||||
"\t double probability_gradient_greater_than()"
|
||||
<< "\n\t You need more than 2 elements in the given container to call this function."
|
||||
);
|
||||
return g.probability_gradient_greater_than(thresh);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
}
|
||||
|
||||
#endif // DLIB_RuNNING_GRADIENT_Hh_
|
||||
|
|
|
@ -116,6 +116,45 @@ namespace dlib
|
|||
/*!
|
||||
provides serialization support
|
||||
!*/
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
template <
|
||||
typename T
|
||||
>
|
||||
double probability_gradient_less_than (
|
||||
const T& container,
|
||||
double thresh
|
||||
);
|
||||
/*!
|
||||
requires
|
||||
- container muse be a container of double values that can be enumerated with a
|
||||
range based for loop.
|
||||
- The container must contain more than 2 elements.
|
||||
ensures
|
||||
- Puts all the elements of container into a running_gradient object, R, and
|
||||
then returns R.probability_gradient_less_than(thresh).
|
||||
!*/
|
||||
|
||||
template <
|
||||
typename T
|
||||
>
|
||||
double probability_gradient_greater_than (
|
||||
const T& container,
|
||||
double thresh
|
||||
);
|
||||
/*!
|
||||
requires
|
||||
- container muse be a container of double values that can be enumerated with a
|
||||
range based for loop.
|
||||
- The container must contain more than 2 elements.
|
||||
ensures
|
||||
- Puts all the elements of container into a running_gradient object, R, and
|
||||
then returns R.probability_gradient_greater_than(thresh).
|
||||
!*/
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
}
|
||||
|
||||
#endif // DLIB_RuNNING_GRADIENT_ABSTRACT_Hh_
|
||||
|
|
|
@ -258,6 +258,8 @@
|
|||
<term file="linear_algebra.html" name="rotation_matrix" include="dlib/geometry.h"/>
|
||||
<term file="algorithms.html" name="running_stats" include="dlib/statistics.h"/>
|
||||
<term file="algorithms.html" name="running_gradient" include="dlib/statistics/running_gradient.h"/>
|
||||
<term file="dlib/statistics/running_gradient_abstract.h.html" name="probability_gradient_greater_than" include="dlib/statistics/running_gradient.h"/>
|
||||
<term file="dlib/statistics/running_gradient_abstract.h.html" name="probability_gradient_less_than" include="dlib/statistics/running_gradient.h"/>
|
||||
<term file="algorithms.html" name="running_scalar_covariance" include="dlib/statistics.h"/>
|
||||
<term file="algorithms.html" name="mean_sign_agreement" include="dlib/statistics.h"/>
|
||||
<term file="algorithms.html" name="correlation" include="dlib/statistics.h"/>
|
||||
|
|
Loading…
Reference in New Issue