Changeset 2334


Ignore:
Timestamp:
Oct 15, 2010, 4:35:09 AM (11 years ago)
Author:
Peter
Message:

fixes #625

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/distance_test.cc

    r2202 r2334  
    2828#include "yat/statistics/EuclideanDistance.h"
    2929#include "yat/statistics/PearsonDistance.h"
     30#include "yat/utility/concept_check.h"
    3031#include "yat/utility/DataIterator.h"
    3132#include "yat/utility/Matrix.h"
     
    3536
    3637#include <boost/concept_archetype.hpp>
     38#include <boost/concept_check.hpp>
    3739
    3840#include <cassert>
     
    193195                   unsigned int long N)
    194196{
     197  BOOST_CONCEPT_ASSERT((utility::DistanceConcept<Distance>));
    195198  test_duplicate(dist, suite, N);
    196199  test_rescaling(dist, suite, N);
  • trunk/yat/classifier/IGP.h

    r2119 r2334  
    2727#include "MatrixLookup.h"
    2828#include "Target.h"
     29#include "yat/utility/concept_check.h"
    2930#include "yat/utility/Vector.h"
    3031#include "yat/utility/yat_assert.h"
     32
     33#include <boost/concept_check.hpp>
    3134
    3235#include <cmath>
     
    9295    : matrix_(data), target_(target)
    9396  {   
     97    BOOST_CONCEPT_ASSERT((utility::DistanceConcept<Distance>));
    9498    calculate();
    9599  }
     
    99103    : matrix_(data), target_(target), distance_(dist)
    100104  {   
     105    BOOST_CONCEPT_ASSERT((utility::DistanceConcept<Distance>));
    101106    calculate();
    102107  }
  • trunk/yat/classifier/KNN.h

    r2210 r2334  
    3131#include "SupervisedClassifier.h"
    3232#include "Target.h"
     33#include "yat/utility/concept_check.h"
    3334#include "yat/utility/Exception.h"
    3435#include "yat/utility/Matrix.h"
    3536#include "yat/utility/yat_assert.h"
     37
     38#include <boost/concept_check.hpp>
    3639
    3740#include <cmath>
     
    191194    : SupervisedClassifier(),data_ml_(0),data_mlw_(0),target_(0),k_(3)
    192195  {
     196    BOOST_CONCEPT_ASSERT((utility::DistanceConcept<Distance>));
    193197  }
    194198
     
    197201    : SupervisedClassifier(),data_ml_(0),data_mlw_(0),target_(0),k_(3), distance_(dist)
    198202  {
     203    BOOST_CONCEPT_ASSERT((utility::DistanceConcept<Distance>));
    199204  }
    200205
  • trunk/yat/classifier/NCC.h

    r2210 r2334  
    3232#include "yat/statistics/Averager.h"
    3333#include "yat/statistics/AveragerWeighted.h"
     34#include "yat/utility/concept_check.h"
    3435#include "yat/utility/Exception.h"
    3536#include "yat/utility/Matrix.h"
     
    3839#include "yat/utility/stl_utility.h"
    3940#include "yat/utility/yat_assert.h"
     41
     42#include <boost/concept_check.hpp>
    4043
    4144#include <iterator>
     
    179182    : SupervisedClassifier(), centroids_nan_(false)
    180183  {
     184    BOOST_CONCEPT_ASSERT((utility::DistanceConcept<Distance>));
    181185  }
    182186
     
    185189    : SupervisedClassifier(), centroids_nan_(false), distance_(dist)
    186190  {
     191    BOOST_CONCEPT_ASSERT((utility::DistanceConcept<Distance>));
    187192  }
    188193
  • trunk/yat/utility/concept_check.h

    r2263 r2334  
    2525#include "iterator_traits.h"
    2626
     27#include <boost/concept_archetype.hpp>
    2728#include <boost/concept_check.hpp>
    2829
     
    4647     }
    4748     \endcode
     49
     50     \since New in yat 0.7
    4851  */
    4952  template <class T>
     
    102105     }
    103106     \endcode
     107
     108     \since New in yat 0.7
    104109  */
    105110  template <class T>
     
    154159     }
    155160     \endcode
     161
     162     \since New in yat 0.7
    156163  */
    157164  template <class T>
     
    201208     }
    202209     \endcode
     210
     211     \since New in yat 0.7
    203212  */
    204213  template <class T>
     
    230239      BOOST_CONCEPT_ASSERT((boost::Convertible<value_type, DataWeight>));
    231240    }
    232 
     241  };
     242
     243
     244  /**
     245     \brief Concept check for a \ref concept_distance
     246
     247     This class is intended to be used in a <a
     248     href="\boost_url/concept_check/using_concept_check.htm">
     249     BOOST_CONCEPT_ASSERT </a>
     250
     251     \code
     252     template<class Distance>
     253     void some_function(double x)
     254     {
     255     BOOST_CONCEPT_ASSERT((DistanceConcept<Distance>));
     256     ...
     257     }
     258     \endcode
     259
     260     \since New in yat 0.7
     261  */
     262  template <class T>
     263  class DistanceConcept
     264  {
     265  public:
     266    /**
     267       \brief function doing the concept test
     268     */
     269    BOOST_CONCEPT_USAGE(DistanceConcept)
     270    {
     271      boost::random_access_iterator_archetype<double> unweighted;
     272      boost::random_access_iterator_archetype<DataWeight> weighted;
     273      double d;
     274      d = distance_(unweighted, unweighted, unweighted);
     275      d = distance_(unweighted, unweighted, weighted);
     276      d = distance_(weighted, weighted, unweighted);
     277      d = distance_(weighted, weighted, weighted);
     278    }
     279  private:
     280    T distance_;
    233281  };
    234282
Note: See TracChangeset for help on using the changeset viewer.