Changeset 1132 for trunk/yat/classifier
 Timestamp:
 Feb 23, 2008, 9:16:22 PM (16 years ago)
 Location:
 trunk/yat/classifier
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

trunk/yat/classifier/KernelLookup.cc
r1127 r1132 38 38 39 39 KernelLookup::KernelLookup(const Kernel& kernel, const bool own) 40 : DataLookup2D(own), kernel_(&kernel) 41 { 40 : kernel_(&kernel) 41 { 42 if (own) 43 ref_count_ = new u_int(1); 44 else 45 ref_count_ = NULL; 42 46 column_index_.reserve(kernel.size()); 43 47 for(size_t i=0; i<kernel.size(); i++) … … 51 55 const std::vector<size_t>& column, 52 56 const bool owner) 53 : DataLookup2D(row,column,owner), kernel_(&kernel) 57 : column_index_(column), kernel_(&kernel), ref_count_(NULL), 58 row_index_(row) 54 59 { 55 60 // Checking that each row index is less than kernel.rows() … … 65 70 const std::vector<size_t>& row, 66 71 const std::vector<size_t>& column) 67 : DataLookup2D(other,row,column), kernel_(other.kernel_) 68 { 72 : kernel_(other.kernel_) 73 { 74 assert(row_index_.empty()); 75 row_index_.reserve(row.size()); 76 for (size_t i=0; i<row.size(); i++) { 77 assert(row[i]<other.row_index_.size()); 78 row_index_.push_back(other.row_index_[row[i]]); 79 } 80 assert(column_index_.empty()); 81 column_index_.reserve(column.size()); 82 for (size_t i=0; i<column.size(); i++) { 83 assert(column[i]<other.column_index_.size()); 84 column_index_.push_back(other.column_index_[column[i]]); 85 } 69 86 ref_count_=other.ref_count_; 70 87 if (ref_count_) … … 74 91 75 92 KernelLookup::KernelLookup(const KernelLookup& other) 76 : DataLookup2D(other), kernel_(other.kernel_) 93 : column_index_(other.column_index_), kernel_(other.kernel_), 94 row_index_(other.row_index_) 77 95 { 78 96 // Checking that no index is out of range … … 92 110 const std::vector<size_t>& index, 93 111 const bool row) 94 : DataLookup2D(other,index,row), kernel_(other.kernel_) 95 { 112 : kernel_(other.kernel_) 113 { 114 if (row){ 115 assert(row_index_.empty()); 116 row_index_.reserve(index.size()); 117 for (size_t i=0; i<index.size(); i++) { 118 assert(index[i]<other.row_index_.size()); 119 row_index_.push_back(other.row_index_[index[i]]); 120 } 121 column_index_= other.column_index_; 122 } 123 else{ 124 assert(column_index_.empty()); 125 column_index_.reserve(index.size()); 126 for (size_t i=0; i<index.size(); i++) { 127 column_index_.push_back(other.column_index_[index[i]]); 128 } 129 row_index_= other.row_index_; 130 } 96 131 assert(kernel_>size()); 97 132 … … 138 173 139 174 175 size_t KernelLookup::columns(void) const 176 { 177 return column_index_.size(); 178 } 179 180 140 181 const DataLookup2D* KernelLookup::data(void) const 141 182 { … … 173 214 { 174 215 return const_row_iterator(const_row_iterator::iterator_type(*this,i+1,0),1); 216 } 217 218 219 size_t KernelLookup::rows(void) const 220 { 221 return row_index_.size(); 175 222 } 176 223 
trunk/yat/classifier/KernelLookup.h
r1127 r1132 66 66 /// constructors and assignments. 67 67 /// 68 class KernelLookup : public DataLookup2D68 class KernelLookup 69 69 { 70 70 … … 199 199 const_row_iterator begin_row(size_t) const; 200 200 201 /** 202 \return number of columns 203 */ 204 size_t columns(void) const; 205 201 206 /// 202 207 /// Each column in returned DataLookup corresponds to the column … … 243 248 */ 244 249 const_row_iterator end_row(size_t) const; 250 251 /** 252 \return number of rows 253 */ 254 size_t rows(void) const; 245 255 246 256 /** … … 326 336 const KernelLookup& operator=(const KernelLookup&); 327 337 338 std::vector<size_t> column_index_; 328 339 const Kernel* kernel_; 340 /// 341 /// poiter telling how many owners to underlying data. NULL if 342 /// this is not an owner. 343 /// 344 u_int* ref_count_; 345 std::vector<size_t> row_index_; 329 346 330 347 }; // class KernelLookup
Note: See TracChangeset
for help on using the changeset viewer.