Ignore:
Timestamp:
Feb 10, 2009, 5:11:04 PM (12 years ago)
Author:
Peter
Message:

Speeding up copying from Matrix to MatrixWeighted? using
BinaryWeight?. Moving BinaryWeight? from stl_utility.h to
utility.h. Improved docs in MatrixWeighted?.

File:
1 edited

Legend:

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

    r1786 r1789  
    7777    inline T operator()(T x) const
    7878    { return std::abs(x); }
    79   };
    80 
    81 
    82   /**
    83      For each element in resulting range assign it to 0.0 if
    84      corresponding element in input range is NaN else assign it to
    85      1.0.
    86 
    87      \since New in yat 0.5
    88    */
    89   struct BinaryWeight
    90   {
    91     /**
    92         \return true if there is at least one NaN in input range
    93         [first, last).
    94      */
    95     template<typename InputIterator, typename OutputIterator>
    96     bool inline operator()(InputIterator first, InputIterator last,
    97                            OutputIterator result) const
    98     {
    99       bool nan=false;
    100       while (first!=last) {
    101         if (std::isnan(*first)) {
    102           *result=0;
    103           nan=true;
    104         }
    105         else
    106           *result = 1.0;
    107         ++first;
    108         ++result;
    109       }
    110       return nan;
    111     }
    11279  };
    11380
Note: See TracChangeset for help on using the changeset viewer.