Changeset 1031 for trunk/test/vector_distance_test.cc
 Timestamp:
 Feb 4, 2008, 4:44:44 PM (14 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/test/vector_distance_test.cc
r1012 r1031 24 24 #include "yat/classifier/DataLookupWeighted1D.h" 25 25 #include "yat/classifier/MatrixLookupWeighted.h" 26 #include "yat/statistics/euclidean_ vector_distance.h"27 #include "yat/statistics/pearson_ vector_distance.h"26 #include "yat/statistics/euclidean_distance.h" 27 #include "yat/statistics/pearson_distance.h" 28 28 #include "yat/utility/matrix.h" 29 29 #include "yat/utility/vector.h" … … 47 47 error = new std::ofstream("/dev/null"); 48 48 if (argc>1) 49 std::cout << " vector_distance_test v : for printing extra information\n";49 std::cout << "distance_test v : for printing extra information\n"; 50 50 } 51 *error << "testing vector_distance" << std::endl;51 *error << "testing distance" << std::endl; 52 52 bool ok = true; 53 53 … … 59 59 double tolerance=1e4; 60 60 61 double dist=statistics:: vector_distance(a.begin(),a.end(),b.begin(),62 statistics::euclidean_ vector_distance_tag());61 double dist=statistics::distance(a.begin(),a.end(),b.begin(), 62 statistics::euclidean_distance_tag()); 63 63 if(fabs(dist2.23607)>tolerance) { 64 *error << "Error in unweighted Euclidean vector_distance " << std::endl;64 *error << "Error in unweighted Euclidean distance " << std::endl; 65 65 ok=false; 66 66 } 67 67 68 dist=statistics:: vector_distance(a.begin(),a.end(),b.begin(),69 statistics::pearson_ vector_distance_tag());68 dist=statistics::distance(a.begin(),a.end(),b.begin(), 69 statistics::pearson_distance_tag()); 70 70 if(fabs(dist1.5)>tolerance) { 71 *error << "Error in unweighted Pearson vector_distance " << std::endl;71 *error << "Error in unweighted Pearson distance " << std::endl; 72 72 ok=false; 73 73 } … … 85 85 classifier::DataLookupWeighted1D bw(mw,1,true); 86 86 87 dist=statistics:: vector_distance(aw.begin(),aw.end(),bw.begin(),88 statistics::euclidean_ vector_distance_tag());87 dist=statistics::distance(aw.begin(),aw.end(),bw.begin(), 88 statistics::euclidean_distance_tag()); 89 89 90 90 if(fabs(distsqrt(6))>tolerance) { 91 *error << "Error in weighted Euclidean vector_distance " << std::endl;91 *error << "Error in weighted Euclidean distance " << std::endl; 92 92 ok=false; 93 93 } 94 94 95 dist=statistics:: vector_distance(aw.begin(),aw.end(),bw.begin(),96 statistics::pearson_ vector_distance_tag());95 dist=statistics::distance(aw.begin(),aw.end(),bw.begin(), 96 statistics::pearson_distance_tag()); 97 97 98 98 if(fabs(dist2)>tolerance) { 99 *error << "Error in weighted Pearson vector_distance " << std::endl;99 *error << "Error in weighted Pearson distance " << std::endl; 100 100 ok=false; 101 101 } … … 108 108 sb[2] = 1; 109 109 110 dist=statistics:: vector_distance(sa.begin(),sa.end(),sb.begin(),111 statistics::euclidean_ vector_distance_tag());110 dist=statistics::distance(sa.begin(),sa.end(),sb.begin(), 111 statistics::euclidean_distance_tag()); 112 112 if(fabs(dist2.23607)>tolerance) { 113 *error << "Error in vector_distance for std::vector " << std::endl;113 *error << "Error in distance for std::vector " << std::endl; 114 114 ok=false; 115 115 } … … 118 118 std::list<double> la; 119 119 std::copy(sa.begin(),sa.end(),std::back_inserter<std::list<double> >(la)); 120 dist=statistics:: vector_distance(la.begin(),la.end(),sb.begin(),121 statistics::euclidean_ vector_distance_tag());120 dist=statistics::distance(la.begin(),la.end(),sb.begin(), 121 statistics::euclidean_distance_tag()); 122 122 if(fabs(dist2.23607)>tolerance) { 123 *error << "Error in vector_distance for std::list " << std::endl;123 *error << "Error in distance for std::list " << std::endl; 124 124 ok=false; 125 125 } 126 126 127 127 if(!ok) { 128 *error << " vector_distance_test failed" << std::endl;128 *error << "distance_test failed" << std::endl; 129 129 } 130 130 if (error!=&std::cerr)
Note: See TracChangeset
for help on using the changeset viewer.