Changeset 1121 for trunk/yat


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

fixes #308

Location:
trunk/yat
Files:
44 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/yat/classifier/DataLookup1D.cc

    r1120 r1121  
    2828#include "MatrixLookup.h"
    2929
    30 #include "yat/utility/matrix.h"
     30#include "yat/utility/Matrix.h"
    3131#include "yat/utility/Vector.h"
    3232
     
    6666    : column_vector_(true), index_(0), owner_(true)
    6767  {
    68     utility::matrix* m = new utility::matrix(1,index.size());
     68    utility::Matrix* m = new utility::Matrix(1,index.size());
    6969    for (size_t i=0; i<index.size(); ++i){
    7070      assert(index[i]<v.size());
     
    7878    : column_vector_(false), index_(0), owner_(true)
    7979  {
    80     utility::matrix* m = new utility::matrix(1,v.size());
     80    utility::Matrix* m = new utility::Matrix(1,v.size());
    8181    for (size_t i=0; i<v.size(); ++i){
    8282      (*m)(0,i)=v(i);
  • trunk/yat/classifier/EnsembleBuilder.h

    r1088 r1121  
    3131#include "SubsetGenerator.h"
    3232#include "yat/statistics/Averager.h"
     33#include "yat/utility/Matrix.h"
    3334
    3435#include <vector>
     
    177178      result.push_back(std::vector<statistics::Averager>(data.columns()));
    178179   
    179     utility::matrix prediction; 
     180    utility::Matrix prediction; 
    180181
    181182    for(u_long k=0;k<subset_->size();++k) {       
     
    203204      validation_result_.push_back(std::vector<statistics::Averager>(subset_->target().size()));
    204205   
    205     utility::matrix prediction; 
     206    utility::Matrix prediction; 
    206207    for(u_long k=0;k<subset_->size();k++) {
    207208      classifier(k).predict(subset_->validation_data(k),prediction);
  • trunk/yat/classifier/KNN.h

    r1115 r1121  
    3232#include "SupervisedClassifier.h"
    3333#include "Target.h"
    34 #include "yat/utility/matrix.h"
     34#include "yat/utility/Matrix.h"
    3535#include "yat/utility/yat_assert.h"
    3636
     
    107107    ///
    108108    ///
    109     void predict(const DataLookup2D&, utility::matrix&) const;
     109    void predict(const DataLookup2D&, utility::Matrix&) const;
    110110
    111111
     
    129129    /// generated and needs to be deleted by the caller.
    130130    ///
    131     utility::matrix* calculate_distances(const DataLookup2D&) const;
     131    utility::Matrix* calculate_distances(const DataLookup2D&) const;
    132132
    133133    void calculate_unweighted(const MatrixLookup&,
    134134                              const MatrixLookup&,
    135                               utility::matrix*) const;
     135                              utility::Matrix*) const;
    136136    void calculate_weighted(const MatrixLookupWeighted&,
    137137                            const MatrixLookupWeighted&,
    138                             utility::matrix*) const;
     138                            utility::Matrix*) const;
    139139  };
    140140 
     
    162162 
    163163  template <typename Distance, typename NeighborWeighting>
    164   utility::matrix* KNN<Distance, NeighborWeighting>::calculate_distances
     164  utility::Matrix* KNN<Distance, NeighborWeighting>::calculate_distances
    165165  (const DataLookup2D& test) const
    166166  {
    167167    // matrix with training samples as rows and test samples as columns
    168     utility::matrix* distances =
    169       new utility::matrix(data_.columns(),test.columns());
     168    utility::Matrix* distances =
     169      new utility::Matrix(data_.columns(),test.columns());
    170170   
    171171   
     
    210210  void  KNN<Distance, NeighborWeighting>::calculate_unweighted
    211211  (const MatrixLookup& training, const MatrixLookup& test,
    212    utility::matrix* distances) const
     212   utility::Matrix* distances) const
    213213  {
    214214    for(size_t i=0; i<training.columns(); i++) {
     
    226226  KNN<Distance, NeighborWeighting>::calculate_weighted
    227227  (const MatrixLookupWeighted& training, const MatrixLookupWeighted& test,
    228    utility::matrix* distances) const
     228   utility::Matrix* distances) const
    229229  {
    230230    for(size_t i=0; i<training.columns(); i++) {
     
    295295  template <typename Distance, typename NeighborWeighting>
    296296  void KNN<Distance, NeighborWeighting>::predict(const DataLookup2D& test,
    297                                                  utility::matrix& prediction) const
     297                                                 utility::Matrix& prediction) const
    298298  {   
    299299    utility::yat_assert<std::runtime_error>(data_.rows()==test.rows());
    300300
    301     utility::matrix* distances=calculate_distances(test);
     301    utility::Matrix* distances=calculate_distances(test);
    302302   
    303303    prediction.resize(target_.nof_classes(),test.columns(),0.0);
  • trunk/yat/classifier/KernelLookup.cc

    r1105 r1121  
    2626#include "MatrixLookup.h"
    2727#include "MatrixLookupWeighted.h"
    28 #include "../utility/matrix.h"
     28#include "yat/utility/Matrix.h"
    2929
    3030#include <cassert>
     
    205205    assert(data.rows()==kernel_->data().rows());
    206206    if (!weighted()){
    207       utility::matrix* data_all =
    208         new utility::matrix(data.rows(), row_index_.size()+data.columns());
     207      utility::Matrix* data_all =
     208        new utility::Matrix(data.rows(), row_index_.size()+data.columns());
    209209
    210210      for (size_t i=0; i<data_all->rows(); ++i) {
     
    240240    // kernel_ holds MatrixLookupWeighted, hence new Kernel also
    241241    // should hold a MatrixLookupweighted.
    242     utility::matrix* data_all =
    243       new utility::matrix(data.rows(), rows()+data.columns());
    244     utility::matrix* weight_all =
    245       new utility::matrix(data.rows(), rows()+data.columns(), 1.0);
     242    utility::Matrix* data_all =
     243      new utility::Matrix(data.rows(), rows()+data.columns());
     244    utility::Matrix* weight_all =
     245      new utility::Matrix(data.rows(), rows()+data.columns(), 1.0);
    246246    const MatrixLookupWeighted& kernel_data =
    247247      dynamic_cast<const MatrixLookupWeighted&>(kernel_->data());
     
    281281  KernelLookup::test_kernel(const MatrixLookupWeighted& data) const
    282282  {
    283     utility::matrix* data_all =
    284       new utility::matrix(data.rows(), rows()+data.columns());
    285     utility::matrix* weight_all =
    286       new utility::matrix(data.rows(), rows()+data.columns(), 1.0);
     283    utility::Matrix* data_all =
     284      new utility::Matrix(data.rows(), rows()+data.columns());
     285    utility::Matrix* weight_all =
     286      new utility::Matrix(data.rows(), rows()+data.columns(), 1.0);
    287287
    288288    if (weighted()){
  • trunk/yat/classifier/Kernel_SEV.cc

    r1098 r1121  
    2828#include "KernelFunction.h"
    2929#include "MatrixLookup.h"
    30 #include "yat/utility/matrix.h"
     30#include "yat/utility/Matrix.h"
    3131
    3232namespace theplu {
  • trunk/yat/classifier/Kernel_SEV.h

    r1000 r1121  
    2828
    2929#include "Kernel.h"
    30 #include "yat/utility/matrix.h"
     30#include "yat/utility/Matrix.h"
    3131
    3232namespace theplu {
     
    113113    void build_kernel(void);
    114114
    115     utility::matrix kernel_matrix_;
     115    utility::Matrix kernel_matrix_;
    116116
    117117  }; // class Kernel_SEV
  • trunk/yat/classifier/MatrixLookup.cc

    r1105 r1121  
    2525
    2626#include "MatrixLookup.h"
    27 #include "yat/utility/matrix.h"
     27#include "yat/utility/Matrix.h"
    2828
    2929#include <algorithm>
     
    3535namespace classifier {
    3636
    37   MatrixLookup::MatrixLookup(const utility::matrix& data, const bool own)
     37  MatrixLookup::MatrixLookup(const utility::Matrix& data, const bool own)
    3838    : DataLookup2D(own), data_(&data)
    3939  {
     
    4848
    4949
    50   MatrixLookup::MatrixLookup(const utility::matrix& data,
     50  MatrixLookup::MatrixLookup(const utility::Matrix& data,
    5151                             const std::vector<size_t>& row,
    5252                             const std::vector<size_t>& col)
     
    6363
    6464
    65   MatrixLookup::MatrixLookup(const utility::matrix& data,
     65  MatrixLookup::MatrixLookup(const utility::Matrix& data,
    6666                             const std::vector<size_t>& index,
    6767                             const bool row)
     
    136136    : DataLookup2D(rows,columns)
    137137  {
    138     data_ = new utility::matrix(1,1,value);
     138    data_ = new utility::Matrix(1,1,value);
    139139    ref_count_= new u_int(1);
    140140  }
     
    144144    : DataLookup2D()
    145145  {
    146     data_ = new utility::matrix(is,sep);
     146    data_ = new utility::Matrix(is,sep);
    147147    ref_count_= new u_int(1);
    148148    for(size_t i=0;i<(*data_).rows();i++)
  • trunk/yat/classifier/MatrixLookup.h

    r1110 r1121  
    3939
    4040namespace utility {
    41   class matrix;
     41  class Matrix;
    4242}
    4343
     
    9696    /// undefined.
    9797    ///
    98     MatrixLookup(const utility::matrix& matrix, const bool own=false);
     98    MatrixLookup(const utility::Matrix& matrix, const bool own=false);
    9999
    100100    ///
     
    111111    /// undefined.
    112112    ///
    113     MatrixLookup(const utility::matrix& matrix, const std::vector<size_t>& row,
     113    MatrixLookup(const utility::Matrix& matrix, const std::vector<size_t>& row,
    114114                 const std::vector<size_t>& column);
    115115
     
    131131    /// undefined.
    132132    ///
    133     MatrixLookup(const utility::matrix& matrix,
     133    MatrixLookup(const utility::Matrix& matrix,
    134134                 const std::vector<size_t>& index,
    135135                 const bool row_vectors);
     
    330330    friend class MatrixLookupWeighted;
    331331
    332     const utility::matrix* data_;
     332    const utility::Matrix* data_;
    333333  }; 
    334334 
  • trunk/yat/classifier/MatrixLookupWeighted.cc

    r1105 r1121  
    2525#include "MatrixLookupWeighted.h"
    2626#include "MatrixLookup.h"
    27 #include "yat/utility/matrix.h"
     27#include "yat/utility/Matrix.h"
    2828
    2929#include <algorithm>
     
    3535namespace classifier {
    3636
    37   MatrixLookupWeighted::MatrixLookupWeighted(const utility::matrix& data,
    38                                              const utility::matrix& weights,
     37  MatrixLookupWeighted::MatrixLookupWeighted(const utility::Matrix& data,
     38                                             const utility::Matrix& weights,
    3939                                             const bool own)
    4040    : DataLookup2D(own), data_(&data), weights_(&weights),
     
    5050
    5151
    52   MatrixLookupWeighted::MatrixLookupWeighted(const utility::matrix& data)
     52  MatrixLookupWeighted::MatrixLookupWeighted(const utility::Matrix& data)
    5353    : DataLookup2D(), data_(&data)
    5454  {
    55     utility::matrix weights;
     55    utility::Matrix weights;
    5656    utility::nan(*data_,weights);
    57     weights_= new utility::matrix(weights);
     57    weights_= new utility::Matrix(weights);
    5858    ref_count_weights_=new u_int(1);
    5959    for(size_t i=0;i<(*data_).rows();i++)
     
    6767    : DataLookup2D(ml), data_(ml.data_)
    6868  {
    69     weights_= new utility::matrix(data_->rows(), data_->columns(), 1.0);
     69    weights_= new utility::Matrix(data_->rows(), data_->columns(), 1.0);
    7070    ref_count_weights_=new u_int(1);
    7171    ref_count_=ml.ref_count_;
     
    7676 
    7777
    78   MatrixLookupWeighted::MatrixLookupWeighted(const utility::matrix& data,
    79                                              const utility::matrix& weights,
     78  MatrixLookupWeighted::MatrixLookupWeighted(const utility::Matrix& data,
     79                                             const utility::Matrix& weights,
    8080                                             const std::vector<size_t>& row,
    8181                                             const std::vector<size_t>& col)
     
    9999
    100100
    101   MatrixLookupWeighted::MatrixLookupWeighted(const utility::matrix& data,
    102                                              const utility::matrix& weights,
     101  MatrixLookupWeighted::MatrixLookupWeighted(const utility::Matrix& data,
     102                                             const utility::Matrix& weights,
    103103                                             const std::vector<size_t>& index,
    104104                                             const bool row)
     
    209209    : DataLookup2D(rows,columns)
    210210  {
    211     data_ = new utility::matrix(1,1,value);
     211    data_ = new utility::Matrix(1,1,value);
    212212    ref_count_=new u_int(1);
    213     weights_ = new utility::matrix(1,1,weight);
     213    weights_ = new utility::Matrix(1,1,weight);
    214214    ref_count_weights_=new u_int(1);
    215215  }
     
    219219    : DataLookup2D()
    220220  {
    221     data_ = new utility::matrix(is,sep);
     221    data_ = new utility::Matrix(is,sep);
    222222    ref_count_=new u_int(1);
    223223    for(size_t i=0;i<(*data_).rows();i++)
     
    225225    for(size_t i=0;i<(*data_).columns();i++)
    226226      column_index_.push_back(i);
    227     utility::matrix weights;
     227    utility::Matrix weights;
    228228    utility::nan(*data_,weights);
    229     weights_= new utility::matrix(weights);
     229    weights_= new utility::Matrix(weights);
    230230    ref_count_weights_=new u_int(1);
    231231  }
  • trunk/yat/classifier/MatrixLookupWeighted.h

    r1110 r1121  
    3939
    4040namespace utility {
    41   class matrix;
     41  class Matrix;
    4242}
    4343
     
    9191    /// result of further use is undefined.
    9292    ///
    93     MatrixLookupWeighted(const utility::matrix& matrix,
    94                          const utility::matrix& weights,
     93    MatrixLookupWeighted(const utility::Matrix& matrix,
     94                         const utility::Matrix& weights,
    9595                         const bool owner=false);
    9696
     
    107107    /// result of further use is undefined.
    108108    ///
    109     MatrixLookupWeighted(const utility::matrix& matrix);
     109    MatrixLookupWeighted(const utility::Matrix& matrix);
    110110
    111111
     
    140140    /// undefined.
    141141    ///
    142     MatrixLookupWeighted(const utility::matrix& matrix,
    143                          const utility::matrix& weights,
     142    MatrixLookupWeighted(const utility::Matrix& matrix,
     143                         const utility::Matrix& weights,
    144144                         const std::vector<size_t>& row,
    145145                         const std::vector<size_t>& column);
     
    163163    /// result of further use is undefined.
    164164    ///
    165     MatrixLookupWeighted(const utility::matrix& matrix,
    166                          const utility::matrix& weights,
     165    MatrixLookupWeighted(const utility::Matrix& matrix,
     166                         const utility::Matrix& weights,
    167167                         const std::vector<size_t>& index,
    168168                         const bool row_vectors);
     
    368368   
    369369  private:
    370     const utility::matrix* data_;
    371     const utility::matrix* weights_;
     370    const utility::Matrix* data_;
     371    const utility::Matrix* weights_;
    372372    u_int* ref_count_weights_;
    373373  }; 
  • trunk/yat/classifier/NBC.cc

    r1120 r1121  
    2929#include "Target.h"
    3030#include "yat/statistics/AveragerWeighted.h"
    31 #include "yat/utility/matrix.h"
     31#include "yat/utility/Matrix.h"
    3232
    3333#include <cassert>
     
    8686    sigma2_.resize(data_.rows(), target_.nof_classes());
    8787    centroids_.resize(data_.rows(), target_.nof_classes());
    88     utility::matrix nof_in_class(data_.rows(), target_.nof_classes());
     88    utility::Matrix nof_in_class(data_.rows(), target_.nof_classes());
    8989   
    9090    // unweighted
     
    144144
    145145  void NBC::predict(const DataLookup2D& x,                   
    146                     utility::matrix& prediction) const
     146                    utility::Matrix& prediction) const
    147147  {   
    148148    assert(data_.rows()==x.rows());
  • trunk/yat/classifier/NBC.h

    r1042 r1121  
    2727
    2828#include "SupervisedClassifier.h"
    29 #include "yat/utility/matrix.h"
     29#include "yat/utility/Matrix.h"
    3030
    3131namespace theplu {
     
    9999       using all weight equal to unity.
    100100    */
    101     void predict(const DataLookup2D& data, utility::matrix& res) const;
     101    void predict(const DataLookup2D& data, utility::Matrix& res) const;
    102102
    103103
    104104  private:
    105     utility::matrix centroids_;
    106     utility::matrix sigma2_;
     105    utility::Matrix centroids_;
     106    utility::Matrix sigma2_;
    107107    const DataLookup2D& data_;
    108108
  • trunk/yat/classifier/NCC.h

    r1120 r1121  
    3737#include "yat/statistics/Averager.h"
    3838#include "yat/statistics/AveragerWeighted.h"
    39 #include "yat/utility/matrix.h"
     39#include "yat/utility/Matrix.h"
    4040#include "yat/utility/Vector.h"
    4141#include "yat/utility/stl_utility.h"
     
    8181    /// @return the centroids for each class as columns in a matrix.
    8282    ///
    83     const utility::matrix& centroids(void) const;
     83    const utility::Matrix& centroids(void) const;
    8484
    8585    const DataLookup2D& data(void) const;
     
    100100    /// Calculate the distance to each centroid for test samples
    101101    ///
    102     void predict(const DataLookup2D&, utility::matrix&) const;
     102    void predict(const DataLookup2D&, utility::Matrix&) const;
    103103   
    104104   
    105105  private:
    106106
    107     void predict_unweighted(const MatrixLookup&, utility::matrix&) const;
    108     void predict_weighted(const MatrixLookupWeighted&, utility::matrix&) const;   
    109 
    110     utility::matrix* centroids_;
     107    void predict_unweighted(const MatrixLookup&, utility::Matrix&) const;
     108    void predict_weighted(const MatrixLookupWeighted&, utility::Matrix&) const;   
     109
     110    utility::Matrix* centroids_;
    111111    bool centroids_nan_;
    112112    Distance distance_;
     
    145145
    146146  template <typename Distance>
    147   const utility::matrix& NCC<Distance>::centroids(void) const
     147  const utility::Matrix& NCC<Distance>::centroids(void) const
    148148  {
    149149    return *centroids_;
     
    185185    if(centroids_)
    186186      delete centroids_;
    187     centroids_= new utility::matrix(data_.rows(), target_.nof_classes());
     187    centroids_= new utility::Matrix(data_.rows(), target_.nof_classes());
    188188    // data_ is a MatrixLookup or a MatrixLookupWeighted
    189189    if(data_.weighted()) {
     
    226226  template <typename Distance>
    227227  void NCC<Distance>::predict(const DataLookup2D& test,                     
    228                               utility::matrix& prediction) const
     228                              utility::Matrix& prediction) const
    229229  {   
    230230    utility::yat_assert<std::runtime_error>
     
    262262  template <typename Distance>
    263263  void NCC<Distance>::predict_unweighted(const MatrixLookup& test,
    264                                          utility::matrix& prediction) const
     264                                         utility::Matrix& prediction) const
    265265  {
    266266    MatrixLookup unweighted_centroids(*centroids_);
     
    277277  template <typename Distance>
    278278  void NCC<Distance>::predict_weighted(const MatrixLookupWeighted& test,
    279                                           utility::matrix& prediction) const
     279                                          utility::Matrix& prediction) const
    280280  {
    281281    MatrixLookupWeighted weighted_centroids(*centroids_);
  • trunk/yat/classifier/SVM.cc

    r1120 r1121  
    2929#include "yat/random/random.h"
    3030#include "yat/statistics/Averager.h"
    31 #include "yat/utility/matrix.h"
     31#include "yat/utility/Matrix.h"
    3232#include "yat/utility/Vector.h"
    3333
     
    139139  }
    140140
    141   void SVM::predict(const KernelLookup& input, utility::matrix& prediction) const
     141  void SVM::predict(const KernelLookup& input, utility::Matrix& prediction) const
    142142  {
    143143    assert(input.rows()==alpha_.size());
  • trunk/yat/classifier/SVM.h

    r1120 r1121  
    3636namespace theplu {
    3737namespace yat {
     38namespace utility{
     39  class Matrix;
     40}
     41
    3842namespace classifier { 
    3943
     
    133137       for training.
    134138    */
    135     void predict(const KernelLookup& input, utility::matrix& predict) const;
     139    void predict(const KernelLookup& input, utility::Matrix& predict) const;
    136140
    137141    ///
  • trunk/yat/classifier/SVindex.cc

    r1120 r1121  
    2626#include "yat/random/random.h"
    2727#include "yat/statistics/Averager.h"
    28 #include "yat/utility/matrix.h"
    2928#include "yat/utility/Vector.h"
    3029
  • trunk/yat/classifier/SupervisedClassifier.h

    r1042 r1121  
    3333
    3434  namespace utility {
    35     class matrix;
     35    class Matrix;
    3636  }
    3737
     
    8282    /// Generate output values for a data set
    8383    ///
    84     virtual void predict(const DataLookup2D&, utility::matrix&) const =0;   
     84    virtual void predict(const DataLookup2D&, utility::Matrix&) const =0;   
    8585
    8686
  • trunk/yat/regression/MultiDimensional.cc

    r1120 r1121  
    2525#include "MultiDimensional.h"
    2626#include "yat/utility/Exception.h"
    27 #include "yat/utility/matrix.h"
     27#include "yat/utility/Matrix.h"
    2828#include "yat/utility/VectorBase.h"
    2929#include "yat/utility/Vector.h"
     
    4949
    5050
    51   const utility::matrix& MultiDimensional::covariance(void) const
     51  const utility::Matrix& MultiDimensional::covariance(void) const
    5252  {
    5353    return covariance_;
     
    5555
    5656
    57   void MultiDimensional::fit(const utility::matrix& x,
     57  void MultiDimensional::fit(const utility::Matrix& x,
    5858                             const utility::VectorBase& y)
    5959  {
  • trunk/yat/regression/MultiDimensional.h

    r1120 r1121  
    2525*/
    2626
    27 #include "yat/utility/matrix.h"
     27#include "yat/utility/Matrix.h"
    2828#include "yat/utility/VectorBase.h"
    2929
     
    5454    /// @brief covariance of parameters
    5555    ///
    56     const utility::matrix& covariance(void) const;
     56    const utility::Matrix& covariance(void) const;
    5757
    5858    /**
     
    6464       dimension errors).
    6565    */
    66     void fit(const utility::matrix& X, const utility::VectorBase& y);
     66    void fit(const utility::Matrix& X, const utility::VectorBase& y);
    6767
    6868    ///
     
    9595    double chisquare_;
    9696    double s2_;
    97     utility::matrix covariance_;
     97    utility::Matrix covariance_;
    9898    utility::Vector fit_parameters_;
    9999    gsl_multifit_linear_workspace* work_;
  • trunk/yat/regression/MultiDimensionalWeighted.cc

    r1120 r1121  
    2424#include "MultiDimensionalWeighted.h"
    2525#include "yat/statistics/AveragerWeighted.h"
    26 #include "yat/utility/matrix.h"
     26#include "yat/utility/Matrix.h"
    2727#include "yat/utility/Vector.h"
    2828
     
    5151
    5252
    53   void MultiDimensionalWeighted::fit(const utility::matrix& x,
     53  void MultiDimensionalWeighted::fit(const utility::Matrix& x,
    5454                                     const utility::VectorBase& y,
    5555                                     const utility::VectorBase& w)
  • trunk/yat/regression/MultiDimensionalWeighted.h

    r1120 r1121  
    2525*/
    2626
    27 #include "yat/utility/matrix.h"
     27#include "yat/utility/Matrix.h"
    2828#include "yat/utility/Vector.h"
    2929
     
    6363       dimension errors).
    6464    */
    65     void fit(const utility::matrix& X, const utility::VectorBase& y,
     65    void fit(const utility::Matrix& X, const utility::VectorBase& y,
    6666             const utility::VectorBase& w);
    6767
     
    9494  private:
    9595    double chisquare_;
    96     utility::matrix covariance_;
     96    utility::Matrix covariance_;
    9797    utility::Vector fit_parameters_;
    9898    double s2_;
  • trunk/yat/regression/Polynomial.cc

    r1120 r1121  
    2525
    2626#include "Polynomial.h"
    27 #include "yat/utility/matrix.h"
     27#include "yat/utility/Matrix.h"
    2828#include "yat/utility/VectorBase.h"
    2929
     
    4343
    4444
    45   const utility::matrix& Polynomial::covariance(void) const
     45  const utility::Matrix& Polynomial::covariance(void) const
    4646  {
    4747    return md_.covariance();
     
    5353  {
    5454    add(ap_, x.begin(), x.end(), y.begin());
    55     utility::matrix X=utility::matrix(x.size(),power_+1,1);
     55    utility::Matrix X=utility::Matrix(x.size(),power_+1,1);
    5656    for (size_t i=0; i<X.rows(); ++i)
    5757      for (u_int j=1; j<X.columns(); j++)
  • trunk/yat/regression/Polynomial.h

    r1120 r1121  
    5959    /// @brief covariance of parameters
    6060    ///
    61     const utility::matrix& covariance(void) const;
     61    const utility::Matrix& covariance(void) const;
    6262
    6363    ///
  • trunk/yat/regression/PolynomialWeighted.cc

    r1120 r1121  
    2424
    2525#include "PolynomialWeighted.h"
    26 #include "yat/utility/matrix.h"
     26#include "yat/utility/Matrix.h"
    2727#include "yat/utility/Vector.h"
    2828
     
    5454    utility::Vector dummy(x.size(), 1.0);
    5555    add(ap_,x.begin(), x.end(),y.begin(),dummy.begin(),w.begin());
    56     utility::matrix X=utility::matrix(x.size(),power_+1,1);
     56    utility::Matrix X=utility::Matrix(x.size(),power_+1,1);
    5757    for (size_t i=0; i<X.rows(); ++i)
    5858      for (u_int j=1; j<X.columns(); j++)
  • 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.