Changeset 1520
- Timestamp:
- Sep 21, 2008, 6:53:12 AM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/normalization_test.cc
r1512 r1520 26 26 #include "yat/utility/DataIterator.h" 27 27 #include "yat/normalizer/QuantileNormalizer.h" 28 #include "yat/normalizer/RowNormalizer.h" 28 29 #include "yat/normalizer/Spearman.h" 29 30 … … 40 41 void test_column_normalize(test::Suite&); 41 42 void test_quantile_normalize(test::Suite&); 43 void test_row_normalize(test::Suite&); 42 44 void test_spearman(test::Suite&); 43 45 void test_spearman_weighted(test::Suite&); … … 51 53 test_column_normalize(suite); 52 54 test_quantile_normalize(suite); 55 test_row_normalize(suite); 53 56 test_spearman(suite); 54 57 … … 112 115 suite.err() << "Testing m(1,1)\n"; 113 116 suite.add(suite.equal(m(1,1), 2)); 117 } 118 119 void 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()); 114 137 } 115 138 -
trunk/yat/normalizer/Makefile.am
r1497 r1520 26 26 27 27 include_normalizer_HEADERS = Centralizer.h ColumnNormalizer.h \ 28 QuantileNormalizer.h Spearman.h28 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_ 3 3 4 4 /* … … 31 31 32 32 /** 33 \brief Normalize each column33 \brief Normalize each row 34 34 35 Using a functor T to normalize each column.35 Using a functor T to normalize each row. 36 36 37 37 \since New in yat 0.5 38 38 */ 39 39 template<class T> 40 class ColumnNormalizer40 class RowNormalizer 41 41 { 42 42 public: … … 49 49 \brief Default constructor 50 50 */ 51 ColumnNormalizer(void) {}51 RowNormalizer(void) {} 52 52 53 53 /** 54 54 \brief Constructor taking a functor \a norm 55 55 */ 56 ColumnNormalizer(T norm)56 RowNormalizer(T norm) 57 57 : normalizer_(norm) {} 58 58 59 59 /** 60 Each columnin \a matrix is normalized using class T, and60 Each row in \a matrix is normalized using class T, and 61 61 assigned to Matrix \a result. 62 62 … … 70 70 71 71 template<class T> 72 void ColumnNormalizer<T>::operator()(const utility::Matrix& matrix,73 72 void RowNormalizer<T>::operator()(const utility::Matrix& matrix, 73 utility::Matrix& result) const 74 74 { 75 75 using utility::yat_assert; 76 76 yat_assert<std::runtime_error>(matrix.rows()==result.rows(), 77 " ColumnNormalizer: rows mismatch");77 "RowNormalizer: rows mismatch"); 78 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));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 83 84 84 }
Note: See TracChangeset
for help on using the changeset viewer.