Changeset 1121 for trunk/yat/utility


Ignore:
Timestamp:
Feb 22, 2008, 4:29:56 PM (14 years ago)
Author:
Peter
Message:

fixes #308

Location:
trunk/yat/utility
Files:
20 edited
2 moved

Legend:

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

    r1120 r1121  
    2525
    2626#include "Alignment.h"
    27 #include "matrix.h"
     27#include "Matrix.h"
    2828#include "stl_utility.h"
    2929
     
    3636namespace utility {
    3737
    38   double NeedlemanWunsch(const utility::matrix& s,
     38  double NeedlemanWunsch(const utility::Matrix& s,
    3939                         std::vector<std::pair<size_t, size_t> >& path,
    4040                         const double gap)
    4141  {
    42     utility::matrix m(s.rows()+1,s.columns()+1);
     42    utility::Matrix m(s.rows()+1,s.columns()+1);
    4343    // Init upper and left border of matrix
    4444    for (size_t i=1; i<m.rows(); i++)
     
    4848    // choice(i,j) tells us how we came to s(i,j). 1 is diagonal, 2
    4949    // vertical, and 3 horizontal,
    50     utility::matrix choice(m.rows(),m.columns());
     50    utility::Matrix choice(m.rows(),m.columns());
    5151
    5252    // Calculating NeedlemanWunsch matrix
     
    9090                 double open_gap)
    9191  {
    92     matrix m(first.size(), second.size());
     92    Matrix m(first.size(), second.size());
    9393    for (size_t i=0; i<first.size(); ++i)
    9494      for (size_t j=0; j<second.size(); ++j)
     
    9898
    9999
    100   double SmithWaterman(const utility::matrix& s,
     100  double SmithWaterman(const utility::Matrix& s,
    101101                       double gap, double open_gap)
    102102  {
     
    104104
    105105    // Calculating S-W matrix
    106     matrix m(s.rows()+1,s.columns()+1);
    107     matrix array(m);
     106    Matrix m(s.rows()+1,s.columns()+1);
     107    Matrix array(m);
    108108    for (size_t i=1; i<m.rows(); ++i)
    109109      for (size_t j=1; j<m.columns(); ++j){
  • trunk/yat/utility/Alignment.h

    r1000 r1121  
    3535namespace utility {
    3636
    37   class matrix;
     37  class Matrix;
    3838
    3939  ///
     
    5757  /// @return the global maximum alignment score.
    5858  ///
    59   double NeedlemanWunsch(const utility::matrix& s,
     59  double NeedlemanWunsch(const utility::Matrix& s,
    6060                         std::vector<std::pair<size_t, size_t> >& path,
    6161                         const double gap);
     
    7878     gap of length \f$l\f$ the total cost is \f$open_gap + l*gap\f$.
    7979   */
    80   double SmithWaterman(const utility::matrix& s,
     80  double SmithWaterman(const utility::Matrix& s,
    8181                       double gap, double open_gap);
    8282
  • trunk/yat/utility/Makefile.am

    r1120 r1121  
    2727libutility_la_SOURCES = \
    2828  Alignment.cc ColumnStream.cc CommandLine.cc FileUtil.cc Index.cc kNNI.cc \
    29   matrix.cc NNI.cc Option.cc OptionFile.cc OptionInFile.cc OptionOutFile.cc \
     29  Matrix.cc NNI.cc Option.cc OptionFile.cc OptionInFile.cc OptionOutFile.cc \
    3030  OptionHelp.cc OptionSwitch.cc \
    3131  PCA.cc stl_utility.cc SVD.cc TypeInfo.cc utility.cc Vector.cc \
     
    3838  Container2DIterator.h \
    3939  Exception.h FileUtil.h Index.h IteratorPolicy.h iterator_traits.h \
    40   kNNI.h matrix.h NNI.h \
     40  kNNI.h Matrix.h NNI.h \
    4141  Option.h OptionArg.h OptionFile.h OptionInFile.h OptionOutFile.h \
    4242  OptionHelp.h OptionSwitch.h \
  • trunk/yat/utility/Matrix.cc

    r1120 r1121  
    2525*/
    2626
    27 #include "yat/utility/matrix.h"
    28 #include "yat/utility/Vector.h"
     27#include "Matrix.h"
     28#include "Vector.h"
    2929#include "VectorBase.h"
    3030#include "VectorConstView.h"
     
    4444
    4545
    46   matrix::matrix(void)
     46  Matrix::Matrix(void)
    4747    : blas_result_(NULL), m_(NULL)
    4848  {
     
    5050
    5151
    52   matrix::matrix(const size_t& r, const size_t& c, double init_value)
     52  Matrix::Matrix(const size_t& r, const size_t& c, double init_value)
    5353    : blas_result_(NULL), m_(gsl_matrix_alloc(r,c))
    5454  {
    5555    if (!m_)
    56       throw utility::GSL_error("matrix::matrix failed to allocate memory");
     56      throw utility::GSL_error("Matrix::Matrix failed to allocate memory");
    5757    all(init_value);
    5858  }
    5959
    6060
    61   matrix::matrix(const matrix& o)
     61  Matrix::Matrix(const Matrix& o)
    6262    : blas_result_(NULL), m_(o.create_gsl_matrix_copy())
    6363  {
     
    6666
    6767  // Constructor that gets data from istream
    68   matrix::matrix(std::istream& is, char sep)
     68  Matrix::Matrix(std::istream& is, char sep)
    6969    throw (utility::IO_error,std::exception)
    7070    : blas_result_(NULL)
     
    113113      else if (v.size()!=nof_columns) {
    114114        std::ostringstream s;
    115         s << "matrix::matrix(std::istream&, char) data file error: "
     115        s << "Matrix::Matrix(std::istream&, char) data file error: "
    116116          << "line " << nof_rows << " has " << v.size()
    117117          << " columns; expected " << nof_columns << " columns.";
     
    126126    m_ = gsl_matrix_alloc ( nof_rows, nof_columns );
    127127    if (!m_)
    128       throw utility::GSL_error("matrix::matrix failed to allocate memory");
     128      throw utility::GSL_error("Matrix::Matrix failed to allocate memory");
    129129
    130130    // if gsl error handler disabled, out of bounds index will not
     
    136136
    137137
    138   matrix::~matrix(void)
     138  Matrix::~Matrix(void)
    139139  {
    140140    delete_allocated_memory();
     
    145145
    146146
    147   void matrix::all(const double value)
     147  void Matrix::all(const double value)
    148148  {
    149149    assert(m_);
     
    152152
    153153
    154   matrix::iterator matrix::begin(void)
     154  Matrix::iterator Matrix::begin(void)
    155155  {
    156156    return iterator(&(*this)(0,0), 1);
     
    158158
    159159
    160   matrix::const_iterator matrix::begin(void) const
     160  Matrix::const_iterator Matrix::begin(void) const
    161161  {
    162162    return const_iterator(&(*this)(0,0), 1);
     
    164164
    165165
    166   matrix::column_iterator matrix::begin_column(size_t i)
     166  Matrix::column_iterator Matrix::begin_column(size_t i)
    167167  {
    168168    return iterator(&(*this)(0,i), this->columns());
     
    170170
    171171
    172   matrix::const_column_iterator matrix::begin_column(size_t i) const
     172  Matrix::const_column_iterator Matrix::begin_column(size_t i) const
    173173  {
    174174    return const_iterator(&(*this)(0,i), this->columns());
     
    176176
    177177
    178   matrix::row_iterator matrix::begin_row(size_t i)
     178  Matrix::row_iterator Matrix::begin_row(size_t i)
    179179  {
    180180    return iterator(&(*this)(i,0), 1);
     
    182182
    183183
    184   matrix::const_row_iterator matrix::begin_row(size_t i) const
     184  Matrix::const_row_iterator Matrix::begin_row(size_t i) const
    185185  {
    186186    return const_iterator(&(*this)(i,0), 1);
     
    188188
    189189
    190   VectorView matrix::column_view(size_t col)
     190  VectorView Matrix::column_view(size_t col)
    191191  {
    192192    VectorView res(*this, col, false);
     
    195195
    196196
    197   const VectorConstView matrix::column_const_view(size_t col) const
     197  const VectorConstView Matrix::column_const_view(size_t col) const
    198198  {
    199199    return VectorConstView(*this, col, false);
     
    201201
    202202
    203   size_t matrix::columns(void) const
     203  size_t Matrix::columns(void) const
    204204  {
    205205    return (m_ ? m_->size2 : 0);
     
    207207
    208208
    209   gsl_matrix* matrix::create_gsl_matrix_copy(void) const
     209  gsl_matrix* Matrix::create_gsl_matrix_copy(void) const
    210210  {
    211211    gsl_matrix* m = gsl_matrix_alloc(rows(),columns());
    212212    if (!m)
    213       throw utility::GSL_error("matrix::create_gsl_matrix_copy failed to allocate memory");
     213      throw utility::GSL_error("Matrix::create_gsl_matrix_copy failed to allocate memory");
    214214    if (gsl_matrix_memcpy(m,m_))
    215       throw utility::GSL_error("matrix::create_gsl_matrix_copy dimension mis-match");
     215      throw utility::GSL_error("Matrix::create_gsl_matrix_copy dimension mis-match");
    216216    return m;
    217217  }
    218218
    219219
    220   void matrix::delete_allocated_memory(void)
     220  void Matrix::delete_allocated_memory(void)
    221221  {
    222222    if (m_)
     
    226226
    227227
    228   void matrix::div(const matrix& other)
     228  void Matrix::div(const Matrix& other)
    229229  {
    230230    assert(m_);
     
    235235
    236236
    237   matrix::iterator matrix::end(void)
     237  Matrix::iterator Matrix::end(void)
    238238  {
    239239    return iterator(&(*this)(0,0)+rows()*columns(), 1);
     
    241241
    242242
    243   matrix::const_iterator matrix::end(void) const
     243  Matrix::const_iterator Matrix::end(void) const
    244244  {
    245245    return const_iterator(&(*this)(0,0)+rows()*columns(), 1);
     
    247247
    248248
    249   matrix::column_iterator matrix::end_column(size_t i)
     249  Matrix::column_iterator Matrix::end_column(size_t i)
    250250  {
    251251    return column_iterator(&(*this)(0,i)+rows()*columns(), this->columns());
     
    253253
    254254
    255   matrix::const_column_iterator matrix::end_column(size_t i) const
     255  Matrix::const_column_iterator Matrix::end_column(size_t i) const
    256256  {
    257257    return const_column_iterator(&(*this)(0,i)+rows()*columns(),this->columns());
     
    259259
    260260
    261   matrix::row_iterator matrix::end_row(size_t i)
     261  Matrix::row_iterator Matrix::end_row(size_t i)
    262262  {
    263263    return row_iterator(&(*this)(i,0)+columns(), 1);
     
    265265
    266266
    267   matrix::const_row_iterator matrix::end_row(size_t i) const
     267  Matrix::const_row_iterator Matrix::end_row(size_t i) const
    268268  {
    269269    return const_row_iterator(&(*this)(i,0)+columns(), 1);
     
    271271
    272272
    273   bool matrix::equal(const matrix& other, const double d) const
     273  bool Matrix::equal(const Matrix& other, const double d) const
    274274  {
    275275    if (this==&other)
     
    287287
    288288
    289   const gsl_matrix* matrix::gsl_matrix_p(void) const
     289  const gsl_matrix* Matrix::gsl_matrix_p(void) const
    290290  {
    291291    return m_;
     
    293293
    294294
    295   gsl_matrix* matrix::gsl_matrix_p(void)
     295  gsl_matrix* Matrix::gsl_matrix_p(void)
    296296  {
    297297    return m_;
     
    299299
    300300
    301   void matrix::mul(const matrix& other)
     301  void Matrix::mul(const Matrix& other)
    302302  {
    303303    assert(m_);
    304304    int status=gsl_matrix_mul_elements(m_, other.gsl_matrix_p());
    305305    if (status)
    306       throw utility::GSL_error(std::string("matrix::mul_elements",status));
    307   }
    308 
    309 
    310   void matrix::resize(size_t r, size_t c, double init_value)
     306      throw utility::GSL_error(std::string("Matrix::mul_elements",status));
     307  }
     308
     309
     310  void Matrix::resize(size_t r, size_t c, double init_value)
    311311  {
    312312    delete_allocated_memory();
     
    314314    m_ = gsl_matrix_alloc(r,c);
    315315    if (!m_)
    316       throw utility::GSL_error("matrix::matrix failed to allocate memory");
     316      throw utility::GSL_error("Matrix::Matrix failed to allocate memory");
    317317    all(init_value);
    318318
     
    326326
    327327
    328   size_t matrix::rows(void) const
     328  size_t Matrix::rows(void) const
    329329  {
    330330    return (m_ ? m_->size1 : 0);
     
    332332
    333333
    334   const VectorConstView matrix::row_const_view(size_t col) const
     334  const VectorConstView Matrix::row_const_view(size_t col) const
    335335  {
    336336    return VectorConstView(*this, col, true);
     
    338338
    339339
    340   VectorView matrix::row_view(size_t row)
     340  VectorView Matrix::row_view(size_t row)
    341341  {
    342342    VectorView res(*this, row, true);
     
    345345
    346346
    347   void matrix::swap_columns(const size_t i, const size_t j)
     347  void Matrix::swap_columns(const size_t i, const size_t j)
    348348  {
    349349    assert(m_);
    350350    int status=gsl_matrix_swap_columns(m_, i, j);
    351351    if (status)
    352       throw utility::GSL_error(std::string("matrix::swap_columns",status));
    353   }
    354 
    355 
    356   void matrix::swap_rowcol(const size_t i, const size_t j)
     352      throw utility::GSL_error(std::string("Matrix::swap_columns",status));
     353  }
     354
     355
     356  void Matrix::swap_rowcol(const size_t i, const size_t j)
    357357  {
    358358    assert(m_);
    359359    int status=gsl_matrix_swap_rowcol(m_, i, j);
    360360    if (status)
    361       throw utility::GSL_error(std::string("matrix::swap_rowcol",status));
    362   }
    363 
    364 
    365   void matrix::swap_rows(const size_t i, const size_t j)
     361      throw utility::GSL_error(std::string("Matrix::swap_rowcol",status));
     362  }
     363
     364
     365  void Matrix::swap_rows(const size_t i, const size_t j)
    366366  {
    367367    assert(m_);
    368368    int status=gsl_matrix_swap_rows(m_, i, j);
    369369    if (status)
    370       throw utility::GSL_error(std::string("matrix::swap_rows",status));
    371   }
    372 
    373 
    374   void matrix::transpose(void)
     370      throw utility::GSL_error(std::string("Matrix::swap_rows",status));
     371  }
     372
     373
     374  void Matrix::transpose(void)
    375375  {
    376376    assert(m_);
     
    380380      gsl_matrix* transposed = gsl_matrix_alloc(columns(),rows());
    381381      if (!transposed)
    382         throw utility::GSL_error("matrix::transpose failed to allocate memory");
     382        throw utility::GSL_error("Matrix::transpose failed to allocate memory");
    383383      // next line never fails if allocation above succeeded.
    384384      gsl_matrix_transpose_memcpy(transposed,m_);
     
    393393
    394394
    395   double& matrix::operator()(size_t row, size_t column)
     395  double& Matrix::operator()(size_t row, size_t column)
    396396  {
    397397    assert(m_);
     
    400400    double* d=gsl_matrix_ptr(m_, row, column);
    401401    if (!d)
    402       throw utility::GSL_error("matrix::operator()",GSL_EINVAL);
     402      throw utility::GSL_error("Matrix::operator()",GSL_EINVAL);
    403403    return *d;
    404404  }
    405405
    406406
    407   const double& matrix::operator()(size_t row, size_t column) const
     407  const double& Matrix::operator()(size_t row, size_t column) const
    408408  {
    409409    assert(row<rows());
     
    411411    const double* d=gsl_matrix_const_ptr(m_, row, column);
    412412    if (!d)
    413       throw utility::GSL_error("matrix::operator()",GSL_EINVAL);
     413      throw utility::GSL_error("Matrix::operator()",GSL_EINVAL);
    414414    return *d;
    415415  }
    416416
    417417
    418   bool matrix::operator==(const matrix& other) const
     418  bool Matrix::operator==(const Matrix& other) const
    419419  {
    420420    return equal(other);
     
    422422
    423423
    424   bool matrix::operator!=(const matrix& other) const
     424  bool Matrix::operator!=(const Matrix& other) const
    425425  {
    426426    return !equal(other);
     
    428428
    429429
    430   const matrix& matrix::operator=( const matrix& other )
     430  const Matrix& Matrix::operator=( const Matrix& other )
    431431  {
    432432    assert(other.m_);
     
    435435        resize(other.m_->size1,other.m_->size2);
    436436      if (gsl_matrix_memcpy(m_, other.gsl_matrix_p()))
    437         throw utility::GSL_error("matrix::create_gsl_matrix_copy dimension mis-match");
     437        throw utility::GSL_error("Matrix::create_gsl_matrix_copy dimension mis-match");
    438438    }
    439439    return *this;
     
    441441
    442442
    443   const matrix& matrix::operator+=(const matrix& other)
     443  const Matrix& Matrix::operator+=(const Matrix& other)
    444444  {
    445445    assert(m_);
    446446    int status=gsl_matrix_add(m_, other.m_);
    447447    if (status)
    448       throw utility::GSL_error(std::string("matrix::operator+=", status));
    449     return *this;
    450   }
    451 
    452 
    453   const matrix& matrix::operator+=(const double d)
     448      throw utility::GSL_error(std::string("Matrix::operator+=", status));
     449    return *this;
     450  }
     451
     452
     453  const Matrix& Matrix::operator+=(const double d)
    454454  {
    455455    assert(m_);
     
    459459
    460460
    461   const matrix& matrix::operator-=(const matrix& other)
     461  const Matrix& Matrix::operator-=(const Matrix& other)
    462462  {
    463463    assert(m_);
    464464    int status=gsl_matrix_sub(m_, other.m_);
    465465    if (status)
    466       throw utility::GSL_error(std::string("matrix::operator-=", status));
    467     return *this;
    468   }
    469 
    470 
    471   const matrix& matrix::operator-=(const double d)
     466      throw utility::GSL_error(std::string("Matrix::operator-=", status));
     467    return *this;
     468  }
     469
     470
     471  const Matrix& Matrix::operator-=(const double d)
    472472  {
    473473    assert(m_);
     
    477477
    478478
    479   const matrix& matrix::operator*=(const matrix& other)
     479  const Matrix& Matrix::operator*=(const Matrix& other)
    480480  {
    481481    assert(m_);
     
    488488      blas_result_ = gsl_matrix_alloc(rows(),other.columns());
    489489      if (!blas_result_)
    490         throw utility::GSL_error("matrix::operator*= failed to allocate memory");
     490        throw utility::GSL_error("Matrix::operator*= failed to allocate memory");
    491491    }
    492492    gsl_blas_dgemm(CblasNoTrans, CblasNoTrans, 1.0, m_, other.m_, 0.0, blas_result_);
     
    498498
    499499
    500   const matrix& matrix::operator*=(const double d)
     500  const Matrix& Matrix::operator*=(const double d)
    501501  {
    502502    assert(m_);
     
    506506
    507507
    508   bool isnull(const matrix& other)
     508  bool isnull(const Matrix& other)
    509509  {
    510510    return gsl_matrix_isnull(other.gsl_matrix_p());
     
    512512
    513513
    514   double max(const matrix& other)
     514  double max(const Matrix& other)
    515515  {
    516516    return gsl_matrix_max(other.gsl_matrix_p());
     
    518518
    519519
    520   double min(const matrix& other)
     520  double min(const Matrix& other)
    521521  {
    522522    return gsl_matrix_min(other.gsl_matrix_p());
     
    524524
    525525
    526   void minmax_index(const matrix& other,
     526  void minmax_index(const Matrix& other,
    527527                    std::pair<size_t,size_t>& min, std::pair<size_t,size_t>& max)
    528528  {
     
    532532
    533533
    534   bool nan(const matrix& templat, matrix& flag)
     534  bool nan(const Matrix& templat, Matrix& flag)
    535535  {
    536536    size_t rows=templat.rows();
     
    551551
    552552
    553   void swap(matrix& a, matrix& b)
     553  void swap(Matrix& a, Matrix& b)
    554554  {
    555555    assert(a.gsl_matrix_p()); assert(b.gsl_matrix_p());
    556556    int status=gsl_matrix_swap(a.gsl_matrix_p(), b.gsl_matrix_p());
    557557    if (status)
    558       throw utility::GSL_error(std::string("swap(matrix&,matrix&)",status));
    559   }
    560 
    561 
    562   std::ostream& operator<<(std::ostream& s, const matrix& m)
     558      throw utility::GSL_error(std::string("swap(Matrix&,Matrix&)",status));
     559  }
     560
     561
     562  std::ostream& operator<<(std::ostream& s, const Matrix& m)
    563563  {
    564564    s.setf(std::ios::dec);
     
    576576
    577577
    578   Vector operator*(const matrix& m, const VectorBase& v)
     578  Vector operator*(const Matrix& m, const VectorBase& v)
    579579  {
    580580    utility::Vector res(m.rows());
     
    585585
    586586
    587   Vector operator*(const VectorBase& v, const matrix& m)
     587  Vector operator*(const VectorBase& v, const Matrix& m)
    588588  {
    589589    utility::Vector res(m.columns());
  • trunk/yat/utility/Matrix.h

    r1120 r1121  
    6262  /// superdiagonals.
    6363  ///
    64   class matrix
     64  class Matrix
    6565  {
    6666  public:
     
    9595       structures.
    9696    */
    97     matrix(void);
     97    Matrix(void);
    9898
    9999    /**
     
    103103       \throw GSL_error if memory allocation fails.
    104104    */
    105     matrix(const size_t& r, const size_t& c, double init_value=0);
     105    Matrix(const size_t& r, const size_t& c, double init_value=0);
    106106
    107107    /**
     
    111111       fails.
    112112    */
    113     matrix(const matrix&);
     113    Matrix(const Matrix&);
    114114
    115115    /**
     
    127127       unexpected input is found in the input stream.
    128128    */
    129     explicit matrix(std::istream &, char sep='\0')
     129    explicit Matrix(std::istream &, char sep='\0')
    130130      throw(utility::IO_error, std::exception);
    131131
     
    133133       \brief The destructor.
    134134    */
    135     ~matrix(void);
     135    ~Matrix(void);
    136136
    137137    ///
     
    206206       \throw GSL_error if dimensions mis-match.
    207207    */
    208     void div(const matrix& b);
     208    void div(const Matrix& b);
    209209
    210210    /**
     
    247247       \see operator== and operator!=
    248248    */
    249     bool equal(const matrix&, const double precision=0) const;
     249    bool equal(const Matrix&, const double precision=0) const;
    250250
    251251    ///
     
    260260
    261261    /**
    262        Multiply the elements of matrix \a b with the elements of the
    263        calling matrix ,\f$ a_{ij} = a_{ij} * b_{ij} \; \forall i,j
    264        \f$. The result is stored into the calling matrix.
     262       Multiply the elements of Matrix \a b with the elements of the
     263       calling Matrix ,\f$ a_{ij} = a_{ij} * b_{ij} \; \forall i,j
     264       \f$. The result is stored into the calling Matrix.
    265265
    266266       \throw GSL_error if dimensions mis-match.
    267267    */
    268     void mul(const matrix& b);
    269 
    270     /**
    271        \brief Resize matrix
     268    void mul(const Matrix& b);
     269
     270    /**
     271       \brief Resize Matrix
    272272       
    273273       All elements are set to @a init_value.
    274274
    275275       \note underlying GSL matrix is destroyed and views into this
    276        matrix becomes invalid.
     276       Matrix becomes invalid.
    277277    */
    278278    void resize(size_t, size_t, double init_value=0);
     
    303303       \brief Swap row \a i and column \a j.
    304304
    305        The matrix must be square.
     305       The Matrix must be square.
    306306
    307307       \throw GSL_error if either index is out of bounds, or if matrix
     
    359359       \see equal
    360360    */
    361     bool operator==(const matrix& other) const;
     361    bool operator==(const Matrix& other) const;
    362362
    363363    /**
     
    372372       \see equal
    373373    */
    374     bool operator!=(const matrix& other) const;
     374    bool operator!=(const Matrix& other) const;
    375375
    376376    /**
    377377       \brief The assignment operator.
    378378
    379        \return A const reference to the resulting matrix.
    380     */
    381     const matrix& operator=(const matrix& other);
     379       \return A const reference to the resulting Matrix.
     380    */
     381    const Matrix& operator=(const Matrix& other);
    382382
    383383    /**
    384384       \brief Add and assign operator.
    385385
    386        Elementwise addition of the elements of matrix \a b to the left
    387        hand side matrix ,\f$ a_{ij} = a_{ij} + b_{ij} \; \forall i,j
     386       Elementwise addition of the elements of Matrix \a b to the left
     387       hand side Matrix ,\f$ a_{ij} = a_{ij} + b_{ij} \; \forall i,j
    388388       \f$.
    389389
    390        \return A const reference to the resulting matrix.
     390       \return A const reference to the resulting Matrix.
    391391
    392392       \throw GSL_error if dimensions mis-match.
    393393    */
    394     const matrix& operator+=(const matrix& b);
     394    const Matrix& operator+=(const Matrix& b);
    395395
    396396    /**
    397397       \brief Add and assign operator
    398398
    399        Add the scalar value \a d to the left hand side matrix, \f$
     399       Add the scalar value \a d to the left hand side Matrix, \f$
    400400       a_{ij} = a_{ij} + d \; \forall i,j \f$.
    401401    */
    402     const matrix& operator+=(const double d);
     402    const Matrix& operator+=(const double d);
    403403
    404404    /**
    405405       \brief Subtract and assign operator.
    406406
    407        Elementwise subtraction of the elements of matrix \a b to the
    408        left hand side matrix ,\f$ a_{ij} = a_{ij} + b_{ij} \; \forall
     407       Elementwise subtraction of the elements of Matrix \a b to the
     408       left hand side Matrix ,\f$ a_{ij} = a_{ij} + b_{ij} \; \forall
    409409       i,j \f$.
    410410
    411        \return A const reference to the resulting matrix.
     411       \return A const reference to the resulting Matrix.
    412412
    413413       \throw GSL_error if dimensions mis-match.
    414414    */
    415     const matrix& operator-=(const matrix&);
     415    const Matrix& operator-=(const Matrix&);
    416416
    417417    /**
    418418       \brief Subtract and assign operator
    419419
    420        Subtract the scalar value \a d to the left hand side matrix,
     420       Subtract the scalar value \a d to the left hand side Matrix,
    421421       \f$ a_{ij} = a_{ij} + d \; \forall i,j \f$.
    422422    */
    423     const matrix& operator-=(const double d);
     423    const Matrix& operator-=(const double d);
    424424
    425425    /**
    426426       \brief Multiply and assigment operator.
    427427
    428        \return Const reference to the resulting matrix.
     428       \return Const reference to the resulting Matrix.
    429429
    430430       \throw GSL_error if memory allocation fails.
    431431    */
    432     const matrix& operator*=(const matrix&);
     432    const Matrix& operator*=(const Matrix&);
    433433
    434434    /**
    435435       \brief Multiply and assignment operator
    436436
    437        Multiply the elements of the left hand side matrix with a
     437       Multiply the elements of the left hand side Matrix with a
    438438       scalar \a d, \f$ a_{ij} = d * a_{ij} \; \forall i,j \f$.
    439439
    440440       \throw GSL_error if memory allocation fails.
    441441    */
    442     const matrix& operator*=(double d);
     442    const Matrix& operator*=(double d);
    443443
    444444  private:
     
    473473
    474474  /**
    475      \brief Check if all elements of the matrix are zero.
    476 
    477      \return True if all elements in the matrix is zero, false
     475     \brief Check if all elements of the Matrix are zero.
     476
     477     \return True if all elements in the Matrix is zero, false
    478478     othwerwise.
    479479  */
    480   bool isnull(const matrix&);
    481 
    482   /**
    483      \brief Get the maximum value of the matrix.
    484 
    485      \return The maximum value of the matrix.
    486   */
    487   double max(const matrix&);
    488 
    489   /**
    490      \brief Get the minimum value of the matrix.
    491 
    492      \return The minimum value of the matrix.
    493   */
    494   double min(const matrix&);
    495 
    496   /**
    497      \brief Locate the maximum and minumum element in the matrix.
     480  bool isnull(const Matrix&);
     481
     482  /**
     483     \brief Get the maximum value of the Matrix.
     484
     485     \return The maximum value of the Matrix.
     486  */
     487  double max(const Matrix&);
     488
     489  /**
     490     \brief Get the minimum value of the Matrix.
     491
     492     \return The minimum value of the Matrix.
     493  */
     494  double min(const Matrix&);
     495
     496  /**
     497     \brief Locate the maximum and minumum element in the Matrix.
    498498
    499499     \return The indecies to the element with the minimum and maximum
    500      values of the matrix, respectively.
     500     values of the Matrix, respectively.
    501501
    502502     \note Lower index has precedence (searching in row-major order).
    503503  */
    504   void minmax_index(const matrix&,
     504  void minmax_index(const Matrix&,
    505505                    std::pair<size_t,size_t>& min,
    506506                    std::pair<size_t,size_t>& max);
    507507
    508508  /**
    509      \brief Create a matrix \a flag indicating NaN's in another matrix
     509     \brief Create a Matrix \a flag indicating NaN's in another Matrix
    510510     \a templat.
    511511
    512      The \a flag matrix is changed to contain 1's and 0's only. A 1
    513      means that the corresponding element in the \a templat matrix is
     512     The \a flag Matrix is changed to contain 1's and 0's only. A 1
     513     means that the corresponding element in the \a templat Matrix is
    514514     valid and a zero means that the corresponding element is a NaN.
    515515
    516      \note Space for matrix \a flag is reallocated to fit the size of
    517      matrix \a templat if sizes mismatch.
    518 
    519      \return True if the \a templat matrix contains at least one NaN.
    520   */
    521   bool nan(const matrix& templat, matrix& flag);
     516     \note Space for Matrix \a flag is reallocated to fit the size of
     517     Matrix \a templat if sizes mismatch.
     518
     519     \return True if the \a templat Matrix contains at least one NaN.
     520  */
     521  bool nan(const Matrix& templat, Matrix& flag);
    522522
    523523  /**
     
    528528     \throw GSL_error if either index is out of bounds.
    529529  */
    530   void swap(matrix&, matrix&);
    531 
    532   /**
    533      \brief The output operator for the matrix class.
    534   */
    535   std::ostream& operator<< (std::ostream& s, const matrix&);
    536 
    537   /**
    538      \brief vector matrix multiplication
     530  void swap(Matrix&, Matrix&);
     531
     532  /**
     533     \brief The output operator for the Matrix class.
     534  */
     535  std::ostream& operator<< (std::ostream& s, const Matrix&);
     536
     537  /**
     538     \brief vector Matrix multiplication
    539539   */
    540   Vector operator*(const matrix&, const VectorBase&);
    541 
    542   /**
    543      \brief matrix vector multiplication
     540  Vector operator*(const Matrix&, const VectorBase&);
     541
     542  /**
     543     \brief Matrix vector multiplication
    544544   */
    545   Vector operator*(const VectorBase&, const matrix&);
     545  Vector operator*(const VectorBase&, const Matrix&);
    546546
    547547}}} // of namespace utility, yat, and theplu
  • trunk/yat/utility/NNI.cc

    r1000 r1121  
    3838  // implementations here see the paper cited in the class definition
    3939  // documentation.
    40   NNI::NNI(const utility::matrix& matrix,const utility::matrix& weight,
     40  NNI::NNI(const utility::Matrix& matrix,const utility::Matrix& weight,
    4141           const u_int neighbours)
    4242    : data_(matrix), imputed_data_(matrix), neighbours_(neighbours),
     
    7575
    7676
    77   const utility::matrix& NNI::imputed_data(void) const
     77  const utility::Matrix& NNI::imputed_data(void) const
    7878  {
    7979    return imputed_data_;
  • trunk/yat/utility/NNI.h

    r1000 r1121  
    2727*/
    2828
    29 #include "matrix.h"
     29#include "Matrix.h"
    3030
    3131#include <iostream>
     
    8888    /// algorithms.
    8989    ///
    90     NNI(const utility::matrix& matrix,const utility::matrix& weight,
     90    NNI(const utility::Matrix& matrix,const utility::Matrix& weight,
    9191        const u_int neighbours);
    9292
     
    103103    /// @return A const reference to the modified data.
    104104    ///
    105     const utility::matrix& imputed_data(void) const;
     105    const utility::Matrix& imputed_data(void) const;
    106106
    107107    ///
     
    124124    /// original data matrix
    125125    ///
    126     const utility::matrix& data_;
     126    const utility::Matrix& data_;
    127127
    128128    ///
    129129    /// data after imputation
    130130    ///
    131     utility::matrix imputed_data_;
     131    utility::Matrix imputed_data_;
    132132
    133133    ///
     
    144144    /// weight matrix
    145145    ///
    146     const utility::matrix& weight_;
     146    const utility::Matrix& weight_;
    147147  };
    148148
  • trunk/yat/utility/PCA.cc

    r1120 r1121  
    4040
    4141
    42   PCA::PCA(const utility::matrix& A)
     42  PCA::PCA(const utility::Matrix& A)
    4343    : A_(A)
    4444  {
     
    5353
    5454
    55   const utility::matrix& PCA::eigenvectors(void) const
     55  const utility::Matrix& PCA::eigenvectors(void) const
    5656  {
    5757    return eigenvectors_;
     
    6262  {
    6363    // Row-center the data matrix
    64     utility::matrix A_center( A_.rows(), A_.columns() );
     64    utility::Matrix A_center( A_.rows(), A_.columns() );
    6565    this->row_center( A_center );
    6666
     
    6868    std::auto_ptr<SVD> pSVD( new SVD( A_center ) );
    6969    pSVD->decompose();
    70     utility::matrix U(pSVD->U());
    71     utility::matrix V(pSVD->V());
     70    utility::Matrix U(pSVD->U());
     71    utility::Matrix V(pSVD->V());
    7272
    7373    // Read the eigenvectors and eigenvalues
     
    141141
    142142
    143   utility::matrix PCA::projection(const utility::matrix& samples ) const
     143  utility::Matrix PCA::projection(const utility::Matrix& samples ) const
    144144  {
    145145    const size_t Ncol = samples.columns();
    146146    const size_t Nrow = samples.rows();
    147     utility::matrix projs( Ncol, Ncol );
     147    utility::Matrix projs( Ncol, Ncol );
    148148
    149149    utility::Vector temp(samples.rows());
     
    189189  // that is, A_ = A_ - M, where M is a matrix
    190190  // with the meanvalues of each row
    191   void PCA::row_center(utility::matrix& A_center)
     191  void PCA::row_center(utility::Matrix& A_center)
    192192  {
    193193    meanvalues_ = Vector(A_.rows());
  • trunk/yat/utility/PCA.h

    r1120 r1121  
    2929*/
    3030
    31 #include "matrix.h"
     31#include "Matrix.h"
    3232#include "Vector.h"
    3333
     
    5656       should have been performed and no products.
    5757     */
    58     explicit PCA(const utility::matrix&);
     58    explicit PCA(const utility::Matrix&);
    5959 
    6060    /**
     
    8181       eigenvectors.
    8282    */
    83     const utility::matrix& eigenvectors(void) const;
     83    const utility::Matrix& eigenvectors(void) const;
    8484
    8585    /**
     
    9090       spanned by the eigenvectors.
    9191    */
    92     utility::matrix projection( const utility::matrix& ) const;
     92    utility::Matrix projection( const utility::Matrix& ) const;
    9393
    9494    /**
     
    116116       with the meanvalues of each row
    117117    */
    118     void row_center( utility::matrix& A_center );
     118    void row_center( utility::Matrix& A_center );
    119119
    120     utility::matrix A_;
     120    utility::Matrix A_;
    121121    utility::Vector eigenvalues_;
    122     utility::matrix eigenvectors_;
     122    utility::Matrix eigenvectors_;
    123123    utility::Vector meanvalues_;
    124124  };
  • trunk/yat/utility/SVD.cc

    r1120 r1121  
    3636
    3737
    38   SVD::SVD(const utility::matrix& Ain)
     38  SVD::SVD(const utility::Matrix& Ain)
    3939    : U_(Ain), V_(Ain.columns(),Ain.columns()), s_(Ain.columns())
    4040  {
     
    8888  {
    8989    utility::Vector w(U_.columns());
    90     utility::matrix X(U_.columns(),U_.columns());
     90    utility::Matrix X(U_.columns(),U_.columns());
    9191    return gsl_linalg_SV_decomp_mod(U_.gsl_matrix_p(), X.gsl_matrix_p(),
    9292                                    V_.gsl_matrix_p(), s_.gsl_vector_p(),
     
    111111
    112112
    113   const utility::matrix& SVD::U(void) const
     113  const utility::Matrix& SVD::U(void) const
    114114  {
    115115    return U_;
     
    117117
    118118
    119   const utility::matrix& SVD::V(void) const
     119  const utility::Matrix& SVD::V(void) const
    120120  {
    121121    return V_;
  • trunk/yat/utility/SVD.h

    r1120 r1121  
    2929*/
    3030
    31 #include "matrix.h"
     31#include "Matrix.h"
    3232#include "Vector.h"
    3333
     
    8080       object.
    8181    */
    82     SVD(const utility::matrix& Ain);
     82    SVD(const utility::Matrix& Ain);
    8383
    8484    /**
     
    124124       is undefined.
    125125    */
    126     const utility::matrix& U(void) const;
     126    const utility::Matrix& U(void) const;
    127127
    128128    /**
     
    134134       is undefined.
    135135    */
    136     const utility::matrix& V(void) const;
     136    const utility::Matrix& V(void) const;
    137137
    138138  private:
     
    158158    int modified_golub_reinsch(void);
    159159
    160     utility::matrix U_, V_;
     160    utility::Matrix U_, V_;
    161161    utility::Vector s_;
    162162  }; 
  • trunk/yat/utility/Vector.cc

    r1120 r1121  
    2626
    2727#include "Vector.h"
    28 #include "matrix.h"
    2928#include "utility.h"
    3029#include "yat/random/random.h"
  • trunk/yat/utility/VectorBase.cc

    r1120 r1121  
    2626
    2727#include "VectorBase.h"
    28 #include "matrix.h"
     28#include "Vector.h"
    2929#include "utility.h"
    3030#include "yat/random/random.h"
  • trunk/yat/utility/VectorConstView.cc

    r1029 r1121  
    2626
    2727#include "VectorConstView.h"
    28 #include "matrix.h"
     28#include "Matrix.h"
    2929
    3030namespace theplu {
     
    5656
    5757
    58   VectorConstView::VectorConstView(const matrix& m, size_t i, bool row)
     58  VectorConstView::VectorConstView(const Matrix& m, size_t i, bool row)
    5959    : VectorBase(), const_view_(NULL)
    6060  {
  • trunk/yat/utility/VectorConstView.h

    r1029 r1121  
    3838namespace utility {
    3939
    40   class matrix;
     40  class Matrix;
    4141
    4242  /**
     
    100100       use is undefined.
    101101    */
    102     VectorConstView(const matrix& m, size_t i, bool row=true);
     102    VectorConstView(const Matrix& m, size_t i, bool row=true);
    103103
    104104    /**
  • trunk/yat/utility/VectorMutable.cc

    r1118 r1121  
    2626
    2727#include "VectorMutable.h"
    28 #include "matrix.h"
    2928#include "utility.h"
    3029#include "yat/random/random.h"
  • trunk/yat/utility/VectorView.cc

    r1118 r1121  
    2727#include "VectorView.h"
    2828#include "VectorMutable.h"
    29 #include "matrix.h"
     29#include "Matrix.h"
    3030#include "utility.h"
    3131#include "yat/random/random.h"
     
    7777
    7878
    79   VectorView::VectorView(matrix& m, size_t i, bool row)
     79  VectorView::VectorView(Matrix& m, size_t i, bool row)
    8080    : VectorMutable()
    8181  {
  • trunk/yat/utility/VectorView.h

    r1120 r1121  
    4343namespace utility {
    4444
    45   class matrix;
     45  class Matrix;
    4646  class Vector;
    4747
     
    144144    /// use is undefined.
    145145    ///
    146     VectorView(matrix& m, size_t i, bool row=true);
     146    VectorView(Matrix& m, size_t i, bool row=true);
    147147
    148148    /**
  • trunk/yat/utility/WeNNI.cc

    r1000 r1121  
    2525
    2626#include "WeNNI.h"
    27 #include "matrix.h"
     27#include "Matrix.h"
    2828#include "stl_utility.h"
    2929
     
    3737
    3838
    39   WeNNI::WeNNI(const utility::matrix& matrix,const utility::matrix& flag,
     39  WeNNI::WeNNI(const utility::Matrix& matrix,const utility::Matrix& flag,
    4040               const u_int neighbours)
    4141    : NNI(matrix,flag,neighbours), imputed_data_raw_(matrix)
  • trunk/yat/utility/WeNNI.h

    r1000 r1121  
    2929
    3030#include "NNI.h"
    31 #include "matrix.h"
     31#include "Matrix.h"
    3232
    3333#include <iostream>
     
    5454    /// Constructor
    5555    ///
    56     WeNNI(const utility::matrix& matrix,const utility::matrix& weight,
     56    WeNNI(const utility::Matrix& matrix,const utility::Matrix& weight,
    5757          const u_int neighbours);
    5858
     
    6767    /// @return A const reference to imputed_data_raw.
    6868    ///
    69     const utility::matrix& imputed_data_raw(void) const
     69    const utility::Matrix& imputed_data_raw(void) const
    7070    { return imputed_data_raw_; }
    7171
     
    7373  private:
    7474
    75     utility::matrix imputed_data_raw_;
     75    utility::Matrix imputed_data_raw_;
    7676  };
    7777
  • trunk/yat/utility/kNNI.cc

    r1000 r1121  
    3636namespace utility {
    3737
    38   kNNI::kNNI(const utility::matrix& matrix,const utility::matrix& flag,
     38  kNNI::kNNI(const utility::Matrix& matrix,const utility::Matrix& flag,
    3939             const u_int neighbours)
    4040    : NNI(matrix,flag,neighbours)
  • trunk/yat/utility/kNNI.h

    r1000 r1121  
    5555    /// Constructor
    5656    ///
    57     kNNI(const utility::matrix& matrix,const utility::matrix& weight,
     57    kNNI(const utility::Matrix& matrix,const utility::Matrix& weight,
    5858         const u_int neighbours);
    5959
Note: See TracChangeset for help on using the changeset viewer.