Changeset 1482 for trunk/yat/classifier


Ignore:
Timestamp:
Sep 9, 2008, 3:39:43 PM (15 years ago)
Author:
Peter
Message:

refs #396
stupid implementation of constructors - copying should be avoided when
internal representation in MatrixLookupWeighted? has changed

Location:
trunk/yat/classifier
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/classifier/MatrixLookupWeighted.cc

    r1437 r1482  
    2626#include "MatrixLookupWeighted.h"
    2727#include "MatrixLookup.h"
     28#include "yat/utility/DataIterator.h"
    2829#include "yat/utility/Matrix.h"
    29 
     30#include "yat/utility/MatrixWeighted.h"
     31#include "yat/utility/WeightIterator.h"
     32
     33#include <algorithm>
    3034#include <cassert>
    3135#include <fstream>
     
    3539namespace yat {
    3640namespace classifier {
     41
     42  MatrixLookupWeighted::MatrixLookupWeighted(const utility::MatrixWeighted& m,
     43                                             const utility::Index& rows,
     44                                             const utility::Index& columns)
     45    : column_index_(columns), row_index_(rows)
     46  {
     47    utility::Matrix* data = new utility::Matrix(m.rows(), m.columns());
     48    utility::Matrix* weight = new utility::Matrix(m.rows(), m.columns());
     49    for (size_t i=0; i<m.rows(); ++i)
     50      for (size_t j=0; j<m.columns(); ++j) {
     51        (*data)(i,j) = m(i,j).data();
     52        (*weight)(i,j) = m(i,j).weight();
     53      }
     54    // smart pointers are taking ownership
     55    data_ = MatrixP(data);
     56    weights_ = MatrixP(weight);
     57  }
     58
     59
     60  MatrixLookupWeighted::MatrixLookupWeighted(const utility::MatrixWeighted& m)
     61    : column_index_(utility::Index(m.columns())),
     62      row_index_(utility::Index(m.rows()))
     63  {
     64    utility::Matrix* data = new utility::Matrix(m.rows(), m.columns());
     65    utility::Matrix* weight = new utility::Matrix(m.rows(), m.columns());
     66    for (size_t i=0; i<m.rows(); ++i)
     67      for (size_t j=0; j<m.columns(); ++j) {
     68        (*data)(i,j) = m(i,j).data();
     69        (*weight)(i,j) = m(i,j).weight();
     70      }
     71  // smart pointers are taking ownership
     72    data_ = MatrixP(data);
     73    weights_ = MatrixP(weight);
     74  }
     75
    3776
    3877  MatrixLookupWeighted::MatrixLookupWeighted(const utility::Matrix& data,
  • trunk/yat/classifier/MatrixLookupWeighted.h

    r1437 r1482  
    4141
    4242namespace utility {
     43  class Index;
    4344  class Matrix;
     45  class MatrixWeighted;
    4446}
    4547
     
    9294    typedef const_iterator const_row_iterator;
    9395
     96    /**
     97       \brief Create a lookup into \a matrix.
     98
     99       The created lookup, mlw, will fullfil: mlw(i,j) =
     100       matrix(rows(i), columns(j))
     101     */
     102    MatrixLookupWeighted(const utility::MatrixWeighted& matrix,
     103                         const utility::Index& rows,
     104                         const utility::Index& columns);
     105
     106    /**
     107       \brief Create a lookup into entire \a matrix.
     108     */
     109    MatrixLookupWeighted(const utility::MatrixWeighted& matrix);
     110
    94111    ///
    95112    /// Constructor creating a lookup into the entire \a matrix and \a
Note: See TracChangeset for help on using the changeset viewer.