Changeset 1581 for trunk/yat/classifier


Ignore:
Timestamp:
Oct 15, 2008, 5:24:48 PM (13 years ago)
Author:
Peter
Message:

refs #396 - fixing in KernelLookup?

Location:
trunk/yat/classifier
Files:
3 edited

Legend:

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

    r1549 r1581  
    2525#include "MatrixLookupWeighted.h"
    2626#include "yat/utility/Matrix.h"
     27#include "yat/utility/MatrixWeighted.h"
    2728
    2829#include <cassert>
     
    240241    // kernel_ holds MatrixLookupWeighted, hence new Kernel also
    241242    // should hold a MatrixLookupweighted.
    242     utility::Matrix* data_all =
    243       new utility::Matrix(data.rows(), rows()+data.columns());
    244     utility::Matrix* weight_all =
    245       new utility::Matrix(data.rows(), rows()+data.columns(), 1.0);
     243    utility::MatrixWeighted* x_all =
     244      new utility::MatrixWeighted(data.rows(), rows()+data.columns());
    246245    const MatrixLookupWeighted& kernel_data = kernel_->data_weighted();
    247246
     
    250249      // first some columns from data in kernel_
    251250      for (size_t j=0; j<row_index_.size(); ++j){
    252         (*data_all)(i,j) = kernel_data.data(i,row_index_[j]);
    253         (*weight_all)(i,j) = kernel_data.weight(i,row_index_[j]);
     251        (*x_all)(i,j) = kernel_data(i,row_index_[j]);
    254252      }
    255253
    256254      // last columns are equal to new data
    257255      for (size_t j=0;j<data.columns(); ++j){
    258         (*data_all)(i,j+row_index_.size()) = data(i,j);
     256        (*x_all)(i,j+row_index_.size()).data() = data(i,j);
    259257      }
    260258    }
     
    269267      row_index.push_back(i);
    270268
    271     MatrixLookupWeighted* tmp = new MatrixLookupWeighted(*data_all,
    272                                                          *weight_all, true);
     269    MatrixLookupWeighted* tmp = new MatrixLookupWeighted(*x_all, true);
    273270    const Kernel* kernel = kernel_->make_kernel(*tmp, true);
    274271
     
    282279  KernelLookup KernelLookup::test_kernel(const MatrixLookupWeighted& data) const
    283280  {
    284     utility::Matrix* data_all =
    285       new utility::Matrix(data.rows(), rows()+data.columns());
    286     utility::Matrix* weight_all =
    287       new utility::Matrix(data.rows(), rows()+data.columns(), 1.0);
     281    utility::MatrixWeighted* x_all =
     282      new utility::MatrixWeighted(data.rows(), rows()+data.columns());
    288283
    289284    if (weighted()){
     
    293288        // first columns are equal to data in kernel_
    294289        for (size_t j=0; j<row_index_.size(); ++j){
    295           (*data_all)(i,j) = kernel_data.data(i,row_index_[j]);
    296           (*weight_all)(i,j) = kernel_data.weight(i,row_index_[j]);
     290          (*x_all)(i,j) = kernel_data(i,row_index_[j]);
    297291        }
    298292      }
     
    303297        // first columns are equal to data in kernel_
    304298        for (size_t j=0; j<row_index_.size(); ++j)
    305           (*data_all)(i,j) = kernel_->data()(i,row_index_[j]);
     299          (*x_all)(i,j).data() = kernel_->data()(i,row_index_[j]);
    306300      }
    307301    }
     
    310304    for (size_t i=0; i<data.rows(); ++i){
    311305      for (size_t j=0;j<data.columns(); ++j){
    312         (*data_all)(i,j+row_index_.size()) = data.data(i,j);
    313         (*weight_all)(i,j+row_index_.size()) = data.weight(i,j);
     306        (*x_all)(i,j+row_index_.size()) = data(i,j);
    314307      }
    315308    }
     
    320313      column_index.push_back(i+row_index_.size());
    321314    const Kernel* kernel =
    322       kernel_->make_kernel(MatrixLookupWeighted(*data_all, *weight_all, true));
     315      kernel_->make_kernel(MatrixLookupWeighted(*x_all, true));
    323316    return KernelLookup(*kernel, row_index_,
    324317                        utility::Index(column_index), true);
  • trunk/yat/classifier/MatrixLookupWeighted.cc

    r1552 r1581  
    5656
    5757
    58   MatrixLookupWeighted::MatrixLookupWeighted(const utility::MatrixWeighted& m)
     58  MatrixLookupWeighted::MatrixLookupWeighted(const utility::MatrixWeighted& m,
     59                                             bool owner)
    5960    : column_index_(utility::Index(m.columns())),
    6061      row_index_(utility::Index(m.rows()))
    6162  {
     63    // Peter, remember to take care of ownership (but for now leave a leak)
     64
    6265    utility::Matrix* data = new utility::Matrix(m.rows(), m.columns());
    6366    utility::Matrix* weight = new utility::Matrix(m.rows(), m.columns());
  • trunk/yat/classifier/MatrixLookupWeighted.h

    r1580 r1581  
    2424  along with yat. If not, see <http://www.gnu.org/licenses/>.
    2525*/
     26
     27#include "yat/utility/deprecate.h"
    2628
    2729#include "yat/utility/Container2DIterator.h"
     
    114116       \brief Create a lookup into entire \a matrix.
    115117     */
    116     explicit MatrixLookupWeighted(const utility::MatrixWeighted& matrix);
     118    explicit MatrixLookupWeighted(const utility::MatrixWeighted& matrix,
     119                                  bool owner=false);
    117120
    118121    ///
     
    127130    MatrixLookupWeighted(const utility::Matrix& matrix,
    128131                         const utility::Matrix& weights,
    129                          const bool owner=false);
     132                         const bool owner=false);// YAT_DEPRECATE;
    130133   
    131134    /**
     
    160163                         const utility::Matrix& weights,
    161164                         const utility::Index& row,
    162                          const utility::Index& column);
     165                         const utility::Index& column);// YAT_DEPRECATE;
    163166
    164167    ///
Note: See TracChangeset for help on using the changeset viewer.