Changeset 1133
- Timestamp:
- Feb 23, 2008, 9:40:35 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/kernel_test.cc
r1121 r1133 31 31 #include "yat/classifier/Kernel_MEV.h" 32 32 #include "yat/classifier/Kernel_SEV.h" 33 #include "yat/classifier/MatrixLookup.h" 33 34 34 35 #include <cassert> -
trunk/test/svm_test.cc
r1121 r1133 29 29 #include "yat/classifier/Kernel_SEV.h" 30 30 #include "yat/classifier/Kernel_MEV.h" 31 #include "yat/classifier/MatrixLookup.h" 31 32 #include "yat/classifier/PolynomialKernelFunction.h" 32 33 #include "yat/classifier/Target.h" -
trunk/yat/classifier/KernelLookup.cc
r1132 r1133 38 38 39 39 KernelLookup::KernelLookup(const Kernel& kernel, const bool own) 40 : kernel_(&kernel) 41 { 42 if (own) 43 ref_count_ = new u_int(1); 44 else 45 ref_count_ = NULL; 40 : kernel_(utility::SmartPtr<const Kernel>(&kernel, own)) 41 { 46 42 column_index_.reserve(kernel.size()); 47 43 for(size_t i=0; i<kernel.size(); i++) … … 55 51 const std::vector<size_t>& column, 56 52 const bool owner) 57 : column_index_(column), kernel_(&kernel), ref_count_(NULL), 53 : column_index_(column), 54 kernel_(utility::SmartPtr<const Kernel>(&kernel, owner)), 58 55 row_index_(row) 59 56 { … … 84 81 column_index_.push_back(other.column_index_[column[i]]); 85 82 } 86 ref_count_=other.ref_count_;87 if (ref_count_)88 ++(*ref_count_);89 83 } 90 84 … … 101 95 *(max_element(column_index_.begin(), column_index_.end()))< 102 96 kernel_->size()); 103 ref_count_=other.ref_count_;104 if (ref_count_)105 ++(*ref_count_);106 97 } 107 98 … … 138 129 *(max_element(column_index_.begin(), column_index_.end()))< 139 130 kernel_->size()); 140 ref_count_=other.ref_count_;141 if (ref_count_)142 ++(*ref_count_);143 131 } 144 132 … … 146 134 KernelLookup::~KernelLookup(void) 147 135 { 148 if (ref_count_)149 if (!--(*ref_count_))150 delete kernel_;151 136 } 152 137 -
trunk/yat/classifier/KernelLookup.h
r1132 r1133 28 28 29 29 #include "Kernel.h" 30 #include "DataLookup2D.h"31 #include "MatrixLookup.h"32 30 #include "yat/utility/Container2DIterator.h" 33 31 #include "yat/utility/iterator_traits.h" 32 #include "yat/utility/SmartPtr.h" 34 33 #include "yat/utility/StrideIterator.h" 35 36 34 37 35 #include <vector> … … 41 39 namespace classifier { 42 40 41 class DataLookup2D; 43 42 class KernelFunction; 43 class MatrixLookup; 44 class MatrixLookupWeighted; 44 45 45 46 /// … … 337 338 338 339 std::vector<size_t> column_index_; 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_; 340 utility::SmartPtr<const Kernel> kernel_; 345 341 std::vector<size_t> row_index_; 346 342 -
trunk/yat/utility/SmartPtr.h
r1125 r1133 26 26 27 27 #include "yat_assert.h" 28 29 // debug 30 #include <iostream> 28 31 29 32 namespace theplu { … … 70 73 if (owner) 71 74 ref_count_ = new u_int(1); 75 else 76 ref_count_ = NULL; 72 77 } 73 78
Note: See TracChangeset
for help on using the changeset viewer.