Ignore:
Timestamp:
Mar 5, 2007, 10:17:31 PM (15 years ago)
Author:
Jari Häkkinen
Message:

Fixes #195.

File:
1 edited

Legend:

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

    r775 r782  
    6262
    6363     \par
    64      Currently there is no restriction on how a vector is used in
    65      cases when the vector is a const view into another vector or
     64     Currently there is no restriction on how a vector is used when
     65     the vector is a const view into another vector or
    6666     matrix. To avoid unexpected runtime errors, the programmer must
    6767     declare const view vectors as const in order to get compile time
     
    234234
    235235    ///
    236     /// @return True if all elements in the vector is zero, false
    237     /// othwerwise;
    238     ///
    239     bool isnull(void) const;
    240 
    241     ///
    242236    /// Check if the vector object is a view (sub-vector) to another
    243237    /// vector.
     
    247241    bool isview(void) const;
    248242
    249     ///
    250     /// @return The maximum value of the vector.
    251     ///
    252     double max(void) const;
    253 
    254     ///
    255     /// @return The element index to the maximum value of the
    256     /// vector. The lowest index has precedence.
    257     ///
    258     size_t max_index(void) const;
    259 
    260     ///
    261     /// @return The minimum value of the vector.
    262     ///
    263     double min(void) const;
    264 
    265     ///
    266     /// @return The element index to the minimum value of the
    267     /// vector. The lowest index has precedence.
    268     ///
    269     size_t min_index(void) const;
    270 
    271     ///
    272     /// @return The minimum and maximum values of the vector, as the
    273     /// \a first and \a second member of the returned \a pair,
    274     /// respectively.
    275     ///
    276     std::pair<double,double> minmax(void) const;
    277 
    278     ///
    279     /// @return The indecies to the minimum and maximum values of the
    280     /// vector, as the \a first and \a second member of the returned
    281     /// \a pair, respectively. The lowest index has precedence.
    282     ///
    283     std::pair<size_t,size_t> minmax_index(void) const;
    284 
    285243    /**
    286244       \brief This function performs element-wise multiplication, \f$
     
    313271
    314272    ///
    315     /// Makes a basis vector by setting all elements to
    316     /// zero except the \a i-th element which is set to
    317     /// one.
    318     ///
    319     void set_basis(const size_t i);
    320    
    321     ///
    322     /// Set all elements to zero.
    323     ///
    324     void set_zero(void);
    325 
    326     ///
    327273    /// @return the number of elements in the vector.
    328274    ///
    329275    size_t size(void) const;
    330276
    331     ///
    332     /// Sort the elements in the vector.
    333     ///
    334     /// Bug in gsl: if vector contains NaN an infinite loop is entered.
    335     ///
    336     void sort(void);
    337 
    338     ///
    339     /// Calculate the sum of all vector elements.
    340     ///
    341     /// @return The sum.
    342     ///
    343     double sum(void) const;
    344 
    345     /**
    346        \brief Swap vector elements by copying.
    347 
    348        The two vectors must have the same length.
     277    /**
     278       \brief Exchange elements \a i and \a j.
    349279
    350280       \throw GSL_error if vector lengths differs.
    351281    */
    352     void swap(vector& other);
    353 
    354     /**
    355        \brief Exchange elements \a i and \a j.
    356 
    357        \throw GSL_error if vector lengths differs.
    358     */
    359     void swap_elements(size_t i, size_t j);
     282    void swap(size_t i, size_t j);
    360283
    361284    /**
     
    496419  };
    497420
    498   ///
    499   /// The output operator for the vector class.
    500   ///
    501   std::ostream& operator<<(std::ostream&, const vector& );
    502 
     421  /**
     422     \brief Check if all elements of the vector are zero.
     423
     424     \return True if all elements in the vector is zero, false
     425     othwerwise.
     426  */
     427  bool isnull(const vector&);
     428
     429  /**
     430     \brief Get the maximum value of the vector.
     431
     432     \return The maximum value of the vector.
     433  */
     434  double max(const vector&);
     435
     436  /**
     437     \brief Locate the maximum value in the vector.
     438
     439     \return The index to the maximum value of the vector.
     440
     441     \note Lower index has precedence.
     442  */
     443  size_t max_index(const vector&);
     444
     445  /**
     446     \brief Get the minimum value of the vector.
     447
     448     \return The minimum value of the vector.
     449  */
     450  double min(const vector&);
     451
     452  /**
     453     \brief Locate the minimum value in the vector.
     454
     455     \return The index to the minimum value of the vector.
     456
     457     \note Lower index has precedence.
     458  */
     459  size_t min_index(const vector&);
     460
     461  /**
     462     \brief Get the minimum and maximim values of the vector.
     463
     464     \return The minimum and maximum values of the vector,
     465     respectively.
     466  */
     467  std::pair<double,double> minmax(const vector&);
     468
     469  /**
     470     \brief Locate the maximum and minumum element in the vector.
     471
     472     \return The indecies to the element with the minimum and maximum
     473     values of the vector, respectively.
     474
     475     \note Lower index has precedence.
     476  */
     477  std::pair<size_t,size_t> minmax_index(const vector&);
     478
     479  /**
     480     \brief Transforms a vector to a basis vector.
     481
     482     All elements are set to zero except the \a i-th element which is
     483     set to one.
     484  */
     485  void set_basis(vector&, size_t i);
     486
     487  /**
     488     Sort the elements in the vector.
     489
     490     \note Bug in GSL: if the vector contains one ore more NaNs the
     491     call never returns.
     492  */
     493  void sort(vector&);
     494
     495  /**
     496     \brief Calculate the sum of all vector elements.
     497
     498     \return The sum.
     499  */
     500  double sum(const vector&);
     501
     502  /**
     503     \brief Swap vector elements by copying.
     504
     505     The two vectors must have the same length.
     506
     507     \throw GSL_error if vector lengths differs.
     508  */
     509  void swap(vector&, vector&);
     510
     511  /**
     512     \brief The output operator for the vector class.
     513  */
     514  std::ostream& operator<<(std::ostream&, const vector&);
    503515
    504516}}} // of namespace utility, yat, and theplu
Note: See TracChangeset for help on using the changeset viewer.