Changeset 590
 Timestamp:
 Aug 24, 2006, 1:15:57 PM (16 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/c++_tools/classifier/MatrixLookup.h
r565 r590 15 15 16 16 /// 17 /// Interface class for classifier data 18 /// 19 /// @todo document, especially describe when object becomes invalid, 20 /// as now documentation is conservative. 17 /// MatrixLookups can be used to create lookups/views into matrices 18 /// in a more general way than the views supported in the matrix 19 /// class. The object does not contain any data, but only a pointer 20 /// to a matrix and row and columns incices defining which 21 /// submatrix to look into. Each row and each column corresponds 22 /// to a row and a column in the Kernel, respectively. This design 23 /// allow for fast creation of submatrices, which is a common 24 /// operation in most traning/validation procedures. 25 /// 26 /// A MatrixLookup can be created directly from a matrix or from an 27 /// other MatrixLookup. In the latter case, the resulting 28 /// MatrixLookup is looking directly into the underlying matrix to 29 /// avoid multiple lookups. 30 /// 31 /// There is a possibility to set the MatrixLookup as owner of the 32 /// underlying matrix. In that case the underlying matrix will be 33 /// destroyed in the destructor. Consequently, the underlying matrix 34 /// must have been dynamically allocated and no other MatrixLookup 35 /// can own the Kernel. 36 /// 21 37 class MatrixLookup : public DataLookup2D 22 38 { … … 26 42 27 43 /// 28 /// Constructor creating a lookup into the wholematrix.44 /// Constructor creating a lookup into the entire @a matrix. 29 45 /// 30 46 /// @note If @a matrix goes out of scope or is deleted, the … … 34 50 explicit MatrixLookup(const gslapi::matrix& matrix); 35 51 36 /// 37 /// Constructor creating a lookup into parts of matrix. The 38 /// \f$i\f$th row in constructed lookup is identical to row number 39 /// row[i] in matrix. The \f$i\f$th column in constructed lookup 40 /// is identical to column number column[i] in matrix. 41 /// 52 /// 53 /// Constructor creating a lookup into a submatrix of @a matrix. 54 /// The @a row and @a column define what submatrix to look into, 55 /// in other words, the created MatrixLookup will fullfill the 56 /// following: \f$ MatrixLookup(i,j)=matrix(row[i],column[j]) 57 /// \f$. This also means that number of rows in created 58 /// MatrixLookup is equal to size of vector @a row, and number of 59 /// columns is equal to size of vector @a column. 60 /// 42 61 /// @note If @a matrix goes out of scope or is deleted, the 43 62 /// MatrixLookup becomes invalid and the result of further use is … … 45 64 /// 46 65 MatrixLookup(const gslapi::matrix& matrix, const std::vector<size_t>& row, 47 const std::vector<size_t>& column); 48 49 /// 50 /// Constructor taking rows or columns 51 /// 52 /// @parameter row_vectors if true (default) the new MatrixLookup 53 /// will look into a submatrix defined by all columns and rows 54 /// defined by @a index. If not true the new MatrixLookup will 55 /// look into a submatrix defined by all rows and columns defined 56 /// by @a index. 57 /// 66 const std::vector<size_t>& column); 67 68 /// 69 /// Constructor creating a lookup into a submatrix of @matrix. 70 /// 71 /// If @a row_vectors is true the new MatrixLookup will be consist 72 /// of the row vectors defined by @a index. This means that the 73 /// created MatrixLookup will fullfill: 74 /// \f$ MatrixLookup(i,j)=matrix(i,index[j]) \f$ 75 /// 76 /// If @a row_vectors is false the new MatrixLookup will be consist 77 /// of the rolumn vectors defined by @a index. This means that the 78 /// created MatrixLookup will fullfill: 79 /// \f$ MatrixLookup(i,j)=matrix(index[i],j) \f$ 80 /// 58 81 /// @note If @a matrix goes out of scope or is deleted, the 59 82 /// MatrixLookup becomes invalid and the result of further use is … … 64 87 const bool row_vectors); 65 88 66 67 68 89 /// 90 /// @brief Copy constructor. 91 /// 69 92 /// @note If underlying matrix goes out of scope or is deleted, the 70 93 /// MatrixLookup becomes invalid and the result of further use is … … 73 96 MatrixLookup(const MatrixLookup&); 74 97 75 /// 76 /// Constructor taking the row index vector and column index vector 77 /// as input. 78 /// 79 /// @note If underlying matrix goes out of scope or is deleted, the 80 /// MatrixLookup becomes invalid and the result of further use is 81 /// undefined. 82 /// 83 MatrixLookup(const MatrixLookup& matrix, const std::vector<size_t>&, 84 const std::vector<size_t>&); 85 86 /// 87 /// Constructor taking the column or row index vector (default) as 88 /// input. If @a row is false the created MatrixLookup will have 89 /// equally many rows as @a matrix. 90 /// 91 /// @note If underlying matrix goes out of scope or is deleted, the 92 /// MatrixLookup becomes invalid and the result of further use is 93 /// undefined. 94 /// 95 MatrixLookup(const MatrixLookup& matrix, const std::vector<size_t>&, 98 /// 99 /// Creates a subMatrixLookup. The Lookup is independent of 100 /// MatrixLookup @a ml. The MatrixLookup is created to look 101 /// directly into the underlying matrix to avoid multiple lookups. 102 /// 103 /// The @a row and @a column define what submatrix to look into, 104 /// in other words, the created MatrixLookup will fullfill the 105 /// following: \f$ MatrixLookup(i,j)=ml(row[i],column[j]) \f$. This 106 /// also means that number of rows in created MatrixLookup is 107 /// equal to size of vector @a row, and number of columns is equal 108 /// to size of vector @a column. 109 /// 110 /// @note If underlying matrix goes out of scope or is deleted, the 111 /// MatrixLookup becomes invalid and the result of further use is 112 /// undefined. 113 /// 114 MatrixLookup(const MatrixLookup& ml, const std::vector<size_t>& row, 115 const std::vector<size_t>& column); 116 117 /// 118 /// Constructor creating a lookup into a submatrix of 119 /// @a ml. The MatrixLookup is created to look directly into the 120 /// underlying matrix to avoid multiple lookups. 121 /// 122 /// If @a row_vectors is true the new MatrixLookup will be consist 123 /// of the row vectors defined by @a index. This means that the 124 /// created MatrixLookup will fullfill: 125 /// \f$ MatrixLookup(i,j)=ml(i,index[j])\f$ 126 /// 127 /// If @a row_vectors is false the new MatrixLookup will be consist 128 /// of the rolumn vectors defined by @a index. This means that the 129 /// created MatrixLookup will fullfill: 130 /// \f$ MatrixLookup(i,j) = ml(index[i],j) \f$ 131 /// 132 /// @note If underlying matrix goes out of scope or is deleted, the 133 /// MatrixLookup becomes invalid and the result of further use is 134 /// undefined. 135 /// 136 MatrixLookup(const MatrixLookup& ml, const std::vector<size_t>&, 96 137 const bool row_vectors); 97 138 … … 99 140 /// Constructor creating a MatrixLookup with @a rows rows, @a 100 141 /// columns columns, and all values are set to @a value. Created 101 /// objectowns its underlying matrix.142 /// MatrixLookup owns its underlying matrix. 102 143 /// 103 144 MatrixLookup(const size_t rows, const size_t columns, const double value=0); 104 145 105 146 /// 106 /// Destructor 147 /// @brief The istream constructor. 148 /// 149 /// In construction the underlying matrix is created from 150 /// stream. The MatrixLookup will be owner of the underlying 151 /// matrix. 152 /// 153 /// @see matrix(istream&) for details. 154 /// 155 MatrixLookup(std::istream&, char sep='\0'); 156 157 /// 158 /// Destructor. If MatrixLookup is owner of underlying matrix, the 159 /// matrix is destroyed. 107 160 /// 108 161 virtual ~MatrixLookup(); … … 110 163 111 164 /// 165 /// The created MatrixLookup corresponds to all rows and the 166 /// columns defined by @a index in the original MatrixLookup. The 167 /// created MatrixLookup will fullfill: 168 /// \f$ novel_ml(i,j)=original(i,index[j]) \f$. 169 /// 112 170 /// @return pointer to subLookup of the MatrixLookup 113 171 /// … … 116 174 /// undefined. 117 175 /// 118 const MatrixLookup* training_data(const std::vector<size_t>& i ) const;176 const MatrixLookup* training_data(const std::vector<size_t>& index) const; 119 177 178 /// 179 /// The created MatrixLookup corresponds to all rows and the 180 /// columns defined by @a index in the original MatrixLookup. The 181 /// created MatrixLookup will fullfill: 182 /// \f$ novel_ml(i,j)=original(i,index[j]) \f$. 120 183 /// 121 184 /// @return pointer to subLookup of the MatrixLookup … … 135 198 { 136 199 assert(row<rows()); 137 assert(column s());200 assert(column<columns()); 138 201 return (*data_)(row_index_[row], column_index_[column]); 139 202 } … … 141 204 /// 142 205 /// @brief assigment operator 206 /// 207 /// Does only change MatrixLookup not the underlying matrix 208 /// object. However if the MatrixLookup is owner of its underlying 209 /// matrix, that matrix will be deleted here. 143 210 /// 144 211 const MatrixLookup& operator=(const MatrixLookup&);
Note: See TracChangeset
for help on using the changeset viewer.