CombinedFeatures.cpp

Go to the documentation of this file.
00001 /*
00002  * This program is free software; you can redistribute it and/or modify
00003  * it under the terms of the GNU General Public License as published by
00004  * the Free Software Foundation; either version 3 of the License, or
00005  * (at your option) any later version.
00006  *
00007  * Written (W) 1999-2008 Soeren Sonnenburg
00008  * Written (W) 1999-2008 Gunnar Raetsch
00009  * Copyright (C) 1999-2008 Fraunhofer Institute FIRST and Max-Planck-Society
00010  */
00011 
00012 #include "features/CombinedFeatures.h"
00013 #include "lib/io.h"
00014 
00015 class CCombinedFeatures;
00016 
00017 CCombinedFeatures::CCombinedFeatures()
00018 : CFeatures(0)
00019 {
00020     feature_list=new CList<CFeatures*>(true);
00021 }
00022 
00023 CCombinedFeatures::CCombinedFeatures(const CCombinedFeatures & orig)
00024 : CFeatures(0)
00025 {
00026 }
00027 
00028 CFeatures* CCombinedFeatures::duplicate() const
00029 {
00030     return new CCombinedFeatures(*this);
00031 }
00032 
00033 CCombinedFeatures::~CCombinedFeatures()
00034 {
00035     delete feature_list;
00036 }
00037 
00038 void CCombinedFeatures::list_feature_objs()
00039 {
00040     SG_INFO( "BEGIN COMBINED FEATURES LIST - ");
00041     this->list_feature_obj();
00042 
00043     CListElement<CFeatures*> * current = NULL ;
00044     CFeatures* f=get_first_feature_obj(current);
00045 
00046     while (f)
00047     {
00048         f->list_feature_obj();
00049         f=get_next_feature_obj(current);
00050     }
00051 
00052     SG_INFO( "END COMBINED FEATURES LIST - ");
00053 }
00054 
00055 bool CCombinedFeatures::check_feature_obj_compatibility(CCombinedFeatures* comb_feat)
00056 {
00057     bool result=false;
00058 
00059     if (comb_feat && (this->get_num_feature_obj() == comb_feat->get_num_feature_obj()) )
00060     {
00061         CFeatures* f1=this->get_first_feature_obj();
00062         CFeatures* f2=comb_feat->get_first_feature_obj();
00063 
00064         if (f1 && f2 && f1->check_feature_compatibility(f2))
00065         {
00066             while( ( (f1=this->get_next_feature_obj()) != NULL )  && 
00067                    ( (f2=comb_feat->get_next_feature_obj()) != NULL) )
00068             {
00069                 if (!f1->check_feature_compatibility(f2))
00070                 {
00071                     SG_INFO( "not compatible, combfeat\n");
00072                     comb_feat->list_feature_objs();
00073                     SG_INFO( "vs this\n");
00074                     this->list_feature_objs();
00075                     return false;
00076                 }
00077             }
00078 
00079             SG_DEBUG( "features are compatible\n");
00080             result=true;
00081         }
00082         else
00083             SG_WARNING( "first 2 features not compatible\n");
00084     }
00085     else
00086     {
00087         SG_WARNING( "number of features in combined feature objects differs (%d != %d)\n", this->get_num_feature_obj(), comb_feat->get_num_feature_obj());
00088         SG_INFO( "compare\n");
00089         comb_feat->list_feature_objs();
00090         SG_INFO( "vs this\n");
00091         this->list_feature_objs();
00092     }
00093 
00094     return result;
00095 }

SHOGUN Machine Learning Toolbox - Documentation