Changeset 1168


Ignore:
Timestamp:
Feb 26, 2008, 9:48:22 PM (13 years ago)
Author:
Peter
Message:

fixes #342

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/matrix_lookup_test.cc

    r1134 r1168  
    146146
    147147  *error << "MatrixLookup::training_data(const std::vector<size_t>)...";
    148   const classifier::MatrixLookup* TrnData =m2.training_data(utility::Index(one));
     148  const classifier::MatrixLookup* TrnData =
     149    new MatrixLookup(m2, utility::Index(one), false);
    149150  if (TrnData->rows() != m2.rows() || TrnData->columns()!=one.size()){
    150151    ok =false;
     
    159160  std::vector<size_t> val(23,2);
    160161  const classifier::MatrixLookup* ValData =
    161     m2.validation_data(utility::Index(one), utility::Index(val));
     162    new MatrixLookup(m2, utility::Index(val), false);
    162163  if (ValData->rows() != m2.rows() || TrnData->columns()!=val.size()){
    163164    ok =false;
  • trunk/yat/classifier/Kernel.cc

    r1166 r1168  
    6767   
    6868    if (other.weighted()){
    69       mlw_ = other.mlw_->selected(utility::Index(index));
     69      mlw_ = new MatrixLookupWeighted(*other.mlw_, utility::Index(index),true);
    7070      ref_count_w_ = new u_int(1);
    7171      ml_=NULL;
     
    7373    }
    7474    else{
    75       ml_ = other.ml_->selected(utility::Index(index));
     75      ml_ = new MatrixLookup(*other.ml_, utility::Index(index),true);
    7676      ref_count_ = new u_int(1);
    7777      mlw_=NULL;
  • trunk/yat/classifier/KernelLookup.cc

    r1167 r1168  
    137137  {
    138138    return utility::SmartPtr<const MatrixLookup>
    139       (kernel_->data().training_data(column_index_));
     139      (new MatrixLookup(kernel_->data(), column_index_, false));
    140140  }
    141141
     
    145145  {
    146146    return utility::SmartPtr<const MatrixLookupWeighted>
    147       (kernel_->data_weighted().training_data(column_index_));
     147      (new MatrixLookupWeighted(kernel_->data_weighted(),column_index_,false));
    148148  }
    149149
  • trunk/yat/classifier/MatrixLookup.cc

    r1134 r1168  
    170170    return const_row_iterator(const_row_iterator::iterator_type(*this,i+1,0),1);
    171171  }
    172 
    173 
    174   const MatrixLookup*
    175   MatrixLookup::selected(const utility::Index& i) const
    176   {
    177     return new MatrixLookup(*this,i, true);
    178   }
    179 
    180 
    181 
    182   const MatrixLookup*
    183   MatrixLookup::training_data(const utility::Index& i) const
    184   {
    185     return new MatrixLookup(*this,i, false);
    186   }
    187 
    188 
    189 
    190   const MatrixLookup*
    191   MatrixLookup::validation_data(const utility::Index& train,
    192                                 const utility::Index& val) const
    193   {
    194     return new MatrixLookup(*this,val, false);
    195   }
    196 
    197172
    198173
  • trunk/yat/classifier/MatrixLookup.h

    r1134 r1168  
    270270    const_row_iterator end_row(size_t) const;
    271271
    272     /**
    273        the new MatrixLookup will consist of the rolumn vectors
    274        defined by @a index. This means that the returned MatrixLookup
    275        will fullfill: \f$ returned(i,j) = original(index[i],j) \f$
    276 
    277        @note If underlying matrix goes out of scope or is deleted, the
    278        returned pointer becomes invalid and the result of further use is
    279        undefined.
    280    
    281     */
    282     const MatrixLookup* selected(const utility::Index&) const;
    283 
    284     ///
    285     /// The created MatrixLookup corresponds to all rows and the
    286     /// columns defined by @a index in the original MatrixLookup. The
    287     /// created MatrixLookup will fullfill:
    288     /// \f$ novel_ml(i,j)=original(i,index[j]) \f$.
    289     ///
    290     /// @return pointer to sub-Lookup of the MatrixLookup
    291     ///
    292     /// @note If underlying matrix goes out of scope or is deleted, the
    293     /// returned pointer becomes invalid and the result of further use is
    294     /// undefined.
    295     ///
    296     /// @note Returns a dynamically allocated DataLookup2D, which has
    297     /// to be deleted by the caller to avoid memory leaks.
    298     ///
    299     const MatrixLookup* training_data(const utility::Index& index) const;
    300    
    301     ///
    302     /// The created MatrixLookup corresponds to all rows and the
    303     /// columns defined by @a index in the original MatrixLookup. The
    304     /// created MatrixLookup will fullfill:
    305     /// \f$ novel_ml(i,j)=original(i,index[j]) \f$.
    306     ///
    307     /// @return pointer to sub-Lookup of the MatrixLookup
    308     ///
    309     /// @note If underlying matrix goes out of scope or is deleted, the
    310     /// returned pointer becomes invalid and the result of further use is
    311     /// undefined.
    312     ///
    313     const MatrixLookup* validation_data(const utility::Index&,
    314                                         const utility::Index&) const;
    315272    ///
    316273    /// @return false
  • trunk/yat/classifier/MatrixLookupWeighted.cc

    r1134 r1168  
    246246    return const_row_iterator(const_row_iterator::iterator_type(*this,i+1,0),1);
    247247  }
    248 
    249 
    250   const MatrixLookupWeighted*
    251   MatrixLookupWeighted::selected(const utility::Index& i) const
    252   {
    253     return new MatrixLookupWeighted(*this,i, true);
    254   }
    255 
    256 
    257 
    258   const MatrixLookupWeighted*
    259   MatrixLookupWeighted::training_data(const utility::Index& i) const
    260   {
    261     return new MatrixLookupWeighted(*this,i, false);
    262   }
    263 
    264 
    265 
    266   const MatrixLookupWeighted*
    267   MatrixLookupWeighted::validation_data(const utility::Index& train,
    268                                         const utility::Index& val) const
    269   {
    270     return new MatrixLookupWeighted(*this,val, false);
    271   }
    272 
    273248
    274249
  • trunk/yat/classifier/MatrixLookupWeighted.h

    r1134 r1168  
    303303    const_row_iterator end_row(size_t) const;
    304304
    305     /**
    306        the new MatrixLookup will consist of the rolumn vectors
    307        defined by @a index. This means that the returned
    308        MatrixLookupWeighted
    309        will fullfill:
    310        returned(i,j) = original(index[i],j)
    311 
    312        @note If underlying matrix goes out of scope or is deleted, the
    313        returned pointer becomes invalid and the result of further use is
    314        undefined.
    315    
    316     */
    317     const MatrixLookupWeighted* selected(const utility::Index& i) const;
    318 
    319     ///
    320     /// The created MatrixLookupWeighted corresponds to all rows and the
    321     /// columns defined by @a index in the original MatrixLookupWeighted. The
    322     /// created MatrixLookupWeighted will fullfill:
    323     /// novel_ml(i,j)=original(i,index[j]).
    324     ///
    325     /// @return pointer to sub-Lookup of the MatrixLookupWeighted
    326     ///
    327     /// @note If underlying matrix goes out of scope or is deleted, the
    328     /// returned pointer becomes invalid and the result of further use is
    329     /// undefined.
    330     ///
    331     const MatrixLookupWeighted*
    332     training_data(const utility::Index& index) const;
    333    
    334     ///
    335     /// The created MatrixLookupWeighted corresponds to all rows and the
    336     /// columns defined by @a index in the original MatrixLookupWeighted. The
    337     /// created MatrixLookupWeighted will fullfill:
    338     /// novel_ml(i,j)=original(i,index[j])
    339     ///
    340     /// @return pointer to sub-Lookup of the MatrixLookupWeighted
    341     ///
    342     /// @note If underlying matrix goes out of scope or is deleted, the
    343     /// returned pointer becomes invalid and the result of further use is
    344     /// undefined.
    345     ///
    346     const MatrixLookupWeighted* validation_data(const utility::Index&,
    347                                         const utility::Index&) const;
    348 
    349305    ///
    350306    /// @return weight value of element (@a row, @a column)
  • trunk/yat/classifier/SubsetGenerator.h

    r1167 r1168  
    209209        // training data with no feature selection
    210210        const MatrixLookup* train_data_all_feat =
    211           ml.training_data(training_index(k));
     211          new MatrixLookup(ml, training_index(k), false);
    212212        // use these data to create feature selection
    213213        utility::yat_assert<std::runtime_error>(train_data_all_feat);
     
    241241        // training data with no feature selection
    242242        const MatrixLookupWeighted* train_data_all_feat =
    243           ml.training_data(training_index(k));
     243          new MatrixLookupWeighted(ml, training_index(k), false);
    244244        // use these data to create feature selection
    245245        f_selector_->update(*train_data_all_feat, training_target(k));
Note: See TracChangeset for help on using the changeset viewer.