Changeset 1059


Ignore:
Timestamp:
May 8, 2009, 3:02:55 PM (12 years ago)
Author:
Jari Häkkinen
Message:

Use functionality already in yat.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/base2/net.sf.basedb.normalizers/trunk/src/c++/bin/qQN.cc

    r1054 r1059  
    3434#include <yat/utility/OptionOutFile.h>
    3535#include <yat/utility/OptionSwitch.h>
     36#include <yat/utility/stl_utility.h>
    3637
    3738#include <cstdlib>
     
    4748void create_target(std::vector<double>&, const MatrixWeighted&,
    4849                   const std::string&);
    49 
    50 template<typename Iterator> void exp_numbers(Iterator first, Iterator last);
    51 template<typename Iterator> void log_numbers(Iterator first, Iterator last);
    5250
    5351/**
     
    107105  ( assay.present() ? create_target(target,m,assay.value()) :
    108106                      create_target(target,m) );
    109   log_numbers(target.begin(),target.end());
    110   log_numbers(m.begin(),m.end());
     107  std::transform(target.begin(), target.end(),
     108                 target.begin(), theplu::yat::utility::Log<double>());
     109  std::transform(data_iterator(m.begin()), data_iterator(m.end()),
     110                 data_iterator(m.begin()), theplu::yat::utility::Log<double>());
    111111  qQuantileNormalizer qqn(target.begin(), target.end(), 100);
    112112  ColumnNormalizer<qQuantileNormalizer> cn(qqn);
    113113  MatrixWeighted result(m.rows(),m.columns());
    114114  cn(m,result);
    115   exp_numbers(result.begin(),result.end());
     115  std::transform(data_iterator(result.begin()), data_iterator(result.end()),
     116                 data_iterator(result.begin()), theplu::yat::utility::Exp<double>());
    116117
    117118  std::ofstream* outfile=NULL;
     
    183184
    184185
    185 template<typename Iterator> void exp_numbers(Iterator i, Iterator last)
    186 {
    187   while (i!=last) {
    188     *data_iterator(i)=std::exp(*data_iterator(i));
    189     ++i;
    190   }
    191 }
    192 
    193 
    194 template<typename Iterator> void log_numbers(Iterator i, Iterator last)
    195 {
    196   while (i!=last) {
    197     *data_iterator(i)=std::log(*data_iterator(i));
    198     ++i;
    199   }
    200 }
    201 
    202 
    203186std::ostream& operator<< (std::ostream& s, const MatrixWeighted& m)
    204187{
Note: See TracChangeset for help on using the changeset viewer.