Changeset 1066


Ignore:
Timestamp:
Feb 10, 2008, 11:48:19 PM (13 years ago)
Author:
Peter
Message:

Iterators for KernelLookup? - refs #267

Location:
trunk/yat
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/classifier/KernelLookup.cc

    r1000 r1066  
    117117
    118118
     119  KernelLookup::const_iterator KernelLookup::begin(void) const
     120  {
     121    return const_iterator(const_iterator::iterator_type(*this, 0, 0), 1);
     122  }
     123
     124
     125  KernelLookup::const_iterator KernelLookup::begin_column(size_t i) const
     126  {
     127    return const_iterator(const_iterator::iterator_type(*this, 0, i), columns());
     128  }
     129
     130
     131  KernelLookup::const_iterator KernelLookup::begin_row(size_t i) const
     132  {
     133    return const_iterator(const_iterator::iterator_type(*this, i, 0), 1);
     134  }
     135
     136
    119137  const DataLookup2D* KernelLookup::data(void) const
    120138  {
     
    132150  {
    133151    return kernel_->element(vec, row_index_[i]);
     152  }
     153
     154
     155  KernelLookup::const_iterator KernelLookup::end(void) const
     156  {
     157    return const_iterator(const_iterator::iterator_type(*this, rows(), 0), 1);
     158  }
     159
     160
     161  KernelLookup::const_iterator KernelLookup::end_column(size_t i) const
     162  {
     163    return const_iterator(const_iterator::iterator_type(*this, this->rows(), i),
     164                          this->columns());
     165  }
     166
     167
     168  KernelLookup::const_iterator KernelLookup::end_row(size_t i) const
     169  {
     170    return const_iterator(const_iterator::iterator_type(*this, i+1, 0), 1);
    134171  }
    135172
  • trunk/yat/classifier/KernelLookup.h

    r1000 r1066  
    77  Copyright (C) 2005 Jari Häkkinen, Peter Johansson
    88  Copyright (C) 2006 Jari Häkkinen, Markus Ringnér, Peter Johansson
    9   Copyright (C) 2007 Peter Johansson
     9  Copyright (C) 2007, 2008 Peter Johansson
    1010
    1111  This file is part of the yat library, http://trac.thep.lu.se/yat
     
    3030#include "DataLookup2D.h"
    3131#include "MatrixLookup.h"
     32#include "yat/utility/Iterator.h"
     33#include "yat/utility/StrideIterator.h"
     34
    3235
    3336#include <vector>
     
    6669
    6770  public:
     71    /// 'Read Only' iterator
     72    typedef utility::StrideIterator<utility::Iterator<const KernelLookup,
     73                                                      const double> >
     74    const_iterator;
    6875
    6976    ///
     
    158165    virtual ~KernelLookup(void);
    159166
     167    /**
     168       Iterator iterates along a row. When end of row is reached it
     169       jumps to beginning of next row.
     170
     171       \return const_iterator pointing to upper-left element.
     172     */
     173    const_iterator begin(void) const;
     174
     175    /**
     176       Iterator iterates along a column.
     177
     178       \return iterator pointing to first element of column \a i.
     179     */
     180    const_iterator begin_column(size_t) const;
     181
     182    /**
     183       Iterator iterates along a column.
     184
     185       \return const_iterator pointing to first element of column \a i.
     186     */
     187    const_iterator begin_row(size_t) const;
     188
    160189    ///
    161190    /// Each column in returned DataLookup corresponds to the column
     
    187216    */
    188217    double element(const DataLookupWeighted1D& vec, size_t i) const;
     218
     219    /**
     220       \return const_iterator pointing to end of matrix
     221     */
     222    const_iterator end(void) const;
     223
     224    /**
     225       \return const_iterator pointing to end of column \a i
     226     */
     227    const_iterator end_column(size_t) const;
     228
     229    /**
     230       \return const_iterator pointing to end of row \a i
     231     */
     232    const_iterator end_row(size_t) const;
    189233
    190234    /**
  • trunk/yat/classifier/MatrixLookup.cc

    r1063 r1066  
    163163  MatrixLookup::const_iterator MatrixLookup::begin(void) const
    164164  {
    165     return const_iterator(normal_iter(*this, 0, 0), 1);
     165    return const_iterator(const_iterator::iterator_type(*this, 0, 0), 1);
    166166  }
    167167
     
    169169  MatrixLookup::const_iterator MatrixLookup::begin_column(size_t i) const
    170170  {
    171     return const_iterator(normal_iter(*this, 0, i),this->columns());
     171    return const_iterator(const_iterator::iterator_type(*this, 0, i),columns());
    172172  }
    173173
     
    175175  MatrixLookup::const_iterator MatrixLookup::begin_row(size_t i) const
    176176  {
    177     return const_iterator(normal_iter(*this, i, 0), 1);
     177    return const_iterator(const_iterator::iterator_type(*this, i, 0), 1);
    178178  }
    179179
     
    181181  MatrixLookup::const_iterator MatrixLookup::end(void) const
    182182  {
    183     return const_iterator(normal_iter(*this, this->rows(), 0), 1);
     183    return const_iterator(const_iterator::iterator_type(*this, rows(), 0), 1);
    184184  }
    185185
     
    187187  MatrixLookup::const_iterator MatrixLookup::end_column(size_t i) const
    188188  {
    189     return const_iterator(normal_iter(*this, this->rows(), i), this->columns());
     189    return const_iterator(const_iterator::iterator_type(*this, rows(), i),
     190                          columns());
    190191  }
    191192
     
    193194  MatrixLookup::const_iterator MatrixLookup::end_row(size_t i) const
    194195  {
    195     return const_iterator(normal_iter(*this, i+1, 0), 1);
     196    return const_iterator(const_iterator::iterator_type(*this, i+1, 0), 1);
    196197  }
    197198
  • trunk/yat/classifier/MatrixLookup.h

    r1063 r1066  
    221221
    222222    /**
     223       Iterator iterates along a row. When end of row is reached it
     224       jumps to beginning of next row.
     225
     226       \return const_iterator pointing to upper-left element.
    223227     */
    224228    const_iterator begin(void) const;
    225229
    226230    /**
     231       Iterator iterates along a column.
     232
     233       \return iterator pointing to first element of column \a i.
    227234     */
    228235    const_iterator begin_column(size_t) const;
    229236
    230237    /**
     238       Iterator iterates along a column.
     239
     240       \return const_iterator pointing to first element of column \a i.
    231241     */
    232242    const_iterator begin_row(size_t) const;
    233243
    234244    /**
     245       \return const_iterator pointing to end of matrix
    235246     */
    236247    const_iterator end(void) const;
    237248
    238249    /**
     250       \return const_iterator pointing to end of column \a i
    239251     */
    240252    const_iterator end_column(size_t) const;
    241253
    242254    /**
     255       \return const_iterator pointing to end of row \a i
    243256     */
    244257    const_iterator end_row(size_t) const;
     
    310323   
    311324  private:
    312     typedef utility::Iterator<const MatrixLookup, const double> normal_iter;
    313325    friend class MatrixLookupWeighted;
    314326
  • trunk/yat/utility/StrideIterator.h

    r1047 r1066  
    6363  {
    6464  public:
     65    typedef Iter iterator_type;
    6566    typedef typename std::iterator_traits<Iter>::value_type value_type;
    6667    typedef typename std::iterator_traits<Iter>::difference_type difference_type;
  • trunk/yat/utility/matrix.h

    r1065 r1066  
    239239
    240240    /**
    241        \return iterator pointing to end of matrix
     241       \return const_iterator pointing to end of matrix
    242242     */
    243243    const_iterator end(void) const;
Note: See TracChangeset for help on using the changeset viewer.