Changeset 703 for trunk/yat/utility


Ignore:
Timestamp:
Dec 18, 2006, 1:47:44 AM (15 years ago)
Author:
Jari Häkkinen
Message:

Addresses #65 and #170.

Location:
trunk/yat/utility
Files:
11 edited

Legend:

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

    r687 r703  
    148148
    149149    ///
    150     /// If more than maximal number of arguments is found during
    151     /// parsing an error message is displayed followed by exit.
     150    /// @brief If more than maximal number of arguments is found
     151    /// during parsing an error message is displayed followed by exit.
    152152    ///
    153153    /// @return maximal number of arguments allowed.
     
    156156
    157157    ///
    158     /// If less than minimal number of arguments is found during
    159     /// parsing an error message is displayed followed by exit.
     158    /// @brief If less than minimal number of arguments is found
     159    /// during parsing an error message is displayed followed by exit.
    160160    ///
    161161    /// @return minimal number of arguments allowed.
     
    181181
    182182    ///
    183     /// The @a description will be included in help display giving a
    184     /// general explanation what program is doing.
     183    /// @brief The @a description will be included in help display
     184    /// giving a general explanation what program is doing.
    185185    ///
    186186    inline void set_general_description(const std::string& description)
  • trunk/yat/utility/PCA.cc

    r687 r703  
    3232namespace yat {
    3333namespace utility {
     34
     35
     36  PCA::PCA(const utility::matrix& A)
     37    : A_(A), process_(false), explained_calc_(false)
     38  {
     39  }
    3440
    3541
  • trunk/yat/utility/PCA.h

    r687 r703  
    4747  public:
    4848    /**
    49        Default constructor (not implemented)
    50     */
    51     PCA(void);
    52 
    53     /**
    5449       Constructor taking the data-matrix as input. No row-centering
    5550       should have been performed and no products.
    5651     */
    57     inline explicit PCA(const utility::matrix& A)
    58       : A_(A), process_(false), explained_calc_(false) {}
    59 
     52    explicit PCA(const utility::matrix&);
     53 
    6054    /**
    6155       Will perform PCA according to the following scheme: \n
     
    8074       @return Eigenvector \a i.
    8175    */
    82     inline utility::vector get_eigenvector(const size_t& i) const
     76    inline utility::vector get_eigenvector(size_t i) const
    8377      { return utility::vector(eigenvectors_,i); }
    8478
     
    8781       \f$ C = \frac{1}{N^2}A^TA \f$
    8882    */
    89     inline double
    90     get_eigenvalue(const size_t& i) const { return eigenvalues_[i]; }
     83    inline double get_eigenvalue(size_t i) const { return eigenvalues_[i]; }
    9184
    9285    /**
  • trunk/yat/utility/SVD.cc

    r687 r703  
    2727namespace yat {
    2828namespace utility {
     29
     30
     31  SVD::SVD(const utility::matrix& Ain)
     32    : U_(Ain), V_(Ain.columns(),Ain.columns()), s_(Ain.columns())
     33  {
     34  }
     35
     36
     37  SVD::~SVD(void)
     38  {
     39  }
    2940
    3041
  • trunk/yat/utility/SVD.h

    r687 r703  
    7171
    7272    ///
    73     /// Constructs an SVD object using the matrix A as only input. The
     73    /// Constructs an SVD object using the matrix Ain as only input. The
    7474    /// input matrix is copied for further use in the object.
    7575    ///
    76     inline SVD(const utility::matrix& Ain)
    77       : U_(Ain), V_(Ain.columns(),Ain.columns()), s_(Ain.columns()) {}
     76    SVD(const utility::matrix& Ain);
    7877
    79     inline ~SVD(void) {}
     78    ///
     79    /// @brief The destructor
     80    ///
     81    ~SVD(void);
    8082
    8183    ///
     
    8890
    8991    ///
    90     /// Access to the s vector.
     92    /// @brief Access to the s vector.
    9193    ///
    9294    /// @return A copy of the s vector.
     
    98100
    99101    ///
    100     /// Solve the system \f$ Ax=b \f$ using the decomposition of A.
     102    /// @brief Solve the system \f$ Ax=b \f$ using the decomposition
     103    /// of A.
    101104    ///
    102105    /// @note If decompose() has not been run the outcome of the call
     
    111114
    112115    ///
    113     /// Access to the U matrix.
     116    /// @brief Access to the U matrix.
    114117    ///
    115118    /// @return A copy of the U matrix.
     
    121124
    122125    ///
    123     /// Access to the V matrix.
     126    /// @brief Access to the V matrix.
    124127    ///
    125128    /// @return A copy of the V matrix.
  • trunk/yat/utility/WeNNI.h

    r687 r703  
    6868
    6969
    70 
    7170  private:
    7271
  • trunk/yat/utility/matrix.cc

    r680 r703  
    3939namespace utility {
    4040
     41
     42  matrix::matrix(void)
     43    : m_(NULL), view_(NULL)
     44  {
     45  }
     46
     47
     48  matrix::matrix(const size_t& r, const size_t& c, double init_value)
     49    : view_(NULL)
     50  {
     51    m_ = gsl_matrix_alloc(r,c);
     52    set_all(init_value);
     53  }
     54
     55
     56  matrix::matrix(const matrix& o)
     57    : view_(NULL)
     58  {
     59    m_ = o.create_gsl_matrix_copy();
     60  }
    4161
    4262
     
    212232
    213233
     234  const matrix& matrix::operator+=(const matrix& m)
     235  {
     236    add(m);
     237    return *this;
     238  }
     239
     240
     241  const matrix& matrix::operator+=(const double d)
     242  {
     243    add_constant(d);
     244    return *this;
     245  }
     246
     247
     248  const matrix& matrix::operator-=(const matrix& m)
     249  {
     250    sub(m);
     251    return *this;
     252  }
     253
    214254
    215255  const matrix& matrix::operator*=(const matrix& other)
     
    222262  }
    223263
     264
     265  const matrix& matrix::operator*=(const double d)
     266  {
     267    scale(d);
     268    return *this;
     269  }
    224270
    225271
  • trunk/yat/utility/matrix.h

    r687 r703  
    8080       structures.
    8181    */
    82     inline matrix(void) : m_(NULL), view_(NULL) {}
    83 
    84     ///
    85     /// Constructor. Allocates memory space for \a r times \a c
     82    matrix(void);
     83
     84    ///
     85    /// @brief Constructor allocating memory space for \a r times \a c
    8686    /// elements, and sets all elements to \a init_value.
    8787    ///
    88     inline matrix(const size_t& r, const size_t& c, double init_value=0)
    89       : view_(NULL) { m_ = gsl_matrix_alloc(r,c); set_all(init_value); }
    90 
    91     ///
    92     /// The copy constructor.
     88    matrix(const size_t& r, const size_t& c, double init_value=0);
     89
     90    ///
     91    /// @brief The copy constructor.
    9392    ///
    9493    /// @note If the object to be copied is a matrix view, the values
    9594    /// of the view will be copied, i.e. the view is not copied.
    9695    ///
    97     inline matrix(const matrix& o) : view_(NULL) {m_=o.create_gsl_matrix_copy();}
     96    matrix(const matrix&);
    9897
    9998    ///
     
    134133
    135134    ///
    136     /// The destructor.
     135    /// @brief The destructor.
    137136    ///
    138137    ~matrix(void);
     
    199198
    200199    ///
    201     /// Check if the matrix object is a view (sub-matrix) to another
    202     /// matrix.
     200    /// @brief Check if the matrix object is a view (sub-matrix) to
     201    /// another matrix.
    203202    ///
    204203    /// @return True if the object is a view, false othwerwise.
     
    216215    /// row-major order).
    217216    ///
    218     inline std::pair<size_t,size_t> max_index(void) const;
     217    std::pair<size_t,size_t> max_index(void) const;
    219218
    220219    ///
     
    228227    /// row-major order).
    229228    ///
    230     inline std::pair<size_t,size_t> min_index(void) const;
     229    std::pair<size_t,size_t> min_index(void) const;
    231230
    232231    ///
     
    308307
    309308    ///
    310     /// Set \a row values to values in \a vec.
     309    /// @brief Set \a row values to values in \a vec.
    311310    ///
    312311    /// @return Whatever GSL returns.
     
    335334
    336335    ///
    337     /// Swap columns \a i and \a j.
     336    /// @brief Swap columns \a i and \a j.
    338337    ///
    339338    inline int swap_columns(const size_t i,const size_t j)
     
    341340
    342341    ///
    343     /// Swap row \a i and column \a j.
     342    /// @brief Swap row \a i and column \a j.
    344343    ///
    345344    inline int swap_rowcol(const size_t i,const size_t j)
     
    347346
    348347    ///
    349     /// Swap rows \a i and \a j.
     348    /// @brief Swap rows \a i and \a j.
    350349    ///
    351350    inline int swap_rows(const size_t i, const size_t j)
     
    353352
    354353    ///
    355     /// Transpose the matrix.
     354    /// @brief Transpose the matrix.
    356355    ///
    357356    void transpose(void);
     
    371370
    372371    ///
    373     /// Matrix-vector multiplication.
     372    /// @brief Matrix-vector multiplication.
    374373    ///
    375374    /// @return The resulting vector.
     
    379378
    380379    ///
    381     /// Comparison operator.
     380    /// @brief Comparison operator.
    382381    ///
    383382    /// @return True if all elements are equal otherwise False.
     
    388387
    389388    ///
    390     /// Comparison operator.
     389    /// @brief Comparison operator.
    391390    ///
    392391    /// @return False if all elements are equal otherwise True.
     
    397396
    398397    ///
    399     /// The assignment operator. There is no requirements on
    400     /// dimensions, i.e. the matrix is remapped in memory if
    401     /// necessary. This implies that in general views cannot be
    402     /// assigned using this operator. Views will be mutated into
    403     /// normal matrices. The only exception to this behaviour on views
    404     /// is when self-assignemnt is done, since self-assignment is
    405     /// ignored.
     398    /// @brief The assignment operator.
     399    ///
     400    /// There is no requirements on dimensions, i.e. the matrix is
     401    /// remapped in memory if necessary. This implies that in general
     402    /// views cannot be assigned using this operator. Views will be
     403    /// mutated into normal matrices. The only exception to this
     404    /// behaviour on views is when self-assignemnt is done, since
     405    /// self-assignment is ignored.
    406406    ///
    407407    /// @return A const reference to the resulting matrix.
     
    412412
    413413    ///
    414     /// Add and assign operator.
    415     ///
    416     inline const matrix& operator+=(const matrix& m) { add(m); return *this; }
    417 
    418     ///
    419     /// Add and assign operator.
    420     ///
    421     inline const matrix&
    422     operator+=(const double d) { add_constant(d); return *this; }
    423 
    424     ///
    425     /// Subtract and assign operator.
    426     ///
    427     inline const matrix& operator-=(const matrix& m) { sub(m); return *this; }
    428 
    429     ///
    430     /// Multiply and assigment operator.
     414    /// @brief Add and assign operator.
     415    ///
     416    const matrix& operator+=(const matrix&);
     417
     418    ///
     419    /// @brief Add and assign operator.
     420    ///
     421    const matrix& operator+=(const double);
     422
     423    ///
     424    /// @brief Subtract and assign operator.
     425    ///
     426    const matrix& operator-=(const matrix&);
     427
     428    ///
     429    /// @brief Multiply and assigment operator.
    431430    ///
    432431    /// @return Const reference to the resulting matrix.
     
    435434
    436435    ///
    437     /// Multiply and assign operator.
    438     ///
    439     inline const matrix& operator*=(const double d) { scale(d); return *this; }
    440 
     436    /// @brief Multiply and assignment operator
     437    ///
     438    const matrix& operator*=(const double);
    441439
    442440  private:
  • trunk/yat/utility/stl_utility.h

    r687 r703  
    120120
    121121  ///
    122   /// Function converting a string to lower case
     122  /// @brief Function converting a string to lower case
    123123  ///
    124124  inline void to_lower(std::string& s) {
     
    127127
    128128  ///
    129   /// Function converting a string to upper case
     129  /// @brief Function converting a string to upper case
    130130  ///
    131131  inline void to_upper(std::string& s) {
  • trunk/yat/utility/vector.cc

    r686 r703  
    258258
    259259
     260  const vector& vector::operator+=(const vector& other)
     261  {
     262    gsl_vector_add(v_,other.v_);
     263    return *this;
     264  }
     265
     266
     267  const vector& vector::operator-=(const vector& other)
     268  {
     269    gsl_vector_sub(v_,other.v_);
     270    return *this;
     271  }
     272
     273
     274  const vector& vector::operator*=(const double d)
     275  {
     276    gsl_vector_scale(v_,d);
     277    return *this;
     278  }
     279
     280
    260281  std::ostream& operator<<(std::ostream& s, const vector& a)
    261282  {
  • trunk/yat/utility/vector.h

    r693 r703  
    434434
    435435    ///
     436    /// @return The dot product.
     437    ///
     438    double operator*(const vector&) const;
     439
     440    ///
    436441    /// Comparison operator. Takes linear time.
    437442    ///
     
    457462
    458463    ///
    459     /// @return The dot product.
    460     ///
    461     double operator*( const vector &other ) const;
    462 
    463     ///
    464464    /// Addition and assign operator.
    465465    ///
    466466    /// @return A const reference to the resulting vector.
    467467    ///
    468     inline const vector&
    469     operator+=(const vector& other) { gsl_vector_add(v_,other.v_); return *this;}
     468    const vector& operator+=(const vector&);
    470469
    471470    ///
     
    474473    /// @return A const reference to the resulting vector.
    475474    ///
    476     inline const vector&
    477     operator-=(const vector& other) { gsl_vector_sub(v_,other.v_); return *this;}
     475    const vector& operator-=(const vector&);
    478476
    479477    ///
     
    482480    /// @return A const reference to the resulting vector.
    483481    ///
    484     inline const vector&
    485     operator*=(const double d) { gsl_vector_scale(v_,d); return *this; }
     482    const vector& operator*=(const double);
    486483
    487484
Note: See TracChangeset for help on using the changeset viewer.