Changeset 1581
- Timestamp:
- Oct 15, 2008, 5:24:48 PM (14 years ago)
- Location:
- trunk/yat/classifier
- Files:
-
- 3 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); -
trunk/yat/classifier/MatrixLookupWeighted.cc
r1552 r1581 56 56 57 57 58 MatrixLookupWeighted::MatrixLookupWeighted(const utility::MatrixWeighted& m) 58 MatrixLookupWeighted::MatrixLookupWeighted(const utility::MatrixWeighted& m, 59 bool owner) 59 60 : column_index_(utility::Index(m.columns())), 60 61 row_index_(utility::Index(m.rows())) 61 62 { 63 // Peter, remember to take care of ownership (but for now leave a leak) 64 62 65 utility::Matrix* data = new utility::Matrix(m.rows(), m.columns()); 63 66 utility::Matrix* weight = new utility::Matrix(m.rows(), m.columns()); -
trunk/yat/classifier/MatrixLookupWeighted.h
r1580 r1581 24 24 along with yat. If not, see <http://www.gnu.org/licenses/>. 25 25 */ 26 27 #include "yat/utility/deprecate.h" 26 28 27 29 #include "yat/utility/Container2DIterator.h" … … 114 116 \brief Create a lookup into entire \a matrix. 115 117 */ 116 explicit MatrixLookupWeighted(const utility::MatrixWeighted& matrix); 118 explicit MatrixLookupWeighted(const utility::MatrixWeighted& matrix, 119 bool owner=false); 117 120 118 121 /// … … 127 130 MatrixLookupWeighted(const utility::Matrix& matrix, 128 131 const utility::Matrix& weights, 129 const bool owner=false); 132 const bool owner=false);// YAT_DEPRECATE; 130 133 131 134 /** … … 160 163 const utility::Matrix& weights, 161 164 const utility::Index& row, 162 const utility::Index& column); 165 const utility::Index& column);// YAT_DEPRECATE; 163 166 164 167 ///
Note: See TracChangeset
for help on using the changeset viewer.