Commit 50a2113f authored by Davis King's avatar Davis King

Added operator+= to discriminant_pca.

parent 81a04634
...@@ -346,7 +346,7 @@ namespace dlib ...@@ -346,7 +346,7 @@ namespace dlib
serialize( item.within_weight, out); serialize( item.within_weight, out);
} }
const discriminant_pca operator+ ( discriminant_pca operator+ (
const discriminant_pca& item const discriminant_pca& item
) const ) const
{ {
...@@ -408,6 +408,14 @@ namespace dlib ...@@ -408,6 +408,14 @@ namespace dlib
return temp; return temp;
} }
discriminant_pca& operator+= (
const discriminant_pca& rhs
)
{
(*this + rhs).swap(*this);
return *this;
}
private: private:
void compute_dpca_matrix ( void compute_dpca_matrix (
......
...@@ -281,7 +281,7 @@ namespace dlib ...@@ -281,7 +281,7 @@ namespace dlib
reduction to num_rows dimensions. reduction to num_rows dimensions.
!*/ !*/
const discriminant_pca operator+ ( discriminant_pca operator+ (
const discriminant_pca& item const discriminant_pca& item
) const; ) const;
/*! /*!
...@@ -298,6 +298,20 @@ namespace dlib ...@@ -298,6 +298,20 @@ namespace dlib
been done to R. been done to R.
!*/ !*/
discriminant_pca& operator+= (
const discriminant_pca& rhs
);
/*!
requires
- in_vector_size() == 0 || rhs.in_vector_size() == 0 || in_vector_size() == rhs.in_vector_size()
(i.e. the in_vector_size() of *this and rhs must match or one must be zero)
- between_class_weight() == rhs.between_class_weight()
- within_class_weight() == rhs.within_class_weight()
ensures
- #*this == *item + rhs
- returns #*this
!*/
void swap ( void swap (
discriminant_pca& item discriminant_pca& item
); );
......
...@@ -252,7 +252,7 @@ namespace ...@@ -252,7 +252,7 @@ namespace
matrix<double> mat, mat2; matrix<double> mat, mat2;
sum_dpca = dpca_type() + dpca_type() + add_dpca1 + dpca_type() + add_dpca2 + add_dpca3 + add_dpca4; sum_dpca += dpca_type() + dpca_type() + add_dpca1 + dpca_type() + add_dpca2 + add_dpca3 + add_dpca4;
dpca.set_within_class_weight(0); dpca.set_within_class_weight(0);
dpca.set_between_class_weight(0); dpca.set_between_class_weight(0);
sum_dpca.set_within_class_weight(0); sum_dpca.set_within_class_weight(0);
......
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