Changeset 1554


Ignore:
Timestamp:
Oct 9, 2008, 8:31:34 PM (13 years ago)
Author:
Jari Häkkinen
Message:

Fixes #192. Using std::numeric_limits, since impute algorithms are slightly changed template results also changes.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/data/knni_result.data

    r175 r1554  
    440.4372 0.382144 0.763342 0.32924 0.27823 0.3827 0.234764 0.384734 0.398795 0.23498 0.1234
    550.8624 0.286482 0.83248 0.72846 0.28468 0.2347 0.23234 0.98973 0.29874 0.32894 0.1234
    6 0.8624 0.286482 0.83248 0.72846 0.284680000063 0.2347 0.23234 0.98973 0.29874 0.32894 0.1234
     60.8624 0.286482 0.83248 0.72846 0.28468 0.2347 0.23234 0.98973 0.29874 0.32894 0.1234
    770.2342 0.23878 0.97437 0.76236 0.32764 0.3474 0.43276 0.34555 0.29948 0.265321643162 0.1234
    880.2347 0.56783 0.78435 0.35763 0.23468 0.7384 0.23578 0.345533 0.235948 0.32458 0.1234
  • trunk/test/data/wenni_result.data

    r175 r1554  
    440.4372 0.382144 0.763342 0.32924 0.27823 0.3827 0.234764 0.384734 0.398795 0.23498 0.1234
    550.8624 0.286482 0.83248 0.72846 0.28468 0.2347 0.23234 0.98973 0.29874 0.32894 0.1234
    6 0.8624 0.286482 0.83248 0.72846 0.284680000063 0.2347 0.23234 0.98973 0.29874 0.32894 0.1234
     60.8624 0.286482 0.83248 0.72846 0.28468 0.2347 0.23234 0.98973 0.29874 0.32894 0.1234
    770.2342 0.23878 0.97437 0.76236 0.32764 0.3474 0.43276 0.34555 0.29948 0.27341113502 0.1234
    880.2347 0.56783 0.78435 0.35763 0.23468 0.7384 0.23578 0.345533 0.235948 0.32458 0.1234
  • trunk/test/nni_test.cc

    r1487 r1554  
    7373  utility::Matrix control(control_stream);
    7474  control-=knni.imputed_data();
    75   double error_bound = 5e-13;
     75  // error_bound is arbitrarily selected
     76  double error_bound = std::numeric_limits<double>::epsilon()*1e4;
    7677  for (unsigned int i=0; i<control.rows(); i++)
    7778    for (unsigned int j=0; j<control.columns(); j++)
  • trunk/yat/utility/WeNNI.cc

    r1487 r1554  
    55  Copyright (C) 2005 Peter Johansson
    66  Copyright (C) 2006 Jari Häkkinen
    7   Copyright (C) 2007 Jari Häkkinen, Peter Johansson
    8   Copyright (C) 2008 Peter Johansson
     7  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    98
    109  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    3130#include <cmath>
    3231#include <fstream>
     32#include <limits>
    3333
    3434namespace theplu {
     
    5252  unsigned int WeNNI::estimate(void)
    5353  {
     54    double small_number=std::numeric_limits<double>::epsilon();
    5455    for (size_t i=0; i<data_.rows(); i++) {
    5556      std::vector<std::pair<size_t,double> > distance(calculate_distances(i));
     
    6465             ++k) {
    6566          // Avoid division with zero (perfect match vectors)
    66           double d=(distance[*k].second ? distance[*k].second : 1e-10);
     67          double d=(distance[*k].second ? distance[*k].second : small_number);
    6768          new_value+=(weight_(distance[*k].first,j) *
    6869                      data_(distance[*k].first,j)/d);
  • trunk/yat/utility/kNNI.cc

    r1487 r1554  
    55  Copyright (C) 2005 Peter Johansson
    66  Copyright (C) 2006 Jari Häkkinen
    7   Copyright (C) 2007 Jari Häkkinen, Peter Johansson
    8   Copyright (C) 2008 Peter Johansson
     7  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    98
    109  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    3130#include <fstream>
    3231#include <vector>
     32#include <limits>
    3333
    3434namespace theplu {
     
    5757  unsigned int kNNI::estimate(void)
    5858  {
     59    double small_number=std::numeric_limits<double>::epsilon();
    5960    for (size_t i=0; i<mv_rows_.size(); i++) {
    6061      std::vector<std::pair<size_t,double> >
     
    7071               ++k) {
    7172            // Avoid division with zero (perfect match vectors)
    72             double d=(distance[*k].second ? distance[*k].second : 1e-10);
     73            double d=(distance[*k].second ? distance[*k].second : small_number);
    7374            new_value+=data_(distance[*k].first,j)/d;
    7475            norm+=1.0/d;
Note: See TracChangeset for help on using the changeset viewer.