Ignore:
Timestamp:
Feb 18, 2008, 4:13:53 AM (14 years ago)
Author:
Jari Häkkinen
Message:

Fixes #299. Memory leak in matrix was found and removed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/utility/matrix.h

    r1068 r1098  
    5454  /// functionality, and thus binary read and write to streams are not
    5555  /// supported.
    56   ///
    57   /// \par[Matrix views] GSL matrix views are supported and these are
    58   /// disguised as ordinary utility::matrix'es. A support function is
    59   /// added, utility::matrix::isview(), that can be used to check if a
    60   /// matrix object is a view. Note that view matricess do not own the
    61   /// undelying data, and a view is not valid if the matrix owning the
    62   /// data is deallocated.
    6356  ///
    6457  /// @note All GSL matrix related functions are not implement but
     
    9992       \brief The copy constructor.
    10093
    101        \note If the object to be copied is a matrix view, the values
    102        of the view will be copied, i.e. the view is not copied.
    103 
    10494       \throw A GSL_error is indirectly thrown if memory allocation
    10595       fails.
    10696    */
    10797    matrix(const matrix&);
    108 
    109     /**
    110        \brief The matrix view constructor.
    111 
    112        Create a view of matrix \a m, with starting row \a offset_row,
    113        starting column \a offset_column, row size \a n_row, and column
    114        size \a n_column.
    115 
    116        A matrix view can be used as any matrix with the difference
    117        that changes made to the view will also change the object that
    118        is viewed. Also, using the copy constructor will create a new
    119        matrix object that is a copy of whatever is viewed. If a copy
    120        of the view is needed then you should use this constructor to
    121        obtain a copy.
    122 
    123        \note If the object viewed by the view goes out of scope or is
    124        deleted, the view becomes invalid and the result of further use
    125        is undefined.
    126 
    127        \throw GSL_error if a view cannot be set up.
    128     */
    129     matrix(matrix& m, size_t offset_row, size_t offset_column, size_t n_row,
    130            size_t n_column);
    13198
    13299    /**
     
    202169
    203170    /**
    204        \brief Make a copy of \a other.
    205 
    206        This function will make a deep copy of \a other. Memory is
    207        resized and view state is changed to same as in other.
    208     */
    209     const matrix& clone(const matrix& other);
    210 
    211     /**
    212171       \return Vector view of column \a i
    213172     */
     
    284243    gsl_matrix* gsl_matrix_p(void);
    285244
    286     ///
    287     /// @brief Check if the matrix object is a view (sub-matrix) to
    288     /// another matrix.
    289     ///
    290     /// @return True if the object is a view, false othwerwise.
    291     ///
    292     bool isview(void) const;
    293 
    294245    /**
    295246       Multiply the elements of matrix \a b with the elements of the
     
    306257       All elements are set to @a init_value.
    307258
    308        \note underlying GSL matrix is destroyed and a view into this
     259       \note underlying GSL matrix is destroyed and views into this
    309260       matrix becomes invalid.
    310261    */
     
    352303    /**
    353304       \brief Transpose the matrix.
    354 
    355        \note Invalidates view of matrix, unless matrix is square.
    356305
    357306       \throw GSL_error if memory allocation fails for the new
     
    412361       \brief The assignment operator.
    413362
    414        Dimensions of the matrices must match. If the LHS matrix is a
    415        view, the underlying data will be changed.
    416 
    417363       \return A const reference to the resulting matrix.
    418 
    419        \see void set(const matrix&).
    420 
    421        \throw GSL_error if dimensions mis-match.
    422364    */
    423365    const matrix& operator=(const matrix& other);
     
    512454    gsl_matrix* blas_result_;
    513455    gsl_matrix* m_;
    514     gsl_matrix_view* view_;
    515     const gsl_matrix_const_view* view_const_;
    516     // proxy_m_ is used to access the proper underlying gsl_matrix in
    517     // all const member functions. It is not used by design for
    518     // non-const vector functions and operators. This is to make sure
    519     // that runtime errors occur if a const matrix is used in an
    520     // inappropriate manner such as on left hand side in assignment
    521     // (remember, m_ is null for const matrix views).
    522     const gsl_matrix* proxy_m_;
    523456  };
    524457
Note: See TracChangeset for help on using the changeset viewer.