MCPcopy Create free account
hub / github.com/davisking/dlib / randomize_samples

Function randomize_samples

dlib/svm/svm.h:959–992  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

957 typename rand_type
958 >
959 typename enable_if<is_matrix<T>,void>::type randomize_samples (
960 T& t,
961 U& u,
962 V& v,
963 rand_type& r
964 )
965 {
966 // make sure requires clause is not broken
967 DLIB_ASSERT(is_vector(t) && is_vector(u) && is_vector(v) && u.size() == t.size() &&
968 u.size() == v.size(),
969 "\t randomize_samples(t,u,v)"
970 << "\n\t invalid inputs were given to this function"
971 << "\n\t t.size(): " << t.size()
972 << "\n\t u.size(): " << u.size()
973 << "\n\t v.size(): " << v.size()
974 << "\n\t is_vector(t): " << is_vector(t)
975 << "\n\t is_vector(u): " << is_vector(u)
976 << "\n\t is_vector(v): " << is_vector(v)
977 );
978
979 long n = t.size()-1;
980 while (n > 0)
981 {
982 // pick a random index to swap into t[n]
983 const unsigned long idx = r.get_random_32bit_number()%(n+1);
984
985 // swap our randomly selected index into the n position
986 exchange(t(idx), t(n));
987 exchange(u(idx), u(n));
988 exchange(v(idx), v(n));
989
990 --n;
991 }
992 }
993
994// ----------------------------------------------------------------------------------------
995

Callers 15

mainFunction · 0.85
run_testMethod · 0.85
run_testFunction · 0.85
make_datasetFunction · 0.85
run_testMethod · 0.85
test1Function · 0.85
run_testMethod · 0.85
run_testMethod · 0.85

Calls 4

exchangeFunction · 0.85
is_vectorFunction · 0.50
sizeMethod · 0.45

Tested by 15

run_testMethod · 0.68
run_testFunction · 0.68
make_datasetFunction · 0.68
run_testMethod · 0.68
test1Function · 0.68
run_testMethod · 0.68
run_testMethod · 0.68
test_regressionFunction · 0.68