Changeset 916 for trunk/yat/utility


Ignore:
Timestamp:
Sep 30, 2007, 2:50:10 AM (14 years ago)
Author:
Peter
Message:

Sorry this commit is a bit to big.

Adding a yat_assert. The yat assert are turned on by providing a
'-DYAT_DEBUG' flag to preprocessor if normal cassert is turned
on. This flag is activated for developers running configure with
--enable-debug. The motivation is that we can use these yat_asserts in
header files and the yat_asserts will be invisible to the normal user
also if he uses C-asserts.

added output operator in DataLookup2D and removed output operator in
MatrixLookup?

Removed template function add_values in Averager and weighted version

Added function to AveragerWeighted? taking iterator to four ranges.

Location:
trunk/yat/utility
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/utility/Iterator.h

    r884 r916  
    2424  02111-1307, USA.
    2525*/
     26
     27#include "yat_assert.h"
    2628
    2729#include <iterator>
     
    6264       \return element
    6365     */
    64     return_type operator*(void) const { return container_->operator()(index_); }
     66    return_type operator*(void) const
     67    { yat_assert(index_<container_->size());
     68      return container_->operator()(index_); }
    6569
    6670    /**
  • trunk/yat/utility/IteratorTraits.h

    r914 r916  
    6161  };
    6262
     63
     64
     65  /*
     66    struct used to determine if a pair of iterators should be treated
     67    as weighted
     68
     69  template <class T1, class T2>
     70  struct weighted_iterator_traits2 {
     71    typedef weighted_type type;
     72  };
     73
     74  // but specialized to return weighted type for some things
     75  template <class T1, class T2>
     76  struct weighted_iterator_traits2<yat::utility::IteratorWeighted<U,V> > {
     77    typedef weighted_type type;
     78  };
     79  */
     80
    6381  // check (at compile time) that iterator is unweighted.
    6482  inline void check_iterator_is_unweighted(unweighted_type x){}
    6583  template <class Iter>
    6684  void check_iterator_is_unweighted(Iter iter)
    67   {check_iterator_unweighted(typename weighted_iterator_traits<Iter>::type());}
     85  { check_iterator_is_unweighted(typename
     86                                 weighted_iterator_traits<Iter>::type());
     87  }
    6888
    6989
     
    7999  template <class Iter>
    80100  double iterator_traits_data(Iter iter)
    81   { return iterator_traits_data(iter, weighted_iterator_traits<Iter>::type()); }
     101  { return iterator_traits_data(iter, typename
     102                                weighted_iterator_traits<Iter>::type()); }
    82103
    83104  template <class Iter>
     
    101122  template <class Iter>
    102123  double iterator_traits_weight(Iter iter)
    103   { return iterator_traits_data(iter, weighted_iterator_traits<Iter>::type()); }
     124  { return iterator_traits_weight(iter, typename
     125                                  weighted_iterator_traits<Iter>::type()); }
    104126
    105127  template <class Iter>
  • trunk/yat/utility/IteratorWeighted.h

    r909 r916  
    33
    44// $Id$
     5
     6#include "yat_assert.h"
    57
    68#include <iterator>
     
    4143       \return element
    4244     */
    43     return_type operator*(void) const { return container_->operator()(index_); }
     45    return_type operator*(void) const
     46    {
     47      yat_assert(index_<container_->size());
     48      return container_->operator()(index_);
     49    }
    4450
    4551    /**
    4652       \return data
    4753    */
    48     return_type data(void) const { return container_->data(index_); }
     54    return_type data(void) const
     55    { yat_assert(index_<container_->size()); return container_->data(index_); }
    4956
    5057    /**
    5158       \return weight
    5259    */
    53     return_type weight(void) const { return container_->weight(index_); }
     60    return_type weight(void) const
     61    { yat_assert(index_<container_->size());return container_->weight(index_); }
    5462
    5563
  • trunk/yat/utility/Makefile.am

    r908 r916  
    3434  Alignment.h Exception.h FileUtil.h Iterator.h IteratorTraits.h \
    3535  IteratorWeighted.h kNNI.h matrix.h NNI.h  \
    36   PCA.h stl_utility.h SVD.h TypeInfo.h utility.h vector.h WeNNI.h
     36  PCA.h stl_utility.h SVD.h TypeInfo.h utility.h vector.h WeNNI.h \
     37  yat_assert.h
  • trunk/yat/utility/matrix.cc

    r865 r916  
    406406  {
    407407    assert(m_);
    408     if (gsl_matrix_memcpy(m_, other.gsl_matrix_p()))
    409       throw utility::GSL_error("matrix::create_gsl_matrix_copy dimension mis-match");
     408    if (this!=&other)
     409      if (gsl_matrix_memcpy(m_, other.gsl_matrix_p()))
     410        throw utility::GSL_error("matrix::create_gsl_matrix_copy dimension mis-match");
    410411    return *this;
    411412  }
  • trunk/yat/utility/utility.h

    r865 r916  
    6464  bool is_nan(const std::string& s);
    6565
    66 
    67 
    6866}}} // of namespace utility, yat, and theplu
    6967
Note: See TracChangeset for help on using the changeset viewer.