Changeset 301


Ignore:
Timestamp:
Apr 30, 2005, 3:39:27 PM (16 years ago)
Author:
Peter
Message:

modified includes in tests

Location:
trunk
Files:
31 edited
20 moved

Legend:

Unmodified
Added
Removed
  • trunk/Makefile.am

    r5 r301  
    33## $Id$
    44
    5 SUBDIRS = doc src test
     5SUBDIRS = doc lib test
  • trunk/configure.ac

    r297 r301  
    6363# c++_tools specific settings
    6464
    65 CPP_TOOLS_LIB="libc++_tools.a"
     65CPP_TOOLS_LIB="libc++_tools.la"
    6666CPP_TOOLS_LIB_LOCATION="lib"
    6767CPP_TOOLS_HEADER_LOCATION="lib"
  • trunk/lib/gslapi/matrix.cc

    r295 r301  
    5252    u_int nof_rows = 0;
    5353    std::vector<double> v;
    54     for (nof_rows = 0; cpptools::read_to_double(is, v); nof_rows++) {
     54    for (nof_rows = 0; utility::read_to_double(is, v); nof_rows++) {
    5555   
    5656      // Ignoring empty lines
  • trunk/lib/gslapi/utility.cc

    r298 r301  
    3333  {
    3434    vector vec(invec);
    35     theplu::cpptools::random_singleton*
    36       rnd=theplu::cpptools::random_singleton::get_instance();
     35    utility::random_singleton*
     36      rnd=utility::random_singleton::get_instance();
    3737    for (size_t i=0; i<vec.size(); i++){
    3838      size_t index = rnd->get_uniform_int(vec.size()-i);
  • trunk/lib/statistics/ROC.cc

    r295 r301  
    151151    }
    152152    std::sort(value_.begin(),value_.end(),
    153          cpptools::pair_value_compare<double, double>());
     153         utility::pair_value_compare<double, double>());
    154154  }
    155155
  • trunk/lib/svm/ConsensusInputRanker.cc

    r298 r301  
    4444    //sort medians and assign id_ and rank_
    4545    sort(median.begin(), median.end(),
    46          cpptools::pair_value_compare<size_t, double>());
     46         utility::pair_value_compare<size_t, double>());
    4747    id_.resize(data.rows());
    4848    rank_.resize(data.rows());
     
    8181    //sort medians and assign id_ and rank_
    8282    sort(median.begin(), median.end(),
    83          cpptools::pair_value_compare<size_t, double>());
     83         utility::pair_value_compare<size_t, double>());
    8484    id_.resize(data.rows());
    8585    rank_.resize(data.rows());
  • trunk/lib/svm/CrossValidation.cc

    r295 r301  
    2424    }
    2525
    26     cpptools::my_uniform_rng a;
     26    utility::my_uniform_rng a;
    2727    random_shuffle(index_negative_.begin(), index_negative_.end(), a);
    2828    random_shuffle(index_positive_.begin(), index_positive_.end(), a);
     
    3333    if (count_==k_){
    3434      count_=0;
    35       cpptools::my_uniform_rng a;
     35      utility::my_uniform_rng a;
    3636      random_shuffle(index_negative_.begin(), index_negative_.end(), a);
    3737      random_shuffle(index_positive_.begin(), index_positive_.end(), a);
     
    5757  }
    5858 
    59 }} // of namespace cpptools and namespace theplu
     59}} // of namespace svm and namespace theplu
  • trunk/lib/svm/InputRanker.cc

    r295 r301  
    4949    //sort the scores and assign id_ and rank_
    5050    sort(score.begin(), score.end(),
    51          cpptools::pair_value_compare<size_t, double>());
     51         utility::pair_value_compare<size_t, double>());
    5252   
    5353    for (size_t i=0; i<nof_genes; i++){
     
    8484    //sort the scores and assign id_ and rank_
    8585    sort(score.begin(), score.end(),
    86          cpptools::pair_value_compare<size_t, double>());
     86         utility::pair_value_compare<size_t, double>());
    8787
    8888    for (size_t i=0; i<nof_genes; i++){
  • trunk/lib/svm/SVM.cc

    r295 r301  
    7474    for (size_t i=0; i<E.size(); i++)
    7575      tmp[i]=i;
    76     cpptools::my_uniform_rng a;
     76    utility::my_uniform_rng a;
    7777    random_shuffle(tmp.begin(), tmp.end(), a);
    7878    for (size_t i=0; i<tmp.size(); i++){
     
    212212   
    213213
    214 }} // of namespace cpptools and namespace theplu
     214}} // of namespace svm and namespace theplu
  • trunk/lib/utility/Alignment.cc

    r295 r301  
    88
    99namespace theplu {
    10 namespace cpptools {
     10namespace utility {
    1111namespace alignment {
    1212
     
    6161  }
    6262
    63 }}} // of namespace alignment namespace cpptools and namespace theplu
     63}}} // of namespace alignment namespace utility and namespace theplu
  • trunk/lib/utility/Alignment.h

    r295 r301  
    1313}
    1414
    15 namespace cpptools {
     15namespace utility {
    1616// Jari, this should probably go somewhere else for doxygen to process.
    1717///
     
    4646                         const double gap);
    4747
    48 }}} // of namespace alignment namespace cpptools and namespace theplu
     48}}} // of namespace alignment namespace utility and namespace theplu
    4949
    5050#endif
  • trunk/lib/utility/FileIO.cc

    r295 r301  
    88
    99namespace theplu {
    10 namespace cpptools {
     10namespace utility {
    1111
    1212  int FileIO::access_rights(const std::string& path,
     
    3333  }
    3434
    35 }} // of namespace cpptools and namespace theplu
     35}} // of namespace utility and namespace theplu
  • trunk/lib/utility/FileIO.h

    r295 r301  
    77
    88namespace theplu {
    9 namespace cpptools {
     9namespace utility {
    1010
    1111  ///
     
    3434  };
    3535
    36 }} // of namespace cpptools and namespace theplu
     36}} // of namespace utility and namespace theplu
    3737
    3838#endif
  • trunk/lib/utility/Merge.cc

    r295 r301  
    1414
    1515namespace theplu {
    16 namespace cpptools {
     16namespace utility {
    1717
    1818  using namespace std;
     
    117117  }
    118118
    119 }} // of namespace cpptools and namespace theplu
     119}} // of namespace utility and namespace theplu
  • trunk/lib/utility/Merge.h

    r295 r301  
    55
    66#include <c++_tools/gslapi/matrix.h>
    7 //#include <c++_tools/gslapi/vector.h>
    87
    98#include <iostream>
     
    1413
    1514namespace theplu {
    16 namespace cpptools {
     15namespace utility {
    1716
    1817  using namespace std;
     
    7372  };
    7473
    75 }} // of namespace cpptools and namespace theplu
     74}} // of namespace utility and namespace theplu
    7675
    7776#endif
  • trunk/lib/utility/NNI.cc

    r295 r301  
    1111
    1212namespace theplu {
    13 namespace cpptools {
     13namespace utility {
    1414
    1515  using namespace std;
     
    7272
    7373
    74 }} // of namespace cpptools and namespace theplu
     74}} // of namespace utility and namespace theplu
  • trunk/lib/utility/NNI.h

    r295 r301  
    1111
    1212namespace theplu {
    13 namespace cpptools {
     13namespace utility {
    1414
    1515  using namespace std;
     
    100100  };
    101101
    102 }} // of namespace cpptools and namespace theplu
     102}} // of namespace utility and namespace theplu
    103103
    104104#endif
  • trunk/lib/utility/PCA.cc

    r295 r301  
    1010
    1111namespace theplu {
    12 namespace cpptools
     12namespace utility
    1313
    1414  //PCA::PCA() : process_( false ), explained_calc_( false ){}
     
    2929
    3030  // Single value decompose the data matrix
    31   std::auto_ptr<cpptools::SVD> pSVD( new cpptools::SVD( A_center ) );
     31  std::auto_ptr<SVD> pSVD( new SVD( A_center ) );
    3232  pSVD->decompose();
    3333  gslapi::matrix U = pSVD->U();
     
    7777
    7878  // Single value decompose the data matrix
    79   std::auto_ptr<cpptools::SVD> pSVD( new cpptools::SVD( A_center ) );
     79  std::auto_ptr<SVD> pSVD( new SVD( A_center ) );
    8080  pSVD->decompose();
    8181  gslapi::matrix U = pSVD->U();
     
    215215}
    216216
    217 }} // of namespace cpptools and namespace theplu
     217}} // of namespace utility and namespace theplu
  • trunk/lib/utility/PCA.h

    r295 r301  
    1616
    1717namespace theplu {
    18 namespace cpptools {
     18namespace utility {
    1919
    2020  /**
     
    132132  }; // class PCA 
    133133 
    134 }} // of namespace cpptools and namespace theplu
     134}} // of namespace utility and namespace theplu
    135135
    136136#endif
  • trunk/lib/utility/SVD.cc

    r295 r301  
    55
    66namespace theplu {
    7 namespace cpptools {
     7namespace utility {
    88
    99
     
    6262
    6363
    64 }} // of namespace cpptools and namespace theplu
     64}} // of namespace utility and namespace theplu
  • trunk/lib/utility/SVD.h

    r295 r301  
    1515/// namespace.
    1616///
    17 namespace cpptools {
     17namespace utility {
    1818
    1919  // Jari check that interface is complete
     
    128128  }; 
    129129
    130 }} // of namespace cpptools and namespace theplu
     130}} // of namespace utility and namespace theplu
    131131
    132132#endif
  • trunk/lib/utility/WeNNI.cc

    r295 r301  
    1010
    1111namespace theplu {
    12 namespace cpptools {
     12namespace utility {
    1313
    1414
     
    6363
    6464
    65 }} // of namespace cpptools and namespace theplu
     65}} // of namespace utility and namespace theplu
  • trunk/lib/utility/WeNNI.h

    r295 r301  
    1313
    1414namespace theplu {
    15 namespace cpptools {
     15namespace utility {
    1616
    1717  using namespace std;
     
    5555  };
    5656
    57 }} // of namespace cpptools and namespace theplu
     57}} // of namespace utility and namespace theplu
    5858
    5959#endif
  • trunk/lib/utility/kNNI.cc

    r295 r301  
    1111
    1212namespace theplu {
    13 namespace cpptools {
     13namespace utility {
    1414
    1515  kNNI::kNNI(const gslapi::matrix& matrix,const gslapi::matrix& flag,
     
    6767
    6868
    69 }} // of namespace cpptools and namespace theplu
     69}} // of namespace utility and namespace theplu
  • trunk/lib/utility/kNNI.h

    r295 r301  
    1010
    1111namespace theplu {
    12 namespace cpptools {
     12namespace utility {
    1313
    1414  ///
     
    4242  };
    4343
    44 }} // of namespace cpptools and namespace theplu
     44}} // of namespace utility and namespace theplu
    4545
    4646#endif
  • trunk/lib/utility/random_singleton.cc

    r295 r301  
    44
    55namespace theplu {
    6 namespace cpptools
     6namespace utility
    77
    88// Static members
     
    5757}
    5858
    59 }} // of namespace cpptools and namespace theplu
     59}} // of namespace utility and namespace theplu
  • trunk/lib/utility/random_singleton.h

    r295 r301  
    1313
    1414namespace theplu {
    15 namespace cpptools
     15namespace utility
    1616
    1717  /**
     
    215215}
    216216
    217 }} // of namespace cpptools and namespace theplu
     217}} // of namespace utility and namespace theplu
    218218
    219219#endif
  • trunk/lib/utility/stl_utility.cc

    r295 r301  
    99
    1010namespace theplu {
    11 namespace cpptools {
     11namespace utility {
    1212
    1313  bool is_float(const std::string& s)
     
    117117
    118118
    119 }} // end of namespace cpptools and namespace thep
     119}} // end of namespace utility and namespace thep
    120120
  • trunk/lib/utility/stl_utility.h

    r295 r301  
    1717
    1818namespace theplu {
    19 namespace cpptools {
     19namespace utility {
    2020
    2121  ///
     
    8585
    8686
    87 }} // of namespace cpptools and namespace theplu
     87}} // of namespace utility and namespace theplu
    8888
    8989#endif
  • trunk/test/Makefile.am

    r285 r301  
    33## $Id$
    44
    5 TESTS = test_alignment test_averagerpair test_consensus_inputranker \
    6   test_crossvalidation  \
    7   test_inputranker test_kernel test_matrix test_merge test_nni test_pca \
    8   test_regression_linear test_regression_local test_regression_naive \
    9   test_rnd test_roc   \
    10   test_statistics test_stl_utility test_svd test_svm test_vector
     5TESTS = alignment_test averagerpair_test consensus_inputranker_test \
     6  crossvalidation_test inputranker_test kernel_test matrix_test \
     7  merge_test nni_test pca_test regression_linear_test \
     8  regression_local_test regression_naive_test rnd_test roc_test \
     9  statistics_test stl_utility_test svd_test svm_test vector_test
    1110
    1211check_PROGRAMS = $(TESTS)
     
    1514    $(GSL_LIB) $(CBLAS_LIB) $(MATH_LIB)
    1615
    17 INCLUDES = -I@top_srcdir@/$(CPP_TOOLS_HEADER_LOCATION) @LOCAL_INCLUDES@
     16INCLUDES = -I@top_srcdir@ @LOCAL_INCLUDES@
    1817
    1918AM_LDFLAGS = -g
     
    2120
    2221
    23 test_alignment_SOURCES = test_alignment.cc
    24 test_averagerpair_SOURCES = test_averagerpair.cc
    25 test_consensus_inputranker_SOURCES = test_consensus_inputranker.cc
    26 test_crossvalidation_SOURCES = test_crossvalidation.cc
    27 test_inputranker_SOURCES = test_inputranker.cc
    28 test_kernel_SOURCES = test_kernel.cc
    29 test_matrix_SOURCES = test_matrix.cc
    30 test_merge_SOURCES = test_merge.cc
    31 test_nni_SOURCES = test_nni.cc
    32 test_pca_SOURCES = test_pca.cc
    33 test_regression_linear_SOURCES = test_regression_linear.cc
    34 test_regression_local_SOURCES = test_regression_local.cc
    35 test_regression_naive_SOURCES = test_regression_naive.cc
    36 test_rnd_SOURCES = test_rnd.cc
    37 test_roc_SOURCES = test_roc.cc
    38 test_statistics_SOURCES = test_statistics.cc
    39 test_stl_utility_SOURCES = test_stl_utility.cc
    40 test_svd_SOURCES = test_svd.cc
    41 test_svm_SOURCES = test_svm.cc
    42 test_vector_SOURCES = test_vector.cc
     22alignment_test_SOURCES = alignment_test.cc
     23averagerpair_test_SOURCES = averagerpair_test.cc
     24consensus_inputranker_test_SOURCES = consensus_inputranker_test.cc
     25crossvalidation_test_SOURCES = crossvalidation_test.cc
     26inputranker_test_SOURCES = inputranker_test.cc
     27kernel_test_SOURCES = kernel_test.cc
     28matrix_test_SOURCES = matrix_test.cc
     29merge_test_SOURCES = merge_test.cc
     30nni_test_SOURCES = nni_test.cc
     31pca_test_SOURCES = pca_test.cc
     32regression_linear_test_SOURCES = regression_linear_test.cc
     33regression_local_test_SOURCES = regression_local_test.cc
     34regression_naive_test_SOURCES = regression_naive_test.cc
     35rnd_test_SOURCES = rnd_test.cc
     36roc_test_SOURCES = roc_test.cc
     37statistics_test_SOURCES = statistics_test.cc
     38stl_utility_test_SOURCES = stl_utility_test.cc
     39svd_test_SOURCES = svd_test.cc
     40svm_test_SOURCES = svm_test.cc
     41vector_test_SOURCES = vector_test.cc
  • trunk/test/alignment_test.cc

    r300 r301  
    11// $Id$
    22
    3 #include "Alignment.h"
     3#include <c++_tools/utility/Alignment.h>
    44
    5 #include "matrix.h"
     5#include <c++_tools/gslapi/matrix.h>
    66
    77#include <gsl/gsl_cdf.h>
     
    1313#include <string>
    1414#include <vector>
     15
     16using namespace theplu;
    1517
    1618void read_vector(std::vector<double>& v,std::string& str)
     
    6163      dot_matrix(i,j)=match(l1[i],l2[j],sigma);
    6264    }
    63   return theplu::cpptools::alignment::NeedlemanWunsch(dot_matrix,path,0);
     65  return theplu::utility::alignment::NeedlemanWunsch(dot_matrix,path,0);
    6466}
    6567
     
    7577  for (size_t i=0; i<peaksets.size()-1; i++)
    7678    for (size_t j=i+1; j<peaksets.size(); j++) {
    77       theplu::gslapi::matrix dot_m;
     79      gslapi::matrix dot_m;
    7880      std::vector<std::pair<size_t,size_t> > path;
    7981      score(peaksets[i], peaksets[j], 1.0, dot_m, path);
  • trunk/test/averagerpair_test.cc

    r300 r301  
    11// $Id$
    22
    3 #ifndef _THEP_CPPTOOLS_SVM_
    4 #define _THEP_CPPTOOLS_SVM_
     3#include <c++_tools/statistics/AveragerPair.h>
    54
    6 // C++ tools include
    7 ////////////////////
    8 #include "AveragerPair.h"
    9 
    10 // Standard includes
    11 ////////////////////
    12 
    13 
    14 
    15 using namespace std;
    165
    176int main()
     
    2817
    2918
    30 #endif
     19
  • trunk/test/consensus_inputranker_test.cc

    r300 r301  
    33// C++ tools include
    44////////////////////
     5#include <c++_tools/svm/ConsensusInputRanker.h>
     6#include <c++_tools/statistics/ROC.h>
     7#include <c++_tools/gslapi/matrix.h>
    58
    6 #include "ConsensusInputRanker.h"
    7 #include "InputRanker.h"
    8 
    9 #include "ROC.h"
    10 
    11 // Standard includes
    12 ////////////////////
    139#include <cstdlib>
    1410#include <fstream>
     
    2824  is.close();
    2925
    30   theplu::cpptools::ROC roc;
    31   theplu::cpptools::ConsensusInputRanker cir(data,target,roc,10,3);
     26  theplu::statistics::ROC roc;
     27  theplu::svm::ConsensusInputRanker cir(data,target,roc,10,3);
    3228
    3329  if (cir.id(0)!=2 || cir.id(1)!=0 || cir.id(2)!=1){
     
    4238
    4339  theplu::gslapi::matrix flag(data.rows(),data.columns(),1);
    44   theplu::cpptools::ConsensusInputRanker cir2(data,target,flag,roc,10,3);
     40  theplu::svm::ConsensusInputRanker cir2(data,target,flag,roc,10,3);
    4541
    4642  if (cir2.id(0)!=2 || cir2.id(1)!=0 || cir2.id(2)!=1){
  • trunk/test/crossvalidation_test.cc

    r300 r301  
    11// $Id$
    22
    3 // C++ tools include
    4 ////////////////////
    5 #include "CrossValidation.h"
     3#include <c++_tools/svm/CrossValidation.h>
     4#include <c++_tools/gslapi/vector.h>
    65
    7 // Standard includes
    8 ////////////////////
    96#include <vector>
    107#include <cstdlib>
    118#include <iostream>
    129
    13 using namespace std;
     10using namespace theplu;
    1411
    1512int main()
    1613
    17   theplu::cpptools::CrossValidation cv(10);
     14
     15  gslapi::vector target(10,1);
     16  for (size_t i=0; i<5; i++)
     17    target(i)=-1;
     18
     19  svm::CrossValidation cv(target,3);
     20
     21
    1822  std::vector<size_t> training_set;
    19 
    2023  std::vector<size_t> count(10);
    2124
  • trunk/test/inputranker_test.cc

    r300 r301  
    11// $Id$
    22
    3 // C++ tools include
    4 ////////////////////
    5 #include "InputRanker.h"
     3#include <c++_tools/svm/InputRanker.h>
     4#include <c++_tools/statistics/ROC.h>
     5#include <c++_tools/gslapi/matrix.h>
    66
    7 #include "ROC.h"
    8 
    9 // Standard includes
    10 ////////////////////
    117#include <cstdlib>
    128#include <fstream>
    139#include <iostream>
    14 //#include <vector>
    1510
    16 using namespace std;
     11using namespace theplu;
    1712
    1813int main()
    1914
    20   ifstream is("data/rank_data.txt");
    21   theplu::gslapi::matrix data(is);
     15  std::ifstream is("data/rank_data.txt");
     16  gslapi::matrix data(is);
    2217  is.close();
    2318
     
    2621  is.close();
    2722
    28   theplu::cpptools::ROC roc;
    29   theplu::cpptools::InputRanker ir(data,target,roc);
     23  statistics::ROC roc;
     24  svm::InputRanker ir(data,target,roc);
    3025
    3126  if (ir.id(0)!=2 || ir.id(1)!=0 || ir.id(2)!=1){
    32     cerr << "wrong id" << endl;
     27    std::cerr << "wrong id" << std::endl;
    3328    return -1;
    3429  }
    3530 
    3631  if (ir.rank(0)!=1 || ir.rank(1)!=2 || ir.rank(2)!=0){
    37     cerr << "wrong rank" << endl;
     32    std::cerr << "wrong rank" << std::endl;
    3833    return -1;
    3934  }
  • trunk/test/kernel_test.cc

    r300 r301  
    44// C++ tools include
    55////////////////////
    6 #include "matrix.h"
    7 #include "vector.h"
    8 #include <PolynomialKernelFunction.h>
    9 #include <Kernel.h>
     6#include <c++_tools/gslapi/matrix.h>
     7#include <c++_tools/gslapi/vector.h>
     8#include <c++_tools/svm/PolynomialKernelFunction.h>
     9#include <c++_tools/svm/Kernel.h>
    1010
    11 // Standard includes
    12 ////////////////////
    1311#include <cmath>
    1412#include <fstream>
     
    1715
    1816
    19 using namespace std;
     17using namespace theplu;
    2018
    2119int main()
     
    2422 
    2523  bool ok = true;
    26   ifstream is("data/nm_data_centralized.txt");
    27   theplu::gslapi::matrix transposed_data(is);
     24  std::ifstream is("data/nm_data_centralized.txt");
     25  gslapi::matrix transposed_data(is);
    2826  is.close();
    2927  // Because how the kernel is treated is changed, I have to transpose the data
    30   //theplu::gslapi::matrix data=transposed_data.transpose();
    31   theplu::gslapi::matrix data=transposed_data;
     28  gslapi::matrix data=transposed_data;
    3229
    3330  is.open("data/nm_kernel.txt");
    34   theplu::gslapi::matrix kernel_matlab(is);
     31  gslapi::matrix kernel_matlab(is);
    3532  is.close();
    36   theplu::cpptools::KernelFunction* kf =
    37     new theplu::cpptools::PolynomialKernelFunction();
    38   theplu::cpptools::Kernel kernel(data,*kf);
    39   theplu::gslapi::matrix diff(kernel.get()-kernel_matlab);
     33  svm::KernelFunction* kf =
     34    new svm::PolynomialKernelFunction();
     35  svm::Kernel kernel(data,*kf);
     36  gslapi::matrix diff(kernel.get()-kernel_matlab);
    4037  double tmp=0;
    4138  for(u_int i=0;i<diff.rows();i++)
    4239    for(u_int j=0;j<diff.rows();j++)
    43       tmp+=abs(diff(i,j)/kernel_matlab(i,j));
     40      tmp+=fabs(diff(i,j)/kernel_matlab(i,j));
    4441  delete kf;
    4542  if (tmp > diff.rows()*diff.rows()/100000)
     
    4744 
    4845  is.open("data/nm_kernel2.txt");
    49   theplu::gslapi::matrix kernel_matlab2(is);
     46  gslapi::matrix kernel_matlab2(is);
    5047  is.close();
    51   kf = new theplu::cpptools::PolynomialKernelFunction(2);
    52   theplu::cpptools::Kernel kernel2(data,*kf);
     48  kf = new svm::PolynomialKernelFunction(2);
     49  svm::Kernel kernel2(data,*kf);
    5350  diff = kernel2.get()-kernel_matlab2;
    5451  tmp=0;
    5552  for(u_int i=0;i<diff.rows();i++)
    5653    for(u_int j=0;j<diff.rows();j++)
    57       tmp+=abs(diff(i,j)/kernel_matlab2(i,j));
     54      tmp+=fabs(diff(i,j)/kernel_matlab2(i,j));
    5855  if (tmp > diff.rows()*diff.rows()/100)
    5956    ok = false;
  • trunk/test/matrix_test.cc

    r300 r301  
    11// $Id$
    22
    3 // C++ tools include
    4 ////////////////////
    5 #include "matrix.h"
     3#include <c++_tools/gslapi/matrix.h>
    64
    7 // Standard includes
    8 ////////////////////
    95#include <fstream>
    106#include <iostream>
     
    139
    1410
    15   using namespace std;
    16   using namespace theplu::gslapi;
     11  using namespace theplu;
    1712  bool ok = true;
    1813
    19   matrix m(3,3,9);
     14  gslapi::matrix m(3,3,9);
    2015
    21   matrix m2(m);
     16  gslapi::matrix m2(m);
    2217  if (m2!=m)
    2318    ok=false;
     
    2722
    2823  std::ifstream is("data/tmp_test_matrix.txt");
    29   matrix m3(is);
     24  gslapi::matrix m3(is);
    3025  is.close();
    3126  if (m3!=m2)
  • trunk/test/merge_test.cc

    r300 r301  
    11// $Id$
    22
    3 #include "Merge.h"
     3#include <c++_tools/utility/Merge.h>
    44
    55#include <fstream>
     
    99int main(const int argc,const char* argv[])
    1010{
     11  using namespace theplu;
     12 
    1113  std::ifstream data_stream("data/merge_matrix.data");
    1214  std::ifstream error_stream("data/merge_error.data");
    1315  std::ifstream annots_stream("data/merge_annots.data");
    14   theplu::cpptools::Merge merge(data_stream,error_stream,annots_stream);
     16  utility::Merge merge(data_stream, error_stream, annots_stream);
    1517  merge.do_something();
    16   return 0; // normal exit
     18  return 0;
    1719}
  • trunk/test/nni_test.cc

    r300 r301  
    11// $Id$
     2
     3#include <c++_tools/utility/FileIO.h>
     4#include <c++_tools/gslapi/matrix.h>
     5#include <c++_tools/utility/kNNI.h>
     6#include <c++_tools/utility/WeNNI.h>
    27
    38#include <cmath>
     
    611#include <string>
    712
    8 #include "FileIO.h"
    9 #include "matrix.h"
    10 #include "kNNI.h"
    11 #include "WeNNI.h"
     13using namespace theplu;
    1214
    1315void check_file_access(std::string& str)
    1416{
    15   if (theplu::cpptools::FileIO().access_rights(str,"r")) {
     17  if (utility::FileIO().access_rights(str,"r")) {
    1618    std::cerr << "test_nni: Cannot access file " << str << std::endl;
    1719    exit(-1);
     
    4042  std::ifstream data_stream(knni_data.c_str());
    4143  std::ifstream weight_stream(knni_weight.c_str());
    42   theplu::gslapi::matrix data(data_stream);
    43   theplu::gslapi::matrix weight(weight_stream);
    44   theplu::cpptools::kNNI knni(data,weight,neighbours);
     44  gslapi::matrix data(data_stream);
     45  gslapi::matrix weight(weight_stream);
     46  utility::kNNI knni(data,weight,neighbours);
    4547  knni.estimate();
    4648  std::ifstream control_stream(knni_result.c_str());
    47   theplu::gslapi::matrix control(control_stream);
     49  gslapi::matrix control(control_stream);
    4850  control-=knni.imputed_data();
    4951  // Jari, should we use GSL defined round off errors? Anyway, the
     
    7375  // test WeNNI
    7476  data_stream.open(wenni_data.c_str());
    75   data=theplu::gslapi::matrix(data_stream);
     77  data=gslapi::matrix(data_stream);
    7678  weight_stream.open(wenni_weight.c_str());
    77   weight=theplu::gslapi::matrix(weight_stream);
    78   theplu::cpptools::WeNNI wenni(data,weight,neighbours);
     79  weight=gslapi::matrix(weight_stream);
     80  utility::WeNNI wenni(data,weight,neighbours);
    7981  wenni.estimate();
    8082  control_stream.open(wenni_result.c_str());
    81   control=theplu::gslapi::matrix(control_stream);
     83  control=gslapi::matrix(control_stream);
    8284  control-=wenni.imputed_data();
    8385  for (unsigned int i=0; i<control.rows(); i++)
  • trunk/test/pca_test.cc

    r300 r301  
    11// $Id$
    22
    3 #include "PCA.h"
     3#include <c++_tools/utility/PCA.h>
    44
    55#include <cmath>
     
    1818      A(i,j)= sin( static_cast<double>(i+j+2+(i+1)*(j+1)) );
    1919
    20   cpptools::PCA pca(A);
     20  utility::PCA pca(A);
    2121
    2222// Print only matrix that is row-centered as PCA ( process() )
  • trunk/test/regression_linear_test.cc

    r300 r301  
    33// C++ tools include
    44////////////////////
    5 #include "RegressionLinear.h"
    6 #include "vector.h"
     5#include <c++_tools/statistics/RegressionLinear.h>
     6#include <c++_tools/gslapi/vector.h>
    77
    8 
    9 // Standard includes
    10 ////////////////////
    118#include <gsl/gsl_fit.h>
    129#include <iostream>
    1310
    1411
    15 using namespace std;
    16 
    1712int main()
    1813
    1914
     15  using namespace theplu;
    2016  bool ok=true;
    2117
    22   theplu::gslapi::vector x(4);
     18  gslapi::vector x(4);
    2319  x(0)=1970;
    2420  x(1)=1980;
    2521  x(2)=1990;
    2622  x(3)=2000;
    27   theplu::gslapi::vector y(4);
     23  gslapi::vector y(4);
    2824  y(0)=12;
    2925  y(1)=11;
    3026  y(2)=14;
    3127  y(3)=13;
    32   theplu::gslapi::vector w(4);
     28  gslapi::vector w(4);
    3329  w(0)=0.1;
    3430  w(1)=0.2;
     
    3632  w(3)=0.4;
    3733
    38   theplu::statistics::RegressionLinear r;
     34  statistics::RegressionLinear r;
    3935  r.fit(x,w,y);
    4036  double y_predicted=0;
  • trunk/test/regression_local_test.cc

    r300 r301  
    11// $Id$
    22
    3 // C++ tools include
    4 ////////////////////
    5 #include "RegressionKernelBox.h"
    6 #include "RegressionLinear.h"
    7 #include "RegressionLocal.h"
    8 #include "RegressionNaive.h"
    9 #include "vector.h"
     3#include <c++_tools/statistics/KernelBox.h>
     4#include <c++_tools/statistics/RegressionLinear.h>
     5#include <c++_tools/statistics/RegressionLocal.h>
     6#include <c++_tools/statistics/RegressionNaive.h>
     7#include <c++_tools/gslapi/vector.h>
    108
    119#include <string>
    12 // Standard includes
    13 ////////////////////
    1410#include <cmath>
    1511#include <fstream>
     
    1915using namespace theplu;
    2016
    21 bool test(statistics::Regression& r, statistics::RegressionKernel& k)
     17bool test(statistics::Regression& r, statistics::Kernel& k)
    2218{
    2319  statistics::RegressionLocal rl(r,k);
     
    4541 
    4642  statistics::RegressionNaive rn;
    47   statistics::RegressionKernelBox kb;
     43  statistics::KernelBox kb;
    4844  ok = (ok && test(rn,kb));
    4945
  • trunk/test/regression_naive_test.cc

    r300 r301  
    11// $Id$
    22
    3 #include "RegressionNaive.h"
    4 #include "vector.h"
     3#include <c++_tools/statistics/RegressionNaive.h>
     4#include <c++_tools/gslapi/vector.h>
    55
    66int main()
    7 
    87
     8  using namespace theplu;
    99  bool ok=true;
    1010
    11   theplu::gslapi::vector x(4);
     11  gslapi::vector x(4);
    1212  x(0)=1970;
    1313  x(1)=1980;
    1414  x(2)=1990;
    1515  x(3)=2000;
    16   theplu::gslapi::vector y(4);
     16  gslapi::vector y(4);
    1717  y(0)=12;
    1818  y(1)=11;
    1919  y(2)=14;
    2020  y(3)=13;
    21   theplu::gslapi::vector w(4);
     21  gslapi::vector w(4);
    2222  w(0)=0.1;
    2323  w(1)=0.2;
     
    2525  w(3)=0.4;
    2626
    27   theplu::statistics::RegressionNaive r;
     27  statistics::RegressionNaive r;
    2828  r.fit(x,y,w);
    2929  double y_predicted=0;
  • trunk/test/rnd_test.cc

    r300 r301  
    22
    33#include <iostream>
    4 #include "random_singleton.h"
     4#include <c++_tools/utility/random_singleton.h>
    55
    6 using namespace theplu::cpptools;
    7 using namespace std;
    86
     7using namespace theplu;
    98
    109int main()
    1110{
    12   random_singleton* my_rnd;
    13   my_rnd = random_singleton::get_instance( -1 );
     11  utility::random_singleton* my_rnd;
     12  my_rnd = utility::random_singleton::get_instance( -1 );
    1413 
    1514  double* prob = new double[ 5 ];
  • trunk/test/roc_test.cc

    r300 r301  
    11// $Id$
    22
    3 // C++ tools include
    4 ////////////////////
    5 #include "matrix.h"
    6 #include "ROC.h"
    7 #include "vector.h"
     3#include <c++_tools/gslapi/matrix.h>
     4#include <c++_tools/statistics/ROC.h>
     5#include <c++_tools/gslapi/vector.h>
    86
    9 
    10 // Standard includes
    11 ////////////////////
    127#include <gsl/gsl_cdf.h>
    138#include <cmath>
     
    1611
    1712
    18 using namespace std;
     13using namespace theplu;
    1914
    2015int main(const int argc,const char* argv[])
     
    2217  bool print = (argc>1 && argv[1]==std::string("-p"));
    2318  bool ok = true;
    24   theplu::gslapi::vector value(31);
    25   theplu::gslapi::vector target(31,-1);
     19  gslapi::vector value(31);
     20  gslapi::vector target(31,-1);
    2621  for (unsigned int i=0; i<16; i++)
    2722    target(i) = 1;
    2823  for (unsigned int i=0; i<value.size(); i++)
    2924    value(i)=i;
    30   theplu::cpptools::ROC roc;
     25  statistics::ROC roc;
    3126  double area = roc.score(target, value);
    3227  if (area!=1.0){
    3328    if (print)
    34       cerr << "test_roc a: area is " << area << " should be 1.0" << endl;
     29      std::cerr << "test_roc a: area is " << area << " should be 1.0"
     30                << std::endl;
    3531    ok = false;
    3632  }
     
    3834  if (area!=1.0){
    3935    if (print)
    40       cerr << "test_roc: area is " << area << " should be 1.0" << endl;
     36      std::cerr << "test_roc: area is " << area << " should be 1.0"
     37                << std::endl;
    4138    ok = false;
    4239  }
     
    4643  if (p/p_matlab > 1.01 | p/p_matlab < 0.99){
    4744    if (print)
    48       cerr << "get_p_approx: p-value not correct" << endl;
     45      std::cerr << "get_p_approx: p-value not correct" << std::endl;
    4946    ok = false;
    5047  }
     
    5350  if (p > pow(10, -8.0) | p < pow(10, -9.0)){
    5451    if (print)
    55       cerr << "get_p_exact: p-value not correct" << endl;
     52      std::cerr << "get_p_exact: p-value not correct" << std::endl;
    5653    ok = false;
    5754  }
    5855 
    59   ifstream is("data/rank_data.txt");
    60   theplu::gslapi::matrix data(is);
     56  std::ifstream is("data/rank_data.txt");
     57  gslapi::matrix data(is);
    6158  is.close();
    6259
    6360  is.open("data/rank_target.txt");
    64   theplu::gslapi::vector target2(is);
     61  gslapi::vector target2(is);
    6562  is.close();
    6663 
    67   theplu::gslapi::vector correct_area(3);
     64  gslapi::vector correct_area(3);
    6865  correct_area(0)=8.0/9.0;
    6966  correct_area(1)=6.0/9.0;
     
    7269  const double tol = 0.001;
    7370  for (size_t i=0; i<data.rows(); i++){
    74     theplu::gslapi::vector vec = data[i];
     71    gslapi::vector vec = data[i];
    7572    area = roc.score(target2,vec);
    7673    if (area<correct_area(i)-tol || area>correct_area(i)+tol){
    7774      if (print){
    78         cerr << "test_roc: area is " << area << " should be "
    79              << correct_area(i) << endl;
     75        std::cerr << "test_roc: area is " << area << " should be "
     76             << correct_area(i) << std::endl;
    8077      }
    8178      ok=false;
     
    8380  }
    8481
    85   theplu::gslapi::vector weight(target2.size(),1);
     82  gslapi::vector weight(target2.size(),1);
    8683  for (size_t i=0; i<data.rows(); i++){
    87     theplu::gslapi::vector vec = data[i];
     84    gslapi::vector vec = data[i];
    8885    area = roc.score(target2, vec, weight);
    8986    if (area<correct_area(i)-tol || area>correct_area(i)+tol){
    9087      if (print){
    91         cerr << "test_roc: weighted area is " << area << " should be "
    92              << correct_area(i) << endl;
     88        std::cerr << "test_roc: weighted area is " << area << " should be "
     89             << correct_area(i) << std::endl;
    9390      }
    9491      ok=false;
  • trunk/test/statistics_test.cc

    r300 r301  
    11// $Id$
    22
    3 // C++ tools include
    4 ////////////////////
    5 #include "Statistics.h"
     3#include <c++_tools/statistics/utility.h>
    64
    7 // Standard includes
    8 ////////////////////
    95#include <vector>
    106#include <cstdlib>
  • trunk/test/stl_utility_test.cc

    r300 r301  
    11// $Id$
    22
    3 // C++ tools include
    4 ////////////////////
    5 #include "stl_utility.h"
     3#include <c++_tools/utility/stl_utility.h>
    64
    7 // Standard includes
    8 ////////////////////
    95#include <fstream>
    106#include <iostream>
     
    139
    1410
    15   using namespace std;
    16   using namespace theplu::cpptools;
     11  using namespace theplu;
    1712  bool ok = true;
    1813
    19   ifstream is("data/read_to_test.data");
    20   vector<string> vec;
    21   read_to_string(is, vec);
     14  std::ifstream is("data/read_to_test.data");
     15  std::vector<std::string> vec;
     16  utility::read_to_string(is, vec);
    2217  if (vec.size()-2){
    2318    ok=false;
    2419  }
    25   else if (vec[0]!=string("Age"))
     20  else if (vec[0]!=std::string("Age"))
    2621    ok=false;
    2722
    28   vector<int> vec1;
    29   read_to_int(is, vec1);
     23  std::vector<int> vec1;
     24  utility::read_to_int(is, vec1);
    3025  if (vec1.size()-2){
    3126    ok=false;
     
    3429    ok=false;
    3530
    36   vector<double> vec2;
    37   read_to_double(is, vec2);
    38   read_to_double(is, vec2);
     31  std::vector<double> vec2;
     32  utility::read_to_double(is, vec2);
     33  utility::read_to_double(is, vec2);
    3934  if (vec2.size()-2){
    4035    ok=false;
  • trunk/test/svd_test.cc

    r300 r301  
    11// $Id$
    2 //
    3 // Testing for a succesful reconstruction of a decomposed random
    4 // matrix, aswell that U and V are orthogonal.
    52
     3#include <c++_tools/utility/SVD.h>
     4#include <c++_tools/gslapi/matrix.h>
     5#include <c++_tools/utility/random_singleton.h>
     6#include <c++_tools/gslapi/vector.h>
    67
    7 #include "SVD.h"
    8 #include "matrix.h"
    9 #include "random_singleton.h"
    10 #include "vector.h"
     8using namespace theplu;
    119
    12 using namespace std;
    13 using namespace theplu::cpptools;
    14 using namespace theplu::gslapi;
    15 
    16 
    17 
    18 double this_norm(const matrix& A)
     10double this_norm(const gslapi::matrix& A)
    1911{
    2012  double sum=0.0;
     
    2719
    2820
    29 bool test(size_t m, size_t n, SVD::SVDalgorithm algo) {
     21bool test(size_t m, size_t n, utility::SVD::SVDalgorithm algo) {
    3022
    3123  // accepted error, Jari: should be picked up from GSL
    3224  double MAXTOL=1e-13;
    33   random_singleton* rng=random_singleton::get_instance(-1);
     25  utility::random_singleton* rng=utility::random_singleton::get_instance(-1);
    3426
    3527  // initialise a random test-matrix
    36   matrix A(m,n);
     28  gslapi::matrix A(m,n);
    3729  for (size_t i=0; i<m; ++i)
    3830    for(size_t j=0; j<n; ++j)
    3931      A(i,j)=1000*rng->get_uniform_double();
    4032
    41   SVD svd(A);
     33  utility::SVD svd(A);
    4234  svd.decompose(algo);
    4335  theplu::gslapi::vector s(svd.s());
    44   matrix S(s.size(),s.size());
     36  gslapi::matrix S(s.size(),s.size());
    4537  for (size_t i=0; i<s.size(); ++i)
    4638    S(i,i)=s[i];
    47   matrix V=svd.V();
    48   matrix U=svd.U();
     39  gslapi::matrix V=svd.V();
     40  gslapi::matrix U=svd.U();
    4941  double error = this_norm(A-U*S*V.transpose());
    5042  bool testerror=false;
    5143  if (error>MAXTOL) {
    52     cerr << "test_svd: FAILED, algorithm " << algo << " recontruction error ("
    53          << error << ") > tolerance (" << MAXTOL << "), matrix dimension ("
    54          << m << ',' << n << ')' << endl;
     44    std::cerr << "test_svd: FAILED, algorithm " << algo
     45              << " recontruction error ("
     46              << error << ") > tolerance (" << MAXTOL << "), matrix dimension ("
     47              << m << ',' << n << ')' << std::endl;
    5548    testerror=true;
    5649  }
     
    5851  error=this_norm(V.transpose()*V)-n;
    5952  if (error>MAXTOL) {
    60     cerr << "test_svd: FAILED, algorithm " << algo << " V orthogonality error ("
    61          << error << ") > tolerance (" << MAXTOL << ')' << endl;
     53    std::cerr << "test_svd: FAILED, algorithm " << algo
     54              << " V orthogonality error ("
     55              << error << ") > tolerance (" << MAXTOL << ')' << std::endl;
    6256    testerror=true;
    6357  }
     
    6559  error=this_norm(U.transpose()*U)-n;
    6660  if (error>MAXTOL) {
    67     cerr << "test_svd: FAILED, algorithm " << algo << " U orthogonality error ("
    68          << error << ") > tolerance (" << MAXTOL << ')' << endl;
     61    std::cerr << "test_svd: FAILED, algorithm " << algo
     62              << " U orthogonality error ("
     63              << error << ") > tolerance (" << MAXTOL << ')' << std::endl;
    6964    testerror=true;
    7065  }
     
    8075  // The GSL Jacobi, Golub-Reinsch, and modified Golub-Reinsch
    8176  // implementations supports rows>=columns matrix dimensions only
    82   testfail|=test(12,12,SVD::GolubReinsch);
    83   testfail|=test(12,4,SVD::GolubReinsch);
    84   testfail|=test(12,12,SVD::ModifiedGolubReinsch);
    85   testfail|=test(12,4,SVD::ModifiedGolubReinsch);
    86   testfail|=test(12,12,SVD::Jacobi);
    87   testfail|=test(12,4,SVD::Jacobi);
     77  testfail|=test(12,12,utility::SVD::GolubReinsch);
     78  testfail|=test(12,4,utility::SVD::GolubReinsch);
     79  testfail|=test(12,12,utility::SVD::ModifiedGolubReinsch);
     80  testfail|=test(12,4,utility::SVD::ModifiedGolubReinsch);
     81  testfail|=test(12,12,utility::SVD::Jacobi);
     82  testfail|=test(12,4,utility::SVD::Jacobi);
    8883
    8984  return (testfail ? -1 : 0);
  • trunk/test/svm_test.cc

    r300 r301  
    11// $Id$
    22
    3 // C++ tools include
    4 ////////////////////
    5 #include "matrix.h"
    6 #include "vector.h"
    7 #include "SVM.h"
    8 #include "Kernel.h"
    9 #include "PolynomialKernelFunction.h"
     3#include <c++_tools/gslapi/matrix.h>
     4#include <c++_tools/gslapi/vector.h>
     5#include <c++_tools/svm/SVM.h>
     6#include <c++_tools/svm/Kernel.h>
     7#include <c++_tools/svm/PolynomialKernelFunction.h>
    108
    11 // Standard includes
    12 ////////////////////
    139#include <fstream>
    1410#include <iostream>
     
    1612#include <limits.h>
    1713
    18 using namespace std;
     14using namespace theplu;
    1915
    2016int main()
     
    5955 
    6056  // testing on non solvable problem
    61   theplu::gslapi::matrix data(3,1);
     57  gslapi::matrix data(3,1);
    6258  data(0,0)=-1;
    6359  data(1,0)=10;
    6460  data(2,0)=0;
    6561   
    66   theplu::gslapi::vector target(3,1.0);
     62  gslapi::vector target(3,1.0);
    6763  target(2)=-1;
    68   theplu::cpptools::KernelFunction* kf =
    69     new theplu::cpptools::PolynomialKernelFunction();
    70   theplu::cpptools::Kernel kernel(data,*kf);
     64  svm::KernelFunction* kf =
     65    new svm::PolynomialKernelFunction();
     66  svm::Kernel kernel(data,*kf);
    7167  //theplu::gslapi::matrix m=kernel.get();
    7268  //std::cout << "kernel:\n" << m << "\n";
    73   theplu::cpptools::SVM svm(kernel,target);
     69  svm::SVM svm(kernel,target);
    7470  //  svm.set_c(1);
    7571  //svm.train();
  • trunk/test/vector_test.cc

    r300 r301  
    11// $Id$
    22
    3 #include "vector.h"
    4 #include "gslapi_utility.h"
     3#include <c++_tools/gslapi/vector.h>
     4#include <c++_tools/gslapi/utility.h>
     5
     6using namespace theplu;
    57
    68int main(const int argc,const char* argv[])
     
    810  bool ok = true;
    911
    10   theplu::gslapi::vector vec(12);
     12  gslapi::vector vec(12);
    1113  for (unsigned int i=0; i<vec.size(); i++)
    1214    vec(i)=i;
     
    2325  for (unsigned int i=0; i<vec.size(); i+=2)
    2426    sum_before+=vec[i];
    25   theplu::gslapi::vector vec_view(vec,0,6,2);
     27  gslapi::vector vec_view(vec,0,6,2);
    2628  sum_after=vec_view.sum();
    2729  if (sum_after != sum_before)
     
    3335
    3436  // checking that copy contrutor creates an independent object
    35   theplu::gslapi::vector vec2(vec);
     37  gslapi::vector vec2(vec);
    3638  if (vec.size()!=vec2.size())
    3739    ok=false;
  • trunk/todo.txt

    r281 r301  
    1 ///
    2 /// File with items to do. Line should start with class:
    3 ///
Note: See TracChangeset for help on using the changeset viewer.