Commit db4ac3ea authored by Davis King's avatar Davis King

Minor code cleanup

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%403336
parent 47296a7e
...@@ -16,7 +16,7 @@ namespace dlib ...@@ -16,7 +16,7 @@ namespace dlib
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
template < template <
typename column_matrix_type typename matrix_type
> >
class discriminant_pca class discriminant_pca
{ {
...@@ -56,12 +56,11 @@ namespace dlib ...@@ -56,12 +56,11 @@ namespace dlib
discriminant_pca_error(const std::string& message): error(message) {} discriminant_pca_error(const std::string& message): error(message) {}
}; };
typedef column_matrix_type column_matrix; typedef typename matrix_type::mem_manager_type mem_manager_type;
typedef typename column_matrix::mem_manager_type mem_manager_type; typedef typename matrix_type::type scalar_type;
typedef typename column_matrix::type scalar_type; typedef typename matrix_type::layout_type layout_type;
typedef typename column_matrix::layout_type layout_type;
const static long N = column_matrix::NR;
typedef matrix<scalar_type,0,0,mem_manager_type,layout_type> general_matrix; typedef matrix<scalar_type,0,0,mem_manager_type,layout_type> general_matrix;
typedef matrix<scalar_type,0,1,mem_manager_type,layout_type> column_matrix;
discriminant_pca ( discriminant_pca (
) )
...@@ -83,7 +82,7 @@ namespace dlib ...@@ -83,7 +82,7 @@ namespace dlib
within_weight = 1; within_weight = 1;
total_sum.set_size(0,0); total_sum.set_size(0);
between_cov.set_size(0,0); between_cov.set_size(0,0);
total_cov.set_size(0,0); total_cov.set_size(0,0);
within_cov.set_size(0,0); within_cov.set_size(0,0);
...@@ -137,9 +136,10 @@ namespace dlib ...@@ -137,9 +136,10 @@ namespace dlib
return between_weight; return between_weight;
} }
template <typename EXP1, typename EXP2>
void add_to_within_class_variance( void add_to_within_class_variance(
const column_matrix& x, const matrix_exp<EXP1>& x,
const column_matrix& y const matrix_exp<EXP2>& y
) )
{ {
// make sure requires clause is not broken // make sure requires clause is not broken
...@@ -168,9 +168,10 @@ namespace dlib ...@@ -168,9 +168,10 @@ namespace dlib
++within_count; ++within_count;
} }
template <typename EXP1, typename EXP2>
void add_to_between_class_variance( void add_to_between_class_variance(
const column_matrix& x, const matrix_exp<EXP1>& x,
const column_matrix& y const matrix_exp<EXP2>& y
) )
{ {
// make sure requires clause is not broken // make sure requires clause is not broken
...@@ -199,8 +200,9 @@ namespace dlib ...@@ -199,8 +200,9 @@ namespace dlib
++between_count; ++between_count;
} }
template <typename EXP>
void add_to_total_variance( void add_to_total_variance(
const column_matrix& x const matrix_exp<EXP>& x
) )
{ {
// make sure requires clause is not broken // make sure requires clause is not broken
...@@ -445,7 +447,7 @@ namespace dlib ...@@ -445,7 +447,7 @@ namespace dlib
} }
general_matrix total_cov; general_matrix total_cov;
general_matrix total_sum; column_matrix total_sum;
scalar_type total_count; scalar_type total_count;
long vect_size; long vect_size;
...@@ -460,11 +462,11 @@ namespace dlib ...@@ -460,11 +462,11 @@ namespace dlib
}; };
template < template <
typename column_matrix typename matrix_type
> >
inline void swap ( inline void swap (
discriminant_pca<column_matrix>& a, discriminant_pca<matrix_type>& a,
discriminant_pca<column_matrix>& b discriminant_pca<matrix_type>& b
) { a.swap(b); } ) { a.swap(b); }
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
......
...@@ -13,13 +13,13 @@ namespace dlib ...@@ -13,13 +13,13 @@ namespace dlib
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
template < template <
typename column_matrix_type typename matrix_type
> >
class discriminant_pca class discriminant_pca
{ {
/*! /*!
REQUIREMENTS ON column_matrix_type REQUIREMENTS ON matrix_type
Must be some type of dlib::matrix capable of representing a column vector. Must be some type of dlib::matrix.
INITIAL VALUE INITIAL VALUE
- in_vector_size() == 0 - in_vector_size() == 0
...@@ -60,12 +60,11 @@ namespace dlib ...@@ -60,12 +60,11 @@ namespace dlib
a DPCA matrix. a DPCA matrix.
!*/ !*/
typedef column_matrix_type column_matrix; typedef typename matrix_type::mem_manager_type mem_manager_type;
typedef typename column_matrix::mem_manager_type mem_manager_type; typedef typename matrix_type::type scalar_type;
typedef typename column_matrix::type scalar_type; typedef typename matrix_type::layout_type layout_type;
typedef typename column_matrix::layout_type layout_type;
const static long N = column_matrix::NR;
typedef matrix<scalar_type,0,0,mem_manager_type,layout_type> general_matrix; typedef matrix<scalar_type,0,0,mem_manager_type,layout_type> general_matrix;
typedef matrix<scalar_type,0,1,mem_manager_type,layout_type> column_matrix;
discriminant_pca ( discriminant_pca (
); );
...@@ -128,8 +127,8 @@ namespace dlib ...@@ -128,8 +127,8 @@ namespace dlib
!*/ !*/
void add_to_within_class_variance( void add_to_within_class_variance(
const column_matrix& x, const matrix_exp& x,
const column_matrix& y const matrix_exp& y
); );
/*! /*!
requires requires
...@@ -147,8 +146,8 @@ namespace dlib ...@@ -147,8 +146,8 @@ namespace dlib
!*/ !*/
void add_to_between_class_variance( void add_to_between_class_variance(
const column_matrix& x, const matrix_exp& x,
const column_matrix& y const matrix_exp& y
); );
/*! /*!
requires requires
...@@ -166,7 +165,7 @@ namespace dlib ...@@ -166,7 +165,7 @@ namespace dlib
!*/ !*/
void add_to_total_variance( void add_to_total_variance(
const column_matrix& x const matrix_exp& x
); );
/*! /*!
requires requires
...@@ -271,21 +270,21 @@ namespace dlib ...@@ -271,21 +270,21 @@ namespace dlib
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
template < template <
typename column_matrix typename matrix_type
> >
inline void swap ( inline void swap (
discriminant_pca<column_matrix>& a, discriminant_pca<matrix_type>& a,
discriminant_pca<column_matrix>& b discriminant_pca<matrix_type>& b
) { a.swap(b); } ) { a.swap(b); }
/*! /*!
provides a global swap function provides a global swap function
!*/ !*/
template < template <
typename column_matrix, typename matrix_type,
> >
void deserialize ( void deserialize (
discriminant_pca<column_matrix>& item, discriminant_pca<matrix_type>& item,
std::istream& in std::istream& in
); );
/*! /*!
...@@ -293,10 +292,10 @@ namespace dlib ...@@ -293,10 +292,10 @@ namespace dlib
!*/ !*/
template < template <
typename column_matrix, typename matrix_type,
> >
void serialize ( void serialize (
const discriminant_pca<column_matrix>& item, const discriminant_pca<matrix_type>& item,
std::ostream& out std::ostream& out
); );
/*! /*!
......
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