Changeset 616


Ignore:
Timestamp:
Aug 31, 2006, 10:52:02 AM (15 years ago)
Author:
Jari Häkkinen
Message:

Removed gslapi namespace and put the code into utility namespace.
Move #ifndef _header_ idiom to top of touched header files.
Removed unneccesary #includes, and added needed #includes.

Location:
trunk
Files:
1 deleted
106 edited
4 copied

Legend:

Unmodified
Added
Removed
  • trunk/c++_tools/Makefile.am

    r461 r616  
    66INCLUDES = @local_includes@
    77
    8 SUBDIRS = classifier gslapi random statistics utility
     8SUBDIRS = classifier random statistics utility
    99
    1010lib_LTLIBRARIES = libc++_tools.la
     
    1414libc___tools_la_LIBADD = \
    1515  classifier/libclassifier.la \
    16   gslapi/libgslapi.la \
    1716  random/librandom.la \
    1817  statistics/libstatistics.la \
  • trunk/c++_tools/classifier/ConsensusInputRanker.cc

    r615 r616  
    11// $Id$
    2 
    32
    43#include <c++_tools/classifier/ConsensusInputRanker.h>
  • trunk/c++_tools/classifier/EnsembleBuilder.cc

    r615 r616  
    99#include <c++_tools/classifier/Target.h>
    1010
    11 #include <c++_tools/gslapi/matrix.h>
     11#include <c++_tools/utility/matrix.h>
    1212
    1313namespace theplu {
     
    5050   
    5151    size_t k=0;
    52     gslapi::matrix prediction;   
     52    utility::matrix prediction; 
    5353   
    5454
     
    9191   
    9292    size_t k=0;
    93     gslapi::matrix prediction;   
     93    utility::matrix prediction; 
    9494    while(subset_.more()) {
    9595      classifier(k++).predict(subset_.validation_data(),prediction);
  • trunk/c++_tools/classifier/GaussianKernelFunction.cc

    r608 r616  
    55#include <c++_tools/classifier/KernelFunction.h>
    66#include <c++_tools/classifier/DataLookup1D.h>
    7 #include <c++_tools/gslapi/matrix.h>
    8 
    97
    108#include <math.h>
  • trunk/c++_tools/classifier/GaussianKernelFunction.h

    r608 r616  
    1 // $Id$
    2 
    31#ifndef _theplu_classifier_gaussian_kernel_function_
    42#define _theplu_classifier_gaussian_kernel_function_
    53
    6 #include <c++_tools/gslapi/vector.h>
     4// $Id$
     5
    76#include <c++_tools/classifier/KernelFunction.h>
    87#include <c++_tools/classifier/DataLookup1D.h>
  • trunk/c++_tools/classifier/IGP.cc

    r608 r616  
    77#include <c++_tools/classifier/Target.h>
    88#include <c++_tools/classifier/utility.h>
    9 #include <c++_tools/gslapi/vector.h>
     9#include <c++_tools/utility/vector.h>
    1010#include <c++_tools/statistics/Distance.h>
    1111
     
    2424   
    2525    // Calculate IGP for each class
    26     igp_=gslapi::vector(target_.nof_classes());
     26    igp_=utility::vector(target_.nof_classes());
    2727    for(u_int i=0; i<target_.size(); i++) {
    2828      u_int neighbor=i;
    2929      double mindist=std::numeric_limits<double>::max();
    30       gslapi::vector a;
     30      utility::vector a;
    3131      convert(DataLookup1D(matrix_,i,false),a);
    32       gslapi::vector wa(a.size(),0);
     32      utility::vector wa(a.size(),0);
    3333      for(size_t k=0; k<a.size(); k++)  { // take care of missing values
    3434          if(!std::isnan(a(k)))
     
    3737
    3838      for(u_int j=0; j<target_.size(); j++) {           
    39         gslapi::vector b;
     39        utility::vector b;
    4040        convert(DataLookup1D(matrix_,j,false),b);
    41         gslapi::vector wb(b.size(),0);
     41        utility::vector wb(b.size(),0);
    4242        for(size_t k=0; k<b.size(); k++)  { // take care of missing values
    4343          if(!std::isnan(b(k)))
  • trunk/c++_tools/classifier/IGP.h

    r608 r616  
    1 // $Id$
    2 
    31#ifndef _theplu_classifier_igp_
    42#define _theplu_classifier_igp_
    53
    6 #include <c++_tools/gslapi/matrix.h>
     4// $Id$
     5
     6#include <c++_tools/utility/vector.h>
    77
    88namespace theplu {
     
    3939    /// @return the IGP score for each class as elements in a vector.
    4040    ///
    41     const gslapi::vector& score(void) const {return igp_;}
     41    const utility::vector& score(void) const {return igp_;}
    4242
    4343
    4444  private:
    45     gslapi::vector igp_;
     45    utility::vector igp_;
    4646
    4747    const statistics::Distance& distance_;
  • trunk/c++_tools/classifier/Kernel.h

    r608 r616  
    1 // $Id$
    2 
    31#ifndef _theplu_classifier_kernel_
    42#define _theplu_classifier_kernel_
    53
    6 #include <c++_tools/gslapi/matrix.h>
    7 #include <c++_tools/gslapi/vector.h>
     4// $Id$
     5
    86#include <c++_tools/classifier/KernelFunction.h>
    97#include <c++_tools/classifier/MatrixLookup.h>
  • trunk/c++_tools/classifier/KernelWeighted_SEV.cc

    r608 r616  
    77#include <c++_tools/classifier/KernelFunction.h>
    88#include <c++_tools/classifier/MatrixLookup.h>
    9 #include <c++_tools/gslapi/matrix.h>
    10 #include <c++_tools/gslapi/vector.h>
     9#include <c++_tools/utility/matrix.h>
    1110
    1211#include <cassert>
     
    3736  void KernelWeighted_SEV::build_kernel(void)
    3837  {
    39     kernel_matrix_ = gslapi::matrix(data_->columns(),data_->columns());
     38    kernel_matrix_ = utility::matrix(data_->columns(),data_->columns());
    4039    for (size_t i=0; i<kernel_matrix_.rows(); i++)
    4140      for (size_t j=i; j<kernel_matrix_.columns(); j++)
  • trunk/c++_tools/classifier/KernelWeighted_SEV.h

    r608 r616  
    1 // $Id$
    2 
    31#ifndef _theplu_classifier_kernel_weighted_sev_
    42#define _theplu_classifier_kernel_weighted_sev_
     3
     4// $Id$
    55
    66#include <c++_tools/classifier/DataLookup1D.h>
    77#include <c++_tools/classifier/Kernel.h>
    88#include <c++_tools/classifier/MatrixLookup.h>
    9 #include <c++_tools/gslapi/matrix.h>
    10 #include <c++_tools/gslapi/vector.h>
     9#include <c++_tools/utility/matrix.h>
    1110
    1211
     
    114113    void build_kernel(void);
    115114
    116     gslapi::matrix kernel_matrix_;
     115    utility::matrix kernel_matrix_;
    117116
    118117  }; // class Kernel_SEV
  • trunk/c++_tools/classifier/Kernel_MEV.h

    r608 r616  
    1 // $Id$
    2 
    31#ifndef _theplu_classifier_kernel_mev_
    42#define _theplu_classifier_kernel_mev_
     3
     4// $Id$
    55
    66#include <c++_tools/classifier/DataLookup1D.h>
    77#include <c++_tools/classifier/Kernel.h>
    88#include <c++_tools/classifier/KernelFunction.h>
    9 #include <c++_tools/gslapi/vector.h>
    10 #include <c++_tools/gslapi/matrix.h>
    119
    1210namespace theplu {
  • trunk/c++_tools/classifier/Kernel_SEV.cc

    r608 r616  
    77#include <c++_tools/classifier/KernelFunction.h>
    88#include <c++_tools/classifier/MatrixLookup.h>
    9 #include <c++_tools/gslapi/matrix.h>
    10 #include <c++_tools/gslapi/vector.h>
     9#include <c++_tools/utility/matrix.h>
    1110
    1211namespace theplu {
     
    3029  void Kernel_SEV::build_kernel(void)
    3130  {
    32     kernel_matrix_ = gslapi::matrix(data_->columns(),data_->columns());
     31    kernel_matrix_ = utility::matrix(data_->columns(),data_->columns());
    3332    for (size_t i=0; i<kernel_matrix_.rows(); i++)
    3433      for (size_t j=i; j<kernel_matrix_.columns(); j++)
  • trunk/c++_tools/classifier/Kernel_SEV.h

    r608 r616  
    1 // $Id$
    2 
    31#ifndef _theplu_classifier_kernel_sev_
    42#define _theplu_classifier_kernel_sev_
    53
     4// $Id$
     5
    66#include <c++_tools/classifier/Kernel.h>
    7 #include <c++_tools/gslapi/matrix.h>
     7#include <c++_tools/utility/matrix.h>
    88
    99
     
    8989    void build_kernel(void);
    9090
    91     gslapi::matrix kernel_matrix_;
     91    utility::matrix kernel_matrix_;
    9292
    9393  }; // class Kernel_SEV
  • trunk/c++_tools/classifier/MatrixLookup.cc

    r608 r616  
    22
    33#include <c++_tools/classifier/MatrixLookup.h>
     4
     5#include <c++_tools/utility/matrix.h>
    46
    57#ifndef NDEBUG
     
    1214namespace classifier {
    1315
    14   MatrixLookup::MatrixLookup(const gslapi::matrix& data)
     16  MatrixLookup::MatrixLookup(const utility::matrix& data)
    1517    : DataLookup2D(), data_(&data)
    1618  {
     
    2325
    2426
    25   MatrixLookup::MatrixLookup(const gslapi::matrix& data,
     27  MatrixLookup::MatrixLookup(const utility::matrix& data,
    2628                             const std::vector<size_t>& row,
    2729                             const std::vector<size_t>& col)
     
    3840
    3941
    40   MatrixLookup::MatrixLookup(const gslapi::matrix& data,
     42  MatrixLookup::MatrixLookup(const utility::matrix& data,
    4143                     const std::vector<size_t>& index,
    4244                     const bool row)
     
    101103    : DataLookup2D(rows,columns, true)
    102104  {
    103     data_ = new gslapi::matrix(1,1,value);
     105    data_ = new utility::matrix(1,1,value);
    104106  }
    105107
     
    108110    : DataLookup2D(true)
    109111  {
    110     data_ = new gslapi::matrix(is,sep);
     112    data_ = new utility::matrix(is,sep);
    111113    for(size_t i=0;i<(*data_).rows();i++)
    112114      row_index_.push_back(i);
  • trunk/c++_tools/classifier/MatrixLookup.h

    r608 r616  
    1 // $Id$
    2 
    31#ifndef _theplu_classifier_matrix_lookup_
    42#define _theplu_classifier_matrix_lookup_
    53
     4// $Id$
     5
    66#include <c++_tools/classifier/DataLookup2D.h>
    7 #include <c++_tools/gslapi/matrix.h>
     7#include <c++_tools/utility/matrix.h>
    88
    99#include <cassert>
     
    4848    /// undefined.
    4949    ///
    50     explicit MatrixLookup(const gslapi::matrix& matrix);
     50    explicit MatrixLookup(const utility::matrix& matrix);
    5151
    5252    ///
     
    6363    /// undefined.
    6464    ///
    65     MatrixLookup(const gslapi::matrix& matrix, const std::vector<size_t>& row,
     65    MatrixLookup(const utility::matrix& matrix, const std::vector<size_t>& row,
    6666                 const std::vector<size_t>& column);
    6767
     
    8383    /// undefined.
    8484    ///
    85     MatrixLookup(const gslapi::matrix& matrix,
     85    MatrixLookup(const utility::matrix& matrix,
    8686                 const std::vector<size_t>& index,
    8787                 const bool row_vectors);
     
    246246   
    247247  private:
    248     const gslapi::matrix* data_;
     248    const utility::matrix* data_;
    249249  }; 
    250250 
  • trunk/c++_tools/classifier/MatrixLookupWeighted.cc

    r611 r616  
    22
    33#include <c++_tools/classifier/MatrixLookupWeighted.h>
     4
     5#include <c++_tools/utility/matrix.h>
    46
    57#ifndef NDEBUG
     
    1214namespace classifier {
    1315
    14   MatrixLookupWeighted::MatrixLookupWeighted(const gslapi::matrix& data,
    15                              const gslapi::matrix& weights)
     16  MatrixLookupWeighted::MatrixLookupWeighted(const utility::matrix& data,
     17                                             const utility::matrix& weights)
    1618    : DataLookup2D(), data_(&data), weights_(&weights)
    1719  {
     
    2628
    2729
    28   MatrixLookupWeighted::MatrixLookupWeighted(const gslapi::matrix& data,
    29                              const gslapi::matrix& weights,
    30                             const std::vector<size_t>& row,
    31                             const std::vector<size_t>& col)
     30  MatrixLookupWeighted::MatrixLookupWeighted(const utility::matrix& data,
     31                                             const utility::matrix& weights,
     32                                            const std::vector<size_t>& row,
     33                                            const std::vector<size_t>& col)
    3234    : DataLookup2D(row,col), data_(&data), weights_(&weights)
    3335  {
     
    4850
    4951
    50   MatrixLookupWeighted::MatrixLookupWeighted(const gslapi::matrix& data,
    51                              const gslapi::matrix& weights,
    52                             const std::vector<size_t>& index,
    53                             const bool row)
     52  MatrixLookupWeighted::MatrixLookupWeighted(const utility::matrix& data,
     53                                             const utility::matrix& weights,
     54                                            const std::vector<size_t>& index,
     55                                            const bool row)
    5456    : DataLookup2D(), data_(&data), weights_(&weights)
    5557  {
     
    135137    : DataLookup2D(rows,columns, true)
    136138  {
    137     data_ = new gslapi::matrix(1,1,value);
    138     weights_ = new gslapi::matrix(1,1,1.0);
     139    data_ = new utility::matrix(1,1,value);
     140    weights_ = new utility::matrix(1,1,1.0);
    139141  }
    140142
     
    143145    : DataLookup2D(true)
    144146  {
    145     data_ = new gslapi::matrix(is,sep);
     147    data_ = new utility::matrix(is,sep);
    146148    for(size_t i=0;i<(*data_).rows();i++)
    147149      row_index_.push_back(i);
    148150    for(size_t i=0;i<(*data_).columns();i++)
    149151      column_index_.push_back(i);
    150     gslapi::matrix weights;
     152    utility::matrix weights;
    151153    data_->nan(weights);   
    152     weights_= new gslapi::matrix(weights);
     154    weights_= new utility::matrix(weights);
    153155  }
    154156 
  • trunk/c++_tools/classifier/MatrixLookupWeighted.h

    r608 r616  
    1 // $Id$
    2 
    31#ifndef _theplu_classifier_matrix_lookup_weighted_
    42#define _theplu_classifier_matrix_lookup_weighted_
    53
     4// $Id$
     5
    66#include <c++_tools/classifier/DataLookup2D.h>
    7 #include <c++_tools/gslapi/matrix.h>
     7#include <c++_tools/utility/matrix.h>
    88
    99#include <cassert>
     
    4545    /// result of further use is undefined.
    4646    ///
    47     MatrixLookupWeighted(const gslapi::matrix& matrix,
    48                          const gslapi::matrix& weights);
     47    MatrixLookupWeighted(const utility::matrix& matrix,
     48                         const utility::matrix& weights);
    4949
    5050    ///
     
    6363    /// undefined.
    6464    ///
    65     MatrixLookupWeighted(const gslapi::matrix& matrix,
    66                          const gslapi::matrix& weights,
     65    MatrixLookupWeighted(const utility::matrix& matrix,
     66                         const utility::matrix& weights,
    6767                         const std::vector<size_t>& row,
    6868                         const std::vector<size_t>& column);
     
    8686    /// result of further use is undefined.
    8787    ///
    88     MatrixLookupWeighted(const gslapi::matrix& matrix,
    89                          const gslapi::matrix& weights,
     88    MatrixLookupWeighted(const utility::matrix& matrix,
     89                         const utility::matrix& weights,
    9090                         const std::vector<size_t>& index,
    9191                         const bool row_vectors);
     
    269269   
    270270  private:
    271     const gslapi::matrix* data_;
    272     const gslapi::matrix* weights_;
     271    const utility::matrix* data_;
     272    const utility::matrix* weights_;
    273273  }; 
    274274 
  • trunk/c++_tools/classifier/NCC.cc

    r615 r616  
    99#include <c++_tools/classifier/SubsetGenerator.h>
    1010#include <c++_tools/classifier/Target.h>
    11 #include <c++_tools/gslapi/vector.h>
     11#include <c++_tools/utility/matrix.h>
     12#include <c++_tools/utility/vector.h>
    1213#include <c++_tools/statistics/Distance.h>
    1314#include <c++_tools/utility/stl_utility.h>
     
    101102      rows=nof_inputs_;
    102103    }
    103     centroids_=gslapi::matrix(rows, target_.nof_classes());
    104     gslapi::matrix nof_in_class(rows, target_.nof_classes());
     104    centroids_=utility::matrix(rows, target_.nof_classes());
     105    utility::matrix nof_in_class(rows, target_.nof_classes());
    105106    for(size_t i=0; i<rows; i++) {
    106107      for(size_t j=0; j<matrix_.columns(); j++) {
     
    124125
    125126  void NCC::predict(const DataLookup1D& input,
    126                     gslapi::vector& prediction) const
     127                    utility::vector& prediction) const
    127128  {
    128     prediction=gslapi::vector(centroids_.columns());   
     129    prediction=utility::vector(centroids_.columns());   
    129130    size_t size=input.size();
    130131    if(ranker_)
    131132      size=nof_inputs_;
    132     gslapi::vector w(size,0);
    133     gslapi::vector value(size,0);
     133    utility::vector w(size,0);
     134    utility::vector value(size,0);
    134135    for(size_t i=0; i<size; i++)  { // take care of missing values
    135136      value(i)=input(i);
     
    140141    }
    141142    for(size_t j=0; j<centroids_.columns(); j++) {
    142       gslapi::vector centroid=gslapi::vector(centroids_,j,false);
    143       gslapi::vector wc(centroid.size(),0);
     143      utility::vector centroid=utility::vector(centroids_,j,false);
     144      utility::vector wc(centroid.size(),0);
    144145      for(size_t i=0; i<centroid.size(); i++)  { // take care of missing values
    145146        if(!std::isnan(centroid(i)))
     
    152153
    153154  void NCC::predict(const DataLookup2D& input,                   
    154                     gslapi::matrix& prediction) const
     155                    utility::matrix& prediction) const
    155156  {
    156     prediction=gslapi::matrix(centroids_.columns(), input.columns());   
     157    prediction=utility::matrix(centroids_.columns(), input.columns());   
    157158    for(size_t j=0; j<input.columns();j++) {     
    158159      DataLookup1D in(input,j,false);
    159       gslapi::vector out;
     160      utility::vector out;
    160161      predict(in,out);
    161162      prediction.set_column(j,out);
  • trunk/c++_tools/classifier/NCC.h

    r615 r616  
    1 // $Id$
    2 
    31#ifndef _theplu_classifier_ncc_
    42#define _theplu_classifier_ncc_
    53
    6 #include <c++_tools/gslapi/matrix.h>
     4// $Id$
     5
     6#include <c++_tools/utility/matrix.h>
    77
    88#include <c++_tools/classifier/SupervisedClassifier.h>
     
    1111
    1212namespace theplu {
     13
     14  namespace utlitity {
     15    class vector;
     16  }
    1317
    1418  namespace statistics {
     
    7377    /// @return the centroids for each class as columns in a matrix.
    7478    ///
    75     const gslapi::matrix& centroids(void) const {return centroids_;}
     79    const utility::matrix& centroids(void) const {return centroids_;}
    7680
    7781    inline SupervisedClassifier*
     
    9094    /// Calculate the distance to each centroid for a test sample
    9195    ///
    92     void predict(const DataLookup1D&, gslapi::vector&) const;
     96    void predict(const DataLookup1D&, utility::vector&) const;
    9397   
    9498    ///
    9599    /// Calculate the distance to each centroid for test samples
    96100    ///
    97     void predict(const DataLookup2D&, gslapi::matrix&) const;
     101    void predict(const DataLookup2D&, utility::matrix&) const;
    98102
    99103
    100104  private:
    101     gslapi::matrix centroids_;
     105    utility::matrix centroids_;
    102106    const statistics::Distance& distance_;                 
    103107    const MatrixLookup& matrix_;
  • trunk/c++_tools/classifier/PolynomialKernelFunction.cc

    r608 r616  
    55#include <c++_tools/classifier/DataLookup1D.h>
    66
    7 #include <c++_tools/gslapi/matrix.h>
    8 #include <c++_tools/gslapi/vector.h>
    97#include <c++_tools/statistics/AveragerPairWeighted.h>
    108
  • trunk/c++_tools/classifier/SVM.cc

    r615 r616  
    66#include <c++_tools/classifier/InputRanker.h>
    77#include <c++_tools/classifier/SubsetGenerator.h>
    8 #include <c++_tools/gslapi/matrix.h>
    9 #include <c++_tools/gslapi/vector.h>
     8#include <c++_tools/random/random.h>
    109#include <c++_tools/statistics/Averager.h>
    1110#include <c++_tools/statistics/Score.h>
    12 #include <c++_tools/random/random.h>
     11#include <c++_tools/utility/matrix.h>
     12#include <c++_tools/utility/vector.h>
    1313
    1414#include <algorithm>
     
    133133  }
    134134
    135   void SVM::predict(const DataLookup2D& input, gslapi::matrix& prediction) const
     135  void SVM::predict(const DataLookup2D& input, utility::matrix& prediction) const
    136136  {
    137137    // Peter, should check success of dynamic_cast
     
    150150
    151151    assert(input.rows()==alpha_.size());
    152     prediction = gslapi::matrix(2,input.columns(),0);
     152    prediction = utility::matrix(2,input.columns(),0);
    153153    for (size_t i = 0; i<input.columns(); i++){
    154154      for (size_t j = 0; j<input.rows(); j++){
     
    192192
    193193    sample_.init(alpha_,tolerance_);
    194     gslapi::vector  E(target_.size(),0);
     194    utility::vector   E(target_.size(),0);
    195195    for (size_t i=0; i<E.size(); i++) {
    196196      for (size_t j=0; j<E.size(); j++)
     
    275275
    276276
    277   bool SVM::choose(const theplu::gslapi::vector& E)
     277  bool SVM::choose(const theplu::utility::vector& E)
    278278  {
    279279    // First check for violation among SVs
     
    420420  }
    421421
    422   void Index::init(const gslapi::vector& alpha, const double tol)
     422  void Index::init(const utility::vector& alpha, const double tol)
    423423  {
    424424    nof_sv_=0;
  • trunk/c++_tools/classifier/SVM.h

    r615 r616  
    1 // $Id$
    2 
    31#ifndef _theplu_classifier_svm_
    42#define _theplu_classifier_svm_
     3
     4// $Id$
    55
    66#include <c++_tools/classifier/DataLookup2D.h>
     
    88#include <c++_tools/classifier/SupervisedClassifier.h>
    99#include <c++_tools/classifier/Target.h>
    10 #include <c++_tools/gslapi/vector.h>
     10#include <c++_tools/utility/vector.h>
    1111
    1212#include <cassert>
     
    4444
    4545    // synch the object against alpha
    46     void init(const gslapi::vector& alpha, const double);
     46    void init(const utility::vector& alpha, const double);
    4747
    4848    // @return nof samples
     
    144144    /// @return \f$ \alpha \f$
    145145    ///
    146     inline const gslapi::vector& alpha(void) const { return alpha_; }
     146    inline const utility::vector& alpha(void) const { return alpha_; }
    147147
    148148    ///
     
    175175    /// @return output
    176176    ///
    177     inline const theplu::gslapi::vector& output(void) const { return output_; }
     177    inline const theplu::utility::vector& output(void) const { return output_; }
    178178
    179179    ///
     
    193193    /// @note
    194194    ///
    195     void predict(const DataLookup2D& input, gslapi::matrix& predict) const;
     195    void predict(const DataLookup2D& input, utility::matrix& predict) const;
    196196
    197197    ///
     
    211211    ///
    212212    inline void reset(void)
    213     { trained_=false; alpha_=gslapi::vector(target_.size(),0); }
     213    { trained_=false; alpha_=utility::vector(target_.size(),0); }
    214214
    215215    ///
     
    262262    ///  can be found
    263263    ///
    264     bool choose(const theplu::gslapi::vector&);
     264    bool choose(const theplu::utility::vector&);
    265265
    266266    ///
     
    273273    inline int target(size_t i) const { return target_.binary(i) ? 1 : -1; }
    274274
    275     gslapi::vector alpha_;
     275    utility::vector alpha_;
    276276    double bias_;
    277277    double C_inverse_;
     
    279279    double margin_;
    280280    unsigned long int max_epochs_;
    281     gslapi::vector output_;
     281    utility::vector output_;
    282282    bool owner_;
    283283    Index sample_;
  • trunk/c++_tools/classifier/SupervisedClassifier.h

    r615 r616  
    1 // $Id$
    2 
    31#ifndef _theplu_classifier_supervisedclassifier_
    42#define _theplu_classifier_supervisedclassifier_
     3
     4// $Id$
    55
    66#include <stddef.h>
     
    88namespace theplu {
    99
    10   namespace gslapi {
    11     class vector;
     10  namespace utility {
    1211    class matrix;
    1312  }
     
    7170    /// Generate output values for a data set
    7271    ///
    73     virtual void predict(const DataLookup2D&, gslapi::matrix&) const =0;   
     72    virtual void predict(const DataLookup2D&, utility::matrix&) const =0;   
    7473
    7574   
  • trunk/c++_tools/classifier/utility.cc

    r608 r616  
    55
    66#include <c++_tools/classifier/DataLookup1D.h>
    7 #include <c++_tools/gslapi/vector.h>
     7#include <c++_tools/utility/vector.h>
    88
    99
     
    1111namespace classifier {
    1212
    13   void convert(const DataLookup1D& lookup, gslapi::vector& vector)
     13  void convert(const DataLookup1D& lookup, utility::vector& vector)
    1414  {
    15     vector=gslapi::vector(lookup.size());
     15    vector=utility::vector(lookup.size());
    1616    for(u_int i=0; i<lookup.size(); i++)
    1717      vector(i)=lookup(i);
  • trunk/c++_tools/classifier/utility.h

    r608 r616  
    1 // $Id$
    2 
    31#ifndef _theplu_classifier_utility_
    42#define _theplu_classifier_utility_
    53
     4// $Id$
     5
    66namespace theplu {
    77
    8   namespace gslapi {
     8  namespace utility {
    99    class vector;
    1010  }
     
    1515
    1616  ///
    17   /// Converts a DataLookup1D to a gslapi::vector
     17  /// Converts a DataLookup1D to a utility::vector
    1818  ///
    19   void convert(const DataLookup1D&, gslapi::vector&);
     19  void convert(const DataLookup1D&, utility::vector&);
    2020
    2121
  • trunk/c++_tools/statistics/Averager.cc

    r420 r616  
    22
    33#include <c++_tools/statistics/Averager.h>
    4 #include <c++_tools/gslapi/vector.h>
    5 
    6 #include <sys/types.h>
    7 #include <ostream>
    84
    95namespace theplu {
  • trunk/c++_tools/statistics/Averager.h

    r597 r616  
    1 // $Id$
    2 
    31#ifndef _theplu_statistics_averager_
    42#define _theplu_statistics_averager_
    53
    6 #include <c++_tools/gslapi/vector.h>
     4// $Id$
    75
    86#include <cmath>
     7#include <sys/types.h>
    98
    109namespace theplu{
  • trunk/c++_tools/statistics/AveragerPairWeighted.h

    r582 r616  
    1 // $Id$
    2 
    31#ifndef _theplu_statistics_averager_pair_weighted_
    42#define _theplu_statistics_averager_pair_weighted_
    53
     4// $Id$
     5
    66#include <c++_tools/statistics/AveragerWeighted.h>
    7 #include <c++_tools/gslapi/vector.h>
    87
    98#include <cmath>
    10 //#include <utility>
    119
    1210
  • trunk/c++_tools/statistics/AveragerWeighted.cc

    r582 r616  
    22
    33#include <c++_tools/statistics/AveragerWeighted.h>
    4 #include <c++_tools/statistics/Averager.h>
    5 #include <c++_tools/gslapi/vector.h>
    6 
    7 #include <cassert>
    8 #include <ostream>
    9 #include <sys/types.h>
    104
    115namespace theplu {
  • trunk/c++_tools/statistics/AveragerWeighted.h

    r589 r616  
    1 // $Id$
    2 
    31#ifndef _theplu_statistics_averager_weighted_
    42#define _theplu_statistics_averager_weighted_
    53
     4// $Id$
     5
    66#include <c++_tools/statistics/Averager.h>
    77
    88#include <cmath>
    9 //#include <ostream>
    109
    1110namespace theplu{
    12   class gslapi::vector;
    13 
    1411namespace statistics{
    1512
  • trunk/c++_tools/statistics/Distance.cc

    r582 r616  
    55#include <c++_tools/classifier/DataLookup1D.h>
    66#include <c++_tools/classifier/utility.h>
    7 #include <c++_tools/gslapi/vector.h>
     7#include <c++_tools/utility/vector.h>
    88
    99namespace theplu{
     
    1313                              const classifier::DataLookup1D& y) const
    1414  {
    15     gslapi::vector a;
     15    utility::vector a;
    1616    classifier::convert(x,a);
    17     gslapi::vector b;
     17    utility::vector b;
    1818    classifier::convert(y,b);     
    1919    return this->operator()(a,b);
     
    2626                              const classifier::DataLookup1D& wy) const
    2727  {
    28     gslapi::vector a;
     28    utility::vector a;
    2929    classifier::convert(x,a);
    30     gslapi::vector b;
     30    utility::vector b;
    3131    classifier::convert(y,b);
    32     gslapi::vector c;
     32    utility::vector c;
    3333    classifier::convert(wx,c);
    34     gslapi::vector d;
     34    utility::vector d;
    3535    classifier::convert(wy,d);
    3636    return this->operator()(a,b,c,d);
     
    3838
    3939
    40 
    41 
    4240}} // of namespace statistics and namespace theplu
    4341
  • trunk/c++_tools/statistics/Distance.h

    r582 r616  
    1 // $Id$
    2 
    31#ifndef _theplu_statistics_distance_
    42#define _theplu_statistics_distance_
    53
     4// $Id$
     5
    66namespace theplu{
    77
    8   namespace gslapi {
     8  namespace utility {
    99    class vector;
    1010  }
     
    3030    }
    3131
    32     virtual double operator()(const gslapi::vector& x,
    33                               const gslapi::vector& y) const = 0;
     32    virtual double operator()(const utility::vector& x,
     33                              const utility::vector& y) const = 0;
    3434
    3535
     
    3838       
    3939   
    40     virtual double operator()(const gslapi::vector& x,
    41                               const gslapi::vector& y,
    42                               const gslapi::vector& wx,
    43                               const gslapi::vector& wy) const = 0;
     40    virtual double operator()(const utility::vector& x,
     41                              const utility::vector& y,
     42                              const utility::vector& wx,
     43                              const utility::vector& wy) const = 0;
    4444   
    4545    virtual double operator()(const classifier::DataLookup1D& x,
  • trunk/c++_tools/statistics/Fisher.cc

    r556 r616  
    111111
    112112    double Fisher::score(const classifier::Target& target,
    113                          const gslapi::vector& value)
     113                         const utility::vector& value)
    114114  {
    115115    weighted_=false;
     
    137137 
    138138    double Fisher::score(const classifier::Target& target,
    139                          const gslapi::vector& value,
    140                          const gslapi::vector& weight)
     139                         const utility::vector& value,
     140                         const utility::vector& weight)
    141141  {
    142142    weighted_=true;
  • trunk/c++_tools/statistics/Fisher.h

    r556 r616  
    1 // $Id$
    2 
    31#ifndef _theplu_statistics_fisher_
    42#define _theplu_statistics_fisher_
    53
     4// $Id$
     5
    66#include <c++_tools/statistics/Score.h>
    7 #include <c++_tools/gslapi/vector.h>
     7#include <c++_tools/utility/vector.h>
    88
    99#include <cmath>
     
    106106    ///
    107107    double score(const classifier::Target& target,
    108                  const gslapi::vector& value);
     108                 const utility::vector& value);
    109109
    110110    ///
     
    118118    ///
    119119    double score(const classifier::Target& target,
    120                  const gslapi::vector& value,
    121                  const gslapi::vector& weight);
     120                 const utility::vector& value,
     121                 const utility::vector& weight);
    122122
    123123    ///
  • trunk/c++_tools/statistics/FoldChange.cc

    r514 r616  
    3232
    3333  double FoldChange::score(const classifier::Target& target,
    34                            const gslapi::vector& value)
     34                           const utility::vector& value)
    3535  {
    3636    weighted_=false;
     
    5050
    5151  double FoldChange::score(const classifier::Target& target,
    52                            const gslapi::vector& value,
    53                            const gslapi::vector& weight)
     52                           const utility::vector& value,
     53                           const utility::vector& weight)
    5454  {
    5555    weighted_=true;
  • trunk/c++_tools/statistics/FoldChange.h

    r475 r616  
    1 // $Id$
    2 
    31#ifndef _theplu_statistics_foldchange_
    42#define _theplu_statistics_foldchange_
     3
     4// $Id$
    55
    66#include "Score.h"
     
    88namespace theplu {
    99
    10   class gslapi::vector;
     10  class utility::vector;
    1111
    1212
     
    3434    ///
    3535    double score(const classifier::Target& target,
    36                  const gslapi::vector& value);
     36                 const utility::vector& value);
    3737 
    3838    ///
     
    4646    ///
    4747    double score(const classifier::Target& target,
    48                  const gslapi::vector& value,
    49                  const gslapi::vector& weight);
     48                 const utility::vector& value,
     49                 const utility::vector& weight);
    5050 
    5151  private:
  • trunk/c++_tools/statistics/Linear.cc

    r586 r616  
    44
    55#include <c++_tools/statistics/AveragerPair.h>
    6 #include <c++_tools/gslapi/vector.h>
     6#include <c++_tools/utility/vector.h>
    77
    88#include <gsl/gsl_fit.h>
     
    1414
    1515
    16   void Linear::fit(const gslapi::vector& x, const gslapi::vector& y)
     16  void Linear::fit(const utility::vector& x, const utility::vector& y)
    1717  {
    1818    ap_.reset();
  • trunk/c++_tools/statistics/Linear.h

    r586 r616  
    1 // $Id$
    2 
    31#ifndef _theplu_statistics_regression_linear_
    42#define _theplu_statistics_regression_linear_
    53
     4// $Id$
     5
    66#include <c++_tools/statistics/OneDimensional.h>
    7 #include <c++_tools/gslapi/vector.h>
    87
    98#include <cmath>
    109
    1110namespace theplu {
     11  namespace utility {
     12    class vector;
     13  }
    1214namespace statistics { 
    1315namespace regression {
     
    6163    /// construction \f$ \alpha \f$ and \f$ \beta \f$ are independent.
    6264    ///
    63     void fit(const gslapi::vector& x, const gslapi::vector& y) ;
     65    void fit(const utility::vector& x, const utility::vector& y) ;
    6466   
    6567    ///
  • trunk/c++_tools/statistics/LinearWeighted.cc

    r586 r616  
    44
    55#include <c++_tools/statistics/AveragerPairWeighted.h>
    6 #include <c++_tools/gslapi/vector.h>
     6#include <c++_tools/utility/vector.h>
    77
    88#include <gsl/gsl_fit.h>
     
    1414
    1515
    16   void LinearWeighted::fit(const gslapi::vector& x,
    17                            const gslapi::vector& y,
    18                            const gslapi::vector& w)
     16  void LinearWeighted::fit(const utility::vector& x,
     17                           const utility::vector& y,
     18                           const utility::vector& w)
    1919  {
    2020    // AveragerPairWeighted requires 2 weights but works only on the
    2121    // product wx*wy, so we can send in w and a dummie to get what we
    2222    // want.
    23     gslapi::vector dummie(w.size(),1);
     23    utility::vector dummie(w.size(),1);
    2424    AveragerPairWeighted ap;
    2525    ap.add_values(x,y,w,dummie);
  • trunk/c++_tools/statistics/LinearWeighted.h

    r586 r616  
    1 // $Id$
    2 
    31#ifndef _theplu_statistics_regression_linear_weighted_
    42#define _theplu_statistics_regression_linear_weighted_
    53
     4// $Id$
     5
    66#include <c++_tools/statistics/OneDimensionalWeighted.h>
    7 #include <c++_tools/gslapi/vector.h>
    87
    98#include <cmath>
    109
    1110namespace theplu {
    12 namespace statistics { 
     11  namespace utility {
     12    class vector;
     13  }
     14namespace statistics {
    1315namespace regression {
    1416
     
    6365    /// \alpha \f$ and \f$ \beta \f$ are independent.
    6466    ///
    65     void fit(const gslapi::vector& x, const gslapi::vector& y,
    66              const gslapi::vector& w);
     67    void fit(const utility::vector& x, const utility::vector& y,
     68             const utility::vector& w);
    6769   
    6870    ///
  • trunk/c++_tools/statistics/Local.cc

    r586 r616  
    33#include <c++_tools/statistics/Local.h>
    44
    5 #include <c++_tools/gslapi/vector.h>
     5#include <c++_tools/utility/vector.h>
    66#include <c++_tools/statistics/Kernel.h>
    77#include <c++_tools/statistics/OneDimensionalWeighted.h>
     
    2626
    2727    size_t nof_fits=data_.size()/step_size;
    28     x_= gslapi::vector(nof_fits);
    29     y_predicted_ = gslapi::vector(x_.size());
    30     y_err_ = gslapi::vector(x_.size());
     28    x_= utility::vector(nof_fits);
     29    y_predicted_ = utility::vector(x_.size());
     30    y_err_ = utility::vector(x_.size());
    3131    sort(data_.begin(), data_.end());
    3232
    33     // coying data to 2 gslapi vectors ONCE to use views from
    34     gslapi::vector x(data_.size());
    35     gslapi::vector y(data_.size());
     33    // coying data to 2 utility vectors ONCE to use views from
     34    utility::vector x(data_.size());
     35    utility::vector y(data_.size());
    3636    for (size_t j=0; j<x.size(); j++){
    3737      x(j)=data_[j].first;
     
    6969      assert(max_index<data_.size());
    7070                               
    71       gslapi::vector x_local(x, min_index, max_index-min_index+1);
    72       gslapi::vector y_local(y, min_index, max_index-min_index+1);
     71      utility::vector x_local(x, min_index, max_index-min_index+1);
     72      utility::vector y_local(y, min_index, max_index-min_index+1);
    7373
    7474      // calculating weights
    75       gslapi::vector w(max_index-min_index+1);
     75      utility::vector w(max_index-min_index+1);
    7676      for (size_t j=0; j<w.size(); j++)
    7777        w(j) = kernel_->weight( (x_local(j)- x_mid)/width );
  • trunk/c++_tools/statistics/Local.h

    r614 r616  
    1 // $Id$
    2 
    31#ifndef _theplu_statistics_regression_local_
    42#define _theplu_statistics_regression_local_
    53
     4// $Id$
     5
    66#include <c++_tools/statistics/Kernel.h>
    77#include <c++_tools/statistics/OneDimensionalWeighted.h>
    8 #include <c++_tools/gslapi/vector.h>
     8#include <c++_tools/utility/vector.h>
    99
    1010#include <iostream>
     
    5151    /// Function returning predicted values
    5252    ///
    53     inline const gslapi::vector& y_predicted(void) const
     53    inline const utility::vector& y_predicted(void) const
    5454    { return y_predicted_; }
    5555
     
    5757    /// Function returning error of predictions
    5858    ///
    59     inline const gslapi::vector& y_err(void) const { return y_err_; }
     59    inline const utility::vector& y_err(void) const { return y_err_; }
    6060 
    6161    ///
     
    6868    /// @return x-values where fitting was performed.
    6969    ///
    70     inline const gslapi::vector& x(void) const { return x_; }
     70    inline const utility::vector& x(void) const { return x_; }
    7171
    7272  private:
     
    7979    Kernel* kernel_;
    8080    OneDimensionalWeighted* regressor_;
    81     gslapi::vector x_;
    82     gslapi::vector y_predicted_;
    83     gslapi::vector y_err_;
    84 
     81    utility::vector x_;
     82    utility::vector y_predicted_;
     83    utility::vector y_err_;
    8584  };
    8685
  • trunk/c++_tools/statistics/MultiDimensional.cc

    r586 r616  
    22
    33#include <c++_tools/statistics/MultiDimensional.h>
    4 #include <c++_tools/gslapi/matrix.h>
    5 #include <c++_tools/gslapi/vector.h>
     4#include <c++_tools/utility/matrix.h>
     5#include <c++_tools/utility/vector.h>
    66
    77namespace theplu {
     
    1010
    1111
    12   void MultiDimensional::fit(const gslapi::matrix& x, const gslapi::vector& y)
     12  void MultiDimensional::fit(const utility::matrix& x, const utility::vector& y)
    1313  {
    14     covariance_=gslapi::matrix(x.columns(),x.columns());
    15     fit_parameters_=gslapi::vector(x.columns());
     14    covariance_=utility::matrix(x.columns(),x.columns());
     15    fit_parameters_=utility::vector(x.columns());
    1616    if (work_)
    1717      gsl_multifit_linear_free(work_);
     
    2323
    2424
    25   double MultiDimensional::prediction_error(const gslapi::vector& x) const
     25  double MultiDimensional::prediction_error(const utility::vector& x) const
    2626  {
    2727    double s2 = 0;
     
    3535
    3636
    37   double MultiDimensional::standard_error(const gslapi::vector& x) const
     37  double MultiDimensional::standard_error(const utility::vector& x) const
    3838  {
    3939    double s2 = 0;
  • trunk/c++_tools/statistics/MultiDimensional.h

    r586 r616  
    1 // $Id$
    2 
    31#ifndef _theplu_statistics_regression_multidimensional_
    42#define _theplu_statistics_regression_multidimensional_
    53
    6 #include <c++_tools/gslapi/matrix.h>
    7 #include <c++_tools/gslapi/vector.h>
     4// $Id$
     5
     6#include <c++_tools/utility/matrix.h>
     7#include <c++_tools/utility/vector.h>
    88
    99#include <gsl/gsl_multifit.h>
     
    3434    ///
    3535    ///
    36     void fit(const gslapi::matrix& X, const gslapi::vector& y);
     36    void fit(const utility::matrix& X, const utility::vector& y);
    3737
    3838    ///
    3939    ///
    4040    ///
    41     gslapi::vector fit_parameters(void) { return fit_parameters_; }
     41    utility::vector fit_parameters(void) { return fit_parameters_; }
    4242
    4343    ///
    4444    /// @return value in @a x according to fitted model
    4545    ///
    46     inline double predict(const gslapi::vector& x) const
     46    inline double predict(const utility::vector& x) const
    4747    { return fit_parameters_ * x; }
    4848
     
    5050    /// @return expected prediction error for a new data point in @a x
    5151    ///
    52     double prediction_error(const gslapi::vector& x) const;
     52    double prediction_error(const utility::vector& x) const;
    5353
    5454    ///
    5555    /// @return error of model value in @a x
    5656    ///
    57     double standard_error(const gslapi::vector& x) const;
     57    double standard_error(const utility::vector& x) const;
    5858
    5959  private:
    6060    double chisquare_;
    61     gslapi::matrix covariance_;
    62     gslapi::vector fit_parameters_;
     61    utility::matrix covariance_;
     62    utility::vector fit_parameters_;
    6363    gsl_multifit_linear_workspace* work_;
    6464
  • trunk/c++_tools/statistics/MultiDimensionalWeighted.cc

    r586 r616  
    22
    33#include <c++_tools/statistics/MultiDimensionalWeighted.h>
    4 #include <c++_tools/gslapi/matrix.h>
    5 #include <c++_tools/gslapi/vector.h>
     4#include <c++_tools/utility/matrix.h>
     5#include <c++_tools/utility/vector.h>
    66
    77#include <cassert>
     
    1212
    1313
    14   void MultiDimensionalWeighted::fit(const gslapi::matrix& x,
    15                                      const gslapi::vector& y,
    16                                      const gslapi::vector& w)
     14  void MultiDimensionalWeighted::fit(const utility::matrix& x,
     15                                     const utility::vector& y,
     16                                     const utility::vector& w)
    1717  {
    1818    assert(y.size()==w.size());
    1919    assert(x.rows()==y.size());
    2020
    21     covariance_=gslapi::matrix(x.columns(),x.columns());
    22     fit_parameters_=gslapi::vector(x.columns());
     21    covariance_=utility::matrix(x.columns(),x.columns());
     22    fit_parameters_=utility::vector(x.columns());
    2323    if (work_)
    2424      gsl_multifit_linear_free(work_);
     
    2929  }
    3030
    31   double MultiDimensionalWeighted::prediction_error(const gslapi::vector& x,
     31  double MultiDimensionalWeighted::prediction_error(const utility::vector& x,
    3232                                                    const double w) const
    3333  {
     
    4242
    4343
    44   double MultiDimensionalWeighted::standard_error(const gslapi::vector& x) const
     44  double MultiDimensionalWeighted::standard_error(const utility::vector& x) const
    4545  {
    4646    double s2 = 0;
  • trunk/c++_tools/statistics/MultiDimensionalWeighted.h

    r586 r616  
    1 // $Id$
    2 
    31#ifndef _theplu_statistics_regression_multidimensional_weighted_
    42#define _theplu_statistics_regression_multidimensional_weighted_
    53
    6 #include <c++_tools/gslapi/matrix.h>
    7 #include <c++_tools/gslapi/vector.h>
     4// $Id$
     5
     6#include <c++_tools/utility/matrix.h>
     7#include <c++_tools/utility/vector.h>
    88
    99#include <gsl/gsl_multifit.h>
     
    3535    /// @todo doc
    3636    ///
    37     void fit(const gslapi::matrix& X, const gslapi::vector& y,
    38              const gslapi::vector& w);
     37    void fit(const utility::matrix& X, const utility::vector& y,
     38             const utility::vector& w);
    3939
    4040    ///
    4141    /// @return value in @a x according to fitted model
    4242    ///
    43     inline double predict(const gslapi::vector& x) const
     43    inline double predict(const utility::vector& x) const
    4444    { return fit_parameters_ * x; }
    4545
     
    4747    /// @return expected prediction error for a new data point in @a x
    4848    ///
    49     double prediction_error(const gslapi::vector& x, const double w) const;
     49    double prediction_error(const utility::vector& x, const double w) const;
    5050
    5151    ///
    5252    /// @return error of model value in @a x
    5353    ///
    54     double standard_error(const gslapi::vector& x) const;
     54    double standard_error(const utility::vector& x) const;
    5555
    5656    ///
    5757    ///
    5858    ///
    59     gslapi::vector fit_parameters(void) { return fit_parameters_; }
     59    utility::vector fit_parameters(void) { return fit_parameters_; }
    6060
    6161  private:
    6262    double chisquare_;
    63     gslapi::matrix covariance_;
    64     gslapi::vector fit_parameters_;
     63    utility::matrix covariance_;
     64    utility::vector fit_parameters_;
    6565    gsl_multifit_linear_workspace* work_;
    6666
  • trunk/c++_tools/statistics/Naive.cc

    r586 r616  
    66#include <c++_tools/statistics/AveragerWeighted.h>
    77#include <c++_tools/statistics/OneDimensional.h>
    8 #include <c++_tools/gslapi/vector.h>
     8#include <c++_tools/utility/vector.h>
    99
     10#include <cmath>
    1011#include <iostream>
    1112
     
    1617
    1718
    18   void Naive::fit(const gslapi::vector& x, const gslapi::vector& y)
     19  void Naive::fit(const utility::vector& x, const utility::vector& y)
    1920  {
    2021    ap_.reset();
  • trunk/c++_tools/statistics/Naive.h

    r586 r616  
    1 // $Id$
    2 
    31#ifndef _theplu_statistics_regression_naive_
    42#define _theplu_statistics_regression_naive_
    53
     4// $Id$
     5
    66#include <c++_tools/statistics/OneDimensional.h>
    7 
    8 #include <c++_tools/gslapi/vector.h>
    97
    108#include <iostream>
    119#include <utility>
    1210
    13 
    1411namespace theplu {
     12  namespace utility {
     13    class vector;
     14  }
    1515namespace statistics {
    1616namespace regression {
     
    4646    /// weighted version with unity weights.
    4747    ///
    48     void fit(const gslapi::vector& x, const gslapi::vector& y);
     48    void fit(const utility::vector& x, const utility::vector& y);
    4949
    5050    ///
  • trunk/c++_tools/statistics/NaiveWeighted.cc

    r586 r616  
    55#include <c++_tools/statistics/AveragerWeighted.h>
    66#include <c++_tools/statistics/OneDimensional.h>
    7 #include <c++_tools/gslapi/vector.h>
    8 
    9 #include <iostream>
     7#include <c++_tools/utility/vector.h>
    108
    119
     
    1513
    1614
    17   void NaiveWeighted::fit(const gslapi::vector& x,
    18                   const gslapi::vector& y,
    19                   const gslapi::vector& w)
     15  void NaiveWeighted::fit(const utility::vector& x,
     16                  const utility::vector& y,
     17                  const utility::vector& w)
    2018  {
    2119    AveragerWeighted a;
  • trunk/c++_tools/statistics/NaiveWeighted.h

    r586 r616  
    1 // $Id$
    2 
    31#ifndef _theplu_statistics_regression_naive_weighted_
    42#define _theplu_statistics_regression_naive_weighted_
    53
     4// $Id$
     5
    66#include <c++_tools/statistics/OneDimensionalWeighted.h>
    7 
    8 #include <c++_tools/gslapi/vector.h>
    9 //#include <c++_tools/statistics/AveragerPairWeighted.h>
    107
    118#include <cmath>
     
    1512
    1613namespace theplu {
     14  namespace utility {
     15    class vector;
     16  }
    1717namespace statistics {
    1818namespace regression {
     
    4444    /// the inverse of the variance for \f$ y_i \f$
    4545    ///
    46     void fit(const gslapi::vector& x,
    47              const gslapi::vector& y,
    48              const gslapi::vector& w);
     46    void fit(const utility::vector& x,
     47             const utility::vector& y,
     48             const utility::vector& w);
    4949
    5050    ///
  • trunk/c++_tools/statistics/OneDimensional.h

    r586 r616  
    1 // $Id$
    2 
    31#ifndef _theplu_statistics_regression_onedimensioanl_
    42#define _theplu_statistics_regression_onedimensioanl_
     3
     4// $Id$
    55
    66#include <c++_tools/statistics/AveragerPair.h>
     
    99
    1010namespace theplu {
    11 namespace gslapi {
     11namespace utility {
    1212  class vector;
    1313}
     
    4040    /// \sum{(\hat{y_i}-y_i)^2} \f$, where \f$ \hat{y} \f$ is the fitted value.
    4141    ///
    42     virtual void fit(const gslapi::vector& x, const gslapi::vector& y)=0;
     42    virtual void fit(const utility::vector& x, const utility::vector& y)=0;
    4343   
    4444    ///
  • trunk/c++_tools/statistics/OneDimensionalWeighted.h

    r586 r616  
    1 // $Id$
    2 
    31#ifndef _theplu_statistics_regression_onedimensioanlweighted_
    42#define _theplu_statistics_regression_onedimensioanlweighted_
     3
     4// $Id$
    55
    66#include <ostream>
    77
    88namespace theplu {
    9 namespace gslapi {
     9namespace utility {
    1010  class vector;
    1111}
     
    4141    /// to the inverse of the variance for \f$ y_i \f$
    4242    ///
    43     virtual void fit(const gslapi::vector& x, const gslapi::vector& y,
    44                      const gslapi::vector& w)=0;
     43    virtual void fit(const utility::vector& x, const utility::vector& y,
     44                     const utility::vector& w)=0;
    4545
    4646    ///
  • trunk/c++_tools/statistics/Pearson.cc

    r514 r616  
    11// $Id$
    2 
    32
    43#include <c++_tools/statistics/Pearson.h>
    54#include <c++_tools/statistics/AveragerPair.h>
    65#include <c++_tools/statistics/AveragerPairWeighted.h>
    7 #include <c++_tools/gslapi/vector.h>
     6#include <c++_tools/utility/vector.h>
    87#include <c++_tools/classifier/Target.h>
    98
     
    4140
    4241  double Pearson::score(const classifier::Target& target,
    43                         const gslapi::vector& value)
     42                        const utility::vector& value)
    4443  {
    4544    weighted_=false;
     
    6059   
    6160  double Pearson::score(const classifier::Target& target,
    62                         const gslapi::vector& value,
    63                         const gslapi::vector& weight)
     61                        const utility::vector& value,
     62                        const utility::vector& weight)
    6463  {
    6564    weighted_=true;
  • trunk/c++_tools/statistics/Pearson.h

    r597 r616  
    1 // $Id$
    2 
    31#ifndef _theplu_statistics_pearson_
    42#define _theplu_statistics_pearson_
     3
     4// $Id$
    55
    66#include <c++_tools/statistics/Score.h>
    77
    88namespace theplu {
     9namespace utility {
     10  class vector;
     11}
    912namespace classifier {
    1013  class VectorAbstract;
    1114}
    12 
    1315namespace statistics { 
    1416
     
    3941    ///
    4042    double score(const classifier::Target& target,
    41                  const gslapi::vector& value);
     43                 const utility::vector& value);
    4244
    4345    ///
     
    5153    ///
    5254    double score(const classifier::Target& target,
    53                  const gslapi::vector& value,
    54                  const gslapi::vector& weight);
     55                 const utility::vector& value,
     56                 const utility::vector& weight);
    5557
    5658    ///
     
    6870
    6971
    70     //    void centralize(gslapi::vector&, const gslapi::vector&);
     72    //    void centralize(utility::vector&, const utility::vector&);
    7173  };
    7274
  • trunk/c++_tools/statistics/PearsonDistance.cc

    r582 r616  
    55#include <c++_tools/statistics/AveragerPair.h>
    66#include <c++_tools/statistics/AveragerPairWeighted.h>
    7 #include <c++_tools/gslapi/vector.h>
     7#include <c++_tools/utility/vector.h>
    88
    99namespace theplu{
    1010namespace statistics{
    1111
    12   double PearsonDistance::operator()(const gslapi::vector& x,
    13                                      const gslapi::vector& y) const
     12  double PearsonDistance::operator()(const utility::vector& x,
     13                                     const utility::vector& y) const
    1414  {
    1515    AveragerPair ap;
     
    1919
    2020
    21   double PearsonDistance::operator()(const gslapi::vector& x,
    22                                      const gslapi::vector& y,
    23                                      const gslapi::vector& wx,
    24                                      const gslapi::vector& wy) const
     21  double PearsonDistance::operator()(const utility::vector& x,
     22                                     const utility::vector& y,
     23                                     const utility::vector& wx,
     24                                     const utility::vector& wy) const
    2525  {
    2626    AveragerPairWeighted ap;
  • trunk/c++_tools/statistics/PearsonDistance.h

    r582 r616  
    1 // $Id$
    2 
    31#ifndef _theplu_statistics_pearson_distance_
    42#define _theplu_statistics_pearson_distance_
     3
     4// $Id$
    55
    66#include <c++_tools/statistics/Distance.h>
     
    88namespace theplu{
    99 
    10   namespace gslapi {
     10  namespace utility {
    1111    class vector;
    1212  }
     
    4040    using Distance::operator();
    4141
    42     virtual double operator()(const gslapi::vector& x,
    43                               const gslapi::vector& y) const;
     42    virtual double operator()(const utility::vector& x,
     43                              const utility::vector& y) const;
    4444
    4545
    46     virtual double operator()(const gslapi::vector& x,
    47                               const gslapi::vector& y,
    48                               const gslapi::vector& wx,
    49                               const gslapi::vector& wy) const;
     46    virtual double operator()(const utility::vector& x,
     47                              const utility::vector& y,
     48                              const utility::vector& wx,
     49                              const utility::vector& wy) const;
    5050
    5151  private:
  • trunk/c++_tools/statistics/Polynomial.cc

    r586 r616  
    22
    33#include <c++_tools/statistics/Polynomial.h>
    4 #include <c++_tools/gslapi/matrix.h>
    5 #include <c++_tools/gslapi/vector.h>
     4#include <c++_tools/utility/matrix.h>
     5#include <c++_tools/utility/vector.h>
    66
    77namespace theplu {
     
    1010
    1111
    12   void Polynomial::fit(const gslapi::vector& x, const gslapi::vector& y)
     12  void Polynomial::fit(const utility::vector& x, const utility::vector& y)
    1313  {
    14     gslapi::matrix X=gslapi::matrix(x.size(),power_+1,1);
     14    utility::matrix X=utility::matrix(x.size(),power_+1,1);
    1515    for (size_t i=0; i<X.rows(); ++i)
    1616      for (u_int j=1; j<X.columns(); j++)
     
    2121  double Polynomial::predict(const double x) const
    2222  {
    23     gslapi::vector vec(power_+1,1);
     23    utility::vector vec(power_+1,1);
    2424    for (size_t i=1; i<=power_; ++i)
    2525      vec(i) = vec(i-1)*x;
     
    2929  double Polynomial::prediction_error(const double x) const
    3030  {
    31     gslapi::vector vec(power_+1,1);
     31    utility::vector vec(power_+1,1);
    3232    for (size_t i=1; i<=power_; ++i)
    3333      vec(i) = vec(i-1)*x;
     
    3737  double Polynomial::standard_error(const double x) const
    3838  {
    39     gslapi::vector vec(power_+1,1);
     39    utility::vector vec(power_+1,1);
    4040    for (size_t i=1; i<=power_; ++i)
    4141      vec(i) = vec(i-1)*x;
  • trunk/c++_tools/statistics/Polynomial.h

    r586 r616  
    1 // $Id$
    2 
    31#ifndef _theplu_statistics_regression_polynomial_
    42#define _theplu_statistics_regression_polynomial_
     3
     4// $Id$
    55
    66#include <c++_tools/statistics/OneDimensional.h>
    77#include <c++_tools/statistics/MultiDimensional.h>
    88
    9 #include <c++_tools/gslapi/vector.h>
     9#include <c++_tools/utility/vector.h>
    1010
    1111#include <gsl/gsl_multifit.h>
     
    3939    ///
    4040    ///
    41     void fit(const gslapi::vector& x, const gslapi::vector& y);
     41    void fit(const utility::vector& x, const utility::vector& y);
    4242
    4343    ///
    4444    ///
    4545    ///
    46     gslapi::vector fit_parameters(void) { return md_.fit_parameters(); }
     46    utility::vector fit_parameters(void) { return md_.fit_parameters(); }
    4747
    4848    ///
  • trunk/c++_tools/statistics/PolynomialWeighted.cc

    r586 r616  
    22
    33#include <c++_tools/statistics/PolynomialWeighted.h>
    4 #include <c++_tools/gslapi/matrix.h>
    5 #include <c++_tools/gslapi/vector.h>
     4#include <c++_tools/utility/matrix.h>
     5#include <c++_tools/utility/vector.h>
    66
    77#include <cassert>
     
    1212
    1313
    14   void PolynomialWeighted::fit(const gslapi::vector& x, const gslapi::vector& y,
    15                                const gslapi::vector& w)
     14  void PolynomialWeighted::fit(const utility::vector& x,
     15                               const utility::vector& y,
     16                               const utility::vector& w)
    1617  {
    1718    assert(x.size()==y.size());
    1819    assert(y.size()==w.size());
    19     gslapi::matrix X=gslapi::matrix(x.size(),power_+1,1);
     20    utility::matrix X=utility::matrix(x.size(),power_+1,1);
    2021    for (size_t i=0; i<X.rows(); ++i)
    2122      for (u_int j=1; j<X.columns(); j++)
     
    2627  double PolynomialWeighted::predict(const double x) const
    2728  {
    28     gslapi::vector vec(power_+1,1);
     29    utility::vector vec(power_+1,1);
    2930    for (size_t i=1; i<=power_; ++i)
    3031      vec(i) = vec(i-1)*x;
     
    3536                                              const double w) const
    3637  {
    37     gslapi::vector vec(power_+1,1);
     38    utility::vector vec(power_+1,1);
    3839    for (size_t i=1; i<=power_; ++i)
    3940      vec(i) = vec(i-1)*x;
     
    4344  double PolynomialWeighted::standard_error(const double x) const
    4445  {
    45     gslapi::vector vec(power_+1,1);
     46    utility::vector vec(power_+1,1);
    4647    for (size_t i=1; i<=power_; ++i)
    4748      vec(i) = vec(i-1)*x;
  • trunk/c++_tools/statistics/PolynomialWeighted.h

    r586 r616  
    1 // $Id$
    2 
    31#ifndef _theplu_statistics_regression_polynomial_weighted_
    42#define _theplu_statistics_regression_polynomial_weighted_
     3
     4// $Id$
    55
    66#include <c++_tools/statistics/OneDimensionalWeighted.h>
    77#include <c++_tools/statistics/MultiDimensionalWeighted.h>
    88
    9 #include <c++_tools/gslapi/vector.h>
     9#include <c++_tools/utility/vector.h>
    1010
    1111//#include <gsl/gsl_multifit.h>
     
    4343    /// y_i \f$
    4444    ///
    45     void fit(const gslapi::vector& x, const gslapi::vector& y,
    46              const gslapi::vector& w);
     45    void fit(const utility::vector& x, const utility::vector& y,
     46             const utility::vector& w);
    4747
    4848    ///
    4949    /// @return parameters for polynomial model
    5050    ///
    51     gslapi::vector fit_parameters(void) { return md_.fit_parameters(); }
     51    utility::vector fit_parameters(void) { return md_.fit_parameters(); }
    5252
    5353    ///
  • trunk/c++_tools/statistics/ROC.cc

    r514 r616  
    33#include <c++_tools/statistics/ROC.h>
    44#include <c++_tools/utility/stl_utility.h>
    5 #include <c++_tools/gslapi/vector.h>
     5#include <c++_tools/utility/vector.h>
    66
    77#include <gsl/gsl_cdf.h>
     
    1313
    1414namespace theplu {
    15   class gslapi::vector;
    1615namespace statistics { 
    1716
     
    6766
    6867  double ROC::score(const classifier::Target& target,
    69                     const gslapi::vector& value)
     68                    const utility::vector& value)
    7069  {
    7170    assert(target.size()==value.size());
     
    101100  // Peter, should be possible to do this in NlogN
    102101  double ROC::score(const classifier::Target& target,
    103                     const gslapi::vector& value,
    104                     const gslapi::vector& weight)
     102                    const utility::vector& value,
     103                    const utility::vector& weight)
    105104  {
    106105    weighted_=true;
  • trunk/c++_tools/statistics/ROC.h

    r589 r616  
    1 // $Id$
    2 
    31#ifndef _theplu_statistics_roc_
    42#define _theplu_statistics_roc_
     3
     4// $Id$
    55
    66#include <c++_tools/classifier/Target.h>
     
    1111
    1212namespace theplu {
     13  namespace utility {
     14    class vector;
     15  }
    1316namespace statistics { 
    1417
     
    4245    ///
    4346    double score(const classifier::Target& target,
    44                  const gslapi::vector& value);
     47                 const utility::vector& value);
    4548   
    4649    /// Function taking values, target, weight and a vector defining
     
    5659    ///
    5760    double score(const classifier::Target& target,
    58                  const gslapi::vector& value,
    59                  const gslapi::vector& weight);
     61                 const utility::vector& value,
     62                 const utility::vector& weight);
    6063       
    6164
  • trunk/c++_tools/statistics/SNR.cc

    r560 r616  
    1212
    1313  SNR::SNR(bool b)
    14     : Score(b),  score_(0)
     14    : Score(b), score_(0)
    1515  {
    1616  }
    1717
    1818  double SNR::score(const classifier::Target& target,
    19                        const gslapi::vector& value)
     19                    const utility::vector& value)
    2020  {
    2121    weighted_=false;
     
    3939
    4040  double SNR::score(const classifier::Target& target,
    41                        const gslapi::vector& value,
    42                        const gslapi::vector& weight)
     41                    const utility::vector& value,
     42                    const utility::vector& weight)
    4343  {
    4444    weighted_=true;
  • trunk/c++_tools/statistics/SNR.h

    r532 r616  
    1 // $Id$
    2 
    31#ifndef _theplu_statistics_snr
    42#define _theplu_statistics_snr
    53
    6 // C++ tools include
    7 /////////////////////
     4// $Id$
     5
    86#include <c++_tools/statistics/Score.h>
    9 #include <c++_tools/gslapi/vector.h>
    107
    118#include <gsl/gsl_cdf.h>
    129
    13 
    1410namespace theplu {
     11  namespace utility {
     12    class vector;
     13  }
    1514namespace statistics { 
    1615
     
    3938    ///
    4039    double score(const classifier::Target& target,
    41                  const gslapi::vector& value);
     40                 const utility::vector& value);
    4241
    4342    ///
     
    4645    ///
    4746    double score(const classifier::Target& target,
    48                  const gslapi::vector& value,
    49                  const gslapi::vector& weight);         
     47                 const utility::vector& value,
     48                 const utility::vector& weight);         
    5049  private:
    5150    double score_;
  • trunk/c++_tools/statistics/Score.h

    r581 r616  
    1 // $Id$
    2 
    31#ifndef _theplu_statistics_score_
    42#define _theplu_statistics_score_
    53
     4// $Id$
     5
    66#include <c++_tools/classifier/utility.h>
    7 #include <c++_tools/gslapi/vector.h>
     7#include <c++_tools/utility/vector.h>
    88
    99#include <cassert>
     
    5151    virtual double
    5252    score(const classifier::Target& target,
    53           const gslapi::vector& value) = 0;
     53          const utility::vector& value) = 0;
    5454 
    5555    ///
     
    6969    {
    7070      assert(target.size()==value.size());
    71       gslapi::vector a;
     71      utility::vector a;
    7272      classifier::convert(value,a);
    7373      return score(target,a);
     
    8383    virtual double
    8484    score(const classifier::Target& target,
    85           const gslapi::vector& value,
    86           const gslapi::vector& weight) = 0;
     85          const utility::vector& value,
     86          const utility::vector& weight) = 0;
    8787
    8888    ///
     
    9898          const classifier::DataLookup1D& weight)
    9999    {
    100       gslapi::vector a;
     100      utility::vector a;
    101101      classifier::convert(value,a);
    102       gslapi::vector b;
     102      utility::vector b;
    103103      classifier::convert(weight,a);
    104104      return score(target,a,b);
  • trunk/c++_tools/statistics/WilcoxonFoldChange.cc

    r502 r616  
    44#include <c++_tools/statistics/utility.h>
    55#include <c++_tools/classifier/Target.h>
    6 #include <c++_tools/gslapi/vector.h>
    76
    87#include <cmath>
     
    2221
    2322  double WilcoxonFoldChange::score(const classifier::Target& target,
    24                                    const gslapi::vector& value)
     23                                   const utility::vector& value)
    2524  {
    2625    std::vector<double> distance;
     
    4039
    4140  double WilcoxonFoldChange::score(const classifier::Target& target,
    42                                    const gslapi::vector& value,
    43                                    const gslapi::vector& weight)
     41                                   const utility::vector& value,
     42                                   const utility::vector& weight)
    4443  {
    4544    std::cerr << " WilcoxonFoldChange::score  not implemented" << std::endl;
  • trunk/c++_tools/statistics/WilcoxonFoldChange.h

    r475 r616  
    1 // $Id$
    2 
    31#ifndef _theplu_statistics_wilcoxonfoldchange_
    42#define _theplu_statistics_wilcoxonfoldchange_
     3
     4// $Id$
    55
    66#include <c++_tools/statistics/Score.h>
    77
    88namespace theplu {
     9  namespace utility {
     10    class vector;
     11  }
    912namespace statistics {
    1013
     
    3033    ///
    3134    double score(const classifier::Target& target,
    32                  const gslapi::vector& value);
     35                 const utility::vector& value);
    3336 
    3437    ///
     
    4346    ///
    4447    double score(const classifier::Target& target,
    45                  const gslapi::vector& value,
    46                  const gslapi::vector& weight);
     48                 const utility::vector& value,
     49                 const utility::vector& weight);
    4750 
    4851  private:
  • trunk/c++_tools/statistics/tScore.cc

    r589 r616  
    2020
    2121  double tScore::score(const classifier::Target& target,
    22                        const gslapi::vector& value)
     22                       const utility::vector& value)
    2323  {
    2424    weighted_=false;
     
    4343
    4444  double tScore::score(const classifier::Target& target,
    45                        const gslapi::vector& value,
    46                        const gslapi::vector& weight)
     45                       const utility::vector& value,
     46                       const utility::vector& weight)
    4747  {
    4848    weighted_=true;
  • trunk/c++_tools/statistics/tScore.h

    r597 r616  
     1#ifndef _theplu_statistics_tscore_
     2#define _theplu_statistics_tscore_
     3
    14// $Id$
    2 
    3 #ifndef _theplu_statistics_t_score_
    4 #define _theplu_statistics_t_score_
    55
    66// C++ tools include
    77/////////////////////
    88#include <c++_tools/statistics/Score.h>
    9 #include <c++_tools/gslapi/vector.h>
    109
    1110#include <gsl/gsl_cdf.h>
     
    1312
    1413namespace theplu {
     14  namespace utility {
     15    class vector;
     16  }
    1517namespace statistics { 
    1618
     
    4446    ///
    4547    double score(const classifier::Target& target,
    46                  const gslapi::vector& value);
     48                 const utility::vector& value);
    4749
    4850    ///
     
    6062    ///
    6163    double score(const classifier::Target& target,
    62                  const gslapi::vector& value,
    63                  const gslapi::vector& weight);
     64                 const utility::vector& value,
     65                 const utility::vector& weight);
    6466
    6567    ///
  • trunk/c++_tools/statistics/utility.cc

    r511 r616  
    1818  }
    1919
    20   double median(const gslapi::vector& vec, const bool sorted)
     20  double median(const utility::vector& vec, const bool sorted)
    2121  {
    2222    if (!sorted){
    23       gslapi::vector vec_copy(vec);
     23      utility::vector vec_copy(vec);
    2424      vec_copy.sort();
    2525      return gsl_stats_median_from_sorted_data (vec_copy.gsl_vector_p()->data,
     
    3232  }
    3333
    34   double percentile(const gslapi::vector& vec, const double p,
     34  double percentile(const utility::vector& vec, const double p,
    3535                    const bool sorted)
    3636  {
    3737    if (!sorted){
    38       gslapi::vector vec_c(vec);
     38      utility::vector vec_c(vec);
    3939      vec_c.sort();
    4040      return gsl_stats_quantile_from_sorted_data(vec_c.gsl_vector_p()->data,
  • trunk/c++_tools/statistics/utility.h

    r588 r616  
    1 // $Id$
    2 
    31#ifndef _theplu_statistics_utility_
    42#define _theplu_statistics_utility_
    53
    6 #include <c++_tools/gslapi/vector.h>
     4// $Id$
     5
     6#include <c++_tools/utility/vector.h>
    77
    88#include <algorithm>
     
    4141  /// distribution.
    4242  ///
    43   inline double kurtosis(const gslapi::vector& v)
     43  inline double kurtosis(const utility::vector& v)
    4444  {
    4545    const gsl_vector* gvp=v.gsl_vector_p();
     
    7272  /// @return median
    7373  ///
    74   double median(const gslapi::vector& vec, const bool sorted=false);
     74  double median(const utility::vector& vec, const bool sorted=false);
    7575
    7676  ///
     
    122122  /// @return \a p'th percentile
    123123  ///
    124   double percentile(const gslapi::vector& vec, const double,
     124  double percentile(const utility::vector& vec, const double,
    125125                    const bool sorted=false);
    126126
     
    129129  /// measures the asymmetry of the tails of a distribution.
    130130  ///
    131   inline double skewness(const gslapi::vector& v)
     131  inline double skewness(const utility::vector& v)
    132132  {
    133133    const gsl_vector* gvp=v.gsl_vector_p();
  • trunk/c++_tools/utility/Alignment.cc

    r301 r616  
    22
    33#include <c++_tools/utility/Alignment.h>
    4 #include <c++_tools/gslapi/matrix.h>
     4#include <c++_tools/utility/matrix.h>
    55
    66#include <utility>
     
    1111namespace alignment {
    1212
    13   double NeedlemanWunsch(const gslapi::matrix& s,
     13  double NeedlemanWunsch(const utility::matrix& s,
    1414                         std::vector<std::pair<size_t, size_t> >& path,
    1515                         const double gap)
    1616  {
    17     gslapi::matrix m(s.rows()+1,s.columns()+1);
     17    utility::matrix m(s.rows()+1,s.columns()+1);
    1818    // Init upper and left border of matrix
    1919    for (size_t i=1; i<m.rows(); i++)
     
    2323    // choice(i,j) tells us how we came to s(i,j). 1 is diagonal, 2
    2424    // vertical, and 3 horizontal,
    25     gslapi::matrix choice(m.rows(),m.columns());
     25    utility::matrix choice(m.rows(),m.columns());
    2626
    2727    // Calculating NeedlemanWunsch matrix
  • trunk/c++_tools/utility/Alignment.h

    r304 r616  
    1 // $Id$
    2 
    31#ifndef _theplu_utility_alignment_
    42#define _theplu_utility_alignment_
     3
     4// $Id$
    55
    66#include <utility>
     
    99namespace theplu {
    1010
    11 namespace gslapi {
     11namespace utility {
    1212  class matrix;
    1313}
     
    3636  /// @return the global maximum alignment score.
    3737  ///
    38   double NeedlemanWunsch(const gslapi::matrix& s,
     38  double NeedlemanWunsch(const utility::matrix& s,
    3939                         std::vector<std::pair<size_t, size_t> >& path,
    4040                         const double gap);
  • trunk/c++_tools/utility/Makefile.am

    r594 r616  
    2626noinst_LTLIBRARIES = libutility.la
    2727libutility_la_SOURCES = \
    28   Alignment.cc CommandLine.cc FileIO.cc kNNI.cc NNI.cc Option.cc PCA.cc \
    29   stl_utility.cc SVD.cc utility.cc WeNNI.cc
     28  Alignment.cc CommandLine.cc FileIO.cc kNNI.cc matrix.cc NNI.cc        \
     29  Option.cc PCA.cc stl_utility.cc SVD.cc utility.cc vector.cc WeNNI.cc
     30
    3031
    3132include_utilitydir = $(includedir)/c++_tools/utility
    3233
    3334include_utility_HEADERS = \
    34   Alignment.h CommandLine.h Exception.h FileIO.h kNNI.h NNI.h Option.h PCA.h \
    35   stl_utility.h SVD.h utility.h WeNNI.h
     35  Alignment.h CommandLine.h Exception.h FileIO.h kNNI.h matrix.h NNI.h  \
     36  Option.h PCA.h stl_utility.h SVD.h utility.h vector.h WeNNI.h
  • trunk/c++_tools/utility/NNI.cc

    r570 r616  
    3737namespace utility {
    3838
    39   using namespace std;
    40 
    4139  // For a discussion and motivation for various algorithm
    4240  // implementations here see the paper cited in the class definition
    4341  // documentation.
    44   NNI::NNI(const gslapi::matrix& matrix,const gslapi::matrix& weight,
     42  NNI::NNI(const utility::matrix& matrix,const utility::matrix& weight,
    4543           const u_int neighbours)
    4644    : data_(matrix), imputed_data_(matrix), neighbours_(neighbours),
     
    5351  //                {\sum_{k=l,C} w_{ik} w_{jk} }
    5452  // where C is the number of columns
    55   vector<pair<u_int,double> > NNI::calculate_distances(const u_int row) const
     53  std::vector<std::pair<u_int,double> >
     54  NNI::calculate_distances(const u_int row) const
    5655  {
    57     vector<pair<u_int,double> > distance;
     56    std::vector<std::pair<u_int,double> > distance;
    5857    for (size_t i=0; i<data_.rows(); i++)
    5958      if (i!=row) {
    6059        double contribs=0;
    61         pair<u_int,double> this_distance(i,0.0);
     60        std::pair<u_int,double> this_distance(i,0.0);
    6261        for (size_t j=0; j<data_.columns(); j++)
    6362          // 0 contribution for missing values
     
    8281  // number, and neighbours are disqualified if their element (column)
    8382  // weight is zero
    84   vector<u_int>
     83  std::vector<u_int>
    8584  NNI::nearest_neighbours(const u_int column,
    86                           const vector<pair<u_int,double> >& d) const
     85                          const std::vector<std::pair<u_int,double> >& d) const
    8786  {
    88     vector<u_int> index;
     87    std::vector<u_int> index;
    8988    double contribs=0;
    9089    for (u_int i=0; ((i<d.size()) &&
  • trunk/c++_tools/utility/NNI.h

    r570 r616  
     1#ifndef _theplu_utility_nni_
     2#define _theplu_utility_nni_
     3
    14// $Id$
    25
     
    2528*/
    2629
    27 #ifndef _theplu_utility_nni_
    28 #define _theplu_utility_nni_
    29 
    3030#include <iostream>
    3131#include <utility>
    3232#include <vector>
    3333
    34 #include <c++_tools/gslapi/matrix.h>
     34#include <c++_tools/utility/matrix.h>
    3535
    3636namespace theplu {
     
    8888    /// algorithms.
    8989    ///
    90     NNI(const gslapi::matrix& matrix,const gslapi::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 gslapi::matrix& imputed_data(void) const { return imputed_data_; }
     105    const utility::matrix& imputed_data(void) const { return imputed_data_; }
    106106
    107107    ///
     
    115115                             const std::vector<std::pair<u_int,double> >&) const;
    116116
    117     const gslapi::matrix& data_;
    118     gslapi::matrix imputed_data_;
     117    const utility::matrix& data_;
     118    utility::matrix imputed_data_;
    119119    u_int neighbours_;
    120120    std::vector<size_t> not_imputed_;
    121     const gslapi::matrix& weight_;
     121    const utility::matrix& weight_;
    122122  };
    123123
  • trunk/c++_tools/utility/PCA.cc

    r420 r616  
    1010
    1111namespace theplu {
    12 namespace utility { 
     12namespace utility {
    1313
    1414
    15 void PCA::process()
    16 {
    17   process_ = true;
    18   // Row-center the data matrix
    19   gslapi::matrix A_center( A_.rows(), A_.columns() );
    20   this->row_center( A_center );
    21  
     15  void PCA::process(void)
     16  {
     17    process_ = true;
     18    // Row-center the data matrix
     19    utility::matrix A_center( A_.rows(), A_.columns() );
     20    this->row_center( A_center );
    2221
    23   // Single value decompose the data matrix
    24   std::auto_ptr<SVD> pSVD( new SVD( A_center ) );
    25   pSVD->decompose();
    26   gslapi::matrix U = pSVD->U();
    27   gslapi::matrix V = pSVD->V();
     22    // Single value decompose the data matrix
     23    std::auto_ptr<SVD> pSVD( new SVD( A_center ) );
     24    pSVD->decompose();
     25    utility::matrix U = pSVD->U();
     26    utility::matrix V = pSVD->V();
    2827
    29   // Read the eigenvectors and eigenvalues
    30   eigenvectors_ = U;
    31   eigenvectors_ .transpose();
    32   eigenvalues_ = pSVD->s();
     28    // Read the eigenvectors and eigenvalues
     29    eigenvectors_ = U;
     30    eigenvectors_ .transpose();
     31    eigenvalues_ = pSVD->s();
    3332
    34   // T
    35   for( size_t i = 0; i < eigenvalues_.size(); ++i )
    36     {
    37      eigenvalues_[ i ] = eigenvalues_[ i ]*eigenvalues_[ i ];
    38     }
     33    // T
     34    for( size_t i = 0; i < eigenvalues_.size(); ++i )
     35      eigenvalues_[ i ] = eigenvalues_[ i ]*eigenvalues_[ i ];
     36    eigenvalues_ *= 1.0/A_center.rows();
    3937
    40   eigenvalues_ *= 1.0/A_center.rows(); 
    41  
    42   // Sort the eigenvectors in order of eigenvalues
    43   // Simple (not efficient) algorithm that always
    44   // make sure that the i:th element is in its correct
    45   // position (N element --> Ordo( N*N ))
    46   for ( size_t i = 0; i < eigenvalues_.size(); ++i )
    47     for ( size_t j = i + 1; j < eigenvalues_.size(); ++j )
    48       if ( eigenvalues_[ j ] > eigenvalues_[ i ] ) {
    49         std::swap( eigenvalues_[ i ], eigenvalues_[ j ] );
    50         eigenvectors_.swap_rows(i,j);
    51       }
    52 }
     38    // Sort the eigenvectors in order of eigenvalues
     39    // Simple (not efficient) algorithm that always
     40    // make sure that the i:th element is in its correct
     41    // position (N element --> Ordo( N*N ))
     42    for ( size_t i = 0; i < eigenvalues_.size(); ++i )
     43      for ( size_t j = i + 1; j < eigenvalues_.size(); ++j )
     44        if ( eigenvalues_[ j ] > eigenvalues_[ i ] ) {
     45          std::swap( eigenvalues_[ i ], eigenvalues_[ j ] );
     46          eigenvectors_.swap_rows(i,j);
     47        }
     48  }
    5349
    5450
     51  void PCA::process_transposed_problem(void)
     52  {
     53    process_ = true;
     54    // Row-center the data matrix
     55    utility::matrix A_center( A_.rows(), A_.columns() );
     56    this->row_center( A_center );
    5557
    56 void PCA::process_transposed_problem()
    57 {
    58   process_ = true;
    59   // Row-center the data matrix
    60   gslapi::matrix A_center( A_.rows(), A_.columns() );
    61   this->row_center( A_center );
     58    // Transform into SVD friendly dimension
     59    A_.transpose();
     60    A_center.transpose();
    6261
    63   // Transform into SVD friendly dimension
    64   ////////////////////////////////////////
    65   A_.transpose();
    66   A_center.transpose();
     62    // Single value decompose the data matrix
     63    std::auto_ptr<SVD> pSVD( new SVD( A_center ) );
     64    pSVD->decompose();
     65    utility::matrix U = pSVD->U();
     66    utility::matrix V = pSVD->V();
    6767
    68   // Single value decompose the data matrix
    69   std::auto_ptr<SVD> pSVD( new SVD( A_center ) );
    70   pSVD->decompose();
    71   gslapi::matrix U = pSVD->U();
    72   gslapi::matrix V = pSVD->V();
     68    // Read the eigenvectors and eigenvalues
     69    eigenvectors_=V;
     70    eigenvectors_.transpose();
     71    eigenvalues_ = pSVD->s();
    7372
    74   // Read the eigenvectors and eigenvalues
    75   eigenvectors_=V;
    76   eigenvectors_.transpose();
    77   eigenvalues_ = pSVD->s();
     73    // Transform back when done with SVD!
     74    // (used V insted of U now for eigenvectors)
     75    A_.transpose();
     76    A_center.transpose();
    7877
    79   // Transform back when done with SVD!
    80   // (used V insted of U now for eigenvectors)
    81   ////////////////////////////////////////////
    82   A_.transpose();
    83   A_center.transpose();
     78    // T
     79    for( size_t i = 0; i < eigenvalues_.size(); ++i )
     80      eigenvalues_[ i ] = eigenvalues_[ i ]*eigenvalues_[ i ];
     81    eigenvalues_ *= 1.0/A_center.rows();
    8482
    85   // T
    86   for( size_t i = 0; i < eigenvalues_.size(); ++i )
    87     {
    88      eigenvalues_[ i ] = eigenvalues_[ i ]*eigenvalues_[ i ];
    89     }
    90 
    91   eigenvalues_ *= 1.0/A_center.rows(); 
    92  
    93   // Sort the eigenvectors in order of eigenvalues
    94   // Simple (not efficient) algorithm that always
    95   // make sure that the i:th element is in its correct
    96   // position (N element --> Ordo( N*N ))
    97   for ( size_t i = 0; i < eigenvalues_.size(); ++i )
    98     for ( size_t j = i + 1; j < eigenvalues_.size(); ++j )
    99       if ( eigenvalues_[ j ] > eigenvalues_[ i ] ) {
    100         std::swap( eigenvalues_[ i ], eigenvalues_[ j ] );
    101         eigenvectors_.swap_rows(i,j);
    102       }
    103 }
     83    // Sort the eigenvectors in order of eigenvalues
     84    // Simple (not efficient) algorithm that always
     85    // make sure that the i:th element is in its correct
     86    // position (N element --> Ordo( N*N ))
     87    for ( size_t i = 0; i < eigenvalues_.size(); ++i )
     88      for ( size_t j = i + 1; j < eigenvalues_.size(); ++j )
     89        if ( eigenvalues_[ j ] > eigenvalues_[ i ] ) {
     90          std::swap( eigenvalues_[ i ], eigenvalues_[ j ] );
     91          eigenvectors_.swap_rows(i,j);
     92        }
     93  }
    10494
    10595
    106 
    107 // This function will row-center the matrix A_,
    108 // that is, A_ = A_ - M, where M is a matrix
    109 // with the meanvalues of each row
    110 void PCA::row_center( gslapi::matrix& A_center )
    111 {
    112   meanvalues_ = gslapi::vector( A_.rows() );
    113   gslapi::vector A_row_sum(A_.rows());
    114   for (size_t i=0; i<A_row_sum.size(); ++i)
    115     A_row_sum(i)=gslapi::vector(A_,i).sum();
    116   for( size_t i = 0; i < A_center.rows(); ++i )
    117     {
    118      meanvalues_[i] = A_row_sum(i) / static_cast<double>(A_.columns());
    119      for( size_t j = 0; j < A_center.columns(); ++j )
    120        A_center(i,j) = A_(i,j) - meanvalues_(i);
    121     }
    122 }
     96  // This function will row-center the matrix A_,
     97  // that is, A_ = A_ - M, where M is a matrix
     98  // with the meanvalues of each row
     99  void PCA::row_center(utility::matrix& A_center)
     100  {
     101    meanvalues_ = utility::vector( A_.rows() );
     102    utility::vector A_row_sum(A_.rows());
     103    for (size_t i=0; i<A_row_sum.size(); ++i)
     104      A_row_sum(i)=utility::vector(A_,i).sum();
     105    for( size_t i = 0; i < A_center.rows(); ++i ) {
     106      meanvalues_[i] = A_row_sum(i) / static_cast<double>(A_.columns());
     107      for( size_t j = 0; j < A_center.columns(); ++j )
     108        A_center(i,j) = A_(i,j) - meanvalues_(i);
     109    }
     110  }
    123111
    124112
     113  utility::matrix PCA::projection(const utility::matrix& samples ) const
     114  {
     115    const size_t Ncol = samples.columns();
     116    const size_t Nrow = samples.rows();
     117    utility::matrix projs( Ncol, Ncol );
    125118
    126 gslapi::matrix PCA::projection( const gslapi::matrix&
    127               samples ) const
    128 {
    129   const size_t Ncol = samples.columns();
    130   const size_t Nrow = samples.rows();
    131   gslapi::matrix projs( Ncol, Ncol );
    132  
    133   gslapi::vector temp(samples.rows());
    134   for( size_t j = 0; j < Ncol; ++j )
    135     {
     119    utility::vector temp(samples.rows());
     120    for( size_t j = 0; j < Ncol; ++j ) {
    136121      for (size_t i=0; i<Ncol; ++i )
    137         temp(i) = samples(i,j);   
    138      gslapi::vector centered( Nrow );
    139 
    140      for( size_t i = 0; i < Nrow; ++i )
    141        centered(i) = temp(i) - meanvalues_(i);
    142 
    143      gslapi::vector proj( eigenvectors_ * centered );
    144       for( size_t i = 0; i < Ncol; ++i )
     122        temp(i) = samples(i,j);
     123      utility::vector centered( Nrow );
     124      for( size_t i = 0; i < Nrow; ++i )
     125        centered(i) = temp(i) - meanvalues_(i);
     126      utility::vector proj( eigenvectors_ * centered );
     127      for( size_t i = 0; i < Ncol; ++i )
    145128        projs(i,j)=proj(i);
    146     } 
    147   return projs;
    148 }
     129    }
     130    return projs;
     131  }
    149132
    150133
     134  utility::matrix
     135  PCA::projection_transposed(const utility::matrix& samples) const
     136  {
     137    const size_t Ncol = samples.columns();
     138    const size_t Nrow = samples.rows();
     139    utility::matrix projs( Nrow, Ncol );
    151140
    152 gslapi::matrix PCA::projection_transposed( const gslapi::matrix&
    153              samples ) const
    154 {
    155   const size_t Ncol = samples.columns();
    156   const size_t Nrow = samples.rows();
    157   gslapi::matrix projs( Nrow, Ncol );
    158  
    159   gslapi::vector temp(samples.rows());
    160   for( size_t j = 0; j < Ncol; ++j )
    161     {
     141    utility::vector temp(samples.rows());
     142    for( size_t j = 0; j < Ncol; ++j ) {
    162143      for (size_t i=0; i<Ncol; ++i )
    163         temp(i) = samples(i,j);   
    164      gslapi::vector centered( Nrow );
    165 
    166      for( size_t i = 0; i < Nrow; ++i )
    167        centered(i)=temp(i)-meanvalues_(i);
    168 
    169      gslapi::vector proj( eigenvectors_ * centered );
    170      for( size_t i = 0; i < Nrow; ++i )
    171        projs(i,j)=proj(i);
    172     }
    173   return projs;
    174 }
     144        temp(i) = samples(i,j);
     145      utility::vector centered( Nrow );
     146      for( size_t i = 0; i < Nrow; ++i )
     147        centered(i)=temp(i)-meanvalues_(i);
     148      utility::vector proj( eigenvectors_ * centered );
     149      for( size_t i = 0; i < Nrow; ++i )
     150        projs(i,j)=proj(i);
     151    }
     152    return projs;
     153  }
    175154
    176155
    177 
    178 void PCA::calculate_explained_intensity()
    179 {
    180   size_t DIM = eigenvalues_.size();
    181   explained_intensity_ = gslapi::vector( DIM );
    182   double sum = 0;
    183   for( size_t i = 0; i < DIM; ++i )
    184     {
    185      sum += eigenvalues_[ i ];
    186     }
    187   double exp_sum = 0;
    188   for( size_t i = 0; i < DIM; ++i )
    189     {
    190      exp_sum += eigenvalues_[ i ];
    191      explained_intensity_[ i ] = exp_sum / sum ;
    192     } 
    193 }
     156  void PCA::calculate_explained_intensity(void)
     157  {
     158    size_t DIM = eigenvalues_.size();
     159    explained_intensity_ = utility::vector( DIM );
     160    double sum = 0;
     161    for( size_t i = 0; i < DIM; ++i )
     162      sum += eigenvalues_[ i ];
     163    double exp_sum = 0;
     164    for( size_t i = 0; i < DIM; ++i ) {
     165      exp_sum += eigenvalues_[ i ];
     166      explained_intensity_[ i ] = exp_sum / sum ;
     167    }
     168  }
    194169
    195170
    196 
    197 double PCA::get_explained_intensity( const size_t& k )
    198 {
    199   if( !explained_calc_ )
    200     {
    201      this->calculate_explained_intensity();
    202      explained_calc_ = true;
    203     }
    204   return explained_intensity_[ k ];
    205 }
     171  double PCA::get_explained_intensity( const size_t& k )
     172  {
     173    if( !explained_calc_ ) {
     174      this->calculate_explained_intensity();
     175      explained_calc_ = true;
     176    }
     177    return explained_intensity_[ k ];
     178  }
    206179
    207180
  • trunk/c++_tools/utility/PCA.h

    r420 r616  
    1 // $Id$
    2 
    31#ifndef _theplu_utility_pca_
    42#define _theplu_utility_pca_
    53
    6 #include <c++_tools/gslapi/matrix.h>
    7 #include <c++_tools/gslapi/vector.h>
     4// $Id$
     5
     6#include <c++_tools/utility/matrix.h>
     7#include <c++_tools/utility/vector.h>
    88
    99
     
    3434       should have been performed and no products.
    3535     */
    36     inline explicit PCA(const gslapi::matrix& A)
     36    inline explicit PCA(const utility::matrix& A)
    3737      : A_(A), process_(false), explained_calc_(false) {}
    3838
     
    5959       @return Eigenvector \a i.
    6060    */
    61     inline gslapi::vector get_eigenvector(const size_t& i) const
    62       { return gslapi::vector(eigenvectors_,i); }
     61    inline utility::vector get_eigenvector(const size_t& i) const
     62      { return utility::vector(eigenvectors_,i); }
    6363
    6464    /**
     
    8383       spanned by the eigenvectors.
    8484    */
    85     gslapi::matrix projection( const gslapi::matrix& ) const;
     85    utility::matrix projection( const utility::matrix& ) const;
    8686
    8787    /**
     
    8989       process_transposed_problem().
    9090    */
    91     gslapi::matrix projection_transposed( const gslapi::matrix& ) const;
     91    utility::matrix projection_transposed( const utility::matrix& ) const;
    9292
    9393
    9494  private:
    95     gslapi::matrix  A_;
    96     gslapi::matrix  eigenvectors_;
    97     gslapi::vector  eigenvalues_;
    98     gslapi::vector  explained_intensity_;
    99     gslapi::vector  meanvalues_;
     95    utility::matrix A_;
     96    utility::matrix eigenvectors_;
     97    utility::vector eigenvalues_;
     98    utility::vector explained_intensity_;
     99    utility::vector meanvalues_;
    100100    bool process_, explained_calc_;
    101101   
     
    105105       with the meanvalues of each row
    106106    */
    107     void row_center( gslapi::matrix& A_center );
     107    void row_center( utility::matrix& A_center );
    108108
    109109    /**
  • trunk/c++_tools/utility/SVD.cc

    r420 r616  
    1717        case Jacobi:
    1818          return jacobi();
    19     }
     19    }
    2020    // the program should never end up here, return values should be
    2121    // something different from normal GSL return values, or maybe
     
    2828  int SVD::golub_reinsch(void)
    2929  {
    30     gslapi::vector w(U_.columns());
     30    utility::vector w(U_.columns());
    3131    return gsl_linalg_SV_decomp(U_.gsl_matrix_p(), V_.gsl_matrix_p(),
    3232                                s_.gsl_vector_p(), w.gsl_vector_p());
     
    3737  int SVD::modified_golub_reinsch(void)
    3838  {
    39     gslapi::vector w(U_.columns());
    40     gslapi::matrix X(U_.columns(),U_.columns());
     39    utility::vector w(U_.columns());
     40    utility::matrix X(U_.columns(),U_.columns());
    4141    return gsl_linalg_SV_decomp_mod(U_.gsl_matrix_p(), X.gsl_matrix_p(),
    4242                                    V_.gsl_matrix_p(), s_.gsl_vector_p(),
  • trunk/c++_tools/utility/SVD.h

    r597 r616  
    1 // $Id$
    2 
    31#ifndef _theplu_utility_svd_
    42#define _theplu_utility_svd_
    53
    6 #include <c++_tools/gslapi/matrix.h>
    7 #include <c++_tools/gslapi/vector.h>
     4// $Id$
     5
     6#include <c++_tools/utility/matrix.h>
     7#include <c++_tools/utility/vector.h>
    88
    99#include <gsl/gsl_linalg.h>
     
    5252    /// input matrix is copied for further use in the object.
    5353    ///
    54     inline SVD(const gslapi::matrix& Ain)
     54    inline SVD(const utility::matrix& Ain)
    5555      : U_(Ain), V_(Ain.columns(),Ain.columns()), s_(Ain.columns()) {}
    5656
     
    7373    /// is undefined.
    7474    ///
    75     inline const gslapi::vector& s(void) const { return s_; }
     75    inline const utility::vector& s(void) const { return s_; }
    7676
    7777    ///
     
    8383    /// @return Whatever GSL returns.
    8484    ///
    85     inline int solve(gslapi::vector b, gslapi::vector x)
     85    inline int solve(utility::vector b, utility::vector x)
    8686      { return gsl_linalg_SV_solve(U_.gsl_matrix_p(), V_.gsl_matrix_p(),
    8787                                   s_.gsl_vector_p(), b.gsl_vector_p(),
     
    9696    /// is undefined.
    9797    ///
    98     inline const gslapi::matrix& U(void) const { return U_; }
     98    inline const utility::matrix& U(void) const { return U_; }
    9999
    100100    ///
     
    106106    /// is undefined.
    107107    ///
    108     inline const gslapi::matrix& V(void) const { return V_; }
     108    inline const utility::matrix& V(void) const { return V_; }
    109109
    110110  private:
     
    115115    int modified_golub_reinsch(void);
    116116
    117     gslapi::matrix U_, V_;
    118     gslapi::vector s_;
     117    utility::matrix U_, V_;
     118    utility::vector s_;
    119119  }; 
    120120
  • trunk/c++_tools/utility/WeNNI.cc

    r570 r616  
    2727#include <c++_tools/utility/WeNNI.h>
    2828
     29#include <c++_tools/utility/matrix.h>
    2930#include <c++_tools/utility/stl_utility.h>
    3031
     
    3738
    3839
    39   WeNNI::WeNNI(const gslapi::matrix& matrix,const gslapi::matrix& flag,
     40  WeNNI::WeNNI(const utility::matrix& matrix,const utility::matrix& flag,
    4041               const u_int neighbours)
    4142    : NNI(matrix,flag,neighbours), imputed_data_raw_(matrix)
     
    5253  u_int WeNNI::estimate(void)
    5354  {
    54     using namespace std;
    5555    for (unsigned int i=0; i<data_.rows(); i++) {
    5656      // Jari, avoid copying in next line
    57       vector<pair<u_int,double> > distance=calculate_distances(i);
    58       sort(distance.begin(),distance.end(),
     57      std::vector<std::pair<u_int,double> > distance=calculate_distances(i);
     58      std::sort(distance.begin(),distance.end(),
    5959                pair_value_compare<u_int,double>());
    6060      bool row_imputed=true;
    6161      for (unsigned int j=0; j<data_.columns(); j++) {
    62         vector<u_int> knn=nearest_neighbours(j,distance);
     62        std::vector<u_int> knn=nearest_neighbours(j,distance);
    6363        double new_value=0.0;
    6464        double norm=0.0;
    65         for (vector<u_int>::const_iterator k=knn.begin(); k!=knn.end(); k++) {
     65        for (std::vector<u_int>::const_iterator k=knn.begin(); k!=knn.end();
     66             ++k) {
    6667          // Jari, a small number needed here, use something standardized.
    6768          // Avoid division with zero (perfect match vectors)
  • trunk/c++_tools/utility/WeNNI.h

    r570 r616  
     1#ifndef _theplu_utility_wenni_
     2#define _theplu_utility_wenni_
     3
    14// $Id$
    25
     
    2528*/
    2629
    27 #ifndef _theplu_utility_wenni_
    28 #define _theplu_utility_wenni_
    29 
    3030#include <c++_tools/utility/NNI.h>
    3131
    32 #include <c++_tools/gslapi/matrix.h>
     32#include <c++_tools/utility/matrix.h>
    3333
    3434#include <iostream>
     
    5454    /// Constructor
    5555    ///
    56     WeNNI(const gslapi::matrix& matrix,const gslapi::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 gslapi::matrix& imputed_data_raw(void) const
     69    const utility::matrix& imputed_data_raw(void) const
    7070    { return imputed_data_raw_; }
    7171
     
    7474  private:
    7575
    76     gslapi::matrix imputed_data_raw_;
     76    utility::matrix imputed_data_raw_;
    7777  };
    7878
  • trunk/c++_tools/utility/kNNI.cc

    r570 r616  
    3737namespace utility {
    3838
    39   kNNI::kNNI(const gslapi::matrix& matrix,const gslapi::matrix& flag,
     39  kNNI::kNNI(const utility::matrix& matrix,const utility::matrix& flag,
    4040             const u_int neighbours)
    4141    : NNI(matrix,flag,neighbours)
     
    5858  u_int kNNI::estimate(void)
    5959  {
    60     using namespace std;
    6160    for (unsigned int i=0; i<mv_rows_.size(); i++) {
    6261      // Jari, avoid copying in next line
    63       vector<pair<u_int,double> > distance=calculate_distances(mv_rows_[i]);
    64       sort(distance.begin(),distance.end(),
     62      std::vector<std::pair<u_int,double> > distance=
     63        calculate_distances(mv_rows_[i]);
     64      std::sort(distance.begin(),distance.end(),
    6565                pair_value_compare<u_int,double>());
    6666      for (unsigned int j=0; j<data_.columns(); j++)
    6767        if (!weight_(mv_rows_[i],j)) {
    68           vector<u_int> knn=nearest_neighbours(j,distance);
     68          std::vector<u_int> knn=nearest_neighbours(j,distance);
    6969          double new_value=0.0;
    7070          double norm=0.0;
    71           for (vector<u_int>::const_iterator k=knn.begin(); k!=knn.end(); k++){
     71          for (std::vector<u_int>::const_iterator k=knn.begin(); k!=knn.end();
     72               ++k) {
    7273            // Jari, a small number needed here, use something standardized.
    7374            // Avoid division with zero (perfect match vectors)
  • trunk/c++_tools/utility/kNNI.h

    r570 r616  
     1#ifndef _theplu_utility_knni_
     2#define _theplu_utility_knni_
     3
    14// $Id$
    25
     
    2528*/
    2629
    27 #ifndef _theplu_utility_knni_
    28 #define _theplu_utility_knni_
    29 
    3030#include <c++_tools/utility/NNI.h>
    3131
     
    5252    /// Constructor
    5353    ///
    54     kNNI(const gslapi::matrix& matrix,const gslapi::matrix& weight,
     54    kNNI(const utility::matrix& matrix,const utility::matrix& weight,
    5555         const u_int neighbours);
    5656
  • trunk/c++_tools/utility/matrix.cc

    r613 r616  
    2525*/
    2626
    27 #include <c++_tools/gslapi/matrix.h>
    28 
    29 #include <c++_tools/gslapi/vector.h>
     27#include <c++_tools/utility/matrix.h>
     28
     29#include <c++_tools/utility/vector.h>
    3030#include <c++_tools/utility/stl_utility.h>
    3131#include <c++_tools/utility/utility.h>
     
    3939
    4040namespace theplu {
    41 namespace gslapi {
     41namespace utility {
    4242
    4343
     
    242242
    243243
    244 }} // of namespace gslapi and namespace thep
     244}} // of namespace utility and namespace thep
  • trunk/c++_tools/utility/matrix.h

    r614 r616  
     1#ifndef _theplu_utility_matrix_
     2#define _theplu_utility_matrix_
     3
    14// $Id$
    25
     
    2629*/
    2730
    28 #ifndef _theplu_gslapi_matrix_
    29 #define _theplu_gslapi_matrix_
    30 
    31 #include <c++_tools/gslapi/vector.h>
     31#include <c++_tools/utility/vector.h>
    3232#include <c++_tools/utility/Exception.h>
    3333
     
    3636
    3737namespace theplu {
    38 namespace gslapi {
     38namespace utility {
    3939
    4040  class vector;
     
    5151  ///
    5252  /// \par[Matrix views] GSL matrix views are supported and these are
    53   /// disguised as ordinary gslapi::matrix'es. A support function is
    54   /// added, gslapi::matrix::isview(), that can be used to check if a
     53  /// disguised as ordinary utility::matrix'es. A support function is
     54  /// added, utility::matrix::isview(), that can be used to check if a
    5555  /// matrix object is a view. Note that view matricess do not own the
    5656  /// undelying data, and a view is not valid if the matrix owning the
     
    6161  /// this interface class. Most notable GSL functionality not
    6262  /// supported are no binary file support and views on arrays,
    63   /// gslapi::vectors, gsl_vectors, diagonals, subdiagonals, and
     63  /// utility::vectors, gsl_vectors, diagonals, subdiagonals, and
    6464  /// superdiagonals. If there is an interest from the user community,
    6565  /// the omitted functionality could be included.
     
    464464
    465465
    466 }} // of namespace gslapi and namespace theplu
     466}} // of namespace utility and namespace theplu
    467467
    468468#endif
  • trunk/c++_tools/utility/utility.cc

    r609 r616  
    2626#include <c++_tools/utility/utility.h>
    2727
     28#include <c++_tools/random/random.h>
    2829#include <c++_tools/utility/stl_utility.h>
     30#include <c++_tools/utility/vector.h>
    2931
    3032#include <sstream>
     
    8890  }
    8991
     92
     93  std::pair<size_t, size_t> minmax_index(const vector& vec,
     94                                         const std::vector<size_t>& subset)
     95  {
     96    size_t min_index = subset[0];
     97    size_t max_index = subset[0];
     98    for (unsigned int i=1; i<subset.size(); i++)
     99      if (vec[subset[i]] < vec[min_index])
     100        min_index = subset[i];
     101      else if (vec[subset[i]] > vec[max_index])
     102        max_index = subset[i];
     103    return std::pair<size_t,size_t>(min_index, max_index);
     104  }
     105
     106
     107  void shuffle(vector& invec)
     108  {
     109    vector vec(invec);
     110    random::DiscreteUniform rnd;
     111    for (size_t i=0; i<vec.size(); i++){
     112      size_t index = rnd(vec.size()-i);
     113      invec[i]=vec(index);
     114      vec(index)=vec(vec.size()-i-1);
     115    }
     116  }
     117
     118
    90119}} // end of namespace utility and namespace thep
  • trunk/c++_tools/utility/utility.h

    r570 r616  
     1#ifndef _theplu_utility_utility_
     2#define _theplu_utility_utility_
     3
    14// $Id$
    25
     
    2427*/
    2528
    26 #ifndef _theplu_utility_utility_
    27 #define _theplu_utility_utility_
    28 
    2929///
    3030/// @file utility/utility.h
     
    3434
    3535#include <string>
     36#include <utility>
     37#include <vector>
    3638
    3739namespace theplu {
    3840namespace utility {
    3941
     42  class vector;
    4043
    4144  ///
     
    6063  bool is_nan(const std::string& s);
    6164
     65  /**
     66     This function returns the indices of the minimum and maximum
     67     values in the sub-vector (defined by \a subset), storing them in
     68     imin and imax. When there are several equal minimum or maximum
     69     elements then the lowest indices are returned. The returned index
     70     is the index from the complete vector (not the sub-vector)
     71
     72     @return Index corresponding to the smallest and largest value.
     73
     74     @note If \a subset is emtpy, the result is undefined.
     75  */
     76  std::pair<size_t,size_t> minmax_index(const vector& vec,
     77                                        const std::vector<size_t>& subset);
     78
     79  /**
     80     Randomly shuffles the elements in vector \a invec
     81  */
     82  void shuffle(vector& invec);
     83
     84
    6285}} // of namespace utility and namespace theplu
    6386
  • trunk/c++_tools/utility/vector.cc

    r613 r616  
    2626*/
    2727
    28 #include <c++_tools/gslapi/vector.h>
    29 #include <c++_tools/gslapi/matrix.h>
     28#include <c++_tools/utility/vector.h>
     29#include <c++_tools/utility/matrix.h>
    3030#include <c++_tools/utility/stl_utility.h>
    3131#include <c++_tools/utility/utility.h>
     
    3939
    4040namespace theplu {
    41 namespace gslapi {
     41namespace utility {
    4242
    4343
     
    265265
    266266
    267 }} // of namespace gslapi and namespace thep
     267}} // of namespace utility and namespace thep
  • trunk/c++_tools/utility/vector.h

    r613 r616  
     1#ifndef _theplu_utility_vector_
     2#define _theplu_utility_vector_
     3
    14// $Id$
    25
     
    2629*/
    2730
    28 #ifndef _theplu_gslapi_vector_
    29 #define _theplu_gslapi_vector_
    30 
    3131#include <c++_tools/utility/Exception.h>
    3232
     
    3939
    4040namespace theplu {
    41 namespace gslapi {
     41namespace utility {
    4242
    4343  class matrix;
     
    5454  ///
    5555  /// \par[Vector views] GSL vector views are supported and these are
    56   /// disguised as ordinary gslapi::vectors. A support function is
    57   /// added, gslapi::vector::isview(), that can be used to check if a
     56  /// disguised as ordinary utility::vectors. A support function is
     57  /// added, utility::vector::isview(), that can be used to check if a
    5858  /// vector object is a view. Note that view vectors do not own the
    5959  /// undelying data, and a view is not valid if the vector owning the
     
    491491
    492492
    493 }} // of namespace gslapi and namespace theplu
     493}} // of namespace utility and namespace theplu
    494494
    495495#endif
  • trunk/test/alignment_test.cc

    r442 r616  
    33#include <c++_tools/utility/Alignment.h>
    44
    5 #include <c++_tools/gslapi/matrix.h>
     5#include <c++_tools/utility/matrix.h>
    66
    77#include <gsl/gsl_cdf.h>
     
    5454             const std::vector<double>& l2,
    5555             const double sigma,
    56              theplu::gslapi::matrix& dot_matrix,
     56             theplu::utility::matrix& dot_matrix,
    5757             std::vector<std::pair<size_t,size_t> >& path)
    5858{
    59   dot_matrix  = theplu::gslapi::matrix(l1.size(),l2.size());
     59  dot_matrix  = theplu::utility::matrix(l1.size(),l2.size());
    6060  for (size_t i=0; i<l1.size(); i++)
    6161    for (size_t j=0; j<l2.size(); j++) {
     
    7878  for (size_t i=0; i<peaksets.size()-1; i++)
    7979    for (size_t j=i+1; j<peaksets.size(); j++) {
    80       gslapi::matrix dot_m;
     80      utility::matrix dot_m;
    8181      std::vector<std::pair<size_t,size_t> > path;
    8282      score(peaksets[i], peaksets[j], 1.0, dot_m, path);
  • trunk/test/averager_test.cc

    r583 r616  
    55#include <c++_tools/statistics/AveragerPairWeighted.h>
    66#include <c++_tools/statistics/AveragerWeighted.h>
    7 #include <c++_tools/gslapi/vector.h>
     7#include <c++_tools/utility/vector.h>
    88
    99#include <fstream>
     
    9191  // Testing AveragerWeighted
    9292  *error << "testing AveragerWeighted" << std::endl;
    93   theplu::gslapi::vector x(3,0);
     93  theplu::utility::vector x(3,0);
    9494  x(0)=0;
    9595  x(1)=1;
    9696  x(2)=2;
    97   theplu::gslapi::vector w(3,1);
     97  theplu::utility::vector w(3,1);
    9898  theplu::statistics::AveragerWeighted aw;
    9999  aw.add_values(x,w);
     
    152152  AveragerPairWeighted apw;
    153153  x(0)=0; x(1)=1; x(2)=2;
    154   theplu::gslapi::vector y(3,0);
     154  theplu::utility::vector y(3,0);
    155155  x(0)=0; x(1)=0; x(2)=2;
    156156  apw.add_values(x,y,w,w);
  • trunk/test/consensus_inputranker_test.cc

    r615 r616  
    55#include <c++_tools/classifier/ConsensusInputRanker.h>
    66#include <c++_tools/statistics/ROC.h>
    7 #include <c++_tools/gslapi/matrix.h>
     7#include <c++_tools/utility/matrix.h>
    88#include <c++_tools/classifier/MatrixLookup.h>
    99#include <c++_tools/classifier/CrossValidationSampler.h>
     
    3131
    3232  ifstream is("data/rank_data.txt");
    33   theplu::gslapi::matrix data_tmp(is);
     33  theplu::utility::matrix data_tmp(is);
    3434  theplu::classifier::MatrixLookup data(data_tmp);
    3535  is.close();
     
    5656  }
    5757
    58   theplu::gslapi::matrix flag(data.rows(),data.columns(),1);
     58  theplu::utility::matrix flag(data.rows(),data.columns(),1);
    5959  // Peter, fix weighted version instead
    6060  theplu::classifier::ConsensusInputRanker cir2(sampler,data,roc);
  • trunk/test/crossvalidation_test.cc

    r615 r616  
    55#include <c++_tools/classifier/MatrixLookup.h>
    66#include <c++_tools/classifier/Target.h>
    7 #include <c++_tools/gslapi/matrix.h>
     7#include <c++_tools/utility/matrix.h>
    88
    99#include <cstdlib>
     
    4040                 
    4141  classifier::Target target(label);
    42   gslapi::matrix raw_data(10,10);
     42  utility::matrix raw_data(10,10);
    4343  classifier::MatrixLookup data(raw_data);
    4444  classifier::CrossValidationSampler cv(target,3,3);
     
    8181                 
    8282  target=classifier::Target(label);
    83   gslapi::matrix raw_data2(2,9);
     83  utility::matrix raw_data2(2,9);
    8484  for(size_t i=0;i<raw_data2.rows();i++)
    8585    for(size_t j=0;j<raw_data2.columns();j++)
  • trunk/test/data_lookup_1d_test.cc

    r593 r616  
    11// $Id$
    22
    3 #include <c++_tools/gslapi/matrix.h>
     3#include <c++_tools/utility/matrix.h>
    44#include <c++_tools/classifier/DataLookup1D.h>
    55#include <c++_tools/classifier/MatrixLookup.h>
     
    1212using namespace theplu;
    1313
    14 gslapi::matrix matrix(size_t n);
     14utility::matrix matrix(size_t n);
    1515
    1616int main(const int argc,const char* argv[])
     
    3131
    3232  *error << "Testing DataLookup1D" << std::endl;
    33   gslapi::matrix gsl_m1(matrix(5));
     33  utility::matrix gsl_m1(matrix(5));
    3434  std::vector<size_t> index_odd;
    3535  index_odd.push_back(1);
     
    9797
    9898  *error << "Testing that output from ostream operator for DataLookup1D"
    99          << " can be used by the gslapi::vector istream constructor...";
     99         << " can be used by the utility::vector istream constructor...";
    100100
    101101  // First with a vector with no missing values separated by ' '.
     
    104104  my_out.close();
    105105  std::ifstream is("data/tmp_test_datalookup1D.txt");
    106   gslapi::vector v5(is);
     106  utility::vector v5(is);
    107107  is.close();
    108108  if (v5.size()!=v1.size() || v5(0)!=v1(0) || v5(1)!=v1(1) ||
     
    122122  my_out.close();
    123123  is.open("data/tmp_test_datalookup1D.txt");
    124   gslapi::vector v7(is,'\t');
     124  utility::vector v7(is,'\t');
    125125  is.close();
    126126  if (v7.size()!=v6.size() || !std::isnan(v7(1))) {
     
    141141}
    142142
    143 gslapi::matrix matrix(size_t n)
     143utility::matrix matrix(size_t n)
    144144{
    145   gslapi::matrix res(n,n);
     145  utility::matrix res(n,n);
    146146  for (size_t i=0;i<n;i++)
    147147    for (size_t j=0;j<n;j++)
  • trunk/test/ensemble_test.cc

    r615 r616  
    11// $Id$
    22
    3 #include <c++_tools/gslapi/matrix.h>
    4 #include <c++_tools/gslapi/vector.h>
     3#include <c++_tools/utility/matrix.h>
    54#include <c++_tools/classifier/SubsetGenerator.h>
    65#include <c++_tools/classifier/CrossValidationSampler.h>
     
    3938  *error << "loading data" << std::endl;
    4039  std::ifstream is("data/nm_data_centralized.txt");
    41   gslapi::matrix data_core(is);
     40  utility::matrix data_core(is);
    4241  is.close();
    4342
  • trunk/test/inputranker_test.cc

    r604 r616  
    33#include <c++_tools/classifier/InputRanker.h>
    44#include <c++_tools/statistics/ROC.h>
    5 #include <c++_tools/gslapi/matrix.h>
    6 #include <c++_tools/gslapi/matrix.h>
     5#include <c++_tools/utility/matrix.h>
    76#include <c++_tools/classifier/MatrixLookup.h>
    87#include <c++_tools/classifier/Target.h>
     
    2928
    3029  std::ifstream is("data/rank_data.txt");
    31   theplu::gslapi::matrix data_tmp(is);
     30  theplu::utility::matrix data_tmp(is);
    3231  theplu::classifier::MatrixLookup data(data_tmp);
    3332  is.close();
  • trunk/test/kernel_lookup_test.cc

    r559 r616  
    11// $Id$
    22
    3 #include <c++_tools/gslapi/matrix.h>
     3#include <c++_tools/utility/matrix.h>
    44#include <c++_tools/classifier/DataLookup1D.h>
    55#include <c++_tools/classifier/KernelLookup.h>
     
    3030  bool ok =true;
    3131  *error << "\nTesting KernelLookup" << std::endl;
    32   gslapi::matrix data_core(1,5);
     32  utility::matrix data_core(1,5);
    3333  for (size_t i=0; i<data_core.columns(); i++)
    3434    data_core(0,i)=i;
  • trunk/test/kernel_test.cc

    r536 r616  
    11// $Id$
    2 
    32
    43// C++ tools include
    54////////////////////
    6 #include <c++_tools/gslapi/matrix.h>
    7 #include <c++_tools/gslapi/vector.h>
     5#include <c++_tools/utility/matrix.h>
    86#include <c++_tools/classifier/KernelFunction.h>
    97#include <c++_tools/classifier/PolynomialKernelFunction.h>
     
    2523bool test_MEV(const classifier::MatrixLookup& data,
    2624              const classifier::KernelFunction* kf,
    27               const gslapi::matrix& control, const double error_bound,
     25              const utility::matrix& control, const double error_bound,
    2826              std::ostream* error);
    2927
    3028bool test_SEV(const classifier::MatrixLookup& data,
    3129              const classifier::KernelFunction* kf,
    32               const gslapi::matrix& control, const double error_bound,
     30              const utility::matrix& control, const double error_bound,
    3331              std::ostream* error);
    3432
     
    4846  bool ok = true;
    4947
    50   gslapi::matrix data2_core(2,3);
     48  utility::matrix data2_core(2,3);
    5149  data2_core(0,0)=0;
    5250  data2_core(1,0)=0;
     
    7775  double error_bound = 1e-8;
    7876  std::ifstream is("data/nm_data_centralized.txt");
    79   gslapi::matrix data_core(is);
     77  utility::matrix data_core(is);
    8078  is.close();
    8179
     
    8381
    8482  is.open("data/nm_kernel.txt");
    85   gslapi::matrix kernel_matlab(is);
     83  utility::matrix kernel_matlab(is);
    8684  is.close();
    8785  classifier::KernelFunction* kf = new classifier::PolynomialKernelFunction();
     
    9189 
    9290  is.open("data/nm_kernel2.txt");
    93   gslapi::matrix kernel_matlab2(is);
     91  utility::matrix kernel_matlab2(is);
    9492  is.close();
    9593  kf = new classifier::PolynomialKernelFunction(2);
     
    102100  delete kf;
    103101
    104   data_core = gslapi::matrix(1,5);
     102  data_core = utility::matrix(1,5);
    105103  for (size_t i=0; i<data_core.columns(); i++)
    106104    data_core(0,i)=i;
     
    120118bool test_MEV(const classifier::MatrixLookup& data,
    121119              const classifier::KernelFunction* kf,
    122               const gslapi::matrix& control, const double error_bound,
     120              const utility::matrix& control, const double error_bound,
    123121              std::ostream* error)
    124122{
     
    162160bool test_SEV(const classifier::MatrixLookup& data,
    163161              const classifier::KernelFunction* kf,
    164               const gslapi::matrix& control, const double error_bound,
     162              const utility::matrix& control, const double error_bound,
    165163              std::ostream* error)
    166164{
  • trunk/test/matrix_lookup_test.cc

    r537 r616  
    11// $Id$
    22
    3 #include <c++_tools/gslapi/matrix.h>
     3#include <c++_tools/utility/matrix.h>
    44#include <c++_tools/classifier/MatrixLookup.h>
    55
     
    1010using namespace theplu;
    1111
    12 gslapi::matrix matrix(size_t n);
     12utility::matrix matrix(size_t n);
    1313
    1414int main(const int argc,const char* argv[])
     
    2727
    2828  *error << "\nTesting MatrixLookup" << std::endl;
    29   *error << "MatrixLookup::MatrixLookup(const gslapi::matrix& data)...";
    30   gslapi::matrix gsl_m1(matrix(2));
     29  *error << "MatrixLookup::MatrixLookup(const utility::matrix& data)...";
     30  utility::matrix gsl_m1(matrix(2));
    3131  classifier::MatrixLookup m1(gsl_m1);
    3232  if (m1.rows()!=gsl_m1.rows() || m1.columns()!=gsl_m1.columns() ||
     
    4040
    4141 
    42   *error << "MatrixLookup::MatrixLookup(const gslapi::matrix&,\n"
     42  *error << "MatrixLookup::MatrixLookup(const utility::matrix&,\n"
    4343         << "                           const std::vector<size_t>&,\n"
    4444         << "                           const std::vector<size_t>&)...";
    45   gslapi::matrix gsl_m2(matrix(4));
     45  utility::matrix gsl_m2(matrix(4));
    4646  std::vector<size_t> index_odd;
    4747  index_odd.push_back(1);
     
    6161    *error << "Ok" << std::endl;
    6262
    63   *error << "MatrixLookup::MatrixLookup(const gslapi::matrix&,\n"
     63  *error << "MatrixLookup::MatrixLookup(const utility::matrix&,\n"
    6464         << "                           const std::vector<size_t>&,\n"
    6565         << "                           const bool)...";
     
    152152}
    153153
    154 gslapi::matrix matrix(size_t n)
     154utility::matrix matrix(size_t n)
    155155{
    156   gslapi::matrix res(n,n);
     156  utility::matrix res(n,n);
    157157  for (size_t i=0;i<n;i++)
    158158    for (size_t j=0;j<n;j++)
  • trunk/test/matrix_test.cc

    r611 r616  
    11// $Id$
    22
    3 #include <c++_tools/gslapi/matrix.h>
     3#include <c++_tools/utility/matrix.h>
    44
    55#include <unistd.h>
     
    1313    : m_(i,j,value) {}
    1414
    15   inline theplu::gslapi::vector
    16   row(const size_t& i) { return theplu::gslapi::vector(m_,i); }
    17 
    18   inline const theplu::gslapi::matrix& matrix(void) const { return m_; }
     15  inline theplu::utility::vector
     16  row(const size_t& i) { return theplu::utility::vector(m_,i); }
     17
     18  inline const theplu::utility::matrix& matrix(void) const { return m_; }
    1919
    2020private:
    21   theplu::gslapi::matrix m_;
     21  theplu::utility::matrix m_;
    2222};
    2323
     
    3939
    4040  *error << "\tcopy constructor and operator!=" << std::endl;
    41   gslapi::matrix m(3,3,9);
    42   gslapi::matrix m2(m);
     41  utility::matrix m(3,3,9);
     42  utility::matrix m2(m);
    4343  if (m2!=m)
    4444    ok=false;
     
    5151  my_out.close();
    5252  std::ifstream is("data/tmp_test_matrix.txt");
    53   gslapi::matrix m3(is);
     53  utility::matrix m3(is);
    5454  is.close();
    5555  if (m3!=m2)
     
    5858
    5959  *error << "\toperator*(double)" << std::endl;
    60   gslapi::matrix m4(3,3,1);
     60  utility::matrix m4(3,3,1);
    6161  m4 *= 9;
    6262  if (m4!=m) {
     
    7272  // lines and other whitespaces. The file is not expected to break
    7373  // things.
    74   gslapi::matrix m5(is);
     74  utility::matrix m5(is);
    7575  is.close();
    7676  double m5_sum=0;
     
    7878    for (size_t j=0; j<m5.columns(); ++j)
    7979      m5_sum+=m5(i,j);
    80   gslapi::matrix* m5sub=new gslapi::matrix(m5,3,3,3,3);
     80  utility::matrix* m5sub=new utility::matrix(m5,3,3,3,3);
    8181  double m5sub_sum=0;
    8282  for (size_t i=0; i<m5sub->rows(); ++i)
     
    9898  // Checking that the row view works, i.e. mutation to the view are
    9999  // reflected in the viewed object.
    100   gslapi::vector v5subrow(m5,3);
     100  utility::vector v5subrow(m5,3);
    101101  double v5subrow_sum=0;
    102102  for (size_t i=0; i<v5subrow.size(); ++i) {
     
    116116  // Checking that the column view works, i.e. mutation to the view
    117117  // are reflected in the viewed object.
    118   gslapi::vector v5subcolumn(m5,0,false);
     118  utility::vector v5subcolumn(m5,0,false);
    119119  double v5subcolumn_sum=0;
    120120  for (size_t i=0; i<v5subcolumn.size(); ++i) {
     
    143143  // Checking that a view is not inherited through the copy
    144144  // contructor.
    145   gslapi::vector v6(v5subrow);
     145  utility::vector v6(v5subrow);
    146146  v6.set_all(2);
    147147  double v5subrow_sum3=0;
     
    164164  // Checking that vector::operator= indeed makes a view to become a
    165165  // "normal" vector.
    166   v5subrow=gslapi::vector(23,22);
     166  v5subrow=utility::vector(23,22);
    167167  double m5_sum6=0;
    168168  for (size_t i=0; i<m5.rows(); ++i)
     
    178178  *error << "\tthat class member returns a view" << std::endl;
    179179  matrixwrapper mw(5,2);
    180   gslapi::vector mwrow=mw.row(2);
     180  utility::vector mwrow=mw.row(2);
    181181  if (mwrow.gsl_vector_p()->data != &(mw.matrix()(2,0))) {
    182182    ok=false;
     
    186186  *error << "\tsub-matrix of a sub-matrix" << std::endl;
    187187  // Checking that a sub-matrix of a sub-matrix can be created.
    188   gslapi::matrix sub(m5,3,3,3,3);
    189   gslapi::matrix subsub(sub,2,1,1,2);
     188  utility::matrix sub(m5,3,3,3,3);
     189  utility::matrix subsub(sub,2,1,1,2);
    190190  subsub(0,0)=23221121;
    191191  if (&sub(2,1)!=&subsub(0,0) || subsub(0,0)!=m5(5,4) || &subsub(0,0)!=&m5(5,4)){
     
    196196  *error << "\tmatrix::nan()" << std::endl;
    197197  is.open("data/sorlie_centroids.txt");
    198   gslapi::matrix* m_nan = new gslapi::matrix(is,'\t');
    199   gslapi::matrix m_weight;
     198  utility::matrix* m_nan = new utility::matrix(is,'\t');
     199  utility::matrix m_weight;
    200200  m_nan->nan(m_weight);
    201201  is.close();
  • trunk/test/ncc_test.cc

    r593 r616  
    55#include <c++_tools/classifier/NCC.h>
    66#include <c++_tools/classifier/Target.h>
    7 #include <c++_tools/gslapi/matrix.h>
    8 #include <c++_tools/gslapi/vector.h>
     7#include <c++_tools/utility/matrix.h>
    98#include <c++_tools/statistics/PearsonDistance.h>
    109#include <c++_tools/utility/utility.h>
     
    3534
    3635  std::ifstream is("data/sorlie_centroids.txt");
    37   gslapi::matrix data(is,'\t');
     36  utility::matrix data(is,'\t');
    3837  is.close();
    3938
     
    4342
    4443  // Generate weight matrix with 0 for missing values and 1 for others.
    45   gslapi::matrix weights(data.rows(),data.columns(),0.0);
     44  utility::matrix weights(data.rows(),data.columns(),0.0);
    4645  for(size_t i=0;i<data.rows();++i)
    4746    for(size_t j=0;j<data.columns();++j)
     
    5554  ncc.train();
    5655
    57   gslapi::matrix prediction;
     56  utility::matrix prediction;
    5857  ncc.predict(dataview,prediction);
    5958 
    6059  is.open("data/sorlie_centroid_predictions.txt");
    61   gslapi::matrix result(is,'\t');
     60  utility::matrix result(is,'\t');
    6261  is.close();
    6362
  • trunk/test/nni_test.cc

    r335 r616  
    22
    33#include <c++_tools/utility/FileIO.h>
    4 #include <c++_tools/gslapi/matrix.h>
     4#include <c++_tools/utility/matrix.h>
    55#include <c++_tools/utility/kNNI.h>
    66#include <c++_tools/utility/WeNNI.h>
     
    4242  std::ifstream data_stream(knni_data.c_str());
    4343  std::ifstream weight_stream(knni_weight.c_str());
    44   gslapi::matrix data(data_stream);
    45   gslapi::matrix weight(weight_stream);
     44  utility::matrix data(data_stream);
     45  utility::matrix weight(weight_stream);
    4646  utility::kNNI knni(data,weight,neighbours);
    4747  knni.estimate();
    4848  std::ifstream control_stream(knni_result.c_str());
    49   gslapi::matrix control(control_stream);
     49  utility::matrix control(control_stream);
    5050  control-=knni.imputed_data();
    5151  // Jari, should we use GSL defined round off errors? Anyway, the
     
    7575  // test WeNNI
    7676  data_stream.open(wenni_data.c_str());
    77   data=gslapi::matrix(data_stream);
     77  data=utility::matrix(data_stream);
    7878  weight_stream.open(wenni_weight.c_str());
    79   weight=gslapi::matrix(weight_stream);
     79  weight=utility::matrix(weight_stream);
    8080  utility::WeNNI wenni(data,weight,neighbours);
    8181  wenni.estimate();
    8282  control_stream.open(wenni_result.c_str());
    83   control=gslapi::matrix(control_stream);
     83  control=utility::matrix(control_stream);
    8484  control-=wenni.imputed_data();
    8585  for (unsigned int i=0; i<control.rows(); i++)
     
    108108  // test WeNNI with binary weights
    109109  data_stream.open(knni_data.c_str());
    110   data=gslapi::matrix(data_stream);
     110  data=utility::matrix(data_stream);
    111111  weight_stream.open(knni_weight.c_str());
    112   weight=gslapi::matrix(weight_stream);
     112  weight=utility::matrix(weight_stream);
    113113  utility::WeNNI wenni2(data,weight,neighbours);
    114114  wenni2.estimate();
    115115  control_stream.open(knni_result.c_str());
    116   control=gslapi::matrix(control_stream);
     116  control=utility::matrix(control_stream);
    117117  control-=wenni2.imputed_data();
    118118  for (unsigned int i=0; i<control.rows(); i++)
  • trunk/test/pca_test.cc

    r301 r616  
    11// $Id$
    22
     3#include <c++_tools/utility/matrix.h>
    34#include <c++_tools/utility/PCA.h>
    45
     
    910
    1011
    11 
    1212using namespace theplu;
    1313int main()
    1414{
    15   gslapi::matrix A( 3, 4 );
     15  utility::matrix A( 3, 4 );
    1616  for( size_t i = 0; i < 3; ++i )
    1717    for( size_t j = 0; j < 4; ++j )
  • trunk/test/regression_test.cc

    r586 r616  
    11// $Id$
    22
    3 
    4 #include <c++_tools/gslapi/matrix.h>
    53#include <c++_tools/statistics/KernelBox.h>
    64#include <c++_tools/statistics/Linear.h>
     
    119#include <c++_tools/statistics/Polynomial.h>
    1210#include <c++_tools/statistics/PolynomialWeighted.h>
     11#include <c++_tools/utility/matrix.h>
     12#include <c++_tools/utility/vector.h>
    1313
    1414#include <cmath>
     
    3939
    4040  // test data for Linear and Naive (Weighted and non-weighted)
    41   gslapi::vector x(4); x(0)=1970; x(1)=1980; x(2)=1990; x(3)=2000;
    42   gslapi::vector y(4); y(0)=12;   y(1)=11;   y(2)=14;   y(3)=13;
    43   gslapi::vector w(4); w(0)=0.1;  w(1)=0.2;  w(2)=0.3;  w(3)=0.4;
     41  utility::vector x(4); x(0)=1970; x(1)=1980; x(2)=1990; x(3)=2000;
     42  utility::vector y(4); y(0)=12;   y(1)=11;   y(2)=14;   y(3)=13;
     43  utility::vector w(4); w(0)=0.1;  w(1)=0.2;  w(2)=0.3;  w(3)=0.4;
    4444
    4545  *error << "testing regression::LinearWeighted" << std::endl;
     
    8484  {
    8585    std::ifstream s("data/regression_gauss.data");
    86     gslapi::matrix data(s);
    87     gslapi::vector x(data.rows());
    88     gslapi::vector ln_y(data.rows());
     86    utility::matrix data(s);
     87    utility::vector x(data.rows());
     88    utility::vector ln_y(data.rows());
    8989    for (size_t i=0; i<data.rows(); ++i) {
    9090      x(i)=data(i,0);
     
    9494    statistics::regression::Polynomial polynomialfit(2);
    9595    polynomialfit.fit(x,ln_y);
    96     gslapi::vector fit=polynomialfit.fit_parameters();
     96    utility::vector fit=polynomialfit.fit_parameters();
    9797    if (fabs(fit[0]-1.012229646706 + fit[1]-0.012561322528 +
    9898             fit[2]+1.159674470130)>1e-11) {  // Jari, fix number!
     
    132132  rl.fit(10, 100);
    133133
    134   gslapi::vector y = rl.y_predicted();
     134  utility::vector y = rl.y_predicted();
    135135  for (size_t i=0; i<y.size(); i++)
    136136    if (y(i)!=10.0){
  • trunk/test/score_test.cc

    r514 r616  
    11// $Id$
    22
    3 #include <c++_tools/gslapi/matrix.h>
    43#include <c++_tools/statistics/ROC.h>
    54#include <c++_tools/statistics/tScore.h>
    65#include <c++_tools/statistics/Pearson.h>
    76#include <c++_tools/statistics/FoldChange.h>
    8 #include <c++_tools/gslapi/vector.h>
    97#include <c++_tools/statistics/WilcoxonFoldChange.h>
     8#include <c++_tools/utility/matrix.h>
     9#include <c++_tools/utility/vector.h>
    1010
    1111#include <gsl/gsl_cdf.h>
     
    3131
    3232  *error << "testing ROC" << std::endl;
    33   gslapi::vector value(31);
     33  utility::vector value(31);
    3434  std::vector<std::string> label(31,"negative");
    3535  for (size_t i=0; i<16; i++)
     
    6868 
    6969  std::ifstream is("data/rank_data.txt");
    70   gslapi::matrix data(is);
     70  utility::matrix data(is);
    7171  is.close();
    7272
     
    7575  is.close();
    7676 
    77   gslapi::vector correct_area(3);
     77  utility::vector correct_area(3);
    7878  correct_area(0)=8.0/9.0;
    7979  correct_area(1)=6.0/9.0;
     
    8282  const double tol = 0.001;
    8383  for (size_t i=0; i<data.rows(); i++){
    84     gslapi::vector vec(data,i);
     84    utility::vector vec(data,i);
    8585    if (vec.size()!=target2.size()){
    8686      *error << "vec.size() is " << vec.size() << " and target2.size() is "
     
    9696  }
    9797
    98   gslapi::vector weight(target2.size(),1);
     98  utility::vector weight(target2.size(),1);
    9999  for (size_t i=0; i<data.rows(); i++){
    100     gslapi::vector vec(data,i);
     100    utility::vector vec(data,i);
    101101    area = roc.score(target2, vec, weight);
    102102    if (area<correct_area(i)-tol || area>correct_area(i)+tol){
  • trunk/test/statistics_test.cc

    r588 r616  
    22
    33#include <c++_tools/statistics/utility.h>
    4 #include <c++_tools/gslapi/vector.h>
     4#include <c++_tools/utility/vector.h>
    55
    66#include <vector>
     
    1212
    1313  using namespace theplu;
    14   gslapi::vector gsl_vec(10);
     14  utility::vector gsl_vec(10);
    1515  std::vector<double> data;
    1616  for (unsigned int i=0; i<10; i++){
  • trunk/test/svd_test.cc

    r420 r616  
    11// $Id$
    22
     3#include <c++_tools/random/random.h>
     4#include <c++_tools/utility/matrix.h>
    35#include <c++_tools/utility/SVD.h>
    4 #include <c++_tools/gslapi/matrix.h>
    5 #include <c++_tools/random/random.h>
    6 #include <c++_tools/gslapi/vector.h>
     6#include <c++_tools/utility/vector.h>
    77
    88using namespace theplu;
    99
    10 double this_norm(const gslapi::matrix& A)
     10double this_norm(const utility::matrix& A)
    1111{
    1212  double sum=0.0;
     
    2626  // initialise a random test-matrix
    2727  theplu::random::ContinuousUniform rnd;
    28   gslapi::matrix A(m,n);
     28  utility::matrix A(m,n);
    2929  for (size_t i=0; i<m; ++i)
    3030    for(size_t j=0; j<n; ++j)
     
    3333  utility::SVD svd(A);
    3434  svd.decompose(algo);
    35   theplu::gslapi::vector s(svd.s());
    36   gslapi::matrix S(s.size(),s.size());
     35  theplu::utility::vector s(svd.s());
     36  utility::matrix S(s.size(),s.size());
    3737  for (size_t i=0; i<s.size(); ++i)
    3838    S(i,i)=s[i];
    39   gslapi::matrix Vtranspose=svd.V();
     39  utility::matrix Vtranspose=svd.V();
    4040  Vtranspose.transpose();
    4141  // Reconstructing A = U*S*Vtranspose
    42   gslapi::matrix Areconstruct=svd.U();
     42  utility::matrix Areconstruct=svd.U();
    4343  Areconstruct*=S;
    4444  Areconstruct*=Vtranspose;
     
    6363  }
    6464
    65   gslapi::matrix Utranspose=svd.U();
     65  utility::matrix Utranspose=svd.U();
    6666  Utranspose.transpose();
    6767  Utranspose*=svd.U();  // Expect unity matrix
  • trunk/test/svm_test.cc

    r527 r616  
    11// $Id$
    22
    3 #include <c++_tools/gslapi/matrix.h>
    4 #include <c++_tools/gslapi/vector.h>
    53#include <c++_tools/classifier/SVM.h>
    64#include <c++_tools/classifier/Kernel.h>
     
    97#include <c++_tools/classifier/Kernel_MEV.h>
    108#include <c++_tools/classifier/PolynomialKernelFunction.h>
     9#include <c++_tools/utility/matrix.h>
     10#include <c++_tools/utility/vector.h>
    1111
    1212#include <cassert>
     
    3232  bool ok = true;
    3333
    34   gslapi::matrix data2_core(2,3);
     34  utility::matrix data2_core(2,3);
    3535  data2_core(0,0)=0;
    3636  data2_core(1,0)=0;
     
    8888
    8989  std::ifstream is("data/nm_data_centralized.txt");
    90   gslapi::matrix data_core(is);
     90  utility::matrix data_core(is);
    9191  is.close();
    9292
     
    102102
    103103  is.open("data/nm_alpha_linear_matlab.txt");
    104   theplu::gslapi::vector alpha_matlab(is);
     104  theplu::utility::vector alpha_matlab(is);
    105105  is.close();
    106106
     
    112112  }
    113113
    114   theplu::gslapi::vector alpha = svm.alpha();
     114  theplu::utility::vector alpha = svm.alpha();
    115115     
    116116  // Comparing alpha to alpha_matlab
    117   theplu::gslapi::vector diff_alpha(alpha);
     117  theplu::utility::vector diff_alpha(alpha);
    118118  diff_alpha-=alpha_matlab;
    119119  if (diff_alpha*diff_alpha> 1e-10 ){
     
    123123
    124124  // Comparing output to target
    125   theplu::gslapi::vector output(svm.output());
     125  theplu::utility::vector output(svm.output());
    126126  double slack = 0;
    127127  for (unsigned int i=0; i<target.size(); i++){
  • trunk/test/vector_test.cc

    r438 r616  
    33#include <c++_tools/utility/Exception.h>
    44#include <c++_tools/utility/FileIO.h>
    5 #include <c++_tools/gslapi/vector.h>
    6 #include <c++_tools/gslapi/utility.h>
     5#include <c++_tools/utility/utility.h>
     6#include <c++_tools/utility/vector.h>
    77
    88#include <fstream>
     
    2424  bool ok = true;
    2525
    26   gslapi::vector vec(12);
     26  utility::vector vec(12);
    2727  for (unsigned int i=0; i<vec.size(); i++)
    2828    vec(i)=i;
     
    3939  for (unsigned int i=0; i<vec.size(); i+=2)
    4040    sum_before+=vec[i];
    41   gslapi::vector vec_view(vec,0,6,2);
     41  utility::vector vec_view(vec,0,6,2);
    4242  sum_after=vec_view.sum();
    4343  if (sum_after != sum_before)
     
    4949
    5050  // checking that copy constructor creates an independent object
    51   gslapi::vector vec2(vec);
     51  utility::vector vec2(vec);
    5252  if (vec.size()!=vec2.size())
    5353    ok=false;
     
    8585    std::ifstream data_stream3(data3.c_str());
    8686    std::ifstream data_stream4(data4.c_str());
    87     vec=gslapi::vector(data_stream1);
     87    vec=utility::vector(data_stream1);
    8888    if (vec.size()!=9)
    8989      ok=false;
    90     vec=gslapi::vector(data_stream2);
     90    vec=utility::vector(data_stream2);
    9191    if (vec.size()!=9)
    9292      ok=false;
    93     vec=gslapi::vector(data_stream3);
     93    vec=utility::vector(data_stream3);
    9494    if (vec.size()!=12)
    9595      ok=false;
    96     vec=gslapi::vector(data_stream4);
     96    vec=utility::vector(data_stream4);
    9797    if (vec.size()!=12)
    9898      ok=false;
     
    107107  std::stringstream s;
    108108  s << vec;
    109   vec2=gslapi::vector(s);
     109  vec2=utility::vector(s);
    110110  if (!(vec==vec2))
    111111    ok=false;
     
    120120    check_file_access(data5);
    121121    std::ifstream data_stream5(data5.c_str());
    122     vec=gslapi::vector(data_stream5); // this will give an exception
     122    vec=utility::vector(data_stream5); // this will give an exception
    123123  } catch (utility::IO_error& err) {
    124124    if (print)
     
    130130    check_file_access(data);
    131131    std::ifstream data_stream(data.c_str());
    132     vec=gslapi::vector(data_stream); // this will give an exception
     132    vec=utility::vector(data_stream); // this will give an exception
    133133  } catch (utility::IO_error& err) {
    134134    if (print)
     
    143143    check_file_access(data);
    144144    std::ifstream data_stream(data.c_str());
    145     vec=gslapi::vector(data_stream); // this will give an exception
     145    vec=utility::vector(data_stream); // this will give an exception
    146146  } catch (utility::IO_error& err) {
    147147    if (print)
Note: See TracChangeset for help on using the changeset viewer.