Changeset 1581 for trunk/yat/classifier/KernelLookup.cc
 Timestamp:
 Oct 15, 2008, 5:24:48 PM (13 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/yat/classifier/KernelLookup.cc
r1549 r1581 25 25 #include "MatrixLookupWeighted.h" 26 26 #include "yat/utility/Matrix.h" 27 #include "yat/utility/MatrixWeighted.h" 27 28 28 29 #include <cassert> … … 240 241 // kernel_ holds MatrixLookupWeighted, hence new Kernel also 241 242 // 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()); 246 245 const MatrixLookupWeighted& kernel_data = kernel_>data_weighted(); 247 246 … … 250 249 // first some columns from data in kernel_ 251 250 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]); 254 252 } 255 253 256 254 // last columns are equal to new data 257 255 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); 259 257 } 260 258 } … … 269 267 row_index.push_back(i); 270 268 271 MatrixLookupWeighted* tmp = new MatrixLookupWeighted(*data_all, 272 *weight_all, true); 269 MatrixLookupWeighted* tmp = new MatrixLookupWeighted(*x_all, true); 273 270 const Kernel* kernel = kernel_>make_kernel(*tmp, true); 274 271 … … 282 279 KernelLookup KernelLookup::test_kernel(const MatrixLookupWeighted& data) const 283 280 { 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()); 288 283 289 284 if (weighted()){ … … 293 288 // first columns are equal to data in kernel_ 294 289 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]); 297 291 } 298 292 } … … 303 297 // first columns are equal to data in kernel_ 304 298 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]); 306 300 } 307 301 } … … 310 304 for (size_t i=0; i<data.rows(); ++i){ 311 305 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); 314 307 } 315 308 } … … 320 313 column_index.push_back(i+row_index_.size()); 321 314 const Kernel* kernel = 322 kernel_>make_kernel(MatrixLookupWeighted(* data_all, *weight_all, true));315 kernel_>make_kernel(MatrixLookupWeighted(*x_all, true)); 323 316 return KernelLookup(*kernel, row_index_, 324 317 utility::Index(column_index), true);
Note: See TracChangeset
for help on using the changeset viewer.