Changeset 1520


Ignore:
Timestamp:
Sep 21, 2008, 6:53:12 AM (13 years ago)
Author:
Peter
Message:

adding a RowNormalizer?

Location:
trunk
Files:
2 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/test/normalization_test.cc

    r1512 r1520  
    2626#include "yat/utility/DataIterator.h"
    2727#include "yat/normalizer/QuantileNormalizer.h"
     28#include "yat/normalizer/RowNormalizer.h"
    2829#include "yat/normalizer/Spearman.h"
    2930
     
    4041void test_column_normalize(test::Suite&);
    4142void test_quantile_normalize(test::Suite&);
     43void test_row_normalize(test::Suite&);
    4244void test_spearman(test::Suite&);
    4345void test_spearman_weighted(test::Suite&);
     
    5153  test_column_normalize(suite);
    5254  test_quantile_normalize(suite);
     55  test_row_normalize(suite);
    5356  test_spearman(suite);
    5457
     
    112115  suite.err() << "Testing m(1,1)\n";
    113116  suite.add(suite.equal(m(1,1), 2));
     117}
     118
     119void test_row_normalize(test::Suite& suite)
     120{
     121  using namespace normalizer;
     122  suite.err() << "Testing RowNormalizer\n";
     123 
     124  utility::Matrix m(2,3);
     125  m(0,0) = 0;
     126  m(0,1) = 10;
     127  m(1,0) = 2;
     128  m(1,1) = 4;
     129  utility::Matrix m2(m);
     130  m2.transpose();
     131  ColumnNormalizer<Centralizer<> > cn;
     132  RowNormalizer<Centralizer<> > rn;
     133  cn(m, m);
     134  rn(m2, m2);
     135  m2.transpose();
     136  suite.equal_range(m.begin(), m.end(), m2.begin());
    114137}
    115138
  • trunk/yat/normalizer/Makefile.am

    r1497 r1520  
    2626
    2727include_normalizer_HEADERS = Centralizer.h ColumnNormalizer.h \
    28   QuantileNormalizer.h Spearman.h
     28  QuantileNormalizer.h RowNormalizer.h Spearman.h
  • trunk/yat/normalizer/RowNormalizer.h

    r1518 r1520  
    1 #ifndef _theplu_yat_normalizer_column_normalizer_
    2 #define _theplu_yat_normalizer_column_normalizer_
     1#ifndef _theplu_yat_normalizer_row_normalizer_
     2#define _theplu_yat_normalizer_rows_normalizer_
    33
    44/*
     
    3131
    3232  /**
    33      \brief Normalize each column
     33     \brief Normalize each row
    3434
    35      Using a functor T to normalize each column.
     35     Using a functor T to normalize each row.
    3636
    3737     \since New in yat 0.5
    3838   */
    3939  template<class T>
    40   class ColumnNormalizer
     40  class RowNormalizer
    4141  {
    4242  public:
     
    4949       \brief Default constructor
    5050     */
    51     ColumnNormalizer(void) {}
     51    RowNormalizer(void) {}
    5252
    5353    /**
    5454       \brief Constructor taking a functor \a norm
    5555     */
    56     ColumnNormalizer(T norm)
     56    RowNormalizer(T norm)
    5757      : normalizer_(norm) {}
    5858
    5959    /**
    60        Each column in \a matrix is normalized using class T, and
     60       Each row in \a matrix is normalized using class T, and
    6161       assigned to Matrix \a result.
    6262
     
    7070
    7171  template<class T>
    72   void ColumnNormalizer<T>::operator()(const utility::Matrix& matrix,
    73                                        utility::Matrix& result) const
     72  void RowNormalizer<T>::operator()(const utility::Matrix& matrix,
     73                                    utility::Matrix& result) const
    7474  {
    7575    using utility::yat_assert;
    7676    yat_assert<std::runtime_error>(matrix.rows()==result.rows(),
    77                                    "ColumnNormalizer: rows mismatch");
     77                                   "RowNormalizer: rows mismatch");
    7878    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));
     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));
    8383
    8484  }
Note: See TracChangeset for help on using the changeset viewer.