Changeset 2202


Ignore:
Timestamp:
Feb 21, 2010, 7:39:13 PM (12 years ago)
Author:
Peter
Message:

merging release 0.6 into trunk

Location:
trunk
Files:
40 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/NEWS

    r2163 r2202  
    1111yat 0.6.x series from http://dev.thep.lu.se/yat/svn/branches/0.6-stable
    1212
    13 Version 0.6 (released DATE)
     13Version 0.6 (released 21 February 2010)
    1414
    1515  - Boost 1.35 is now required (#603)
  • trunk/m4/version.m4

    r2163 r2202  
    22#
    33# Copyright (C) 2008, 2009 Jari Häkkinen, Peter Johansson
     4# Copyright (C) 2010 Peter Johansson
    45#
    56# This file is part of the yat library, http://dev.thep.lu.se/yat
     
    6061# yat-0.5.5  2:4:0
    6162# yat-0.5.6  2:5:0
     63# yat-0.6.0  3:0:0
    6264#
    6365# *Accidently, the libtool number was not updated for yat 0.5
  • trunk/m4/yat_svn_release.m4

    r2116 r2202  
    1818m4_define([yat_svn_release_copyright], [
    1919#
    20 #   Copyright (C) 2009 Peter Johansson
     20#   Copyright (C) 2009, 2010 Peter Johansson
    2121#
    2222#   This file is part of the yat library, http://dev.thep.lu.se/yat
     
    7373  *\"\$\$today\"*);; \\
    7474  *) \\
    75     echo \"NEWS: release date incorrect; expected '\$\$date'\" 1>&2;\\
     75    echo \"NEWS: release date incorrect; expected '\$\$today'\" 1>&2;\\
    7676    exit 1;; \\
    7777  esac
  • trunk/test/Makefile.am

    r2121 r2202  
    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, 2010 Peter Johansson
    1010#
    1111# This file is part of the yat library, http://dev.thep.lu.se/yat
     
    6161  range_test regression_test rnd_test roc_test \
    6262  score_test  smart_ptr_test    \
    63   statistics_test stream_redirect_test \
     63  smoother_test statistics_test stream_redirect_test \
    6464  subset_generator_test svd_test svm_test \
    6565  svm_multi_class_test target_test  \
     
    130130score_test_SOURCES = score_test.cc
    131131smart_ptr_test_SOURCES = smart_ptr_test.cc
     132smoother_test_SOURCES = smoother_test.cc
    132133statistics_test_SOURCES = statistics_test.cc
    133134stream_redirect_test_SOURCES = stream_redirect_test.cc
  • trunk/test/Suite.h

    r2161 r2202  
    287287    typename std::iterator_traits<TrivialIterator>::value_type tmp = *iter;
    288288    add(tmp==*iter);
     289    TrivialIterator default_constructed;
     290    default_constructed == default_constructed; // avoid compiler warning
    289291  }
    290292 
  • trunk/test/averager_test.cc

    r2161 r2202  
    210210                << std::endl;
    211211  }
     212  // do not run compile test
     213  if (false) {
     214    AveragerPair ap3;
     215    add(ap3, boost::input_iterator_archetype<double>(),
     216        boost::input_iterator_archetype<double>(),
     217        boost::input_iterator_archetype<double>());
     218    AveragerPairWeighted apw;
     219    add(apw, boost::input_iterator_archetype_no_proxy<utility::DataWeight>(),
     220        boost::input_iterator_archetype_no_proxy<utility::DataWeight>(),
     221        boost::input_iterator_archetype_no_proxy<utility::DataWeight>());
     222    add(apw, boost::input_iterator_archetype<double>(),
     223        boost::input_iterator_archetype<double>(),
     224        boost::input_iterator_archetype<double>());
     225    add(apw, boost::input_iterator_archetype<double>(),
     226        boost::input_iterator_archetype<double>(),
     227        boost::input_iterator_archetype<double>(),
     228        boost::input_iterator_archetype<double>(),
     229        boost::input_iterator_archetype<double>());
     230  }
    212231
    213232
     
    369388    AveragerWeighted averagerw;
    370389    using utility::DataWeight;
    371     typedef boost::input_iterator_archetype<DataWeight> Iter;
     390    typedef boost::input_iterator_archetype_no_proxy<DataWeight> Iter;
    372391    Iter iter;
    373392    utility::iterator_traits<Iter> traits;
    374     //traits.weight(iter);
    375     //    add(averagerw, boost::input_iterator_archetype<DataWeight>(),
    376     //  boost::input_iterator_archetype<DataWeight>());
     393    traits.weight(iter);
     394    add(averagerw, iter, iter);
     395    add(averagerw, boost::input_iterator_archetype<double>(),
     396        boost::input_iterator_archetype<double>(),
     397        boost::input_iterator_archetype<double>());
    377398  }
    378399
  • trunk/test/commandline_test.cc

    r2121 r2202  
    22
    33/*
    4   Copyright (C) 2007, 2008, 2009 Jari Häkkinen, Peter Johansson
     4  Copyright (C) 2007, 2008, 2009, 2010 Jari Häkkinen, Peter Johansson
    55
    66  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    2929#include "yat/utility/OptionSwitch.h"
    3030
     31#include <cassert>
    3132#include <fstream>
    3233#include <stdexcept>
     34#include <string>
     35
     36#include <string.h>
    3337
    3438using namespace theplu;
    3539using namespace yat::utility;
    3640bool cmd_help(yat::test::Suite& error);
     41char** stradup(const char* str[], int size);
     42void strafree(char** str, int size);
    3743bool test_switch(yat::test::Suite& error);
    3844bool test_arg(yat::test::Suite& error);
     
    115121
    116122
     123char** stradup(const char** str, int size)
     124{
     125  char** res = new char*[size];
     126  for (int i = 0; i<size; ++i) {
     127    res[i] = strdup(str[i]);
     128    assert(res[i]);
     129  }
     130  return res;
     131}
     132
     133
     134void strafree(char** str, int size)
     135{
     136  for (int i = 0; i<size; ++i) {
     137    free(str[i]);
     138  }
     139}
     140
     141
    117142void test_exception_msg(yat::test::Suite& suite)
    118143{
     
    129154  OptionSwitch verbose(cmd, "v,verbose", "display progress");
    130155  int ac = 2;
    131   char* av[] = { "test_prog", "--haha" };
     156  const char* cav[] = { "test_prog", "--haha" };
     157  char** av = stradup(cav, ac);
    132158  try {
    133159    cmd.parse(ac,av);
     
    143169    }
    144170  }
     171  strafree(av, ac);
    145172}
    146173
     
    156183  {
    157184    int ac = 2;
    158     char* av[] = { "test_prog", "-T" };
     185    const char* cav[] = { "test_prog", "-T" };
     186    char** av = stradup(cav, ac);
    159187    cmd.parse(ac,av);
    160188    if (target.present() && !verbose.present())
     
    164192      ok =false;
    165193    }
     194    strafree(av, ac);
    166195  }
    167196
     
    170199  {
    171200    int ac = 2;
    172     char* av[] = { "test_prog", "--target" };
     201    const char* cav[] = { "test_prog", "--target" };
     202    char** av = stradup(cav, ac);
    173203    cmd.parse(ac,av);
    174204    if (target.present() && target.value() && !verbose.present())
     
    178208      ok =false;
    179209    }
     210    strafree(av, ac);
    180211  }
    181212
     
    183214  {
    184215    int ac = 3;
    185     char* av[] = { "test_prog", "-T" , "-v"};
     216    const char* cav[] = { "test_prog", "-T" , "-v"};
     217    char** av = stradup(cav, ac);
    186218    cmd.parse(ac,av);
    187219    if (target.present() && verbose.present())
     
    191223      ok =false;
    192224    }
     225    strafree(av, ac);
    193226  }
    194227
     
    196229  {
    197230    int ac = 2;
    198     char* av[] = { "test_prog", "-vT"};
     231    const char* cav[] = { "test_prog", "-vT"};
     232    char** av = stradup(cav, ac);
    199233    cmd.parse(ac,av);
    200234    if (target.present() && verbose.present())
     
    204238      ok =false;
    205239    }
     240    strafree(av, ac);
    206241  }
    207242
     
    209244  {
    210245    int ac = 2;
    211     char* av[] = { "test_prog", "--no-target" };
     246    const char* cav[] = { "test_prog", "--no-target" };
     247    char** av = stradup(cav, ac);
    212248    cmd.parse(ac,av);
    213249    if (target.present() && !target.value())
     
    221257      ok =false;
    222258    }
     259    strafree(av, ac);
    223260  }
    224261  return ok;
     
    237274  {
    238275    int ac = 3;
    239     char* av[] = { "test_prog", "-i", "file" };
     276    const char* cav[] = { "test_prog", "-i", "file" };
     277    char** av = stradup(cav, ac);
    240278    cmd.parse(ac,av);
    241279    if (input.present())
     
    245283      ok =false;
    246284    }
     285    strafree(av, ac);
    247286  }
    248287
     
    250289  {
    251290    int ac = 3;
    252     char* av[] = { "test_prog", "-i", "file" };
     291    const char* cav[] = { "test_prog", "-i", "file" };
     292    char** av = stradup(cav, ac);
    253293    cmd.parse(ac,av);
    254294    if (input.value()=="file")
     
    258298      ok =false;
    259299    }
     300    strafree(av, ac);
    260301  }
    261302
     
    263304  {
    264305    int ac = 3;
    265     char* av[] = { "test_prog", "--input", "file" };
     306    const char* cav[] = { "test_prog", "--input", "file" };
     307    char** av = stradup(cav, ac);
    266308    cmd.parse(ac,av);
    267309    if (input.present())
     
    271313      ok =false;
    272314    }
     315    strafree(av, ac);
    273316  }
    274317
     
    276319  {
    277320    int ac = 2;
    278     char* av[] = { "test_prog", "--input=file" };
     321    const char* cav[] = { "test_prog", "--input=file" };
     322    char** av = stradup(cav, ac);
    279323    cmd.parse(ac,av);
    280324    if (input.value()=="file")
     
    284328      ok =false;
    285329    }
     330    strafree(av, ac);
    286331  }
    287332
     
    289334  {
    290335    int ac = 2;
    291     char* av[] = { "test_prog", "--input=\"file called something\"" };
     336    const char* cav[] = { "test_prog", "--input=\"file called something\"" };
     337    char** av = stradup(cav, ac);
    292338    cmd.parse(ac,av);
    293339    if (input.value()=="file called something")
     
    299345      ok =false;
    300346    }
     347    strafree(av, ac);
    301348  }
    302349
     
    304351  {
    305352    int ac = 3;
    306     char* av[] = { "test_prog", "-n", "3" };
     353    const char* cav[] = { "test_prog", "-n", "3" };
     354    char** av = stradup(cav, ac);
    307355    cmd.parse(ac,av);
    308356    if (n.value()==3)
     
    312360      ok =false;
    313361    }
     362    strafree(av, ac);
    314363  }
    315364
     
    318367  {
    319368    int ac = 5;
    320     char* av[] = { "test_prog", "--input", "file", "-n", "3" };
     369    const char* cav[] = { "test_prog", "--input", "file", "-n", "3" };
     370    char** av = stradup(cav, ac);
    321371    cmd.parse(ac,av);
    322372    if (input.value()=="file")
     
    326376      ok =false;
    327377    }
     378    strafree(av, ac);
    328379  }
    329380
     
    331382  try {
    332383    int ac = 3;
    333     char* av[] = { "test_prog", "-x", "-6" };
     384    const char* cav[] = { "test_prog", "-x", "-6" };
     385    char** av = stradup(cav, ac);
    334386    cmd.parse(ac,av);
    335387    if (x.value()==-6)
     
    339391      ok =false;
    340392    }
     393    strafree(av, ac);
    341394  }
    342395  catch (std::runtime_error& e) {
     
    348401  try {
    349402    int ac = 3;
    350     char* av[] = { "test_prog", "--extra", "-6" };
     403    const char* cav[] = { "test_prog", "--extra", "-6" };
     404    char** av = stradup(cav, ac);
    351405    cmd.parse(ac,av);
    352406    if (x.value()==-6)
     
    356410      ok =false;
    357411    }
     412    strafree(av, ac);
    358413  }
    359414  catch (std::runtime_error& e) {
     
    365420  try {
    366421    int ac = 1;
    367     char* av[] = { "test_prog"};
     422    const char* cav[] = { "test_prog"};
     423    char** av = stradup(cav, ac);
    368424    cmd.parse(ac,av);
    369425    n.value(5);
     
    374430      ok = false;
    375431    }
     432    strafree(av, ac);
    376433  }
    377434  catch (std::runtime_error& e) {
     
    394451  {
    395452    int ac = 2;
    396     char* av[] = { "test_prog", "--peter"};
     453    const char* cav[] = { "test_prog", "--peter"};
     454    char** av = stradup(cav, ac);
    397455    try{
    398456      cmd.parse(ac,av);
     
    403461      suite.err() << "ok\n";
    404462    }
     463    strafree(av, ac);
    405464  }
    406465
     
    408467  {
    409468    int ac = 2;
    410     char* av[] = { "test_prog", "-vjhsgad"};
     469    const char* cav[] = { "test_prog", "-vjhsgad"};
     470    char** av = stradup(cav, ac);
    411471    try{
    412472      cmd.parse(ac,av);
     
    417477      suite.err() << "ok\n";
    418478    }
     479    strafree(av, ac);
    419480  }
    420481
     
    423484  {
    424485    int ac = 3;
    425     char* av[] = { "test_prog", "-nv", "3"};
     486    const char* cav[] = { "test_prog", "-nv", "3"};
     487    char** av = stradup(cav, ac);
    426488    try{
    427489      cmd.parse(ac,av);
     
    432494      suite.err() << "ok\n";
    433495    }
     496    strafree(av, ac);
    434497  }
    435498
     
    438501  {
    439502    int ac = 3;
    440     char* av[] = { "test_prog", "-n", "23.12"};
     503    const char* cav[] = { "test_prog", "-n", "23.12"};
     504    char** av = stradup(cav, ac);
    441505    try{
    442506      cmd.parse(ac,av);
     
    447511      suite.err() << "ok\n";
    448512    }
     513    strafree(av, ac);
    449514  }
    450515
     
    452517  {
    453518    int ac = 3;
    454     char* av[] = { "test_prog", "-n" "-1"};
     519    const char* cav[] = { "test_prog", "-n" "-1"};
     520    char** av = stradup(cav, ac);
    455521    try{
    456522      cmd.parse(ac,av);
     
    461527      suite.err() << "ok\n";
    462528    }
     529    strafree(av, ac);
    463530  }
    464531
     
    467534  {
    468535    int ac = 2;
    469     char* av[] = { "test_prog", "peter" };
     536    const char* cav[] = { "test_prog", "peter" };
     537    char** av = stradup(cav, ac);
    470538    try{
    471539      cmd.parse(ac,av);
     
    476544      suite.err() << "ok\n";
    477545    }
     546    strafree(av, ac);
    478547  }
    479548
     
    482551    OptionArg<std::string> required(cmd, "required", "required", true);
    483552    int ac = 1;
    484     char* av[] = { "test_prog" };
     553    const char* cav[] = { "test_prog" };
     554    char** av = stradup(cav, ac);
    485555    try{
    486556      cmd.parse(ac,av);
     
    491561      suite.err() << "ok\n";
    492562    }
     563    strafree(av, ac);
    493564  }
    494565
     
    510581  {
    511582    int ac = 7;
    512     char* av[] = { "test_prog", "--clones", "commandline_test.cc",
    513                    "--data", "commandline_test.cc", "-o",
    514                    "commandline_test.cc"};
     583    const char* cav[] = { "test_prog", "--clones", "commandline_test.cc",
     584                          "--data", "commandline_test.cc", "-o",
     585                          "commandline_test.cc"};
     586    char** av = stradup(cav, ac);
    515587    cmd.parse(ac,av);
    516588    suite.err() << "ok\n";
     589    strafree(av, ac);
    517590  }
    518591  return ok;
     
    561634  {
    562635    int ac = 3;
    563     char* av[] = { "test_prog", "--out",
    564                    "testSubDir/commandline_test.dir/write-protected/out.txt"};
     636    const char* cav[] = { "test_prog", "--out",
     637                    "testSubDir/commandline_test.dir/write-protected/out.txt"};
     638    char** av = stradup(cav, ac);
    565639    try {
    566640      cmd.parse(ac,av);
     
    572646      suite.err() << "catch expected error: " << e.what() << "\n";
    573647    }
     648    strafree(av, ac);
    574649  }
    575650  return ok;
     
    596671
    597672  suite.err() << "Testing OptionFile '" << perm << "' ... ";
    598   try {
    599     int ac = 3;
    600     char* av[] = { "test_prog", "--file", "sjhgaw/jmegb/tmp.tmpx"};
     673  int ac = 3;
     674  const char* cav[] = { "test_prog", "--file", "sjhgaw/jmegb/tmp.tmpx"};
     675  char** av = stradup(cav, ac);
     676  try {
    601677    cmd.parse(ac,av);
    602678    suite.err() << "no\n";
     679    strafree(av, ac);
    603680    return false;
    604681  }
     
    607684    suite.err() << "catch expected error: " << e.what() << "\n";
    608685  }
     686  strafree(av, ac);
    609687  return true;
    610688}
     
    637715  try {
    638716    int ac = 3;
    639     char* av[] = { "test_prog", "--file",
    640                    "testSubDir/commandline_test.dir/test_file4.txt"};
     717    const char* cav[] = { "test_prog", "--file",
     718                          "testSubDir/commandline_test.dir/test_file4.txt"};
     719    char** av = stradup(cav, ac);
    641720    cmd.parse(ac,av);
    642721    suite.err() << "no\n";
     722    strafree(av, ac);
    643723    return false;
    644724  }
     
    690770  OptionHelp help(cmd);
    691771  int ac = 3;
    692   char* av[] = { "test_prog", "file", "kl"};
     772  const char* cav[] = { "test_prog", "file", "kl"};
     773  char** av = stradup(cav, ac);
    693774  cmd.parse(ac, av);
    694775  suite.err() << "ok\n";
    695   return ok;
    696 }
    697 
    698 
    699 
     776  strafree(av, ac);
     777  return ok;
     778}
     779
     780
     781
  • trunk/test/data_weight_proxy_test.cc

    r2122 r2202  
    22
    33/*
    4   Copyright (C) 2008, 2009 Peter Johansson
     4  Copyright (C) 2008, 2009, 2010 Peter Johansson
    55
    66  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    2424#include "yat/utility/DataWeight.h"
    2525#include "yat/utility/DataWeightProxy.h"
     26
     27#include <boost/concept_archetype.hpp>
    2628
    2729namespace theplu {
     
    109111  suite.add(suite.equal(holder().weight(), 1));
    110112
     113  // do not run compile tests
     114  if (false) {
     115    typedef boost::mutable_forward_iterator_archetype<double> iterator;
     116    iterator iter;
     117    utility::DataWeightProxy<iterator, iterator> proxy(iter, iter);
     118    double x = proxy.data();
     119    x = proxy.weight();
     120    proxy.data() = proxy.weight() = 0.0;
     121  }
     122
    111123  return suite.return_value();
    112124}
  • trunk/test/distance_test.cc

    r2119 r2202  
    44  Copyright (C) 2007 Jari Häkkinen, Markus Ringnér
    55  Copyright (C) 2008 Jari Häkkinen, Peter Johansson, Markus Ringnér
    6   Copyright (C) 2009 Peter Johansson
     6  Copyright (C) 2009, 2010 Peter Johansson
    77
    88  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    3333#include "yat/utility/Vector.h"
    3434#include "yat/utility/WeightIterator.h"
     35
     36#include <boost/concept_archetype.hpp>
    3537
    3638#include <cassert>
     
    197199  test_symmetry(dist, suite, N);
    198200  test_zero_weight(dist, suite, N);
     201
     202  // do not run compiler test
     203  if (false) {
     204    boost::forward_iterator_archetype<double> iter;
     205    boost::forward_iterator_archetype<utility::DataWeight> witer;
     206    dist(iter, iter, iter);
     207    dist(iter, iter, witer);
     208    dist(witer, witer, iter);
     209    dist(witer, witer, witer);
     210  }
    199211}
    200212
  • trunk/test/documentation_test.sh.in

    r2139 r2202  
    55
    66# Copyright (C) 2008 Jari Häkkinen, Peter Johansson
    7 # Copyright (C) 2009 Peter Johansson
     7# Copyright (C) 2009, 2010 Peter Johansson
    88#
    99# This file is part of the yat library, http://dev.thep.lu.se/yat
     
    5151echo @ECHO_N@ "doxygen "
    5252@DOXYGEN@ --version
    53 (cd @abs_top_builddir@/doc && make doc)
     53(cd @abs_top_builddir@/doc && make doc < /dev/null) || exit 1
    5454if test ! -e @abs_top_builddir@/doc/doxygen.error; then
    5555    echo Cannot find file: @abs_top_builddir@/doc/doxygen.error
  • trunk/test/histogram_test.cc

    r2032 r2202  
    22
    33/*
    4   Copyright (C) 2009 Peter Johansson
     4  Copyright (C) 2009, 2010 Peter Johansson
    55
    66  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    2323
    2424#include "yat/statistics/Histogram.h"
     25#include "yat/utility/DataWeight.h"
     26
     27#include <boost/concept_archetype.hpp>
    2528
    2629#include <iostream>
     
    2932{
    3033  using namespace theplu::yat::statistics;
     34  using namespace theplu::yat;
    3135  theplu::yat::test::Suite suite(argc, argv);
    3236  suite.err() << "testing histogram" << std::endl;
     
    4549    suite.add(c[i] == (a[i]+b[i]));
    4650  }
     51  // do not run compiler test
     52  if (false) {
     53    Histogram hist;
     54    add(hist, boost::forward_iterator_archetype<double>(),
     55        boost::forward_iterator_archetype<double>());
     56    using utility::DataWeight;
     57    add(hist, boost::forward_iterator_archetype<DataWeight>(),
     58        boost::forward_iterator_archetype<DataWeight>());
     59  }
    4760
    4861  return suite.return_value();
  • trunk/test/iterator_test.cc

    r2183 r2202  
    4141#include "yat/utility/WeightIterator.h"
    4242
     43#include <boost/concept_archetype.hpp>
    4344#include <boost/iterator/transform_iterator.hpp>
    4445
     
    7879  suite.out() << "testing boost_util\n";
    7980  test_boost_util(suite);
     81  suite.out() << "testing iterator_traits\n";
    8082  test_iterator_traits(suite);
    8183  suite.out() << "testing pair_second_iterator\n";
     
    293295void test_iterator_traits(test::Suite& suite)
    294296{
     297  typedef std::vector<utility::DataWeight>::iterator Iter;
     298  suite.add(utility::detail::iter_has_mutable_weight<Iter>::value);
     299  typedef std::vector<utility::DataWeight>::const_iterator Iter2;
     300  suite.add(!utility::detail::iter_has_mutable_weight<Iter2>::value);
     301
    295302  typedef std::vector<utility::DataWeight> WeightVector;
    296303  WeightVector vec(1);
    297   utility::iterator_traits<WeightVector::const_iterator> traits;
     304  utility::iterator_traits<WeightVector::iterator> traits;
    298305  double w = traits.weight(vec.begin());
     306  traits.weight(vec.begin()) = w;
    299307  suite.add(suite.equal(w, 1.0));
     308
     309  utility::iterator_traits<WeightVector::const_iterator> c_traits;
     310  w = c_traits.weight(vec.begin());
     311  suite.add(suite.equal(w, 1.0));
     312
    300313  utility::iterator_traits<utility::DataWeight*>().weight(&vec[0]);
    301314
     
    303316  utility::DataWeightProxy<double*, double*> dwp(trivial_iter,trivial_iter);
    304317  typedef utility::DataWeightProxy<double*, double*> Proxy;
    305   //utility::iterator_traits<Proxy*> traits2;
    306   //traits2.weight(&dwp);
     318  utility::iterator_traits<Proxy*> traits2;
     319  w = traits2.weight(&dwp);
    307320  delete trivial_iter;
    308321}
     
    338351  // some pointless usage of the iterators
    339352  std::copy(rbegin, rend, rbegin);
    340  
    341 
     353
     354  // do not run compile test
     355  if (false) {
     356    using utility::StrideIterator;
     357    StrideIterator<boost::random_access_iterator_archetype<double> > iter;
     358    suite.test_random_access_iterator(iter);
     359    double x = *iter;
     360    x *= 2; // avoid compiler warning
     361  }
    342362}
    343363
  • trunk/test/kolmogorov_smirnov_test.cc

    r1704 r2202  
    22
    33/*
    4   Copyright (C) 2008, 2009 Peter Johansson
     4  Copyright (C) 2008, 2009, 2010 Peter Johansson
    55
    66  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    2525#include "yat/statistics/Averager.h"
    2626#include "yat/statistics/KolmogorovSmirnov.h"
     27
     28#include <boost/concept_archetype.hpp>
    2729
    2830#include <cmath>
     
    4042void test_reset(test::Suite&);
    4143void test_ties(test::Suite&);
     44void test_compile(void);
    4245
    4346int main(int argc, char* argv[])
     
    5255  test_reset(suite);
    5356  test_ties(suite);
     57  test_compile();
    5458
    5559  return suite.return_value();
     60}
     61
     62void test_compile(void)
     63{
     64  using statistics::KolmogorovSmirnov;
     65  // do not run compiler test
     66  if (false) {
     67    KolmogorovSmirnov ks;
     68    ks.add(boost::forward_iterator_archetype<KolmogorovSmirnov::Element>(),
     69           boost::forward_iterator_archetype<KolmogorovSmirnov::Element>());
     70  }
    5671}
    5772
  • trunk/test/static_test.sh

    r1931 r2202  
    22# $Id$
    33#
    4 # Copyright (C) 2009 Peter Johansson
     4# Copyright (C) 2009, 2010 Peter Johansson
    55#
    66# This file is part of the yat library, http://dev.thep.lu.se/yat
     
    3030echo "Creating acinclude.m4"
    3131cat > acinclude.m4.tmp <<EOF
     32YAT_FIND_YAT
     33CXX=\`\$yat_config --cxx\`
    3234YAT_CHECK_VERSION([0.5.99],,
    3335                  [AC_MSG_ERROR([could not find required version of yat])])
  • trunk/test/statistics_test.cc

    r2121 r2202  
    66  Copyright (C) 2006 Jari Häkkinen, Peter Johansson, Markus Ringnér
    77  Copyright (C) 2007, 2008, 2009 Jari Häkkinen, Peter Johansson
     8  Copyright (C) 2010 Peter Johansson
    89
    910  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    2526#include "Suite.h"
    2627
     28#include "yat/classifier/Target.h"
    2729#include "yat/statistics/Average.h"
    2830#include "yat/statistics/utility.h"
     31#include "yat/statistics/tTest.h"
    2932#include "yat/utility/DataWeight.h"
    3033#include "yat/utility/MatrixWeighted.h"
    3134#include "yat/utility/Vector.h"
     35
     36#include <boost/concept_archetype.hpp>
    3237
    3338#include <cmath>
     
    7176  if (m!=4.5 || m!=m_gsl)
    7277    suite.add(false);
     78  if (false) {
     79    using statistics::median;
     80    double x = median(boost::random_access_iterator_archetype<double>(),
     81                      boost::random_access_iterator_archetype<double>());
     82    x = median(boost::random_access_iterator_archetype<utility::DataWeight>(),
     83               boost::random_access_iterator_archetype<utility::DataWeight>());
     84  }
    7385  statistics::percentile2(data.begin(), data.end(), 100);
    7486  data.resize(1);
     
    90102  classifier::MatrixLookupWeighted mlw(10,20,2.0, 1.0);
    91103  suite.add(suite.equal(func(mlw.begin(), mlw.end()),2.0));
     104  // do not run compiler test
     105  if (false) {
     106    statistics::Average average;
     107    double x = average(boost::input_iterator_archetype<double>(),
     108                       boost::input_iterator_archetype<double>());
     109    x = average(boost::input_iterator_archetype_no_proxy<utility::DataWeight>(),
     110                boost::input_iterator_archetype_no_proxy<utility::DataWeight>());
     111           
     112  }
    92113 
    93114  test_mad(suite);
    94115
     116  // do not run compiler test
     117  if (false) {
     118    statistics::tTest t_test;
     119    classifier::Target target;
     120    add(t_test, boost::forward_iterator_archetype<double>(),
     121        boost::forward_iterator_archetype<double>(), target);
     122    add(t_test, boost::forward_iterator_archetype<utility::DataWeight>(),
     123        boost::forward_iterator_archetype<utility::DataWeight>(), target);
     124           
     125  }
    95126  return suite.return_value();
    96127}
     
    111142  wx[2] = utility::DataWeight(100, 0.6);
    112143  suite.add(suite.equal(statistics::mad(wx.begin(), wx.end()), 2));
     144  // do not run compiler test
     145  if (false) {
     146    using statistics::mad;
     147    double x = mad(boost::random_access_iterator_archetype<double>(),
     148                   boost::random_access_iterator_archetype<double>());
     149    x = mad(boost::random_access_iterator_archetype<utility::DataWeight>(),
     150            boost::random_access_iterator_archetype<utility::DataWeight>());
     151  }
    113152}
    114153
     
    169208  cmp_percentiler(suite, xw.begin(), xw.end(), xw2.begin(), xw2.end());
    170209
     210  // do not run compiler test
     211  if (false) {
     212    statistics::Percentiler percentiler(50);
     213    using boost::random_access_iterator_archetype;
     214    typedef random_access_iterator_archetype<double> Iterator;
     215    double x = percentiler(Iterator(), Iterator());
     216    using utility::DataWeight;
     217    typedef random_access_iterator_archetype<DataWeight> WeigtedItererator;
     218    x = percentiler(WeigtedItererator(), WeigtedItererator());
     219  }
    171220}
    172221
  • trunk/test/utility_test.cc

    r2181 r2202  
    44  Copyright (C) 2006 Jari Häkkinen, Markus Ringnér
    55  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    6   Copyright (C) 2009 Peter Johansson
     6  Copyright (C) 2009, 2010 Peter Johansson
    77
    88  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    3030#include "yat/utility/sort_index.h"
    3131#include "yat/utility/stl_utility.h"
     32
     33#include <boost/concept_archetype.hpp>
    3234
    3335#include <fstream>
     
    226228  utility::inverse(vec.begin()+1, vec.end(), mmap);
    227229  test_inverse_validate(vec.begin()+1, mmap, suite);
     230  // do not run compile tests
     231  if (false) {
     232    std::map<std::string, std::vector<size_t> > m;
     233    boost::input_iterator_archetype<std::string> start;
     234    boost::input_iterator_archetype<std::string> end;
     235    utility::inverse(start, end, m);
     236    std::map<std::string, std::vector<size_t>, std::greater<std::string> > m2;
     237    utility::inverse(start, end, m2);
     238    std::multimap<std::string, size_t> m3;
     239    utility::inverse(start, end, m3);
     240    std::multimap<std::string, size_t, std::greater<std::string> > m4;
     241    utility::inverse(start, end, m4);
     242  }
    228243}
    229244
     
    319334  }
    320335
    321 }
     336  // do not run compiler tests
     337  if (false) {
     338    std::vector<size_t> vec;
     339    utility::sort_index(boost::forward_iterator_archetype<double>(),
     340                        boost::forward_iterator_archetype<double>(),
     341                        vec);
     342  }
     343}
  • trunk/test/yat_m4_test.sh

    r1899 r2202  
    22# $Id$
    33#
    4 # Copyright (C) 2009 Peter Johansson
     4# Copyright (C) 2009, 2010 Peter Johansson
    55#
    66# This file is part of the yat library, http://dev.thep.lu.se/yat
     
    3131echo "Creating acinclude.m4"
    3232cat > acinclude.m4.tmp <<EOF
     33YAT_FIND_YAT
     34CXX=\`\$yat_config --cxx\`
    3335YAT_CHECK_VERSION([0.5.99],,
    3436                  [AC_MSG_ERROR([could not find required version of yat])])
  • trunk/yat/regression/Linear.h

    r2119 r2202  
    66/*
    77  Copyright (C) 2004, 2005, 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
     8  Copyright (C) 2010 Peter Johansson
    89
    910  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    6364
    6465    /**
    65        The standard deviation is estimated as \f$ \sqrt{\frac{s^2}{n}}
     66       The variance is estimated as \f$ \frac{s^2}{n}
    6667       \f$ where \f$ s^2 = \frac{\sum \epsilon^2}{n-2} \f$
    6768       
    68        @return standard deviation of parameter \f$ \alpha \f$
     69       @return variance of parameter \f$ \alpha \f$
    6970    */
    7071    double alpha_var(void) const;
     
    7980
    8081    /**
    81        The standard deviation is estimated as \f$ \frac{s^2}{\sum
     82       The variance is estimated as \f$ \frac{s^2}{\sum
    8283       (x-m_x)^2} \f$ where \f$ s^2 = \frac{\sum \epsilon^2}{n-2} \f$
    8384
    84        @return standard deviation of parameter \f$ \beta \f$
     85       @return variance of parameter \f$ \beta \f$
    8586    */
    8687    double beta_var(void) const;
  • trunk/yat/statistics/AveragerPair.h

    r2119 r2202  
    88  Copyright (C) 2006 Jari Häkkinen, Peter Johansson, Markus Ringnér
    99  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    10   Copyright (C) 2009 Peter Johansson
     10  Copyright (C) 2009, 2010 Peter Johansson
    1111
    1212  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    2929
    3030#include "yat/utility/iterator_traits.h"
     31
     32#include <boost/concept_check.hpp>
    3133
    3234#include <cmath>
     
    164166     \relates AveragerPair
    165167   */
    166   template <class Iter1, class Iter2>
    167   void add(AveragerPair& ap, Iter1 first1, Iter1 last1, Iter2 first2)
     168  template <class InputIterator1, class InputIterator2>
     169  void add(AveragerPair& ap, InputIterator1 first1, InputIterator1 last1,
     170           InputIterator2 first2)
    168171  {
     172    BOOST_CONCEPT_ASSERT((boost::InputIterator<InputIterator1>));
     173    BOOST_CONCEPT_ASSERT((boost::InputIterator<InputIterator2>));
    169174    utility::check_iterator_is_unweighted(first1);
    170175    utility::check_iterator_is_unweighted(first2);
  • trunk/yat/statistics/AveragerPairWeighted.h

    r2119 r2202  
    88  Copyright (C) 2006, 2007 Jari Häkkinen, Peter Johansson, Markus Ringnér
    99  Copyright (C) 2008 Jari Häkkinen, Peter Johansson
    10   Copyright (C) 2009 Peter Johansson
     10  Copyright (C) 2009, 2010 Peter Johansson
    1111
    1212  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    3030#include "yat/utility/iterator_traits.h"
    3131#include "yat/utility/yat_assert.h"
     32
     33#include <boost/concept_check.hpp>
    3234
    3335#include <cmath>
     
    142144     \relates AveragerPairWeighted
    143145   */
    144   template <class Iter1, class Iter2>
    145   void add(AveragerPairWeighted& ap, Iter1 first1, Iter1 last1, Iter2 first2)
     146  template <class InputIterator1, class InputIterator2>
     147  void add(AveragerPairWeighted& ap, InputIterator1 first1,
     148           InputIterator1 last1, InputIterator2 first2)
    146149  {
     150    BOOST_CONCEPT_ASSERT((boost::InputIterator<InputIterator1>));
     151    BOOST_CONCEPT_ASSERT((boost::InputIterator<InputIterator2>));
     152    utility::iterator_traits<InputIterator1> traits1;
     153    utility::iterator_traits<InputIterator2> traits2;
    147154    for ( ; first1 != last1; ++first1, ++first2) {
    148       ap.add(utility::iterator_traits<Iter1>().data(first1),
    149              utility::iterator_traits<Iter2>().data(first2),
    150              utility::iterator_traits<Iter1>().weight(first1),
    151              utility::iterator_traits<Iter2>().weight(first2));
     155      ap.add(traits1.data(first1), traits2.data(first2),
     156             traits1.weight(first1), traits2.weight(first2));
    152157    }
    153158  }
     
    157162     \brief adding four ranges of values to AveragerPairWeighted \a ap
    158163
     164     Iterators must be unweighted.
     165
    159166     \relates AveragerPairWeighted
    160167   */
    161   template <class Iter1, class Iter2, class Iter3, class Iter4>
    162   void add(AveragerPairWeighted& ap, Iter1 x, Iter1 xlast, Iter2 y, Iter3 wx,
    163            Iter4 wy)
     168  template <typename InputIterator1, typename InputIterator2
     169            , typename InputIterator3, typename InputIterator4>
     170  void add(AveragerPairWeighted& ap, InputIterator1 x, InputIterator1 xlast,
     171           InputIterator2 y, InputIterator3 wx, InputIterator4 wy)
    164172  {
     173    BOOST_CONCEPT_ASSERT((boost::InputIterator<InputIterator1>));
     174    BOOST_CONCEPT_ASSERT((boost::InputIterator<InputIterator2>));
     175    BOOST_CONCEPT_ASSERT((boost::InputIterator<InputIterator3>));
     176    BOOST_CONCEPT_ASSERT((boost::InputIterator<InputIterator4>));
    165177    utility::check_iterator_is_unweighted(x);
    166178    utility::check_iterator_is_unweighted(y);
  • trunk/yat/statistics/AveragerWeighted.h

    r2161 r2202  
    2828#include "Averager.h"
    2929#include "yat/utility/iterator_traits.h"
     30
     31#include <boost/concept_check.hpp>
    3032
    3133#include <cmath>
     
    212214     \brief adding a range of values to AveragerWeighted \a a
    213215
    214      If iterator is non-weighted unitary weights are used.
     216     If InputIterator is non-weighted unitary weights are used.
    215217
    216218     \relates AveragerWeighted
    217219   */
    218   template <typename InputIter>
    219   void add(AveragerWeighted& a, InputIter first, InputIter last)
     220  template <typename InputIterator>
     221  void add(AveragerWeighted& a, InputIterator first, InputIterator last)
    220222  {
    221     utility::iterator_traits<InputIter> traits;
     223    BOOST_CONCEPT_ASSERT((boost::InputIterator<InputIterator>));
     224    utility::iterator_traits<InputIterator> traits;
    222225    for ( ; first != last; ++first)
    223226      a.add(traits.data(first), traits.weight(first));
     
    230233     weight in range [first2, first2 + distance(first, last) ).
    231234
    232      Requirement: Iter1 and Iter2 are unweighted iterators.
     235     Requirement: InputIterator1 and InputIterator2 are unweighted
     236     input iterators.
    233237
    234238     \relates AveragerWeighted
    235239   */
    236   template <typename Iter1, typename Iter2>
    237   void add(AveragerWeighted& a, Iter1 first1, Iter1 last1, Iter2 first2)
     240  template <typename InputIterator1, typename InputIterator2>
     241  void add(AveragerWeighted& a, InputIterator1 first1, InputIterator1 last1,
     242           InputIterator2 first2)
    238243  {
     244    BOOST_CONCEPT_ASSERT((boost::InputIterator<InputIterator1>));
     245    BOOST_CONCEPT_ASSERT((boost::InputIterator<InputIterator2>));
    239246    utility::check_iterator_is_unweighted(first1);
    240247    utility::check_iterator_is_unweighted(first2);
  • trunk/yat/statistics/EuclideanDistance.h

    r2119 r2202  
    66/*
    77  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson, Markus Ringnér
     8  Copyright (C) 2010 Peter Johansson
    89
    910  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    6061       set to unity.
    6162    */
    62     template <typename Iter1, typename Iter2>
    63     double operator()
    64     (Iter1 beg1,Iter1 end1, Iter2 beg2) const
     63    template <typename ForwardIterator1, typename ForwardIterator2>
     64    double operator()(ForwardIterator1 beg1, ForwardIterator1 end1,
     65                      ForwardIterator2 beg2) const
    6566    {
    66       return this->distance(beg1, end1, beg2, 
    67                       typename utility::weighted_if_any2<Iter1,Iter2>::type());
     67      using utility::weighted_if_any2;
     68      typename weighted_if_any2<ForwardIterator1,ForwardIterator2>::type tag;
     69      return this->distance(beg1, end1, beg2, tag);
    6870    }
    6971
  • trunk/yat/statistics/Histogram.h

    r2119 r2202  
    99  Copyright (C) 2006 Jari Häkkinen
    1010  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    11   Copyright (C) 2009 Peter Johansson
     11  Copyright (C) 2009, 2010 Peter Johansson
    1212
    1313  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    2929#include "AveragerWeighted.h"
    3030#include "yat/utility/iterator_traits.h"
     31
     32#include <boost/concept_check.hpp>
    3133
    3234#include <string>
     
    211213     Add a range [first, last) of values to Histogram.
    212214
     215     ForwardIterator should be a \ref concept_data_iterator
     216
    213217     \relates Histogram
    214218   */
     
    217221           ForwardIterator first, ForwardIterator last)
    218222  {
     223    BOOST_CONCEPT_ASSERT((boost::ForwardIterator<ForwardIterator>));
     224    utility::iterator_traits<ForwardIterator> traits;
    219225    while (first!=last) {
    220       h.add(utility::iterator_traits<ForwardIterator>().data(),
    221             utility::iterator_traits<ForwardIterator>().weight());
     226      h.add(traits.data(first), traits.weight(first));
    222227      ++first;
    223228    }
  • trunk/yat/statistics/KolmogorovSmirnov.h

    r2119 r2202  
    66/*
    77  Copyright (C) 2008 Jari Häkkinen, Peter Johansson
    8   Copyright (C) 2009 Peter Johansson
     8  Copyright (C) 2009, 2010 Peter Johansson
    99
    1010  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    2323  along with yat. If not, see <http://www.gnu.org/licenses/>.
    2424*/
     25
     26#include <boost/concept_check.hpp>
    2527
    2628#include <iosfwd>
     
    202204  void KolmogorovSmirnov::add(ForwardIterator first, ForwardIterator last)
    203205  {
     206    BOOST_CONCEPT_ASSERT((boost::ForwardIterator<ForwardIterator>));
     207    typedef typename std::iterator_traits<ForwardIterator>::reference ref;
     208    BOOST_CONCEPT_ASSERT((boost::Convertible<ref, KolmogorovSmirnov::Element>));
    204209    ForwardIterator iter(first);
    205210    typename data_w::const_iterator hint(data_.begin());
    206211    for ( ; iter!=last; ++iter)
    207       if (iter->weight) // ignore data points with zero weight
     212      if ((*iter).weight) // ignore data points with zero weight
    208213        hint = data_.insert(hint, *iter);
    209214    add_sum_w(first, last);
     
    217222  {
    218223    while (first!=last) {
    219       if (first->label)
    220         sum_w1_ += first->weight;
     224      if ((*first).label)
     225        sum_w1_ += (*first).weight;
    221226      else
    222         sum_w2_ += first->weight;
     227        sum_w2_ += (*first).weight;
    223228      ++first;
    224229    }
  • trunk/yat/statistics/PearsonDistance.h

    r2119 r2202  
    66/*
    77  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson, Markus Ringnér
     8  Copyright (C) 2010 Peter Johansson
    89
    910  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    5556       set to unity.
    5657    */   
    57     template <typename Iter1, typename Iter2>
    58     double operator()
    59     (Iter1 beg1,Iter1 end1, Iter2 beg2) const
     58    template <typename ForwardIterator1, typename ForwardIterator2>
     59    double operator()(ForwardIterator1 beg1, ForwardIterator1 end1,
     60                      ForwardIterator2 beg2) const
    6061    {
    61       typename averager_pair<Iter1, Iter2>::type ap;
     62      typename averager_pair<ForwardIterator1, ForwardIterator2>::type ap;
    6263      add(ap,beg1,end1,beg2);
    6364      return 1-ap.correlation();
  • trunk/yat/statistics/Percentiler.h

    r2121 r2202  
    66/*
    77  Copyright (C) 2008, 2009 Jari Häkkinen, Peter Johansson
     8  Copyright (C) 2010 Peter Johansson
    89
    910  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    2728#include "yat/utility/yat_assert.h"
    2829#include "yat/utility/WeightIterator.h"
     30
     31#include <boost/concept_check.hpp>
    2932
    3033#include <algorithm>
     
    8487       Note, that data point with weight zero is completely ignored.
    8588
     89       Requirements: \c RandomAccessIterator should be a \ref
     90       concept_data_iterator and \random_access_iterator
     91
    8692       \return percentile of range
    8793     */
     
    9096                      RandomAccessIterator last) const
    9197    {
     98      BOOST_CONCEPT_ASSERT((boost::RandomAccessIterator<RandomAccessIterator>));
    9299      return calculate(first, last, sorted_,
    93100       typename utility::weighted_iterator_traits<RandomAccessIterator>::type());
  • trunk/yat/statistics/Smoother.cc

    r2121 r2202  
    33/*
    44  Copyright (C) 2008 Jari Häkkinen, Peter Johansson
    5   Copyright (C) 2009 Peter Johansson
     5  Copyright (C) 2009, 2010 Peter Johansson
    66
    77  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    4444    : density_(std::vector<double>(n)), kernel_(kernel), width_(width)
    4545  {
     46    assert(n>1);
    4647    x_.reserve(n);
    47     double step_size = (max-min)/n;
     48    double step_size = (max-min)/static_cast<double>(n-1);
    4849    for (double x=min; x_.size()<n; x+=step_size)
    4950      x_.push_back(x);
  • trunk/yat/statistics/Smoother.h

    r2119 r2202  
    66/*
    77  Copyright (C) 2008 Jari Häkkinen, Peter Johansson
    8   Copyright (C) 2009 Peter Johansson
     8  Copyright (C) 2009, 2010 Peter Johansson
    99
    1010  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    2626
    2727#include "yat/utility/iterator_traits.h"
     28
     29#include <boost/concept_check.hpp>
    2830
    2931#include <vector>
     
    109111           ForwardIterator first, ForwardIterator last)
    110112  {
     113    BOOST_CONCEPT_ASSERT((boost::ForwardIterator<ForwardIterator>));
     114    utility::iterator_traits<ForwardIterator> traits;
    111115    while (first!=last) {
    112       h.add(utility::iterator_traits<ForwardIterator>().data(),
    113             utility::iterator_traits<ForwardIterator>().weight());
     116      h.add(traits.data(first), traits.weight(first));
    114117      ++first;
    115118    }
  • trunk/yat/statistics/utility.h

    r2141 r2202  
    103103  /// Function is non-mutable function
    104104  ///
     105  /// Requirements: \c RandomAccessIterator should be a \ref
     106  /// concept_data_iterator and \random_access_iterator
     107  ///
    105108  /// Since 0.6 function also work with a \ref
    106109  /// concept_weighted_iterator
    107110  ///
    108   template <class T>
    109   double mad(T first, T last, const bool sorted=false);
     111  template <class RandomAccessIterator>
     112  double mad(RandomAccessIterator first, RandomAccessIterator last,
     113             bool sorted=false);
    110114
    111115
     
    120124  /// can be const_iterators.
    121125  ///
    122   /// Requirements: \c T should be a \ref concept_data_iterator
     126  /// Requirements: \c RandomAccessIterator should be a \ref
     127  /// concept_data_iterator and \random_access_iterator
    123128  ///
    124129  /// @return median of range
    125130  ///
    126   template <class T>
    127   double median(T first, T last, const bool sorted=false);
     131  template <class RandomAccessIterator>
     132  double median(RandomAccessIterator first, RandomAccessIterator last,
     133                bool sorted=false);
    128134
    129135
     
    186192           const classifier::Target& target)
    187193  {
     194    utility::iterator_traits<ForwardIterator> traits;
    188195    for (size_t i=0; first!=last; ++i, ++first)
    189       o.add(utility::iterator_traits<ForwardIterator>().data(first),
    190             target.binary(i),
    191             utility::iterator_traits<ForwardIterator>().weight(first));
     196      o.add(traits.data(first), target.binary(i), traits.weight(first));
    192197  }
    193198
    194199
    195   template <class T>
    196   double mad(T first, T last, const bool sorted=false)
     200  template <class RandomAccessIterator>
     201  double mad(RandomAccessIterator first, RandomAccessIterator last,
     202             bool sorted)
    197203  {
    198204    double m = median(first, last, sorted);
    199     typedef std::vector<typename std::iterator_traits<T>::value_type> Vec;
     205    typedef typename std::iterator_traits<RandomAccessIterator>::value_type T;
     206    typedef std::vector<T> Vec;
    200207    Vec ad;
    201208    ad.reserve(std::distance(first, last));
    202     // copy values (and weights if T is weighted)
     209    // copy values (and weights if RandomAccessIterator is weighted)
    203210    std::copy(first, last, std::back_insert_iterator<Vec>(ad));
    204211    utility::iterator_traits<typename Vec::iterator> traits;
     
    212219 
    213220
    214   template <class T>
    215   double median(T first, T last, const bool sorted=false)
     221  template <class RandomAccessIterator>
     222  double median(RandomAccessIterator first, RandomAccessIterator last,
     223                bool sorted)
    216224  {
    217225    return percentile2(first, last, 50.0, sorted);
     
    223231                    double p, bool sorted=false)
    224232  {
     233    BOOST_CONCEPT_ASSERT((boost::RandomAccessIterator<RandomAccessIterator>));
    225234    // range is one value only is a special case
    226235    if (first+1 == last)
  • trunk/yat/utility/CommandLine.cc

    r2119 r2202  
    55  Copyright (C) 2008 Jari Häkkinen, Peter Johansson
    66  Copyright (C) 2009 Peter Johansson
     7  Copyright (C) 2010 Jari Häkkinen, Peter Johansson
    78
    89  This file is part of the yat library, http://dev.thep.lu.se/yat
  • trunk/yat/utility/CommandLine.h

    r2121 r2202  
    55
    66/*
    7   Copyright (C) 2007, 2008, 2009 Jari Häkkinen, Peter Johansson
     7  Copyright (C) 2007, 2008, 2009, 2010 Jari Häkkinen, Peter Johansson
    88
    99  This file is part of the yat library, http://dev.thep.lu.se/yat
  • trunk/yat/utility/DataIterator.h

    r2119 r2202  
    66/*
    77  Copyright (C) 2008 Jari Häkkinen, Peter Johansson
    8   Copyright (C) 2009 Peter Johansson
     8  Copyright (C) 2009, 2010 Peter Johansson
    99
    1010  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    3535  /**
    3636     @brief DataIterator
     37
     38     DataIterator is an iterator adaptor that enables iterating over a
     39     weighted range but accessing only the data part. The iterator
     40     behaves just like it Base iterator except that operator* returns
     41     iterator_traits<Base>.data(base), i.e., the data part is
     42     returned.
     43
     44     Here is a short example illustrating typical usage:
     45     \code
     46
     47     std::vector<DataWeight> weighted_vec;
     48     ...
     49     std::vector<double> vec(weighted_vec.size());
     50     std::copy(data_iterator(weighted_vec.begin()),
     51               data_iterator(weighted_vec.end()),
     52               vec.begin());
     53
     54
     55     \endcode
    3756  */
    3857  template<typename Base>
     
    5372    explicit DataIterator(Base b)
    5473      : DataIterator::iterator_adaptor_(b) {}
     74
     75    /**
     76       \brief Default Constructor
     77
     78       \since New in yat 0.6
     79     */
     80    DataIterator(void)
     81      : DataIterator::iterator_adaptor_() {}
    5582
    5683    /**
  • trunk/yat/utility/DataWeightProxy.h

    r2122 r2202  
    66/*
    77  Copyright (C) 2008 Jari Häkkinen, Peter Johansson
    8   Copyright (C) 2009 Peter Johansson
     8  Copyright (C) 2009, 2010 Peter Johansson
    99
    1010  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    3535     \brief Proxy class for DataWeight
    3636
    37      DataIterator and WeightIterator should be a TrivialIterator
     37     DataIterator and WeightIterator should be a mutable TrivialIterator
    3838  */
    3939  template<typename DataIterator, typename WeightIterator>
  • trunk/yat/utility/StrideIterator.h

    r2183 r2202  
    66/*
    77  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
     8  Copyright (C) 2010 Peter Johansson
    89
    910  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    2526#include "iterator_traits.h"
    2627
     28#include <boost/concept_check.hpp>
    2729#include <boost/iterator/iterator_adaptor.hpp>
    2830
     
    3032namespace yat {
    3133namespace utility {
    32 
    33   // forward declaration
    34   template<typename Iter>
    35   class StrideIterator;
    36 
    37   /**
    38      Specialization for StrideIterator that calls underlying iterator.
    39    */
    40   template <typename Iter>
    41   struct weighted_iterator_traits<StrideIterator<Iter> > {
    42     /**
    43        StrideIterator is weighted if underlying iterator is weighted.
    44     */
    45     typedef typename weighted_iterator_traits<Iter>::type type;
    46   };
    47 
    48   /**
    49      Specialization for StrideIterator using iterator_traits with base()
    50    */
    51   template <class Iter>
    52   struct iterator_traits<StrideIterator<Iter> > {
    53     /**
    54        data_reference same as for underlying iterator
    55      */
    56     typedef typename iterator_traits<Iter>::data_reference data_reference;
    57 
    58     /**
    59        weight_reference same as for underlying iterator
    60      */
    61     typedef typename iterator_traits<Iter>::weight_reference weight_reference;
    62 
    63     /**
    64        \return data of iterator
    65     */
    66     data_reference data(StrideIterator<Iter> iter) const
    67     { return iterator_traits<Iter>().data(iter.base()); }
    68 
    69     /**
    70        \return weight of iterator
    71     */
    72     weight_reference weight(StrideIterator<Iter> iter) const
    73     { return iterator_traits<Iter>().weight(iter.base()); }
    74 
    75   };
    7634
    7735  /**
     
    8644     e.g. std or boost).
    8745  */
    88   template<typename Iter>
     46  template<typename RandomAccessIterator>
    8947  class StrideIterator
    90     : public boost::iterator_adaptor<StrideIterator<Iter>, Iter>
     48    : public boost::iterator_adaptor<StrideIterator<RandomAccessIterator>
     49                                     , RandomAccessIterator>
    9150  {
    92     typedef boost::iterator_adaptor<StrideIterator<Iter>,Iter> super_t;
     51    typedef boost::iterator_adaptor<StrideIterator<RandomAccessIterator>,
     52                                    RandomAccessIterator> super_t;
    9353
    9454  public:
    9555    /// type of underlying iterator
    96     typedef Iter iterator_type;
     56    typedef RandomAccessIterator iterator_type;
    9757
    9858    /**
     
    10262     */
    10363    explicit StrideIterator(size_t stride=1)
    104       : StrideIterator::iterator_adaptor_(), stride_(stride) {}
     64      : StrideIterator::iterator_adaptor_(), stride_(stride)
     65    {
     66      BOOST_CONCEPT_ASSERT((boost::RandomAccessIterator<RandomAccessIterator>));
     67    }
    10568
    10669    /**
    10770       \brief Constructor
    10871    */
    109     explicit StrideIterator(Iter p, size_t stride=1)
     72    explicit StrideIterator(RandomAccessIterator p, size_t stride=1)
    11073      : StrideIterator::iterator_adaptor_(p), stride_(stride) {}
    11174
     
    12184       \brief Conversion constructor.
    12285
    123        Create a StrideIterator<Iter> from a StrideIterator<I2>. Possible
    124        if I2 is convertible to a Iter. Constructor allows implicit
    125        conversions such as iterator to const_iterator.
     86       Create a StrideIterator<RandomAccessIterator> from a
     87       StrideIterator<I2>. Possible if I2 is convertible to a
     88       RandomAccessIterator. Constructor allows implicit conversions
     89       such as iterator to const_iterator.
    12690     */
    12791    template<typename I2>
    12892    StrideIterator(StrideIterator<I2> other,
    129                    typename boost::enable_if_convertible<I2, Iter>::type* = 0 )
     93                   typename boost::enable_if_convertible<I2
     94                   , RandomAccessIterator>::type* = 0 )
    13095      : StrideIterator::iterator_adaptor_(other.base()),
    13196        stride_(other.stride()) {}
     
    170135
    171136    void increment(void) { this->base_reference()+=stride_; }
    172 
    173137  };
    174 
    175 
    176 
    177 
    178138
    179139}}} // of namespace utility, yat, and theplu
  • trunk/yat/utility/WeightIterator.h

    r2119 r2202  
    66/*
    77  Copyright (C) 2008 Jari Häkkinen, Peter Johansson
    8   Copyright (C) 2009 Peter Johansson
     8  Copyright (C) 2009, 2010 Peter Johansson
    99
    1010  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    3333  /**
    3434     @brief WeightIterator
     35
     36     WeightIterator is an iterator adaptor that enables iterating over
     37     a weighted range but accessing only the weight part of the
     38     range. The iterator behaves just like it Base iterator except
     39     that operator* returns iterator_traits<Base>.weight(base), i.e.,
     40     the weight part is returned.
     41
     42     Here is a short example illustrating typical usage:
     43     \code
     44
     45     std::vector<DataWeight> weighted_vec;
     46     ...
     47     std::vector<double> vec(weighted_vec.size());
     48     std::copy(weight_iterator(weighted_vec.begin()),
     49               weight_iterator(weighted_vec.end()),
     50               vec.begin());
     51
     52
     53     \endcode
    3554  */
    3655  template<typename Base>
     
    4665  {
    4766  public:
     67    /**
     68       \brief Default Constructor
     69
     70       \since New in yat 0.6
     71     */
     72    WeightIterator(void)
     73      : WeightIterator::iterator_adaptor_() {}
     74
    4875    /**
    4976       \brief Constructor from \a Base iterator
     
    6693
    6794    /**
    68        using iterator_traits::data on Base iterator
     95       using iterator_traits::weight on Base iterator
    6996
    70        \return data
     97       \return weight
    7198     */
    7299    typename iterator_traits<Base>::weight_reference operator*(void) const
  • trunk/yat/utility/WeightedIterator.h

    r1887 r2202  
    55
    66/*
    7   Copyright (C) 2008, 2009 Peter Johansson
     7  Copyright (C) 2008, 2009, 2010 Peter Johansson
    88
    99  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    3636  /**
    3737     \brief WeightedIterator
     38
     39     Adaptor enabling to make two unweighted iterators to behave like
     40     a weighted iterator. The data part corresponds to the
     41     DataIterator and the weight corresponds to the WeightIterator.
    3842  */
    3943  template<typename DataIterator, typename WeightIterator>
     
    5660     */
    5761    typedef WeightIterator weight_iterator;
     62
     63    /**
     64       \brief Default Constructor.
     65
     66       Created iterator is not dereferencable
     67
     68       \since New in yat 0.6
     69    */
     70    WeightedIterator(void)
     71    {}
    5872
    5973    /**
     
    141155  }
    142156 
    143 
    144   /**
    145      Specialization for WeightedIterator
    146    */
    147   template <typename DataIterator, typename WeightIterator>
    148   struct weighted_iterator_traits<WeightedIterator<DataIterator
    149                                                    ,WeightIterator> >
    150   {
    151     /**
    152        WeightedIterator is weighted
    153      */
    154     typedef weighted_iterator_tag type;
    155   };
    156 
    157   /**
    158      Specialization for WeightedIterator
    159    */
    160   template <typename DataIterator, typename WeightIterator>
    161   struct iterator_traits<WeightedIterator<DataIterator, WeightIterator> >
    162   {
    163   private:
    164     typedef WeightedIterator<DataIterator,WeightIterator> WI;
    165     typedef typename WI::data_iterator data_iterator;
    166     typedef typename WI::weight_iterator weight_iterator;
    167   public:
    168     /**
    169        data_reference is same reference of data_iterator_base
    170      */
    171     typedef typename
    172     std::iterator_traits<data_iterator>::reference data_reference;
    173 
    174     /**
    175        weight_reference is same reference of weight_iterator_base
    176      */
    177     typedef typename
    178     std::iterator_traits<weight_iterator>::reference weight_reference;
    179 
    180     /**
    181        \return dereferenced data_iterator
    182      */
    183     data_reference data(WI iter) const { return * iter.data_base(); }
    184 
    185     /**
    186        \return dereferenced weight_iterator
    187      */
    188     weight_reference weight(WI iter) const { return * iter.weight_base(); }
    189   };
    190 
    191157}}} // of namespace utility, yat, and theplu
    192158
  • trunk/yat/utility/iterator_traits.h

    r2161 r2202  
    2727#include "DataWeight.h"
    2828
     29#include <boost/mpl/logical.hpp>
     30#include <boost/type_traits/is_const.hpp>
    2931#include <boost/type_traits/is_convertible.hpp>
     32#include <boost/type_traits/is_same.hpp>
     33#include <boost/type_traits/remove_reference.hpp>
    3034#include <boost/utility/enable_if.hpp>
    3135
     
    6872      \internal
    6973
    70       specialization for iterators with value type DataWeight
     74      specialization for iterators with value type convertible to DataWeight
    7175  */
    7276  template <typename T>
    73   struct weighted_iterator_traits_detail<T, typename boost::enable_if<typename boost::is_convertible<T, DataWeight>::type>::type > {
    74     /**
    75        Iterators with value type DataWeight is weighted
     77  struct weighted_iterator_traits_detail<T, typename boost::enable_if<typename boost::is_convertible<T, DataWeight> >::type > {
     78    /**
     79       Iterators with value type convertible to DataWeight is weighted
    7680     */
    7781    typedef weighted_iterator_tag type;
     
    8286
    8387  /**
    84       Metafunction to decide whether an iterator is weighted or
    85       non-weighted. This (default) implementation return unweighted,
    86       unless value_type of iterator is DataWeight in which case
    87       weighted is returned.
     88      Metafunction to decide whether an Iterator is weighted or
     89      non-weighted. This (default) implementation returns
     90      unweighted_iterator_tag, unless value_type of Iterator is
     91      convertible to DataWeight in which case weighted_iterator_tag is
     92      returned.
    8893  */
    89   template <class T>
     94  template <class Iterator>
    9095  struct weighted_iterator_traits
    9196  {
    9297  private:
    93     typedef typename std::iterator_traits<T>::value_type value;
     98    typedef typename std::iterator_traits<Iterator>::value_type value;
    9499  public:
    95100    /**
    96        \return weighted if value_type is DataWeight
     101       \return weighted_iterator_tag if Iterator::value_type is
     102       convertible to DataWeight
    97103     */
    98104    typedef typename detail::weighted_iterator_traits_detail<value>::type type;
     
    160166
    161167  namespace detail {
    162     /// check (at compile time) that iterator is unweighted.
     168    /**
     169        \internal
     170
     171        check (at compile time) that iterator is unweighted.
     172    */
    163173    inline void
    164174    check_iterator_is_unweighted(utility::unweighted_iterator_tag x){}
     
    178188
    179189namespace detail {
    180   /**
    181      \internal
    182 
    183      This class is used in iterator_traits to separate different cases.
    184 
    185      This the default implementation that could be used for unweighted
    186      iterators.
    187    */
    188   template <typename Iter, typename T >
    189   struct iterator_traits_detail
     190
     191  /**
     192     \internal
     193
     194     The following block of code is used to detect if weighted
     195     iterators have functions 'double& data(void)' or if they only
     196     have the const version.
     197     
     198     The technique used is taken from http://www.martinecker.com/wiki/
     199   */
     200  typedef char yes;
     201  /**
     202     \internal
     203
     204     This type (no) and type yes have different sizes and are used to
     205     differentiate between the two cases.
     206   */
     207  typedef char (&no)[2];
     208  /**
     209     \internal
     210
     211     Overloaded function with template below. If there exists a
     212     function that returns double& that will used and otherwise
     213     overloaded template below will be used. This implementation and
     214     template return different types to differentiate the two cases.
     215   */
     216  yes has_mutable(double&);
     217  /**
     218     \internal
     219
     220     Function used in iter_has_mutable_data and
     221     iter_has_mutable_weight. The default case is used if function
     222     called (e.g. data() does not return double&.
     223   */
     224  template<typename T>
     225  no has_mutable(const T&);
     226
     227  /**
     228     \internal
     229
     230     Struct to check if iterator has mutable data. *Iter must have a
     231     function data(). If that function returns double& ::value is
     232     true.
     233   */
     234  template <class Iter>
     235  struct iter_has_mutable_data
    190236  {
     237    /// instance of Iter
     238    static Iter iter;
     239    /// true if *iter has a function data() that returns double&
     240    static const bool value =
     241      sizeof(has_mutable((*iter).data())) == sizeof(yes);
     242  };
     243
     244
     245  /**
     246     \internal
     247
     248     Struct to check if iterator has mutable data. *Iter must have a
     249     function data(). If that function returns double& ::value is
     250     true.
     251   */
     252  template <class Iter>
     253  struct iter_has_mutable_weight
     254  {
     255    /// instance of Iter
     256    static Iter iter;
     257    /// true if *iter has a function weight() that returns double&
     258    static const bool value =
     259      sizeof(has_mutable((*iter).weight())) == sizeof(yes);
     260  };
     261
     262
     263  /**
     264     \internal
     265
     266     Convenience meta-function. The struct is-a boost::true_type if
     267     Iter is a weighted iterator
     268
     269     The purpose of the struct is to be used in boost::mpl, for
     270     example, in boost::mpl::and_.
     271
     272     \see weighted_iterator_traits
     273   */
     274  template<typename Iter>
     275  struct is_weighted
     276    : public boost::is_same<weighted_iterator_tag
     277                            , typename weighted_iterator_traits<Iter>::type>
     278  {};
     279
     280  /**
     281     \internal
     282
     283     same is_weighted but negated
     284   */
     285  template<typename Iter>
     286  struct is_unweighted
     287    : public boost::is_same<unweighted_iterator_tag
     288                            , typename weighted_iterator_traits<Iter>::type>
     289  {};
     290
     291
     292  /**
     293     \internal
     294
     295     Default implementation of iterator_traits_detail. Is supposed to
     296     be used for unweighted iterators. Weighted iterators use
     297     specialization below.
     298   */
     299  template <typename Iter, typename Enable = void>
     300  struct iterator_traits_detail {
    191301    /**
    192302       for unweighted data_reference is reference
     
    197307       for unweighted weight_reference is a double
    198308    */
    199     typedef double weight_reference;
    200 
    201     /**
    202        Constructor just checking that iterator is unweighted
    203     */
    204     iterator_traits_detail(void)
    205     { check_iterator_is_unweighted(typename
    206                                    weighted_iterator_traits<Iter>::type());
    207     }
    208    
     309    typedef const double weight_reference;
     310
    209311    /**
    210312       \return * \a iter
     
    218320  };
    219321
    220 
    221   /**
    222      specialization for weighted iterator with reference DataWeight&
    223    */
     322  /**
     323     \internal
     324     Metafunction that returns double& if true and const double otherwise
     325   */
     326  template<bool>
     327  struct mutable_reference {
     328    /// return const double if bool is false
     329    typedef const double type;
     330  };
     331
     332  /**
     333     \internal
     334     Specialization that returns double& in true case
     335  */
     336  template<>
     337  struct mutable_reference<true> {
     338    /// return double& if bool is false
     339    typedef double& type;
     340  };
     341
     342
     343  /**
     344     \internal
     345
     346     Specialization for weighted iterators
     347   */
     348  // we need remove_reference because is_const seems to not work on const&
    224349  template <typename Iter>
    225   struct iterator_traits_detail<Iter, DataWeight&> {
    226     /**
    227        for mutable weighted iterator data_reference is double&
    228     */
    229     typedef double& data_reference;
    230 
    231     /**
    232        for mutable weighted iterator weight_reference is double&
    233     */
    234     typedef double& weight_reference;
    235 
    236     /**
    237        \return reference to data of iterator
     350  struct iterator_traits_detail<Iter,
     351                         typename boost::enable_if<is_weighted<Iter> >::type >
     352  {
     353    /**
     354       data_reference is double& for mutable iterators and const
     355       double otherwise
     356    */
     357    typedef
     358    typename mutable_reference<iter_has_mutable_data<Iter>::value>::type
     359    data_reference;
     360
     361    /**
     362       weight_reference is double& for mutable iterators and const
     363       double otherwise
     364    */
     365    typedef
     366    typename mutable_reference<iter_has_mutable_weight<Iter>::value>::type
     367    weight_reference;
     368
     369    /**
     370       return data of \a iter
    238371    */
    239372    data_reference data(Iter iter) const { return (*iter).data(); }
    240373
    241374    /**
    242        \return reference to weight of iterator
     375       return weight of \a iter
    243376    */
    244377    weight_reference weight(Iter iter) const { return (*iter).weight(); }
    245378  };
    246379
    247 
    248   /**
    249      specialization for weighted iterator with reference const DataWeight&
    250    */
    251   template <typename Iter>
    252   struct iterator_traits_detail<Iter, const DataWeight&> {
    253     /**
    254        for read-only weighted iterator data_reference is const double&
    255     */
    256     typedef const double& data_reference;
    257 
    258     /**
    259        for read-only weighted iterator data_reference is const double&
    260     */
    261     typedef const double& weight_reference;
    262 
    263     /**
    264        \return const reference to data of iterator
    265     */
    266     data_reference data(Iter iter) const { return (*iter).data(); }
    267 
    268     /**
    269        \return const reference to weight of iterator
    270     */
    271     weight_reference weight(Iter iter) const { return (*iter).weight(); }
    272   };
    273 
    274 
    275   /**
    276      specialization for weighted iterator with reference const DataWeight
    277    */
    278   template <typename Iter>
    279   struct iterator_traits_detail<Iter, const DataWeight> {
    280     /**
    281        \brief data_reference
    282     */
    283     typedef const double data_reference;
    284 
    285     /**
    286        \brief weight_reference
    287     */
    288     typedef const double weight_reference;
    289 
    290     /**
    291        \return const reference to data of iterator
    292     */
    293     data_reference data(Iter iter) const { return (*iter).data(); }
    294 
    295     /**
    296        \return const reference to weight of iterator
    297     */
    298     weight_reference weight(Iter iter) const { return (*iter).weight(); }
    299   };
    300380} // namespace detail
    301381
     
    305385     weight for both weighted and unweighted iterators.
    306386
    307      This class works for unweighted iterators as well as weighted
    308      iterators as long as they have reference type DataWeight& or
    309      const DataWeight&.
    310 
    311      For others, such as WeightedIterator for which reference type is
    312      a proxy class, this class should be specialized. For adaptors
    313      that have an underlying iterator (e.g. StrideIterator), this
    314      class should be specialized, so the class also works when the
    315      underlying is an iterator that is not covered by this class
    316      e.g. WeightedIterator.
     387     For weighted iterators this class requires that *Iter has
     388     functions data(void) and weight(void).
    317389   */
    318390  template <typename Iter>
    319391  struct iterator_traits {
    320392  private:
    321     typedef typename std::iterator_traits<Iter>::reference reference;
    322     typedef detail::iterator_traits_detail<Iter, reference> traits;
     393    typedef detail::iterator_traits_detail<Iter> traits;
    323394  public:
    324395    /**
    325        data_reference (type returned by data(void) is determined by
    326        iterator_traits_detail
     396       For unweighted iterator, data_reference is the same as
     397       std::iterator_traits<Iter>::reference, i.e., the data if the
     398       iterator is the same as *Iter.
     399
     400       For weighted iterators, data_reference is double& if *Iter has
     401       a function double& data(void). Otherwise data_reference is
     402       const double.
    327403     */
    328404    typedef typename traits::data_reference data_reference;
    329405
    330406    /**
    331        data_reference (type returned by data(void) is determined by
    332        iterator_traits_detail
     407       For unweighted iterator, data_reference const double since the
     408       weight is always implicitly 1.0 and not mutable.
     409
     410       For weighted iterators, data_reference is double& if *Iter has
     411       a function double& data(void). Otherwise data_reference is
     412       const double.
    333413     */
    334414    typedef typename traits::weight_reference weight_reference;
    335415
    336416    /**
    337        \return data
     417       \return data of iterator \a iter
    338418    */
    339419    data_reference data(Iter iter) const
     
    341421
    342422    /**
    343        \return weight
     423       \return weight of iterator \a iter
    344424     */
    345425    weight_reference weight(Iter iter) const
     
    348428  };
    349429
    350 
    351430}}} // of namespace utility, yat, and theplu
    352431
  • trunk/yat/utility/sort_index.h

    r1603 r2202  
    55
    66/*
    7   Copyright (C) 2008 Peter Johansson
     7  Copyright (C) 2008, 2010 Peter Johansson
    88
    99  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    2424
    2525#include "StrideIterator.h"
     26
     27#include <boost/concept_check.hpp>
    2628
    2729#include <algorithm>
     
    9395                  std::vector<size_t>& result)
    9496  {
     97    BOOST_CONCEPT_ASSERT((boost::ForwardIterator<ForwardIterator>));
    9598    std::vector<double> vec;
    9699    vec.reserve(std::distance(first, last));
  • trunk/yat/utility/stl_utility.h

    r2181 r2202  
    99  Copyright (C) 2006 Jari Häkkinen
    1010  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    11   Copyright (C) 2009 Peter Johansson
     11  Copyright (C) 2009, 2010 Peter Johansson
    1212
    1313  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    3737#include "DataWeight.h"
    3838
     39#include <boost/concept_check.hpp>
    3940#include <boost/iterator/transform_iterator.hpp>
    4041#include <boost/mpl/if.hpp>
     
    184185     \since New in yat 0.5
    185186   */
    186   template<typename InputIterator, typename Key>
     187  template<typename InputIterator, typename Key, typename Comp>
    187188  void inverse(InputIterator first, InputIterator last,
    188                std::map<Key, std::vector<size_t> >& m)
    189   {
     189               std::map<Key, std::vector<size_t>, Comp >& m)
     190  {
     191    BOOST_CONCEPT_ASSERT((boost::InputIterator<InputIterator>));
     192    BOOST_CONCEPT_ASSERT((boost::Convertible<typename std::iterator_traits<InputIterator>::value_type, Key>));
    190193    m.clear();
    191194    for (size_t i=0; first!=last; ++i, ++first)
     
    201204     \since New in yat 0.5
    202205   */
    203   template<typename Key, typename InputIterator>
     206  template<typename Key, typename InputIterator, typename Comp>
    204207  void inverse(InputIterator first, InputIterator last,
    205                std::multimap<Key, size_t>& m)
    206   {
     208               std::multimap<Key, size_t, Comp>& m)
     209  {
     210    BOOST_CONCEPT_ASSERT((boost::InputIterator<InputIterator>));
     211    BOOST_CONCEPT_ASSERT((boost::Convertible<typename std::iterator_traits<InputIterator>::value_type, Key>));
    207212    m.clear();
    208213    for (size_t i=0; first!=last; ++i, ++first)
Note: See TracChangeset for help on using the changeset viewer.