Changeset 406


Ignore:
Timestamp:
Nov 27, 2005, 11:39:19 PM (16 years ago)
Author:
Jari Häkkinen
Message:

Polished code and documentation, removed inclusion of nonused header files.

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

Legend:

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

    r357 r406  
    44#include <c++_tools/utility/stl_utility.h>
    55
    6 #include <iostream>
    76#include <sstream>
    8 #include <string>
    97#include <vector>
    108#include <utility>
     
    3533    : view_(NULL)
    3634  {
    37     v_ = other.TEMP_gsl_vector_copy();
     35    v_ = other.gsl_vector_copy();
    3836  }
    3937
     
    4947
    5048
     49  /* Jari, remove this?
    5150  vector::vector(gsl_vector* vec)
    5251    : v_(vec), view_(NULL)
    5352  {
    5453  }
     54  */
    5555
    5656
     
    7979          << ") and columns (" << nof_columns
    8080          << ").\n    Expected a row or a column vector.";
    81         std::string m=s.str();
    82         throw utility::IO_error(m);
     81        throw utility::IO_error(s.str());
    8382      }
    84       else if(v.size()!=nof_columns) {
     83      else if (v.size()!=nof_columns) {
    8584        std::ostringstream s;
    8685        s << "vector::vector(std::istream&) data file error:\n"
    8786          << "    Line " << (nof_rows+1) << " has " << v.size()
    8887          << " columns; expected " << nof_columns << " column.";
    89         std::string m=s.str();
    90         throw utility::IO_error(m);
     88        throw utility::IO_error(s.str());
    9189      }
    9290      data_matrix.push_back(v);
     
    116114
    117115
    118   gsl_vector* vector::TEMP_gsl_vector_copy(void) const
     116  gsl_vector* vector::gsl_vector_copy(void) const
    119117  {
    120118    gsl_vector* vec = gsl_vector_alloc(size());
     
    199197      if ( v_ )
    200198        gsl_vector_free( v_ );
    201       v_ = other.TEMP_gsl_vector_copy();
     199      v_ = other.gsl_vector_copy();
    202200    }
    203201    return *this;
  • branches/better_matrix_class/lib/gslapi/vector.h

    r357 r406  
    11// $Id$
    22
    3 #ifndef _theplu_gslapi_vector_ 
     3#ifndef _theplu_gslapi_vector_
    44#define _theplu_gslapi_vector_
     5
     6#include <c++_tools/utility/Exception.h>
    57
    68#include <iostream>
     
    911
    1012#include <gsl/gsl_vector.h>
    11 #include <c++_tools/utility/Exception.h>
    1213
    1314namespace theplu {
     
    2526  /// \par[Vector views] GSL vector views are supported and these are
    2627  /// disguised as ordinary gslapi::vectors. A support function is
    27   /// added, gslapi::vector::is_view(), that can be used to check if
    28   /// the vector object is a view. Note that view vectors do not own
    29   /// the undelying data, and is not valid if the original vector is
    30   /// deallocated.
     28  /// added, gslapi::vector::isview(), that can be used to check if a
     29  /// vector object is a view. Note that view vectors do not own the
     30  /// undelying data, and a view is not valid if the vector owning the
     31  /// data is deallocated.
    3132  ///
    3233  class vector
     
    6364    /// is viewed. Also, using the copy constructor will create a new
    6465    /// vector object that is a copy of whatever is viewed. If a copy
    65     /// of the view is needed the you should use this consturctor to
     66    /// of the view is needed then you should use this consturctor to
    6667    /// get one.
    6768    ///
    6869    /// @note If the object viewed by the view goes out of scope or is
    69     /// deleted, the view becomes invalid.
    70     ///
    71     vector(vector& v, size_t offset, size_t n, size_t stride=1);
     70    /// deleted, the view becomes invalid and the result of further
     71    /// use is undefined.
     72    ///
     73    vector(vector& v, size_t offset, size_t n, size_t stride=1);
    7274
    7375    ///
     
    7577    /// by the created object.
    7678    ///
    77     vector(gsl_vector*);
     79    // Jari, remove this?
     80//    vector(gsl_vector*);
    7881
    7982    ///
     
    123126
    124127    ///
    125     /// Check if the vector object is a view (sub vector) to another
     128    /// Check if the vector object is a view (sub-vector) to another
    126129    /// vector.
    127130    ///
    128     /// @return True if the object is a view, false othwerwise;
     131    /// @return True if the object is a view, false othwerwise.
    129132    ///
    130133    inline bool isview(void) const { return view_; }
     
    279282    ///
    280283    // Jari, doxygen group as Accessing vector elements
    281     inline const double& operator()(size_t i) const
    282       { return *gsl_vector_const_ptr(v_,i); }
    283    
     284    inline const double&
     285    operator()(size_t i) const { return *gsl_vector_const_ptr(v_,i); }
     286
    284287    ///
    285288    /// Element access operator.
     
    296299    ///
    297300    // Jari, doxygen group as Accessing vector elements
    298     inline const double& operator[](size_t i) const
    299       { return *gsl_vector_const_ptr(v_,i); }
    300    
     301    inline const double&
     302    operator[](size_t i) const { return *gsl_vector_const_ptr(v_,i); }
     303
    301304    ///
    302305    /// @return The dot product.
     
    309312    /// @note This operator is not implemented!
    310313    ///
    311     vector operator*(const double d) const;
     314    vector operator*(const double d) const;
    312315
    313316    ///
     
    346349    /// @return A const reference to the resulting vector.
    347350    ///
    348     inline const vector& operator+=( const vector& other )
    349     { gsl_vector_add(v_,other.v_); return *this; }
     351    inline const vector&
     352    operator+=(const vector& other) { gsl_vector_add(v_,other.v_); return *this;}
    350353
    351354    ///
     
    354357    /// @return A const reference to the resulting vector.
    355358    ///
    356     inline const vector& operator-=( const vector& other )
    357     { gsl_vector_sub(v_,other.v_); return *this; }
     359    inline const vector&
     360    operator-=(const vector& other) { gsl_vector_sub(v_,other.v_); return *this;}
    358361
    359362    ///
     
    362365    /// @return A const reference to the resulting vector.
    363366    ///
    364     inline const vector& operator*=(const double d)
    365     { gsl_vector_scale(v_,d); return *this; }
    366 
    367 
    368   private:
     367    inline const vector&
     368    operator*=(const double d) { gsl_vector_scale(v_,d); return *this; }
     369
     370
     371  private:
    369372
    370373    ///
     
    376379    /// @return A pointer to a copy of the internal GSL vector.
    377380    ///
    378     gsl_vector* TEMP_gsl_vector_copy(void) const;
    379 
    380     gsl_vector* v_;
     381    gsl_vector* gsl_vector_copy(void) const;
     382
     383    gsl_vector* v_;
    381384    gsl_vector_view* view_;
    382   };
     385  };
    383386
    384387  ///
    385388  /// The output operator for the vector class.
    386   /// 
     389  ///
    387390  std::ostream& operator<<(std::ostream&, const vector& );
    388391
     
    390393}} // of namespace gslapi and namespace theplu
    391394
    392 #endif 
     395#endif
Note: See TracChangeset for help on using the changeset viewer.