Changeset 898 for trunk/test
 Timestamp:
 Sep 26, 2007, 3:44:19 PM (15 years ago)
 Location:
 trunk/test
 Files:

 3 edited
Legend:
 Unmodified
 Added
 Removed

trunk/test/iterator_test.cc
r883 r898 24 24 #include "yat/classifier/DataLookup1D.h" 25 25 26 #include "yat/classifier/DataLookupWeighted1D.h" 27 #include "yat/classifier/MatrixLookupWeighted.h" 26 28 #include "yat/utility/Iterator.h" 29 #include "yat/utility/IteratorWeighted.h" 30 #include "yat/utility/matrix.h" 27 31 #include "yat/utility/vector.h" 28 32 … … 63 67 std::sort(begin, end); 64 68 69 // test std algorithm on IteratorWeighted 70 utility::matrix m(1,3,1); 71 m(0,1)=2.0; 72 utility::matrix w(1,3,1); 73 classifier::MatrixLookupWeighted mw(m,w); 74 classifier::DataLookupWeighted1D aw(mw,0,true); 75 size_t nof1=std::count(aw.begin(),aw.end(),1.0); 76 if(nof1!=2) { 77 *message << "std algoritm with IteratorWeighted failed" << std::endl; 78 ok=false; 79 } 80 65 81 if (!ok) 66 82 *message << "iterator test failed" << std::endl; 
trunk/test/ncc_test.cc
r865 r898 28 28 #include "yat/classifier/Target.h" 29 29 #include "yat/utility/matrix.h" 30 #include "yat/statistics/PearsonDistance.h" 30 #include "yat/statistics/vector_distance_ptr.h" 31 #include "yat/statistics/pearson_vector_distance.h" 31 32 #include "yat/utility/utility.h" 32 33 … … 71 72 72 73 classifier::MatrixLookupWeighted dataviewweighted(data,weights); 73 statistics::PearsonDistance pearson; 74 classifier::NCC ncc(dataviewweighted,targets,pearson); 74 statistics::vector_distance_lookup_weighted_ptr distance= 75 statistics::vector_distance<statistics::pearson_vector_distance_tag>; 76 classifier::NCC ncc(dataviewweighted,targets,distance); 75 77 ncc.train(); 76 78 … … 127 129 128 130 129 // Testing IGP130 classifier:: MatrixLookup dataview(data);131 *error << "testing igp" << std::endl;132 classifier::IGP igp(dataview,targets,pearson);133 *error << igp.score() << std::endl;134 135 131 if(ok) 136 132 *error << "OK" << std::endl; 
trunk/test/vector_distance_test.cc
r897 r898 5 5 #include "yat/statistics/euclidean_vector_distance.h" 6 6 #include "yat/statistics/pearson_vector_distance.h" 7 #include "yat/statistics/vector_distance_ptr.h" 7 8 #include "yat/utility/matrix.h" 8 9 #include "yat/utility/vector.h" … … 14 15 15 16 using namespace theplu::yat; 17 18 19 // Function to test pointers to distance specialized for DataLookup1D::iterator 20 double f(statistics::vector_distance_lookup_weighted_ptr distance) { 21 utility::matrix m(2,3,1); 22 m(0,1)=2; 23 m(1,0)=0; 24 m(1,1)=0; 25 utility::matrix w(2,3,1); 26 w(0,0)=0; 27 classifier::MatrixLookupWeighted mw(m,w); 28 classifier::DataLookupWeighted1D aw(mw,0,true); 29 classifier::DataLookupWeighted1D bw(mw,1,true); 30 31 double dist=(*distance)(aw.begin(),aw.end(),bw.begin()); 32 return dist; 33 } 16 34 17 35 int main(const int argc,const char* argv[]) … … 63 81 64 82 dist=statistics::vector_distance(aw.begin(),aw.end(),bw.begin(), 65 83 statistics::euclidean_vector_distance_tag()); 66 84 67 85 if(fabs(dist2)>tolerance) { … … 79 97 80 98 81 // Test with reference to a vector_distance_tag82 st atistics::euclidean_vector_distance_tag tag;83 s tatistics::vector_distance_tag& tagref=tag;84 dist=statistics::vector_distance(aw.begin(),aw.end(),bw.begin(),tagref);85 *error << "Dist: " << dist << std::endl;99 // Test with std::vectors 100 std::vector<double> sa(3,1); 101 sa[1] = 2; 102 std::vector<double> sb(3,0); 103 sb[2] = 1; 86 104 105 dist=statistics::vector_distance(sa.begin(),sa.end(),sb.begin(), 106 statistics::euclidean_vector_distance_tag()); if(fabs(dist2.23607)>tolerance) { 107 *error << "Error in vector_distance for std::vector: " << std::endl; 108 ok=false; 109 } 110 111 112 // Test with pointer to a vector_distance 113 statistics::vector_distance_lookup_weighted_ptr test_ptr= 114 statistics::vector_distance<statistics::euclidean_vector_distance_tag>; 115 dist=(*test_ptr)(aw.begin(),aw.end(),bw.begin()); 116 if(fabs(dist2)>tolerance) { 117 *error << "Error when using pointer to vector_distance" << std::endl; 118 ok=false; 119 } 120 121 if(!ok) { 122 *error << "vector_distance_test failed" << std::endl; 123 } 87 124 if (error!=&std::cerr) 88 125 delete error; 89 90 126 if (ok=true) 91 127 return 0;
Note: See TracChangeset
for help on using the changeset viewer.