Changeset 616 for trunk/test
- Timestamp:
- Aug 31, 2006, 10:52:02 AM (17 years ago)
- Location:
- trunk/test
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/alignment_test.cc
r442 r616 3 3 #include <c++_tools/utility/Alignment.h> 4 4 5 #include <c++_tools/ gslapi/matrix.h>5 #include <c++_tools/utility/matrix.h> 6 6 7 7 #include <gsl/gsl_cdf.h> … … 54 54 const std::vector<double>& l2, 55 55 const double sigma, 56 theplu:: gslapi::matrix& dot_matrix,56 theplu::utility::matrix& dot_matrix, 57 57 std::vector<std::pair<size_t,size_t> >& path) 58 58 { 59 dot_matrix = theplu:: gslapi::matrix(l1.size(),l2.size());59 dot_matrix = theplu::utility::matrix(l1.size(),l2.size()); 60 60 for (size_t i=0; i<l1.size(); i++) 61 61 for (size_t j=0; j<l2.size(); j++) { … … 78 78 for (size_t i=0; i<peaksets.size()-1; i++) 79 79 for (size_t j=i+1; j<peaksets.size(); j++) { 80 gslapi::matrix dot_m;80 utility::matrix dot_m; 81 81 std::vector<std::pair<size_t,size_t> > path; 82 82 score(peaksets[i], peaksets[j], 1.0, dot_m, path); -
trunk/test/averager_test.cc
r583 r616 5 5 #include <c++_tools/statistics/AveragerPairWeighted.h> 6 6 #include <c++_tools/statistics/AveragerWeighted.h> 7 #include <c++_tools/ gslapi/vector.h>7 #include <c++_tools/utility/vector.h> 8 8 9 9 #include <fstream> … … 91 91 // Testing AveragerWeighted 92 92 *error << "testing AveragerWeighted" << std::endl; 93 theplu:: gslapi::vector x(3,0);93 theplu::utility::vector x(3,0); 94 94 x(0)=0; 95 95 x(1)=1; 96 96 x(2)=2; 97 theplu:: gslapi::vector w(3,1);97 theplu::utility::vector w(3,1); 98 98 theplu::statistics::AveragerWeighted aw; 99 99 aw.add_values(x,w); … … 152 152 AveragerPairWeighted apw; 153 153 x(0)=0; x(1)=1; x(2)=2; 154 theplu:: gslapi::vector y(3,0);154 theplu::utility::vector y(3,0); 155 155 x(0)=0; x(1)=0; x(2)=2; 156 156 apw.add_values(x,y,w,w); -
trunk/test/consensus_inputranker_test.cc
r615 r616 5 5 #include <c++_tools/classifier/ConsensusInputRanker.h> 6 6 #include <c++_tools/statistics/ROC.h> 7 #include <c++_tools/ gslapi/matrix.h>7 #include <c++_tools/utility/matrix.h> 8 8 #include <c++_tools/classifier/MatrixLookup.h> 9 9 #include <c++_tools/classifier/CrossValidationSampler.h> … … 31 31 32 32 ifstream is("data/rank_data.txt"); 33 theplu:: gslapi::matrix data_tmp(is);33 theplu::utility::matrix data_tmp(is); 34 34 theplu::classifier::MatrixLookup data(data_tmp); 35 35 is.close(); … … 56 56 } 57 57 58 theplu:: gslapi::matrix flag(data.rows(),data.columns(),1);58 theplu::utility::matrix flag(data.rows(),data.columns(),1); 59 59 // Peter, fix weighted version instead 60 60 theplu::classifier::ConsensusInputRanker cir2(sampler,data,roc); -
trunk/test/crossvalidation_test.cc
r615 r616 5 5 #include <c++_tools/classifier/MatrixLookup.h> 6 6 #include <c++_tools/classifier/Target.h> 7 #include <c++_tools/ gslapi/matrix.h>7 #include <c++_tools/utility/matrix.h> 8 8 9 9 #include <cstdlib> … … 40 40 41 41 classifier::Target target(label); 42 gslapi::matrix raw_data(10,10);42 utility::matrix raw_data(10,10); 43 43 classifier::MatrixLookup data(raw_data); 44 44 classifier::CrossValidationSampler cv(target,3,3); … … 81 81 82 82 target=classifier::Target(label); 83 gslapi::matrix raw_data2(2,9);83 utility::matrix raw_data2(2,9); 84 84 for(size_t i=0;i<raw_data2.rows();i++) 85 85 for(size_t j=0;j<raw_data2.columns();j++) -
trunk/test/data_lookup_1d_test.cc
r593 r616 1 1 // $Id$ 2 2 3 #include <c++_tools/ gslapi/matrix.h>3 #include <c++_tools/utility/matrix.h> 4 4 #include <c++_tools/classifier/DataLookup1D.h> 5 5 #include <c++_tools/classifier/MatrixLookup.h> … … 12 12 using namespace theplu; 13 13 14 gslapi::matrix matrix(size_t n);14 utility::matrix matrix(size_t n); 15 15 16 16 int main(const int argc,const char* argv[]) … … 31 31 32 32 *error << "Testing DataLookup1D" << std::endl; 33 gslapi::matrix gsl_m1(matrix(5));33 utility::matrix gsl_m1(matrix(5)); 34 34 std::vector<size_t> index_odd; 35 35 index_odd.push_back(1); … … 97 97 98 98 *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..."; 100 100 101 101 // First with a vector with no missing values separated by ' '. … … 104 104 my_out.close(); 105 105 std::ifstream is("data/tmp_test_datalookup1D.txt"); 106 gslapi::vector v5(is);106 utility::vector v5(is); 107 107 is.close(); 108 108 if (v5.size()!=v1.size() || v5(0)!=v1(0) || v5(1)!=v1(1) || … … 122 122 my_out.close(); 123 123 is.open("data/tmp_test_datalookup1D.txt"); 124 gslapi::vector v7(is,'\t');124 utility::vector v7(is,'\t'); 125 125 is.close(); 126 126 if (v7.size()!=v6.size() || !std::isnan(v7(1))) { … … 141 141 } 142 142 143 gslapi::matrix matrix(size_t n)143 utility::matrix matrix(size_t n) 144 144 { 145 gslapi::matrix res(n,n);145 utility::matrix res(n,n); 146 146 for (size_t i=0;i<n;i++) 147 147 for (size_t j=0;j<n;j++) -
trunk/test/ensemble_test.cc
r615 r616 1 1 // $Id$ 2 2 3 #include <c++_tools/gslapi/matrix.h> 4 #include <c++_tools/gslapi/vector.h> 3 #include <c++_tools/utility/matrix.h> 5 4 #include <c++_tools/classifier/SubsetGenerator.h> 6 5 #include <c++_tools/classifier/CrossValidationSampler.h> … … 39 38 *error << "loading data" << std::endl; 40 39 std::ifstream is("data/nm_data_centralized.txt"); 41 gslapi::matrix data_core(is);40 utility::matrix data_core(is); 42 41 is.close(); 43 42 -
trunk/test/inputranker_test.cc
r604 r616 3 3 #include <c++_tools/classifier/InputRanker.h> 4 4 #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> 7 6 #include <c++_tools/classifier/MatrixLookup.h> 8 7 #include <c++_tools/classifier/Target.h> … … 29 28 30 29 std::ifstream is("data/rank_data.txt"); 31 theplu:: gslapi::matrix data_tmp(is);30 theplu::utility::matrix data_tmp(is); 32 31 theplu::classifier::MatrixLookup data(data_tmp); 33 32 is.close(); -
trunk/test/kernel_lookup_test.cc
r559 r616 1 1 // $Id$ 2 2 3 #include <c++_tools/ gslapi/matrix.h>3 #include <c++_tools/utility/matrix.h> 4 4 #include <c++_tools/classifier/DataLookup1D.h> 5 5 #include <c++_tools/classifier/KernelLookup.h> … … 30 30 bool ok =true; 31 31 *error << "\nTesting KernelLookup" << std::endl; 32 gslapi::matrix data_core(1,5);32 utility::matrix data_core(1,5); 33 33 for (size_t i=0; i<data_core.columns(); i++) 34 34 data_core(0,i)=i; -
trunk/test/kernel_test.cc
r536 r616 1 1 // $Id$ 2 3 2 4 3 // C++ tools include 5 4 //////////////////// 6 #include <c++_tools/gslapi/matrix.h> 7 #include <c++_tools/gslapi/vector.h> 5 #include <c++_tools/utility/matrix.h> 8 6 #include <c++_tools/classifier/KernelFunction.h> 9 7 #include <c++_tools/classifier/PolynomialKernelFunction.h> … … 25 23 bool test_MEV(const classifier::MatrixLookup& data, 26 24 const classifier::KernelFunction* kf, 27 const gslapi::matrix& control, const double error_bound,25 const utility::matrix& control, const double error_bound, 28 26 std::ostream* error); 29 27 30 28 bool test_SEV(const classifier::MatrixLookup& data, 31 29 const classifier::KernelFunction* kf, 32 const gslapi::matrix& control, const double error_bound,30 const utility::matrix& control, const double error_bound, 33 31 std::ostream* error); 34 32 … … 48 46 bool ok = true; 49 47 50 gslapi::matrix data2_core(2,3);48 utility::matrix data2_core(2,3); 51 49 data2_core(0,0)=0; 52 50 data2_core(1,0)=0; … … 77 75 double error_bound = 1e-8; 78 76 std::ifstream is("data/nm_data_centralized.txt"); 79 gslapi::matrix data_core(is);77 utility::matrix data_core(is); 80 78 is.close(); 81 79 … … 83 81 84 82 is.open("data/nm_kernel.txt"); 85 gslapi::matrix kernel_matlab(is);83 utility::matrix kernel_matlab(is); 86 84 is.close(); 87 85 classifier::KernelFunction* kf = new classifier::PolynomialKernelFunction(); … … 91 89 92 90 is.open("data/nm_kernel2.txt"); 93 gslapi::matrix kernel_matlab2(is);91 utility::matrix kernel_matlab2(is); 94 92 is.close(); 95 93 kf = new classifier::PolynomialKernelFunction(2); … … 102 100 delete kf; 103 101 104 data_core = gslapi::matrix(1,5);102 data_core = utility::matrix(1,5); 105 103 for (size_t i=0; i<data_core.columns(); i++) 106 104 data_core(0,i)=i; … … 120 118 bool test_MEV(const classifier::MatrixLookup& data, 121 119 const classifier::KernelFunction* kf, 122 const gslapi::matrix& control, const double error_bound,120 const utility::matrix& control, const double error_bound, 123 121 std::ostream* error) 124 122 { … … 162 160 bool test_SEV(const classifier::MatrixLookup& data, 163 161 const classifier::KernelFunction* kf, 164 const gslapi::matrix& control, const double error_bound,162 const utility::matrix& control, const double error_bound, 165 163 std::ostream* error) 166 164 { -
trunk/test/matrix_lookup_test.cc
r537 r616 1 1 // $Id$ 2 2 3 #include <c++_tools/ gslapi/matrix.h>3 #include <c++_tools/utility/matrix.h> 4 4 #include <c++_tools/classifier/MatrixLookup.h> 5 5 … … 10 10 using namespace theplu; 11 11 12 gslapi::matrix matrix(size_t n);12 utility::matrix matrix(size_t n); 13 13 14 14 int main(const int argc,const char* argv[]) … … 27 27 28 28 *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)); 31 31 classifier::MatrixLookup m1(gsl_m1); 32 32 if (m1.rows()!=gsl_m1.rows() || m1.columns()!=gsl_m1.columns() || … … 40 40 41 41 42 *error << "MatrixLookup::MatrixLookup(const gslapi::matrix&,\n"42 *error << "MatrixLookup::MatrixLookup(const utility::matrix&,\n" 43 43 << " const std::vector<size_t>&,\n" 44 44 << " const std::vector<size_t>&)..."; 45 gslapi::matrix gsl_m2(matrix(4));45 utility::matrix gsl_m2(matrix(4)); 46 46 std::vector<size_t> index_odd; 47 47 index_odd.push_back(1); … … 61 61 *error << "Ok" << std::endl; 62 62 63 *error << "MatrixLookup::MatrixLookup(const gslapi::matrix&,\n"63 *error << "MatrixLookup::MatrixLookup(const utility::matrix&,\n" 64 64 << " const std::vector<size_t>&,\n" 65 65 << " const bool)..."; … … 152 152 } 153 153 154 gslapi::matrix matrix(size_t n)154 utility::matrix matrix(size_t n) 155 155 { 156 gslapi::matrix res(n,n);156 utility::matrix res(n,n); 157 157 for (size_t i=0;i<n;i++) 158 158 for (size_t j=0;j<n;j++) -
trunk/test/matrix_test.cc
r611 r616 1 1 // $Id$ 2 2 3 #include <c++_tools/ gslapi/matrix.h>3 #include <c++_tools/utility/matrix.h> 4 4 5 5 #include <unistd.h> … … 13 13 : m_(i,j,value) {} 14 14 15 inline theplu:: gslapi::vector16 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_; } 19 19 20 20 private: 21 theplu:: gslapi::matrix m_;21 theplu::utility::matrix m_; 22 22 }; 23 23 … … 39 39 40 40 *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); 43 43 if (m2!=m) 44 44 ok=false; … … 51 51 my_out.close(); 52 52 std::ifstream is("data/tmp_test_matrix.txt"); 53 gslapi::matrix m3(is);53 utility::matrix m3(is); 54 54 is.close(); 55 55 if (m3!=m2) … … 58 58 59 59 *error << "\toperator*(double)" << std::endl; 60 gslapi::matrix m4(3,3,1);60 utility::matrix m4(3,3,1); 61 61 m4 *= 9; 62 62 if (m4!=m) { … … 72 72 // lines and other whitespaces. The file is not expected to break 73 73 // things. 74 gslapi::matrix m5(is);74 utility::matrix m5(is); 75 75 is.close(); 76 76 double m5_sum=0; … … 78 78 for (size_t j=0; j<m5.columns(); ++j) 79 79 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); 81 81 double m5sub_sum=0; 82 82 for (size_t i=0; i<m5sub->rows(); ++i) … … 98 98 // Checking that the row view works, i.e. mutation to the view are 99 99 // reflected in the viewed object. 100 gslapi::vector v5subrow(m5,3);100 utility::vector v5subrow(m5,3); 101 101 double v5subrow_sum=0; 102 102 for (size_t i=0; i<v5subrow.size(); ++i) { … … 116 116 // Checking that the column view works, i.e. mutation to the view 117 117 // are reflected in the viewed object. 118 gslapi::vector v5subcolumn(m5,0,false);118 utility::vector v5subcolumn(m5,0,false); 119 119 double v5subcolumn_sum=0; 120 120 for (size_t i=0; i<v5subcolumn.size(); ++i) { … … 143 143 // Checking that a view is not inherited through the copy 144 144 // contructor. 145 gslapi::vector v6(v5subrow);145 utility::vector v6(v5subrow); 146 146 v6.set_all(2); 147 147 double v5subrow_sum3=0; … … 164 164 // Checking that vector::operator= indeed makes a view to become a 165 165 // "normal" vector. 166 v5subrow= gslapi::vector(23,22);166 v5subrow=utility::vector(23,22); 167 167 double m5_sum6=0; 168 168 for (size_t i=0; i<m5.rows(); ++i) … … 178 178 *error << "\tthat class member returns a view" << std::endl; 179 179 matrixwrapper mw(5,2); 180 gslapi::vector mwrow=mw.row(2);180 utility::vector mwrow=mw.row(2); 181 181 if (mwrow.gsl_vector_p()->data != &(mw.matrix()(2,0))) { 182 182 ok=false; … … 186 186 *error << "\tsub-matrix of a sub-matrix" << std::endl; 187 187 // 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); 190 190 subsub(0,0)=23221121; 191 191 if (&sub(2,1)!=&subsub(0,0) || subsub(0,0)!=m5(5,4) || &subsub(0,0)!=&m5(5,4)){ … … 196 196 *error << "\tmatrix::nan()" << std::endl; 197 197 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; 200 200 m_nan->nan(m_weight); 201 201 is.close(); -
trunk/test/ncc_test.cc
r593 r616 5 5 #include <c++_tools/classifier/NCC.h> 6 6 #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> 9 8 #include <c++_tools/statistics/PearsonDistance.h> 10 9 #include <c++_tools/utility/utility.h> … … 35 34 36 35 std::ifstream is("data/sorlie_centroids.txt"); 37 gslapi::matrix data(is,'\t');36 utility::matrix data(is,'\t'); 38 37 is.close(); 39 38 … … 43 42 44 43 // 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); 46 45 for(size_t i=0;i<data.rows();++i) 47 46 for(size_t j=0;j<data.columns();++j) … … 55 54 ncc.train(); 56 55 57 gslapi::matrix prediction;56 utility::matrix prediction; 58 57 ncc.predict(dataview,prediction); 59 58 60 59 is.open("data/sorlie_centroid_predictions.txt"); 61 gslapi::matrix result(is,'\t');60 utility::matrix result(is,'\t'); 62 61 is.close(); 63 62 -
trunk/test/nni_test.cc
r335 r616 2 2 3 3 #include <c++_tools/utility/FileIO.h> 4 #include <c++_tools/ gslapi/matrix.h>4 #include <c++_tools/utility/matrix.h> 5 5 #include <c++_tools/utility/kNNI.h> 6 6 #include <c++_tools/utility/WeNNI.h> … … 42 42 std::ifstream data_stream(knni_data.c_str()); 43 43 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); 46 46 utility::kNNI knni(data,weight,neighbours); 47 47 knni.estimate(); 48 48 std::ifstream control_stream(knni_result.c_str()); 49 gslapi::matrix control(control_stream);49 utility::matrix control(control_stream); 50 50 control-=knni.imputed_data(); 51 51 // Jari, should we use GSL defined round off errors? Anyway, the … … 75 75 // test WeNNI 76 76 data_stream.open(wenni_data.c_str()); 77 data= gslapi::matrix(data_stream);77 data=utility::matrix(data_stream); 78 78 weight_stream.open(wenni_weight.c_str()); 79 weight= gslapi::matrix(weight_stream);79 weight=utility::matrix(weight_stream); 80 80 utility::WeNNI wenni(data,weight,neighbours); 81 81 wenni.estimate(); 82 82 control_stream.open(wenni_result.c_str()); 83 control= gslapi::matrix(control_stream);83 control=utility::matrix(control_stream); 84 84 control-=wenni.imputed_data(); 85 85 for (unsigned int i=0; i<control.rows(); i++) … … 108 108 // test WeNNI with binary weights 109 109 data_stream.open(knni_data.c_str()); 110 data= gslapi::matrix(data_stream);110 data=utility::matrix(data_stream); 111 111 weight_stream.open(knni_weight.c_str()); 112 weight= gslapi::matrix(weight_stream);112 weight=utility::matrix(weight_stream); 113 113 utility::WeNNI wenni2(data,weight,neighbours); 114 114 wenni2.estimate(); 115 115 control_stream.open(knni_result.c_str()); 116 control= gslapi::matrix(control_stream);116 control=utility::matrix(control_stream); 117 117 control-=wenni2.imputed_data(); 118 118 for (unsigned int i=0; i<control.rows(); i++) -
trunk/test/pca_test.cc
r301 r616 1 1 // $Id$ 2 2 3 #include <c++_tools/utility/matrix.h> 3 4 #include <c++_tools/utility/PCA.h> 4 5 … … 9 10 10 11 11 12 12 using namespace theplu; 13 13 int main() 14 14 { 15 gslapi::matrix A( 3, 4 );15 utility::matrix A( 3, 4 ); 16 16 for( size_t i = 0; i < 3; ++i ) 17 17 for( size_t j = 0; j < 4; ++j ) -
trunk/test/regression_test.cc
r586 r616 1 1 // $Id$ 2 2 3 4 #include <c++_tools/gslapi/matrix.h>5 3 #include <c++_tools/statistics/KernelBox.h> 6 4 #include <c++_tools/statistics/Linear.h> … … 11 9 #include <c++_tools/statistics/Polynomial.h> 12 10 #include <c++_tools/statistics/PolynomialWeighted.h> 11 #include <c++_tools/utility/matrix.h> 12 #include <c++_tools/utility/vector.h> 13 13 14 14 #include <cmath> … … 39 39 40 40 // 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; 44 44 45 45 *error << "testing regression::LinearWeighted" << std::endl; … … 84 84 { 85 85 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()); 89 89 for (size_t i=0; i<data.rows(); ++i) { 90 90 x(i)=data(i,0); … … 94 94 statistics::regression::Polynomial polynomialfit(2); 95 95 polynomialfit.fit(x,ln_y); 96 gslapi::vector fit=polynomialfit.fit_parameters();96 utility::vector fit=polynomialfit.fit_parameters(); 97 97 if (fabs(fit[0]-1.012229646706 + fit[1]-0.012561322528 + 98 98 fit[2]+1.159674470130)>1e-11) { // Jari, fix number! … … 132 132 rl.fit(10, 100); 133 133 134 gslapi::vector y = rl.y_predicted();134 utility::vector y = rl.y_predicted(); 135 135 for (size_t i=0; i<y.size(); i++) 136 136 if (y(i)!=10.0){ -
trunk/test/score_test.cc
r514 r616 1 1 // $Id$ 2 2 3 #include <c++_tools/gslapi/matrix.h>4 3 #include <c++_tools/statistics/ROC.h> 5 4 #include <c++_tools/statistics/tScore.h> 6 5 #include <c++_tools/statistics/Pearson.h> 7 6 #include <c++_tools/statistics/FoldChange.h> 8 #include <c++_tools/gslapi/vector.h>9 7 #include <c++_tools/statistics/WilcoxonFoldChange.h> 8 #include <c++_tools/utility/matrix.h> 9 #include <c++_tools/utility/vector.h> 10 10 11 11 #include <gsl/gsl_cdf.h> … … 31 31 32 32 *error << "testing ROC" << std::endl; 33 gslapi::vector value(31);33 utility::vector value(31); 34 34 std::vector<std::string> label(31,"negative"); 35 35 for (size_t i=0; i<16; i++) … … 68 68 69 69 std::ifstream is("data/rank_data.txt"); 70 gslapi::matrix data(is);70 utility::matrix data(is); 71 71 is.close(); 72 72 … … 75 75 is.close(); 76 76 77 gslapi::vector correct_area(3);77 utility::vector correct_area(3); 78 78 correct_area(0)=8.0/9.0; 79 79 correct_area(1)=6.0/9.0; … … 82 82 const double tol = 0.001; 83 83 for (size_t i=0; i<data.rows(); i++){ 84 gslapi::vector vec(data,i);84 utility::vector vec(data,i); 85 85 if (vec.size()!=target2.size()){ 86 86 *error << "vec.size() is " << vec.size() << " and target2.size() is " … … 96 96 } 97 97 98 gslapi::vector weight(target2.size(),1);98 utility::vector weight(target2.size(),1); 99 99 for (size_t i=0; i<data.rows(); i++){ 100 gslapi::vector vec(data,i);100 utility::vector vec(data,i); 101 101 area = roc.score(target2, vec, weight); 102 102 if (area<correct_area(i)-tol || area>correct_area(i)+tol){ -
trunk/test/statistics_test.cc
r588 r616 2 2 3 3 #include <c++_tools/statistics/utility.h> 4 #include <c++_tools/ gslapi/vector.h>4 #include <c++_tools/utility/vector.h> 5 5 6 6 #include <vector> … … 12 12 { 13 13 using namespace theplu; 14 gslapi::vector gsl_vec(10);14 utility::vector gsl_vec(10); 15 15 std::vector<double> data; 16 16 for (unsigned int i=0; i<10; i++){ -
trunk/test/svd_test.cc
r420 r616 1 1 // $Id$ 2 2 3 #include <c++_tools/random/random.h> 4 #include <c++_tools/utility/matrix.h> 3 5 #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> 7 7 8 8 using namespace theplu; 9 9 10 double this_norm(const gslapi::matrix& A)10 double this_norm(const utility::matrix& A) 11 11 { 12 12 double sum=0.0; … … 26 26 // initialise a random test-matrix 27 27 theplu::random::ContinuousUniform rnd; 28 gslapi::matrix A(m,n);28 utility::matrix A(m,n); 29 29 for (size_t i=0; i<m; ++i) 30 30 for(size_t j=0; j<n; ++j) … … 33 33 utility::SVD svd(A); 34 34 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()); 37 37 for (size_t i=0; i<s.size(); ++i) 38 38 S(i,i)=s[i]; 39 gslapi::matrix Vtranspose=svd.V();39 utility::matrix Vtranspose=svd.V(); 40 40 Vtranspose.transpose(); 41 41 // Reconstructing A = U*S*Vtranspose 42 gslapi::matrix Areconstruct=svd.U();42 utility::matrix Areconstruct=svd.U(); 43 43 Areconstruct*=S; 44 44 Areconstruct*=Vtranspose; … … 63 63 } 64 64 65 gslapi::matrix Utranspose=svd.U();65 utility::matrix Utranspose=svd.U(); 66 66 Utranspose.transpose(); 67 67 Utranspose*=svd.U(); // Expect unity matrix -
trunk/test/svm_test.cc
r527 r616 1 1 // $Id$ 2 2 3 #include <c++_tools/gslapi/matrix.h>4 #include <c++_tools/gslapi/vector.h>5 3 #include <c++_tools/classifier/SVM.h> 6 4 #include <c++_tools/classifier/Kernel.h> … … 9 7 #include <c++_tools/classifier/Kernel_MEV.h> 10 8 #include <c++_tools/classifier/PolynomialKernelFunction.h> 9 #include <c++_tools/utility/matrix.h> 10 #include <c++_tools/utility/vector.h> 11 11 12 12 #include <cassert> … … 32 32 bool ok = true; 33 33 34 gslapi::matrix data2_core(2,3);34 utility::matrix data2_core(2,3); 35 35 data2_core(0,0)=0; 36 36 data2_core(1,0)=0; … … 88 88 89 89 std::ifstream is("data/nm_data_centralized.txt"); 90 gslapi::matrix data_core(is);90 utility::matrix data_core(is); 91 91 is.close(); 92 92 … … 102 102 103 103 is.open("data/nm_alpha_linear_matlab.txt"); 104 theplu:: gslapi::vector alpha_matlab(is);104 theplu::utility::vector alpha_matlab(is); 105 105 is.close(); 106 106 … … 112 112 } 113 113 114 theplu:: gslapi::vector alpha = svm.alpha();114 theplu::utility::vector alpha = svm.alpha(); 115 115 116 116 // Comparing alpha to alpha_matlab 117 theplu:: gslapi::vector diff_alpha(alpha);117 theplu::utility::vector diff_alpha(alpha); 118 118 diff_alpha-=alpha_matlab; 119 119 if (diff_alpha*diff_alpha> 1e-10 ){ … … 123 123 124 124 // Comparing output to target 125 theplu:: gslapi::vector output(svm.output());125 theplu::utility::vector output(svm.output()); 126 126 double slack = 0; 127 127 for (unsigned int i=0; i<target.size(); i++){ -
trunk/test/vector_test.cc
r438 r616 3 3 #include <c++_tools/utility/Exception.h> 4 4 #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> 7 7 8 8 #include <fstream> … … 24 24 bool ok = true; 25 25 26 gslapi::vector vec(12);26 utility::vector vec(12); 27 27 for (unsigned int i=0; i<vec.size(); i++) 28 28 vec(i)=i; … … 39 39 for (unsigned int i=0; i<vec.size(); i+=2) 40 40 sum_before+=vec[i]; 41 gslapi::vector vec_view(vec,0,6,2);41 utility::vector vec_view(vec,0,6,2); 42 42 sum_after=vec_view.sum(); 43 43 if (sum_after != sum_before) … … 49 49 50 50 // checking that copy constructor creates an independent object 51 gslapi::vector vec2(vec);51 utility::vector vec2(vec); 52 52 if (vec.size()!=vec2.size()) 53 53 ok=false; … … 85 85 std::ifstream data_stream3(data3.c_str()); 86 86 std::ifstream data_stream4(data4.c_str()); 87 vec= gslapi::vector(data_stream1);87 vec=utility::vector(data_stream1); 88 88 if (vec.size()!=9) 89 89 ok=false; 90 vec= gslapi::vector(data_stream2);90 vec=utility::vector(data_stream2); 91 91 if (vec.size()!=9) 92 92 ok=false; 93 vec= gslapi::vector(data_stream3);93 vec=utility::vector(data_stream3); 94 94 if (vec.size()!=12) 95 95 ok=false; 96 vec= gslapi::vector(data_stream4);96 vec=utility::vector(data_stream4); 97 97 if (vec.size()!=12) 98 98 ok=false; … … 107 107 std::stringstream s; 108 108 s << vec; 109 vec2= gslapi::vector(s);109 vec2=utility::vector(s); 110 110 if (!(vec==vec2)) 111 111 ok=false; … … 120 120 check_file_access(data5); 121 121 std::ifstream data_stream5(data5.c_str()); 122 vec= gslapi::vector(data_stream5); // this will give an exception122 vec=utility::vector(data_stream5); // this will give an exception 123 123 } catch (utility::IO_error& err) { 124 124 if (print) … … 130 130 check_file_access(data); 131 131 std::ifstream data_stream(data.c_str()); 132 vec= gslapi::vector(data_stream); // this will give an exception132 vec=utility::vector(data_stream); // this will give an exception 133 133 } catch (utility::IO_error& err) { 134 134 if (print) … … 143 143 check_file_access(data); 144 144 std::ifstream data_stream(data.c_str()); 145 vec= gslapi::vector(data_stream); // this will give an exception145 vec=utility::vector(data_stream); // this will give an exception 146 146 } catch (utility::IO_error& err) { 147 147 if (print)
Note: See TracChangeset
for help on using the changeset viewer.