Changeset 534
- Timestamp:
- Mar 3, 2006, 12:27:58 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/classifier/DataLookup2D.cc
r533 r534 54 54 55 55 56 DataLookup2D::DataLookup2D(const std::vector<size_t>& index, bool row)57 {58 }59 60 61 56 DataLookup2D::DataLookup2D(const DataLookup2D& mv) 62 57 : row_index_(mv.row_index_),column_index_(mv.column_index_) -
trunk/lib/classifier/DataLookup2D.h
r533 r534 30 30 /// 31 31 DataLookup2D(const std::vector<size_t>&, const std::vector<size_t>&); 32 33 ///34 /// Constructor taking the row index vector or35 /// column index vector (default)36 ///37 DataLookup2D(const std::vector<size_t>&, bool row=false);38 39 32 40 33 /// -
trunk/lib/classifier/MatrixLookup.cc
r533 r534 29 29 const std::vector<size_t>& index, 30 30 const bool row) 31 : DataLookup2D( index, row), data_(&data)31 : DataLookup2D(), data_(&data) 32 32 { 33 } 34 35 36 37 MatrixLookup::MatrixLookup(const MatrixLookup& ml, 38 const std::vector<size_t>& index, bool row) 39 : DataLookup2D(ml,index,row), data_(ml.data_) 40 { 33 if (row){ 34 row_index_=index; 35 assert(column_index_.empty()); 36 column_index_.reserve(data.columns()); 37 for (size_t i=0; i<data.columns(); i++) 38 column_index_.push_back(i); 39 } 40 else{ 41 column_index_=index; 42 assert(row_index_.empty()); 43 column_index_.reserve(data.rows()); 44 for (size_t i=0; i<data.rows(); i++) 45 row_index_.push_back(i); 46 } 41 47 } 42 48 … … 50 56 51 57 52 MatrixLookup::MatrixLookup(const MatrixLookup& data,58 MatrixLookup::MatrixLookup(const MatrixLookup& ml, 53 59 const std::vector<size_t>& row, 54 60 const std::vector<size_t>& col) 55 : DataLookup2D(data,row,col), data_(data.data_) 61 : DataLookup2D(ml,row,col), data_(ml.data_) 62 { 63 } 64 65 66 67 MatrixLookup::MatrixLookup(const MatrixLookup& ml, 68 const std::vector<size_t>& index, bool row) 69 : DataLookup2D(ml,index,row), data_(ml.data_) 56 70 { 57 71 } … … 62 76 MatrixLookup::training_data(const std::vector<size_t>& i) const 63 77 { 64 return new MatrixLookup(*this,i );78 return new MatrixLookup(*this,i, false); 65 79 } 66 80 … … 71 85 const std::vector<size_t>& val) const 72 86 { 73 return new MatrixLookup(*this,val );87 return new MatrixLookup(*this,val, false); 74 88 } 75 89 -
trunk/lib/classifier/MatrixLookup.h
r533 r534 50 50 51 51 /// 52 /// Copy constructor.52 /// @brief Copy constructor. 53 53 /// 54 54 MatrixLookup(const MatrixLookup&); -
trunk/test/lookup_test.cc
r533 r534 86 86 87 87 std::vector<size_t> one(1,1); 88 classifier::MatrixLookup m3( m2,one,true);89 if (m3.rows()!=1 || m3.columns()!= m2.columns() || m3(0,0)!=m2(1,0) ||90 m3(0,1)!= m2(1,1)) {88 classifier::MatrixLookup m3(gsl_m2,one,true); 89 if (m3.rows()!=1 || m3.columns()!=gsl_m2.columns() || m3(0,0)!=gsl_m2(1,0) || 90 m3(0,1)!=gsl_m2(1,1) || m3(0,2)!=gsl_m2(1,2) || m3(0,3)!=gsl_m2(1,3)) { 91 91 ok =false; 92 92 *error << "ERROR:\n" 93 << "MatrixLookup::MatrixLookup(const MatrixLookup&,\n"93 << "MatrixLookup::MatrixLookup(const gslapi::matrix&,\n" 94 94 << " const std::vector<size_t>&,\n" 95 95 << " const bool)" 96 96 << std::endl; 97 *error << "m3.rows(): " << m3.rows() << " expected 1" << std::endl; 98 *error << "m3.columns(): " << m3.columns() << " expected " 99 << gsl_m2.columns() << std::endl; 97 100 } 98 101 … … 118 121 } 119 122 123 classifier::MatrixLookup m6(m2,one,true); 124 if (m6.rows()!=1 || m6.columns()!=m2.columns() || m6(0,0)!=m2(1,0) || 125 m6(0,1)!=m2(1,1)) { 126 ok =false; 127 *error << "ERROR:\n" 128 << "MatrixLookup::MatrixLookup(const MatrixLookup&,\n" 129 << " const std::vector<size_t>&,\n" 130 << " const bool)" 131 << std::endl; 132 } 133 134 135 const classifier::MatrixLookup* TrnData = m2.training_data(one); 136 if (TrnData->rows() != m2.rows() || TrnData->columns()!=one.size()){ 137 ok =false; 138 *error << "ERROR:\nMatrixLookup::training_data(const std::vector<size_t>)" 139 << std::endl; 140 } 141 delete TrnData; 142 143 std::vector<size_t> val(23,2); 144 const classifier::MatrixLookup* ValData = m2.validation_data(one, val); 145 if (ValData->rows() != m2.rows() || TrnData->columns()!=val.size()){ 146 ok =false; 147 *error << "ERROR:\n" 148 << "MatrixLookup::validation_data(const std::vector<size_t>,\n" 149 << " const std::vector<size_t>)" 150 << std::endl; 151 } 152 delete ValData; 120 153 121 154
Note: See TracChangeset
for help on using the changeset viewer.