Changeset 1719


Ignore:
Timestamp:
Jan 14, 2009, 4:45:15 PM (12 years ago)
Author:
Jari Häkkinen
Message:

Added tests for qQuantileNormalizer.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/normalization_test.cc

    r1708 r1719  
    135135
    136136  utility::Matrix m(data_stream);
     137
     138  suite.err() << "testing number of parts (Q) boundary conditions\n";
     139  qQuantileNormalizer(m.column_const_view(0),m.rows());
     140  qQuantileNormalizer(m.column_const_view(0),3);
     141
     142  qQuantileNormalizer qqn(m.column_const_view(0),9);  // first column as target
    137143  utility::Matrix result(m.rows(),m.columns());
    138 
    139   // testing number of parts boundary conditions
    140   qQuantileNormalizer(m.column_const_view(0),m.rows());
    141   qQuantileNormalizer(m.column_const_view(0),2);
    142 
    143   qQuantileNormalizer qqn(m.column_const_view(0),9);  // first column as target
    144144  qqn(m,result);
     145
     146  suite.err() << "test that result can be stored in the source matrix\n";
     147  qqn(m,m);
     148  suite.add(result==m);
     149
     150  // Enough iteration will make all columns to have the same values as
     151  // the target.
     152  suite.err() << "Testing that iterative normalization\n";
     153  utility::Matrix m2(4,2);
     154  m2(0,0) = 0; m2(0,1) = 10;
     155  m2(1,0) = 2; m2(1,1) = 4;
     156  m2(2,0) = 1; m2(2,1) = 0;
     157  m2(3,0) = 3; m2(3,1) = 7;
     158  qQuantileNormalizer qqn2(m2.column_const_view(0),m2.rows());
     159  utility::Matrix result2(m2.rows(),m2.columns());
     160  qqn2(m2,result2);
     161  for (int d=0; d<50; ++d)
     162    qqn2(result2,result2);
     163  suite.add( suite.equal_fix(m2(0,0),result2(2,1),1.0e-12) &&
     164             suite.equal_fix(m2(1,0),result2(3,1),1.0e-12) &&
     165             suite.equal_fix(m2(2,0),result2(1,1),1.0e-12) &&
     166             suite.equal_fix(m2(3,0),result2(0,1),1.0e-12) );
    145167}
    146168
Note: See TracChangeset for help on using the changeset viewer.