Changeset 936 for trunk/yat/classifier


Ignore:
Timestamp:
Oct 6, 2007, 1:02:08 AM (14 years ago)
Author:
Peter
Message:

reimplementing yat_assert as a throwing function

Location:
trunk/yat/classifier
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/classifier/IGP.h

    r925 r936  
    3434#include <cmath>
    3535#include <limits>
     36#include <stdexcept>
    3637
    3738namespace theplu {
     
    8283    : matrix_(data), target_(target)
    8384  {   
    84     yat_assert(target_.size()==matrix_.columns());
     85    utility::yat_assert<std::runtime_error>(target_.size()==matrix_.columns());
    8586   
    8687    // Calculate IGP for each class
  • trunk/yat/classifier/KNN.h

    r931 r936  
    1414#include <cmath>
    1515#include <map>
     16#include <stdexcept>
    1617
    1718namespace theplu {
     
    129130        for(size_t j=0; j<input.columns(); j++) {
    130131          classifier::DataLookupWeighted1D test(*weighted_input,j,false);
    131           yat_assert(training.size()==test.size());
    132           (*distances)(i,j)=statistics::vector_distance(training.begin(),training.end(),test.begin(),typename statistics::vector_distance_traits<Distance>::distance());
    133           yat_assert(!std::isnan((*distances)(i,j)));
     132          utility::yat_assert<std::runtime_error>(training.size()==test.size());
     133          (*distances)(i,j) =
     134            statistics::vector_distance(training.begin(),training.end(),
     135                                        test.begin(), typename statistics::vector_distance_traits<Distance>::distance());
     136          utility::yat_assert<std::runtime_error>(!std::isnan((*distances)(i,j)));
    134137        }
    135138      }
  • trunk/yat/classifier/NCC.h

    r931 r936  
    5050#include <map>
    5151#include <cmath>
    52 
     52#include <stdexcept>
    5353
    5454namespace theplu {
     
    234234        for(size_t k=0; k<centroids_->columns();k++) {
    235235          DataLookup1D centroid(unweighted_centroids,k,false);           
    236           yat_assert(in.size()==centroid.size());
     236          utility::yat_assert<std::runtime_error>(in.size()==centroid.size());
    237237          prediction(k,j)=statistics::
    238238            vector_distance(in.begin(),in.end(),centroid.begin(),
     
    252252          for(size_t k=0; k<centroids_->columns();k++) {
    253253            DataLookupWeighted1D centroid(weighted_centroids,k,false);
    254             yat_assert(in.size()==centroid.size());
     254            utility::yat_assert<std::runtime_error>(in.size()==centroid.size());
    255255            prediction(k,j)=statistics::
    256256              vector_distance(in.begin(),in.end(),centroid.begin(),
     
    267267          for(size_t k=0; k<centroids_->columns();k++) {
    268268            DataLookupWeighted1D centroid(weighted_centroids,k,false);
    269             yat_assert(in.size()==centroid.size());
     269            utility::yat_assert<std::runtime_error>(in.size()==centroid.size());
    270270            prediction(k,j)=statistics::
    271271              vector_distance(in.begin(),in.end(),centroid.begin(),
Note: See TracChangeset for help on using the changeset viewer.