Changeset 1384 for trunk


Ignore:
Timestamp:
Jul 17, 2008, 11:26:58 PM (13 years ago)
Author:
Peter
Message:

refs #396

Location:
trunk/yat/utility
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/utility/MatrixWeighted.cc

    r1382 r1384  
    5555
    5656
     57  MatrixWeighted::MatrixWeighted(const Matrix& data)
     58  {
     59    copy(data);
     60  }
     61
     62 
    5763  MatrixWeighted::MatrixWeighted(std::istream& is, char sep)
    5864  {
    5965    Matrix data(is, sep);
    60     Matrix weight;
    61     nan(data, weight);
    62     columns_ = data.columns();
    63     resize(data.columns(), data.rows());
    64     std::copy(data.begin(), data.end(), make_data_iterator(vec_.begin()));
    65     std::copy(weight.begin(), weight.end(), make_weight_iterator(vec_.begin()));
     66    copy(data);
    6667  }
    6768
     
    106107  {
    107108    return columns_;
     109  }
     110
     111
     112  void MatrixWeighted::copy(const Matrix& data)
     113  {
     114    Matrix weight;
     115    nan(data, weight);
     116    copy(data, weight);
     117  }
     118
     119
     120  void MatrixWeighted::copy(const Matrix& data, const Matrix& weight)
     121  {
     122    assert(data.rows()==weight.rows());
     123    assert(data.columns()==weight.columns());
     124    columns_ = data.columns();
     125    resize(data.columns(), data.rows());
     126    std::copy(data.begin(), data.end(), make_data_iterator(vec_.begin()));
     127    std::copy(weight.begin(), weight.end(), make_weight_iterator(vec_.begin()));
    108128  }
    109129
  • trunk/yat/utility/MatrixWeighted.h

    r1381 r1384  
    3636namespace yat {
    3737namespace utility {
     38
     39  class Matrix;
    3840
    3941  ///
     
    9799    MatrixWeighted(const MatrixWeighted&);
    98100
     101   
    99102    /**
    100103       \brief The istream constructor.
    101104
    102        Constructor is reading data values using corresponding
    103        constructor in Matrix class. The weights are calculate dusing
     105       Data is copied from \a other and weights are calculated using
    104106       the nan function.
     107    */
     108    explicit MatrixWeighted(const Matrix& other);
     109
     110    /**
     111       \brief The istream constructor.
     112
     113       This constructor first creates a Matrix using the istream
     114       constructor, and then constructs MatrixWeighted using
     115       MatrixWeighted(const Matrix&).
    105116    */
    106117    explicit MatrixWeighted(std::istream &, char sep='\0');
     
    221232
    222233  private:
     234    void copy(const Matrix&);
     235    void copy(const Matrix& data, const Matrix& weight);
     236
    223237    std::vector<DataWeight> vec_;
    224238    size_t columns_;
Note: See TracChangeset for help on using the changeset viewer.