Changeset 3321


Ignore:
Timestamp:
Sep 19, 2014, 8:59:59 AM (8 years ago)
Author:
Peter
Message:

fixes bug #815

Location:
branches/0.12-stable
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/0.12-stable/test/normalization.cc

    r2919 r3321  
    33/*
    44  Copyright (C) 2008, 2009 Jari Häkkinen, Peter Johansson
    5   Copyright (C) 2010, 2012 Peter Johansson
     5  Copyright (C) 2010, 2012, 2014 Peter Johansson
    66
    77  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    289289{
    290290  suite.err() << "Testing QuantileNormalizer\n";
    291  
    292291  utility::Matrix m(2,2);
    293292  m(0,0) = 0;
     
    305304  suite.err() << "Testing m(1,1)\n";
    306305  suite.add(suite.equal(m(1,1), 2));
     306
     307  // testing with landscape-shaped data matrix
     308  m.resize(2, 10);
     309  qn(m, m);
    307310}
    308311
  • branches/0.12-stable/yat/normalizer/QuantileNormalizer.cc

    r2992 r3321  
    44  Copyright (C) 2005, 2006 Jari Häkkinen, Markus Ringnér
    55  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    6   Copyright (C) 2012 Peter Johansson
     6  Copyright (C) 2012, 2014 Peter Johansson
    77
    88  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    4343    assert(data.columns()==result.columns());
    4444
    45     std::vector<std::vector<size_t> > index(data.rows());
    46     for (size_t column=0; column<data.columns(); ++column)
     45    std::vector<std::vector<size_t> > index(data.columns());
     46    for (size_t column=0; column<data.columns(); ++column) {
     47      assert(column<index.size());
    4748      utility::sort_index(index[column], data.column_const_view(column));
    48      
     49    }
     50
    4951    for (size_t rank=0; rank<data.rows(); ++rank) {
    5052      statistics::Averager a;
    51       for (size_t column=0; column<data.columns(); ++column)
     53      for (size_t column=0; column<data.columns(); ++column) {
     54        assert(column<index.size());
     55        assert(rank<index[column].size());
    5256        a.add(data(index[column][rank], column));
     57      }
    5358      double mean = a.mean();
    54       for (size_t column=0; column<data.columns(); ++column)
     59      for (size_t column=0; column<data.columns(); ++column) {
     60        assert(column<index.size());
    5561        result(index[column][rank], column) = mean;
     62      }
    5663    }
    5764  }
Note: See TracChangeset for help on using the changeset viewer.