Changeset 1590

Oct 17, 2008, 8:54:24 PM (15 years ago)

some docs on weighted iterator - closes #395

1 edited


  • trunk/doc/concepts.doxygen

    r1550 r1590  
    2828- \subpage concept_mutable_container_2d
    2929- \subpage concept_neighbor_weighting
     30- \subpage concept_weighted_iterator
     374\page concept_weighted_iterator Weighted Iterator
     376\section Description
     378Most functionality in yat come in two versions: one optimized for
     379speed and one weighted version allowing for missing value (see \ref
     380weighted_statistics). For example, weighted containers such as
     381theplu::yat::utility::MatrixWeighted and
     382theplu::yat::classifier::MatrixLookupWeighted allow an easy way to
     383handle missing values. Iterators that iterate over such weighted
     384containers are by definition \ref concept_weighted_iterator. This
     385concept is orthogonal against other iterator concepts such as Random
     386Access Iterator.
     388\section Requirements
     390When implementing a new iterator that may be a \ref
     391concept_weighted_iterator, there are a few things to concider.
     393\subsection weighted_iterator_traits
     395To decide whether an iterator is weighted, there exists a
     397theplu::yat::utility::weighted_iterator_traits<Iterator>::type that
     398will return either theplu::yat::utility::weighted_iterator_tag or
     399theplu::yat::utility::unweighted_iterator_tag. The default
     400implementation of this meta-function works in most cases, including on
     401all std::iterators, but if you implement a new iterator make sure it
     402behaves as you desire, or you need to create a specialization.
     404\subsection iterator_traits
     406Sometimes it is useful to have unweighted iterators behaving as though
     407they were weighted. For instance,
     408theplu::yat::statistics::EuclideanDistance calculates the distance
     409between two ranges. If both ranges are are unweighted the unweighted
     410version is used, and when any of the two ranges is weighted the
     411weighted version kicks in. In order to make this work also when
     412comparing weighted and unweighted ranges, there must a mechanism to
     413let the unweighted iterator behave as though it were weighted.
     415This can be accomplished through
     416theplu::yat::utility::iterator_traits, which enables access to data
     417value as well as to weight value. For unweighted iterators the weight
     418value is always equal to 1.0 and is not mutable. The default
     419implementation works for most iterators including all unweighted, but
     420if you implement a new weighted iterator you need to check that the
     421default implementation will work for you (see class
     422documentation). Otherwise, you will need to implement a
Note: See TracChangeset for help on using the changeset viewer.