Changeset 408


Ignore:
Timestamp:
Nov 28, 2005, 12:40:10 AM (16 years ago)
Author:
Jari Häkkinen
Message:

Continued fixing with views related to matrix.

Location:
branches/better_matrix_class/lib/gslapi
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/better_matrix_class/lib/gslapi/matrix.cc

    r407 r408  
    4343
    4444
    45   matrix(matrix& m, size_t offset_row, size_t offset_column, size_t n_row,
    46          size_t n_column);
    47   {
    48     view_ = new gsl_matrix_view(gsl_matrix_submatrix(v.m_,offset_row,
    49                                                      offset_column,n_row,
    50                                                      n_column));
    51     v_ = &(view_->matrix);
     45  matrix::matrix(matrix& m, size_t offset_row, size_t offset_column,
     46                 size_t n_row, size_t n_column)
     47  {
     48    // Jari, exception handling needed here. Failure in setting up a
     49    // proper gsl_matrix_view is communicated by NULL pointer in the
     50    // view structure (cf. GSL manual). How about GSL error state?
     51    view_ = new gsl_matrix_view(gsl_matrix_submatrix(m.m_,
     52                                                     offset_row,offset_column,
     53                                                     n_row,n_column));
     54    m_ = &(view_->matrix);
    5255  }
    5356
  • branches/better_matrix_class/lib/gslapi/matrix.h

    r407 r408  
    3232  /// data is deallocated.
    3333  ///
    34   /// @note All GSL matrix related functions are not implement but all
    35   /// functionality, except binary file support, defined for GSL
    36   /// matrices can be achieved with this interface class.
     34  /// @note All GSL matrix related functions are not implement but
     35  /// most functionality defined for GSL matrices can be achieved with
     36  /// this interface class. Most notable GSL functionality not
     37  /// supported are no binary file support and views on arrays,
     38  /// gslapi::vectors, gsl_vectors, diagonals, subdiagonals, and
     39  /// superdiagonals. If there is an interest from the user community,
     40  /// the omitted functionality could be included.
    3741  ///
    3842  class matrix
     
    7377    /// is viewed. Also, using the copy constructor will create a new
    7478    /// matrix object that is a copy of whatever is viewed. If a copy
    75     /// of the view is needed then you should use this consturctor to
    76     /// get one.
     79    /// of the view is needed then you should use this constructor to
     80    /// obtain a copy.
    7781    ///
    7882    /// @note If the object viewed by the view goes out of scope or is
     
    9397    /// of file marker.
    9498    ///
    95     explicit matrix(std::istream &);
     99    explicit matrix(std::istream &) throw (utility::IO_error,std::exception);
    96100
    97101    ///
     
    142146    ///
    143147    bool equal(const matrix&, const double precision=0) const;
     148
     149    ///
     150    /// @return A const pointer to the internal GSL matrix.
     151    ///
     152    // Jari, is this needed?
     153    inline const gsl_matrix* gsl_matrix_pointer(void) const { return m_; }
     154
     155    ///
     156    /// @return A pointer to the internal GSL matrix.
     157    ///
     158    // Jari, is this needed?
     159    inline gsl_matrix* gsl_matrix_pointer(void) { return m_; };
    144160
    145161    ///
     
    387403    gsl_matrix* gsl_matrix_copy(void) const;
    388404
    389     ///
    390     /// @return A const pointer to the internal GSL matrix.
    391     ///
    392     // Jari, is this needed?
    393     inline const gsl_matrix* gsl_matrix_pointer(void) const { return m_; }
    394 
    395     ///
    396     /// @return A pointer to the internal GSL matrix.
    397     ///
    398     // Jari, is this needed?
    399     inline gsl_matrix* gsl_matrix_pointer(void) { return m_; };
    400 
    401405    gsl_matrix* m_;
    402406    gsl_matrix_view* view_;
  • branches/better_matrix_class/lib/gslapi/vector.cc

    r406 r408  
    22
    33#include <c++_tools/gslapi/vector.h>
     4#include <c++_tools/gslapi/matrix.h>
    45#include <c++_tools/utility/stl_utility.h>
    56
     
    4041  vector::vector(vector& v, size_t offset, size_t n, size_t stride)
    4142  {
     43    // Jari, exception handling needed here. Failure in setting up a
     44    // proper gsl_vector_view is communicated by NULL pointer in the
     45    // view structure (cf. GSL manual). How about GSL error state?
    4246    view_ = new gsl_vector_view(gsl_vector_subvector_with_stride(v.v_,offset,
    4347                                                                 stride,n));
    4448    v_ = &(view_->vector);
    4549  }
     50
     51
     52
     53  vector::vector(matrix& m, size_t i, bool row)
     54  {
     55    view_ = new gsl_vector_view(row ?
     56                                gsl_matrix_row   (m.gsl_matrix_pointer(),i) :
     57                                gsl_matrix_column(m.gsl_matrix_pointer(),i) );
     58    v_ = &(view_->vector);
     59  }
     60
    4661
    4762
  • branches/better_matrix_class/lib/gslapi/vector.h

    r406 r408  
    1414namespace theplu {
    1515namespace gslapi {
     16
     17  class matrix;
     18
    1619  ///
    1720  /// This is the C++ tools interface to GSL vector. 'double' is the
     
    3134  /// data is deallocated.
    3235  ///
     36  /// @note Missing support to underlying GSL vector features can in
     37  /// principle be included to this class if requested by the user
     38  /// community.
     39  ///
    3340  class vector
    3441  {
     
    5562
    5663    ///
    57     /// The vector view constructor.
     64    /// Vector view constructor.
    5865    ///
    5966    /// Create a view of vector \a v, with starting index \a offset,
     
    6471    /// is viewed. Also, using the copy constructor will create a new
    6572    /// vector object that is a copy of whatever is viewed. If a copy
    66     /// of the view is needed then you should use this consturctor to
    67     /// get one.
     73    /// of the view is needed then you should use this constructor to
     74    /// obtain a copy.
    6875    ///
    6976    /// @note If the object viewed by the view goes out of scope or is
     
    7481
    7582    ///
     83    /// Matrix row/column view constructor.
     84    ///
     85    /// Create a row/column vector view of matrix \a m, pointing at
     86    /// row/column \a i. The parameter \a row is used to set whether
     87    /// the view should be a row or column view. If \a row is set to
     88    /// true, the view will be a row view (default behaviour), and,
     89    /// naturally, a column view otherwise.
     90    ///
     91    /// A vector view can be used as any vector with the difference
     92    /// that changes made to the view will also change the object that
     93    /// is viewed. Also, using the copy constructor will create a new
     94    /// vector object that is a copy of whatever is viewed. If a copy
     95    /// of the view is needed then you should use the vector view
     96    /// constructor to obtain a copy.
     97    ///
     98    /// @note If the object viewed by the view goes out of scope or is
     99    /// deleted, the view becomes invalid and the result of further
     100    /// use is undefined.
     101    ///
     102    vector(matrix& m, size_t i, bool row=true);
     103
     104    ///
    76105    /// Constructor that imports a GSL vector. The GSL object is owned
    77106    /// by the created object.
     
    120149
    121150    ///
     151    /// @return A const pointer to the internal GSL vector,
     152    ///
     153    // Jari, is this needed?
     154    inline const gsl_vector* gsl_vector_pointer(void) const { return v_; }
     155
     156    ///
     157    /// @return A pointer to the internal GSL vector,
     158    ///
     159    // Jari, is this needed?
     160    inline gsl_vector* TEMP_gsl_vector_pointer(void) { return v_; }
     161
     162    ///
    122163    /// @return True if all elements in the vector is zero, false
    123164    /// othwerwise;
     
    132173    ///
    133174    inline bool isview(void) const { return view_; }
    134 
    135     ///
    136     /// @return A const pointer to the internal GSL vector,
    137     ///
    138     inline const gsl_vector* gsl_vector_pointer(void) const { return v_; }
    139 
    140     ///
    141     /// @return A pointer to the internal GSL vector,
    142     ///
    143     inline gsl_vector* TEMP_gsl_vector_pointer(void) { return v_; }
    144175
    145176    ///
Note: See TracChangeset for help on using the changeset viewer.