Ignore:
Timestamp:
Feb 26, 2008, 8:06:28 PM (14 years ago)
Author:
Peter
Message:

removed dynamic_casts

File:
1 edited

Legend:

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

    r1134 r1165  
    135135
    136136
    137   const DataLookup2D* KernelLookup::data(void) const
    138   {
    139     return kernel_->data().training_data(column_index_);
     137  utility::SmartPtr<const MatrixLookup> KernelLookup::data(void) const
     138  {
     139    return utility::SmartPtr<const MatrixLookup>
     140      (kernel_->data().training_data(column_index_));
     141  }
     142
     143
     144  utility::SmartPtr<const MatrixLookupWeighted>
     145  KernelLookup::data_weighted(void) const
     146  {
     147    return utility::SmartPtr<const MatrixLookupWeighted>
     148      (kernel_->data_weighted().training_data(column_index_));
    140149  }
    141150
     
    184193    const Kernel* kernel;
    185194    if (kernel_->weighted()){
    186       const MatrixLookupWeighted* ml =
    187         dynamic_cast<const MatrixLookupWeighted*>(data());
    188       assert(ml);
     195      utility::SmartPtr<const MatrixLookupWeighted> ml = data_weighted();
    189196      const MatrixLookupWeighted* ms =
    190197        new MatrixLookupWeighted(*ml,inputs,true);
     
    192199    }
    193200    else {
    194       const MatrixLookup* m =
    195         dynamic_cast<const MatrixLookup*>(data());
    196       assert(m);
     201      utility::SmartPtr<const MatrixLookup> m = data();
    197202      // matrix with selected features
    198203      const MatrixLookup* ms = new MatrixLookup(*m,inputs,true);
     
    206211  {
    207212
    208     assert(data.rows()==kernel_->data().rows());
    209213    if (!weighted()){
     214      assert(data.rows()==kernel_->data().rows());
    210215      utility::Matrix* data_all =
    211216        new utility::Matrix(data.rows(), row_index_.size()+data.columns());
     
    242247    }
    243248
     249    assert(data.rows()==kernel_->data_weighted().rows());
    244250    // kernel_ holds MatrixLookupWeighted, hence new Kernel also
    245251    // should hold a MatrixLookupweighted.
     
    248254    utility::Matrix* weight_all =
    249255      new utility::Matrix(data.rows(), rows()+data.columns(), 1.0);
    250     const MatrixLookupWeighted& kernel_data =
    251       dynamic_cast<const MatrixLookupWeighted&>(kernel_->data());
     256    const MatrixLookupWeighted& kernel_data = kernel_->data_weighted();
    252257
    253258    for (size_t i=0; i<data.rows(); ++i){
     
    292297
    293298    if (weighted()){
    294       const MatrixLookupWeighted& kernel_data =
    295         dynamic_cast<const MatrixLookupWeighted&>(kernel_->data());
     299      const MatrixLookupWeighted& kernel_data = kernel_->data_weighted();
    296300   
    297301      for (size_t i=0; i<data.rows(); ++i){
     
    305309    else {
    306310
    307         dynamic_cast<const MatrixLookupWeighted&>(kernel_->data());
    308    
    309311      for (size_t i=0; i<data.rows(); ++i){
    310312        // first columns are equal to data in kernel_
Note: See TracChangeset for help on using the changeset viewer.