Changeset 590


Ignore:
Timestamp:
Aug 24, 2006, 1:15:57 PM (15 years ago)
Author:
Peter
Message:

closes #74 documentation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/c++_tools/classifier/MatrixLookup.h

    r565 r590  
    1515
    1616  ///
    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  /// sub-matrix 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 sub-matrices, 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  ///
    2137  class MatrixLookup : public DataLookup2D
    2238  {
     
    2642
    2743    ///
    28     /// Constructor creating a lookup into the whole matrix.
     44    /// Constructor creating a lookup into the entire @a matrix.
    2945    ///
    3046    /// @note If @a matrix goes out of scope or is deleted, the
     
    3450    explicit MatrixLookup(const gslapi::matrix& matrix);
    3551
    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 sub-matrix of @a matrix.
     54    /// The @a row and @a column define what sub-matrix 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    ///
    4261    /// @note If @a matrix goes out of scope or is deleted, the
    4362    /// MatrixLookup becomes invalid and the result of further use is
     
    4564    ///
    4665    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 sub-matrix defined by all columns and rows
    54     /// defined by @a index. If not true the new MatrixLookup will
    55     /// look into a sub-matrix 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 sub-matrix 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    ///
    5881    /// @note If @a matrix goes out of scope or is deleted, the
    5982    /// MatrixLookup becomes invalid and the result of further use is
     
    6487                 const bool row_vectors);
    6588
    66     ///
    67     /// @brief Copy constructor.
    68     ///
     89    ///
     90    /// @brief Copy constructor.
     91    ///
    6992    /// @note If underlying matrix goes out of scope or is deleted, the
    7093    /// MatrixLookup becomes invalid and the result of further use is
     
    7396    MatrixLookup(const MatrixLookup&);
    7497
    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 sub-MatrixLookup. 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 sub-matrix 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 sub-matrix 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>&,
    96137                 const bool row_vectors);
    97138
     
    99140    /// Constructor creating a MatrixLookup with @a rows rows, @a
    100141    /// columns columns, and all values are set to @a value. Created
    101     /// object owns its underlying matrix.
     142    /// MatrixLookup owns its underlying matrix.
    102143    ///
    103144    MatrixLookup(const size_t rows, const size_t columns, const double value=0);
    104145
    105146    ///
    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.
    107160    ///
    108161    virtual ~MatrixLookup();
     
    110163   
    111164    ///
     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    ///
    112170    /// @return pointer to sub-Lookup of the MatrixLookup
    113171    ///
     
    116174    /// undefined.
    117175    ///
    118     const MatrixLookup* training_data(const std::vector<size_t>& i) const;
     176    const MatrixLookup* training_data(const std::vector<size_t>& index) const;
    119177   
     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$.
    120183    ///
    121184    /// @return pointer to sub-Lookup of the MatrixLookup
     
    135198    {
    136199      assert(row<rows());
    137       assert(columns());
     200      assert(column<columns());
    138201      return (*data_)(row_index_[row], column_index_[column]);
    139202    }
     
    141204    ///
    142205    /// @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.
    143210    ///
    144211    const MatrixLookup& operator=(const MatrixLookup&);
Note: See TracChangeset for help on using the changeset viewer.