Changeset 1518 for trunk


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

changed implementation of a couple of normalizer so that operator() takes two matrices of which one is an input marix and one is a result matrix, i.e., the result does only depend on the input matrix and the result is only used as a receiver - I think this behaviour is more intuitive, although it is not as general as the previous one. We should probably document somewhere how we expect a 2Dnormalizer to behave (refs #425).

Location:
trunk/yat/normalizer
Files:
3 edited

Legend:

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

    r1498 r1518  
    2222
    2323#include "yat/utility/Matrix.h"
     24#include "yat/utility/yat_assert.h"
     25
     26#include <stdexcept>
    2427
    2528namespace theplu {
     
    5558
    5659    /**
    57        Each column in \a result is normalized using class T.
     60       Each column in \a matrix is normalized using class T, and
     61       assigned to Matrix \a result.
    5862
    59        \note matrix is ignored
     63       \note \a result must have same dimensions as \a matrix.
    6064     */
    6165    void operator()(const utility::Matrix& matrix,
     
    6973                                       utility::Matrix& result) const
    7074  {
     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");
    7180    for (size_t i=0; i<matrix.columns(); ++i)
    72       normalizer_(result.begin_column(i), result.end_column(i),
     81      normalizer_(matrix.begin_column(i), matrix.end_column(i),
    7382                  result.begin_column(i));
    7483
  • trunk/yat/normalizer/QuantileNormalizer.cc

    r1497 r1518  
    3939  {
    4040    assert(data.rows()==result.rows());
     41    assert(data.columns()==result.columns());
     42
     43    // create a tmp copy
    4144    utility::Matrix data_copy(data);
    4245   
     
    4851    // calculate average of each row
    4952    std::vector<yat::statistics::Averager> averager(data_copy.rows());
    50     for (size_t row=0; row<data_copy.rows(); ++row){
     53    for (size_t row=0; row<result.rows(); ++row){
    5154      add(averager[row], data_copy.begin_row(row), data_copy.end_row(row));
    5255    }
     
    5457    for (size_t column=0; column<result.columns(); ++column){
    5558      std::vector<size_t> index;
    56       utility::sort_index(index, result.column_const_view(column));
     59      utility::sort_index(index, data.column_const_view(column));
    5760                               
    58       for (size_t row=0; row<result.rows(); ++row)
     61      for (size_t row=0; row<data.rows(); ++row)
    5962        result(index[row], column) = averager[row].mean();
    6063    }
  • trunk/yat/normalizer/QuantileNormalizer.h

    r1497 r1518  
    2929
    3030  /**
    31      \brief Perform quantile normalizer
     31     \brief Perform quantile normalization
    3232
    3333     \since New in yat 0.5
     
    3939       The \a matrix is normalized by sorting each column, replacing
    4040       each value with the average across rows, and undo the sorting
    41        in step 1. This results in a \a matrix in which each column has
    42        the same distribution of data, and the rank of an element
    43        within a column is preserved in the normalizer.
     41       in step 1. This results in a Matrix \a result in which each
     42       column has the same distribution of data, and the rank of an
     43       element within a column is the same as in \a matrix.
    4444
    45        \note Number of rows in \a matrix and \a result must match.
     45       \note dimensions of \a matrix and \a result must match.
    4646     */
    47     void operator()(const utility::Matrix& matrix, 
     47    void operator()(const utility::Matrix& matrix,
    4848                    utility::Matrix& result) const;
    4949  };
Note: See TracChangeset for help on using the changeset viewer.