Changes from tags/0.5.2 at r4063 to tags/0.5.3 at r4063


Ignore:
Location:
tags/0.5.3
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • tags/0.5.3/NEWS

    r4063 r4063  
    22
    33See the end of this file for copyrights and conditions.
     4
     5Version 0.5.3 (released 7 May 2009)
     6
     7  - fixed serious bug in qQuantileNormalization related to sorting
     8    with NaNs in vectors (issue #535). VectorMutable and Percentiler
     9    classes were affected with the same issue.
     10  - fixed problem with running configure on 64-bit CentOS (issue #527)
     11  - make check works again (issue #528)
     12
     13  A complete list of closed tickets can be found here [[br]]
     14  http://dev.thep.lu.se/yat/query?status=closed&milestone=yat+0.5.3
    415
    516Version 0.5.2 (released 17 March 2009)
  • tags/0.5.3/configure.ac

    r4063 r4063  
    135135AC_SEARCH_LIBS(cblas_sdsdot,cblas,cblas_found="yes",
    136136  AC_SEARCH_LIBS(ATL_sdsdot,atlas,
    137     AC_SEARCH_LIBS(cblas_sdsdot,cblas,atlas_found="yes",
     137    AC_SEARCH_LIBS(cblas_srot,cblas,atlas_found="yes",
    138138                   atlas_found="partial",-m64),
    139139      AC_SEARCH_LIBS(cblas_dswap,gslcblas,gslcblas_found="yes"),-m64),)
    140 # CBLAS used in test of GSL
    141 gsl_cblas_lib=-lgslcblas
    142 if test ${cblas_found} = "yes"; then
    143   gsl_cblas_lib=-lcblas
    144 fi
    145 if test ${atlas_found} = "yes"; then
    146   YAT_CXX_ADD_FLAG([CXXFLAGS], [-m64])
    147   YAT_LD_ADD_FLAG([LDFLAGS], [-m64])
    148   gsl_cblas_lib=-latlas
    149 fi
    150 export GSL_CBLAS_LIB=${gsl_cblas_lib}
    151140
    152141# GNU Scientific Library, GSL http://www.gnu.org/software/gsl/, checks
     
    159148   LIBS="-lgsl $LIBS"
    160149   # grep words starting with '-L' in other words LDFLAGS
    161   for i in $GSL_LIBS; do
    162     if test ${i:0:2} = "-L"; then
    163        YAT_LD_ADD_FLAG([LDFLAGS], [$i])
    164      fi
     150  for i in $GSL_LIBS; do
     151      if test ${i:0:2} = "-L"; then
     152           YAT_LD_ADD_FLAG([LDFLAGS], [$i])
     153       fi
    165154   done
     155   YAT_CPP_ADD_FLAG([CPPFLAGS], [`gsl-config --cflags`])
    166156fi
    167157
  • tags/0.5.3/doc/build_tool.doxygen

    r4063 r4063  
    9393\endverbatim
    9494
    95 or when using libtool you could use \c YAT_LA_FILE:
    96 
    97 \verbatim
    98    AM_CPPFLAGS = $(YAT_CPPFLAGS)
    99    AM_CXXFLAGS = $(YAT_CXXFLAGS)
    100    LDADD = $(YAT_LA_FILE)
    101 \endverbatim
    102 
    10395If you have yat installed with a different prefix than aclocal, for
    10496example, if yat is installed in prefix \c /usr/local and aclocal is
  • tags/0.5.3/m4/gsl.m4

    r4063 r4063  
    5353      ac_save_LIBS="$LIBS"
    5454      CFLAGS="$CFLAGS $GSL_CFLAGS"
    55       LIBS="$LIBS $GSL_LIBS"
     55      LIBS="$GSL_LIBS $LIBS"
    5656
    5757      rm -f conf.gsltest
     
    136136          echo "*** Could not run GSL test program, checking why..."
    137137          CFLAGS="$CFLAGS $GSL_CFLAGS"
    138           LIBS="$LIBS $GSL_LIBS"
     138          LIBS="$GSL_LIBS $LIBS"
    139139          AC_TRY_LINK([
    140140#include <stdio.h>
  • tags/0.5.3/m4/version.m4

    r4063 r4063  
    2828m4_define([MINOR_VERSION], [5])
    2929# PATCH - Modify for every released patch
    30 m4_define([PATCH_VERSION], [2])
     30m4_define([PATCH_VERSION], [3])
    3131
    3232# DEV_BUILD - When rolling a tarball we set this to `false'. In
     
    5757# yat-0.5.1  2:0:0
    5858# yat-0.5.2  2:1:0
     59# yat-0.5.3  2:2:0
    5960#
    60 m4_define([YAT_LT_VERSION_INFO], [2:1:0])
    61 
    6261# *Accidently, the libtool number was not updated for yat 0.5
     62#
     63m4_define([YAT_LT_VERSION_INFO], [2:2:0])
    6364
    6465###
  • tags/0.5.3/test/Makefile.am

    r4063 r4063  
    77# Copyright (C) 2005 Jari Häkkinen, Peter Johansson
    88# Copyright (C) 2006, 2007, 2008 Jari Häkkinen, Peter Johansson, Markus Ringnér
    9 # Copyright (C) 2009 Peter Johansson
     9# Copyright (C) 2009 Jari Häkkinen, Peter Johansson
    1010#
    1111# This file is part of the yat library, http://dev.thep.lu.se/yat
  • tags/0.5.3/test/commandline_test.cc

    r4063 r4063  
    2424
    2525#include "yat/utility/CommandLine.h"
     26#include "yat/utility/FileUtil.h"
    2627#include "yat/utility/OptionArg.h"
    2728#include "yat/utility/OptionFile.h"
     29#include "yat/utility/OptionOutFile.h"
    2830#include "yat/utility/OptionHelp.h"
    2931#include "yat/utility/OptionSwitch.h"
     
    3941void test_exception_msg(yat::test::Suite& error);
    4042bool test_file(yat::test::Suite& error);
     43bool test_file2(yat::test::Suite& error);
    4144bool test_failures(yat::test::Suite& error);
    4245bool test_option_name_clash(yat::test::Suite& suite);
     
    5558    suite.add(test_arg(suite));
    5659    suite.add(test_file(suite));
     60    suite.add(test_file2(suite));
    5761    suite.add(test_failures(suite));
    5862    suite.add(test_option_name_clash(suite));
     
    494498}
    495499
     500bool test_file2(yat::test::Suite& suite)
     501{
     502  suite.err() << "Testing OptionOutFile... ";
     503
     504  // Peter, creation of this directory should perhaps be in a more central place
     505  FileUtil dir("testSubDir");
     506  if (!dir.exists())
     507    mkdir(dir.path().c_str(), 0755);
     508
     509  FileUtil subdir("testSubDir/commandline_test.dir");
     510  if (!subdir.exists()) {
     511    if (mkdir(subdir.path().c_str(), 0555)) {
     512      suite.err() << "mkdir " << subdir.path() << " failed\n";
     513      return false;
     514    }
     515  }
     516  else
     517    if (!subdir.permissions("w")) {
     518      suite.err() << subdir.path() << " already exists\n";
     519      return false;
     520    }
     521
     522  bool ok=true;
     523  CommandLine cmd;
     524  OptionOutFile out(cmd, "o,out", "output to file");
     525  OptionSwitch help(cmd, "h,help", "display this help and exit");
     526
     527  {
     528    int ac = 3;
     529    char* av[] = { "test_prog", "--out",
     530                   "testSubDir/commandline_test.dir/out.txt"};
     531    try {
     532      cmd.parse(ac,av);
     533      ok =false;
     534    }
     535    catch (cmd_error& e) {
     536      suite.err() << "ok\n";                                        \
     537      suite.err() << "catch expected error: " << e.what() << "\n";
     538    }
     539  }
     540  return ok;
     541}
     542
    496543bool test_option_name_clash(yat::test::Suite& suite)
    497544{
  • tags/0.5.3/test/normalization_test.cc

    r4063 r4063  
    206206  suite.err() << "Testing with missing value in source\n";
    207207  // adding a missing value
    208   src_w.insert(src_w.begin(),
    209                DataWeight(std::numeric_limits<double>::quiet_NaN(), 0.0));
     208  std::vector<utility::DataWeight>::iterator MWi=src_w.begin();
     209  MWi+=5;
     210  src_w.insert(MWi, DataWeight(std::numeric_limits<double>::quiet_NaN(), 0.0));
    210211  std::vector<utility::DataWeight> result_w2(src_w.size());
    211212  qQN(src_w.begin(), src_w.end(), result_w2.begin());
    212   // excluding missing value (result_w[0])
     213  // excluding missing value from comparison in suite.equal_range
     214  MWi=result_w2.begin();
     215  MWi+=5;
     216  result_w2.erase(MWi);
    213217  suite.add(suite.equal_range(utility::data_iterator(result_w.begin()),
    214218                              utility::data_iterator(result_w.end()),
    215                               ++utility::data_iterator(result_w2.begin())));
     219                              utility::data_iterator(result_w2.begin())));
    216220
    217221  suite.err() << "testing with weighted target" << std::endl;
     
    223227  std::vector<utility::DataWeight> result_w3(src_w.size());
    224228  qQNw(src_w.begin(), src_w.end(), result_w3.begin());
    225   suite.add(suite.equal_range(++utility::data_iterator(result_w3.begin()),
     229  // excluding missing value from comparison in suite.equal_range
     230  MWi=result_w3.begin();
     231  MWi+=5;
     232  result_w3.erase(MWi);
     233  suite.add(suite.equal_range(utility::data_iterator(result_w3.begin()),
    226234                              utility::data_iterator(result_w3.end()),
    227                               ++utility::data_iterator(result_w2.begin())));
     235                              utility::data_iterator(result_w2.begin())));
    228236 
    229237}
  • tags/0.5.3/test/statistics_test.cc

    r4063 r4063  
    66  Copyright (C) 2006 Jari Häkkinen, Peter Johansson, Markus Ringnér
    77  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
     8  Copyright (C) 2009 Peter Johansson
    89
    910  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    3334#include <cstdlib>
    3435#include <iostream>
     36#include <limits>
    3537#include <map>
    3638#include <vector>
     
    3840using namespace theplu::yat;
    3941void test_percentiler(test::Suite&);
     42void test_percentiler_nan(test::Suite&);
    4043
    4144template<typename RandomAccessIterator>
     
    7174  // testing percentile2
    7275  test_percentiler(suite);
     76
     77  // test weighted percentiler with NaNs
     78  test_percentiler_nan(suite);
    7379
    7480  double skewness_gsl=statistics::skewness(gsl_vec);
     
    144150}
    145151
     152void test_percentiler_nan(test::Suite& suite)
     153{
     154  using utility::DataWeight;
     155  std::vector<double> v;
     156  v.push_back(1);
     157  v.push_back(10);
     158  v.push_back(4);
     159  v.push_back(2);
     160  std::vector<DataWeight> wv(5);
     161  wv[0] = DataWeight(v[0]);
     162  wv[1] = DataWeight(v[1]);
     163  wv[2] = DataWeight(std::numeric_limits<double>::quiet_NaN(), 0.0);
     164  wv[3] = DataWeight(v[2]);
     165  wv[4] = DataWeight(v[3]);
     166
     167  cmp_percentiler(suite, v.begin(), v.end(), wv.begin(), wv.end());
     168}
     169
    146170template<typename RandomAccessIterator>
    147171void test_percentiler(test::Suite& suite,
  • tags/0.5.3/test/vector_test.cc

    r4063 r4063  
    4949  }
    5050}
     51
     52void test_sort(test::Suite&);
    5153
    5254int main(int argc,char* argv[])
     
    348350    theplu::yat::utility::Vector vec2(vec);
    349351  }
     352
     353  // test that sort can handle NaN properly
     354  test_sort(suite);
     355
    350356  return suite.return_value();
    351357}
     358
     359void test_sort(test::Suite& suite)
     360{
     361  utility::Vector vec(5);
     362  vec(0) = 0;
     363  vec(1) = 10;
     364  vec(2) = std::numeric_limits<double>::quiet_NaN();
     365  vec(3) = 2;
     366  vec(4) = 5;
     367
     368  sort(vec);
     369  for (size_t i=0; i<vec.size(); ++i)
     370    for (size_t j=i+1; j<vec.size(); ++j) {
     371      if (vec(j)<vec(i)) {
     372        suite.err() << "Vector: '" << vec << "' is not sorted because '"
     373                    << vec(j) << "' is less than '" << vec(i) << "'\n";
     374        suite.add(false);
     375      }
     376    }
     377}
  • tags/0.5.3/yat/classifier/EnsembleBuilder.h

    r4063 r4063  
    99  Copyright (C) 2007 Jari Häkkinen, Peter Johansson
    1010  Copyright (C) 2008 Jari Häkkinen, Peter Johansson, Markus Ringnér
     11  Copyright (C) 2009 Jari Häkkinen
    1112
    1213  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    128129  // implementation
    129130
    130   template <class C, class D>
    131   EnsembleBuilder<C,D>::EnsembleBuilder(const C& sc, const D& data,
    132                                         const Sampler& sampler)
    133     : mother_(sc),subset_(new SubsetGenerator<D>(sampler,data))
    134   {
    135   }
    136 
    137 
    138   template <class C, class D>
    139   EnsembleBuilder<C, D>::EnsembleBuilder(const C& sc, const D& data,
    140                                          const Sampler& sampler,
    141                                          FeatureSelector& fs)
     131  template <class Classifier, class Data>
     132  EnsembleBuilder<Classifier, Data>::EnsembleBuilder(const Classifier& sc,
     133                                                     const Data& data,
     134                                                     const Sampler& sampler)
     135    : mother_(sc),subset_(new SubsetGenerator<Data>(sampler,data))
     136  {
     137  }
     138
     139
     140  template <class Classifier, class Data>
     141  EnsembleBuilder<Classifier, Data>::EnsembleBuilder(const Classifier& sc,
     142                                                     const Data& data,
     143                                                     const Sampler& sampler,
     144                                                     FeatureSelector& fs)
    142145    : mother_(sc),
    143       subset_(new SubsetGenerator<D>(sampler,data,fs))
    144   {
    145   }
    146 
    147 
    148   template <class C, class D>
    149   EnsembleBuilder<C, D>::~EnsembleBuilder(void)
     146      subset_(new SubsetGenerator<Data>(sampler,data,fs))
     147  {
     148  }
     149
     150
     151  template <class Classifier, class Data>
     152  EnsembleBuilder<Classifier, Data>::~EnsembleBuilder(void)
    150153  {
    151154    for(size_t i=0; i<classifier_.size(); i++)
     
    155158
    156159
    157   template <class C, class D>
    158   void EnsembleBuilder<C, D>::build(void)
     160  template <class Classifier, class Data>
     161  void EnsembleBuilder<Classifier, Data>::build(void)
    159162  {
    160163    if (classifier_.empty()){
    161164      for(unsigned long i=0; i<subset_->size();++i) {
    162         C* classifier = mother_.make_classifier();
     165        Classifier* classifier = mother_.make_classifier();
    163166        classifier->train(subset_->training_data(i),
    164167                          subset_->training_target(i));
     
    169172
    170173
    171   template <class C, class D>
    172   const C& EnsembleBuilder<C, D>::classifier(size_t i) const
     174  template <class Classifier, class Data>
     175  const Classifier& EnsembleBuilder<Classifier, Data>::classifier(size_t i) const
    173176  {
    174177    return *(classifier_[i]);
     
    176179
    177180
    178   template <class C, class D>
    179   void EnsembleBuilder<C, D>::predict
    180   (const D& data, std::vector<std::vector<statistics::Averager> >& result)
     181  template <class Classifier, class Data>
     182  void EnsembleBuilder<Classifier, Data>::predict
     183  (const Data& data, std::vector<std::vector<statistics::Averager> >& result)
    181184  {
    182185    result = std::vector<std::vector<statistics::Averager> >
     
    187190
    188191    for(unsigned long k=0;k<size();++k) {       
    189       D sub_data =  test_data(data, k);
     192      Data sub_data = test_data(data, k);
    190193      classifier(k).predict(sub_data,prediction);
    191194    }
     
    197200
    198201 
    199   template <class C, class D>
    200   unsigned long EnsembleBuilder<C, D>::size(void) const
     202  template <class Classifier, class Data>
     203  unsigned long EnsembleBuilder<Classifier, Data>::size(void) const
    201204  {
    202205    return classifier_.size();
     
    204207
    205208
    206   template <class C, class D>
    207   MatrixLookup EnsembleBuilder<C, D>::test_data(const MatrixLookup& data,
     209  template <class Classifier, class Data>
     210  MatrixLookup EnsembleBuilder<Classifier,
     211                               Data>::test_data(const MatrixLookup& data,
    208212                                                size_t k)
    209213  {
     
    212216 
    213217
    214   template <class C, class D>
     218  template <class Classifier, class Data>
    215219  MatrixLookupWeighted
    216   EnsembleBuilder<C, D>::test_data(const MatrixLookupWeighted& data, size_t k)
     220  EnsembleBuilder<Classifier, Data>::test_data(const MatrixLookupWeighted& data,
     221                                               size_t k)
    217222  {
    218223    return MatrixLookupWeighted(data, subset_->training_features(k), true);
     
    220225 
    221226
    222   template <class C, class D>
     227  template <class Classifier, class Data>
    223228  KernelLookup
    224   EnsembleBuilder<C, D>::test_data(const KernelLookup& kernel, size_t k)
     229  EnsembleBuilder<Classifier, Data>::test_data(const KernelLookup& kernel,
     230                                               size_t k)
    225231  {
    226232    // weighted case
     
    245251 
    246252
    247   template <class C, class D>
     253  template <class Classifier, class Data>
    248254  const std::vector<std::vector<statistics::Averager> >&
    249   EnsembleBuilder<C, D>::validate(void)
     255  EnsembleBuilder<Classifier, Data>::validate(void)
    250256  {
    251257    // Don't recalculate validation_result_
  • tags/0.5.3/yat/normalizer/qQuantileNormalizer.h

    r4063 r4063  
    5959     - Data are not assumed to be sorted.
    6060     - Partition sorted \a target data in Q parts. Q must be 3 or larger
    61        because of requirements from the underlying cspline fit
     61       because of requirements from the underlying cubic spline fit
    6262     - Calculate the arithmetic (weighted) mean for each part, the mean is
    6363       assigned to the mid point of each part.
    64      - Do the above for the data to be tranformed (called \a source
     64     - Do the above for the data to be transformed (called \a source
    6565       here).
    6666     - For each part, calculate the difference between the \a target
     
    8282  public:
    8383    /**
    84        \brief Contructor
     84       \brief Constructor
    8585
    8686       Divides a sorted copy of range [\a first,\a last) into \a Q
     
    9393       last).
    9494
    95        As the \a source range is also divided into \a Q parts (in
    96        operator()), it is recommended to keep \a Q smaller (or equal)
    97        than the size of ranges that will be normalized.
     95       The range supplied to the constructor sets the target
     96       distribution.
     97
     98       As the \a source range is also divided into \a Q parts (when
     99       operator() is called), it is recommended to keep \a Q smaller
     100       (or equal) than the size of ranges that will be normalized.
    98101
    99102       Also, \a Q must not be smaller than 3 due to restrictions in
    100        the cspline fit utilized in the normalization.
     103       the cubic spline fit utilized in the normalization.
    101104
    102105       \b Type \b Requirements:
     
    319322
    320323    std::vector<size_t> sorted_index(last-first);
    321     utility::sort_index(utility::data_iterator(first),
    322                         utility::data_iterator(last), sorted_index);
     324    // Code to avoid problems with NaN (ticket:535)
     325    // utility::sort_index(utility::data_iterator(first),
     326    //                     utility::data_iterator(last), sorted_index);
     327    // ... above statement replaced below code block
     328    {
     329      using namespace utility;
     330      std::vector<DataWeight> vec;
     331      vec.reserve(std::distance(first, last));
     332      std::back_insert_iterator<std::vector<DataWeight> > inserter(vec);
     333      std::copy(first, last, inserter);
     334      for (std::vector<DataWeight>::iterator i(vec.begin()); i!=vec.end(); ++i)
     335        if (std::isnan((i->data())))
     336          i->data() = std::numeric_limits<double>::infinity();
     337      utility::sort_index(utility::data_iterator(vec.begin()),
     338                          utility::data_iterator(vec.end()), sorted_index);
     339    }
     340    // end Code to avoid problems with NaN (ticket:535)
    323341
    324342    utility::Vector diff(source.averages());
     
    385403                                               utility::weighted_iterator_tag)
    386404  {
    387     std::vector<utility::DataWeight> vec;
     405    using namespace utility;
     406    std::vector<DataWeight> vec;
    388407    vec.reserve(std::distance(first, last));
    389     std::back_insert_iterator<std::vector<utility::DataWeight> > inserter(vec);
     408    std::back_insert_iterator<std::vector<DataWeight> > inserter(vec);
    390409    std::copy(first, last, inserter);
     410    // Code to avoid problems with NaN (ticket:535)
     411    for (std::vector<DataWeight>::iterator i(vec.begin()); i!=vec.end(); ++i)
     412      if (std::isnan((i->data())))
     413        i->data() = std::numeric_limits<double>::infinity();
     414    // end Code to avoid problems with NaN (ticket:535)
    391415    std::sort(vec.begin(), vec.end());
    392416    init(vec, N);
  • tags/0.5.3/yat/statistics/Percentiler.h

    r4063 r4063  
    66/*
    77  Copyright (C) 2008 Jari Häkkinen, Peter Johansson
     8  Copyright (C) 2009 Peter Johansson
    89
    910  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    184185    std::vector<utility::DataWeight> v_copy;
    185186    v_copy.reserve(last-first);
    186     std::copy(first, last, std::back_inserter(v_copy));
     187    utility::iterator_traits<RandomAccessIterator> traits;
     188    for ( ; first!=last; ++first)
     189      if (traits.weight(first)) // ignore zero weights
     190        v_copy.push_back(*first);
    187191    std::sort(v_copy.begin(), v_copy.end());
    188192    return calculate(v_copy.begin(), v_copy.end(), true, tag);
  • tags/0.5.3/yat/utility/CommandLine.h

    r4063 r4063  
    5151 
    5252     CommandLine cmd;
    53      OptionArg<std::string> dir(cmd, "d,dir", "output directory");
    5453     OptionHelp help(cmd);
     54     OptionInFile in(cmd, "i,in",
     55                     "Read input from file (rather than standard input)");
     56     OptionOutFile out(cmd, "o,out", "Place the output to file");
    5557     OptionSwitch target(cmd, "T,target", "treat DEST as a normal file", true);
    5658     OptionSwitch verbose(cmd, "v,verbose", "explain what is being done");
    5759     OptionSwitch version(cmd, "version", "output version and exit");
     60     std::stringstream copyright;
     61     copyright << "example 1.0\n"
     62               << "Copyright (C) 2007 Peter Johansson\n\n"
     63               << "This is free software see the source for copying "
     64               << "conditions. There is NO\nwarranty; not even for "
     65               << "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n";
    5866     try {
    5967       cmd.parse(argc, argv);
     
    6169     catch (cmd_error& e){
    6270       if (version.present()){
    63          std::cout << cmd.program_name() << " 1.0\n"
    64                    << "Copyright (C) 2007 Peter Johansson\n\n"
    65                    << "This is free software see the source for copying "
    66                    << "conditions. There is NO\nwarranty; not even for "
    67                    << "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n";
    68          exit(0);
     71         std::cout << copyright.str();     
     72         return EXIT_SUCCESS;
    6973       }
    70        std::cout << e.what() << std::endl;
    71        return 1;
     74       std::cerr << e.what() << std::endl;
     75       return EXIT_FAILURE;
    7276     } 
     77     if (version.present()){
     78       std::cout << copyright.str();     
     79       return EXIT_SUCCESS;
     80     }
    7381     ...
    7482     \endcode
  • tags/0.5.3/yat/utility/MatrixWeighted.h

    r4063 r4063  
    88  Copyright (C) 2004 Jari Häkkinen, Peter Johansson
    99  Copyright (C) 2005, 2006 Jari Häkkinen, Peter Johansson, Markus Ringnér
    10   Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    11   Copyright (C) 2009 Peter Johansson
     10  Copyright (C) 2007, 2008, 2009 Jari Häkkinen, Peter Johansson
    1211
    1312  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    119118
    120119       Data is copied from \a other and weights are calculated using
    121        the binary_weight function, i.e., a NaN gets a zero weight and
    122        other data values results in a unity weight (1.0).
     120       the binary_weight function, i.e., a NaN gets a zero weight
     121       (0.0) and other data values results in a unity weight (1.0).
    123122    */
    124123    explicit MatrixWeighted(const Matrix& other);
     
    127126       \brief The istream constructor.
    128127
    129        This constructor first creates a Matrix using the istream
    130        constructor, and then constructs MatrixWeighted using
     128       This constructor first creates a Matrix using the Matrix
     129       istream constructor, and then constructs MatrixWeighted using
    131130       MatrixWeighted(const Matrix&).
    132131
    133        \see Matrix(std::istream &, char)
     132       \note Weights cannot be set from the streams. Weights are set
     133       as outlined in the MatrixWeighted(const Matrix&) documentation.
     134
     135       \see Matrix(std::istream &, char) and MatrixWeighted(const Matrix&)
    134136    */
    135137    explicit MatrixWeighted(std::istream &, char sep='\0');
  • tags/0.5.3/yat/utility/OptionFile.cc

    r4063 r4063  
    33/*
    44  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
     5  Copyright (C) 2009 Peter Johansson
    56
    67  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    6465    if (fu.permissions(bits_)) {
    6566      // Peter, this loop is stupid but I wanna differentiate the error message
    66       for (std::string::const_iterator iter; iter!=bits_.end(); ++iter){
     67      for (std::string::const_iterator iter=bits_.begin();
     68           iter!=bits_.end(); ++iter) {
    6769        if (*iter=='r' && fu.permissions("r")){
    6870          std::stringstream ss;
  • tags/0.5.3/yat/utility/VectorMutable.cc

    r4063 r4063  
    66  Copyright (C) 2005, 2006, 2007 Jari Häkkinen, Peter Johansson, Markus Ringnér
    77  Copyright (C) 2008 Jari Häkkinen, Peter Johansson
     8  Copyright (C) 2009 Peter Johansson
    89
    910  This file is part of the yat library, http://dev.thep.lu.se/trac/yat
     
    2829#include <algorithm>
    2930#include <cassert>
     31#include <cmath>
     32#include <limits>
    3033#include <stdexcept>
    3134#include <string>
     
    172175  void sort(VectorMutable& invec)
    173176  {
     177    // Avoid problems with NaN (#535)
     178    size_t nof_nans=0;
     179    for (size_t i=0; i<invec.size(); ++i)
     180      if (std::isnan(invec(i))) {
     181        invec(i) = std::numeric_limits<double>::infinity();
     182        ++nof_nans;
     183      }
    174184    std::sort(invec.begin(), invec.end());
     185    for (size_t i=invec.size()-nof_nans; i<invec.size(); ++i)
     186      invec(i) = std::numeric_limits<double>::quiet_NaN();
    175187  }
    176188
  • tags/0.5.3/yat/utility/VectorMutable.h

    r4063 r4063  
    232232  /**
    233233     Sort the elements in the VectorMutable \a vec
     234
     235     NaNs are treated as infinity
    234236  */
    235237  void sort(VectorMutable& vec);
Note: See TracChangeset for help on using the changeset viewer.