Changeset 1788


Ignore:
Timestamp:
Feb 9, 2009, 11:11:30 PM (12 years ago)
Author:
Peter
Message:

Changed MatrixLookup::operator() to return const double& rather than double. Fixes #488

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/iterator_test.cc

    r1749 r1788  
    44  Copyright (C) 2007 Jari Häkkinen, Peter Johansson, Markus Ringnér
    55  Copyright (C) 2008 Peter Johansson, Markus Ringnér
     6  Copyright (C) 2009 Peter Johansson
    67
    78  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    2627
    2728#include "yat/classifier/DataLookupWeighted1D.h"
     29#include "yat/classifier/MatrixLookup.h"
    2830#include "yat/classifier/MatrixLookupWeighted.h"
    2931#include "yat/utility/Container2DIterator.h"
     
    7981void test_stride_iterator(test::Suite& suite);
    8082void test_weighted_iterator(test::Suite& suite);
     83void test_matrix_lookup_iterator(test::Suite& suite);
    8184
    8285int main(int argc, char* argv[])
     
    465468  suite.add(*iter_p==*iter); 
    466469}
     470
     471void test_matrix_lookup_iterator(test::Suite& suite)
     472{
     473  classifier::MatrixLookup ml(10, 10);
     474  test_random_access_iterator(ml.begin(), suite);
     475  std::vector<double> vec(ml.rows()*ml.columns());
     476  std::copy(ml.begin(), ml.end(), vec.begin());
     477}
     478
  • trunk/yat/classifier/MatrixLookup.cc

    r1528 r1788  
    55  Copyright (C) 2006 Jari Häkkinen, Peter Johansson, Markus Ringnér
    66  Copyright (C) 2007 Jari Häkkinen, Peter Johansson
    7   Copyright (C) 2008 Peter Johansson
     7  Copyright (C) 2008, 2009 Peter Johansson
    88
    99  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    219219
    220220
    221   double MatrixLookup::operator()(const size_t row, const size_t column) const
     221  MatrixLookup::const_reference
     222  MatrixLookup::operator()(size_t row, size_t column) const
    222223  {
    223224    assert(row<rows());
  • trunk/yat/classifier/MatrixLookup.h

    r1588 r1788  
    88  Copyright (C) 2006 Jari Häkkinen, Peter Johansson, Markus Ringnér
    99  Copyright (C) 2007 Jari Häkkinen, Peter Johansson
    10   Copyright (C) 2008 Peter Johansson
     10  Copyright (C) 2008, 2009 Peter Johansson
    1111
    1212  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    301301    /// @return element
    302302    ///
    303     double operator()(const size_t row, const size_t column) const;
     303    const_reference operator()(size_t row, size_t column) const;
    304304
    305305    ///
Note: See TracChangeset for help on using the changeset viewer.