Changeset 1544


Ignore:
Timestamp:
Oct 1, 2008, 4:25:09 PM (13 years ago)
Author:
Peter
Message:

making RowNormalizer? and ColumnNormalizer? more general

Location:
trunk/yat/normalizer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/normalizer/ColumnNormalizer.h

    r1518 r1544  
    6161       assigned to Matrix \a result.
    6262
     63       Template argument Container2D1 should be a class modelling the
     64       concept \ref concept_container_2d. The template argument
     65       Container2D2 should be a class modelling the concept \ref
     66       concept_mutable_container_2d.
     67
    6368       \note \a result must have same dimensions as \a matrix.
    6469     */
    65     void operator()(const utility::Matrix& matrix,
    66                     utility::Matrix& result) const;
     70    template<class Container2D1, class Container2D2>
     71    void operator()(const Container2D1& matrix, Container2D2& result) const
     72    {
     73      using utility::yat_assert;
     74      yat_assert<std::runtime_error>(matrix.rows()==result.rows(),
     75                                     "ColumnNormalizer: rows mismatch");
     76      yat_assert<std::runtime_error>(matrix.columns()==result.columns(),
     77                                     "ColumnNormalizer: columns mismatch");
     78      for (size_t i=0; i<matrix.columns(); ++i)
     79        normalizer_(matrix.begin_column(i), matrix.end_column(i),
     80                    result.begin_column(i));
     81     
     82    }
     83
    6784  private:
    6885    T normalizer_;
    6986  };
    7087
    71   template<class T>
    72   void ColumnNormalizer<T>::operator()(const utility::Matrix& matrix,
    73                                        utility::Matrix& result) const
    74   {
    75     using utility::yat_assert;
    76     yat_assert<std::runtime_error>(matrix.rows()==result.rows(),
    77                                    "ColumnNormalizer: rows mismatch");
    78     yat_assert<std::runtime_error>(matrix.columns()==result.columns(),
    79                                    "ColumnNormalizer: columns mismatch");
    80     for (size_t i=0; i<matrix.columns(); ++i)
    81       normalizer_(matrix.begin_column(i), matrix.end_column(i),
    82                   result.begin_column(i));
    83 
    84   }
    85 
    86 
    8788}}} // end of namespace normalizer, yat and thep
    8889#endif
  • trunk/yat/normalizer/RowNormalizer.h

    r1520 r1544  
    6161       assigned to Matrix \a result.
    6262
     63       Template argument Container2D1 should be a class modelling the
     64       concept \ref concept_container_2d. The template argument
     65       Container2D2 should be a class modelling the concept \ref
     66       concept_mutable_container_2d.
     67
    6368       \note \a result must have same dimensions as \a matrix.
    6469     */
    65     void operator()(const utility::Matrix& matrix,
    66                     utility::Matrix& result) const;
     70    template<class Container2D1, class Container2D2>
     71    void operator()(const Container2D1& matrix,
     72                    Container2D2& result) const
     73    {
     74      using utility::yat_assert;
     75      yat_assert<std::runtime_error>(matrix.rows()==result.rows(),
     76                                     "RowNormalizer: rows mismatch");
     77      yat_assert<std::runtime_error>(matrix.columns()==result.columns(),
     78                                     "RowNormalizer: columns mismatch");
     79      for (size_t i=0; i<matrix.rows(); ++i)
     80        normalizer_(matrix.begin_row(i), matrix.end_row(i),
     81                  result.begin_row(i));
     82    }
     83
    6784  private:
    6885    T normalizer_;
    6986  };
    7087
    71   template<class T>
    72   void RowNormalizer<T>::operator()(const utility::Matrix& matrix,
    73                                     utility::Matrix& result) const
    74   {
    75     using utility::yat_assert;
    76     yat_assert<std::runtime_error>(matrix.rows()==result.rows(),
    77                                    "RowNormalizer: rows mismatch");
    78     yat_assert<std::runtime_error>(matrix.columns()==result.columns(),
    79                                    "RowNormalizer: columns mismatch");
    80     for (size_t i=0; i<matrix.rows(); ++i)
    81       normalizer_(matrix.begin_row(i), matrix.end_row(i),
    82                   result.begin_row(i));
    83 
    84   }
    85 
    86 
    8788}}} // end of namespace normalizer, yat and thep
    8889#endif
Note: See TracChangeset for help on using the changeset viewer.