Commit 37c815f6 authored by Davis King's avatar Davis King
Browse files

All I did in this change was rename calls to array_to_matrix(),

vector_to_matrix(), pointer_to_column_vector(), and pointer_to_matrix() to
mat() (in addition to adding a few more mat() overloads for certain things).
parent 0d970e47
......@@ -541,7 +541,7 @@ namespace
dlog << LINFO << "score MAP: " << score2;
DLIB_TEST(std::abs(score1 - score2) < 1e-10);
DLIB_TEST(vector_to_matrix(map_assignment1) == vector_to_matrix(map_assignment2));
DLIB_TEST(mat(map_assignment1) == mat(map_assignment2));
}
// ----------------------------------------------------------------------------------------
......@@ -568,10 +568,10 @@ namespace
dlog << LINFO << "score NMPLP: " << score1;
dlog << LINFO << "score MAP: " << score2;
dlog << LINFO << "MAP assignment: "<< trans(vector_to_matrix(map_assignment1));
dlog << LINFO << "MAP assignment: "<< trans(mat(map_assignment1));
DLIB_TEST(std::abs(score1 - score2) < 1e-10);
DLIB_TEST(vector_to_matrix(map_assignment1) == vector_to_matrix(map_assignment2));
DLIB_TEST(mat(map_assignment1) == mat(map_assignment2));
}
// ----------------------------------------------------------------------------------------
......
......@@ -131,9 +131,9 @@ namespace
brute_force_find_max_factor_graph_viterbi(prob, assign);
find_max_factor_graph_viterbi(prob, assign2);
DLIB_TEST_MSG(vector_to_matrix(assign) == vector_to_matrix(assign2),
trans(vector_to_matrix(assign))
<< trans(vector_to_matrix(assign2))
DLIB_TEST_MSG(mat(assign) == mat(assign2),
trans(mat(assign))
<< trans(mat(assign2))
);
}
}
......
......@@ -344,7 +344,7 @@ namespace
// This test is just to make sure the covariance function can compile when used
// on a dlib::vector. The actual test doesn't matter.
DLIB_TEST(sum(covariance(vector_to_matrix(a))) < 10);
DLIB_TEST(sum(covariance(mat(a))) < 10);
}
......@@ -446,7 +446,7 @@ namespace
DLIB_TEST(be.current_element_valid() == false);
DLIB_TEST(be.at_start() == false);
DLIB_TEST(array_to_matrix(img) == array_to_matrix(img2));
DLIB_TEST(mat(img) == mat(img2));
}
}
......@@ -485,7 +485,7 @@ namespace
DLIB_TEST(be.current_element_valid() == false);
DLIB_TEST(be.at_start() == false);
DLIB_TEST(array_to_matrix(img) == array_to_matrix(img2));
DLIB_TEST(mat(img) == mat(img2));
}
}
......@@ -521,7 +521,7 @@ namespace
DLIB_TEST(be.move_next() == false);
DLIB_TEST(be.current_element_valid() == false);
DLIB_TEST(array_to_matrix(img) == array_to_matrix(img2));
DLIB_TEST(mat(img) == mat(img2));
}
}
......
......@@ -57,7 +57,7 @@ namespace
DLIB_TEST(img2.size() == 0);
DLIB_TEST(img2.nr() == 0);
DLIB_TEST(img2.nc() == 0);
assign_image(img2, array_to_matrix(img1));
assign_image(img2, mat(img1));
DLIB_TEST_MSG(img1.nr() == 100 && img1.nc() == 100 &&
img2.nr() == 100 && img2.nc() == 100,"");
......@@ -669,22 +669,22 @@ namespace
assign_border_pixels(img, 2,2, 4);
DLIB_TEST(zeros_matrix<unsigned char>(6,6) == subm(array_to_matrix(img), rectangle(2,2,7,7)));
DLIB_TEST(uniform_matrix<unsigned char>(1,10, 4) == rowm(array_to_matrix(img), 0));
DLIB_TEST(uniform_matrix<unsigned char>(1,10, 4) == rowm(array_to_matrix(img), 1));
DLIB_TEST(uniform_matrix<unsigned char>(1,10, 4) == rowm(array_to_matrix(img), 8));
DLIB_TEST(uniform_matrix<unsigned char>(1,10, 4) == rowm(array_to_matrix(img), 9));
DLIB_TEST(zeros_matrix<unsigned char>(6,6) == subm(mat(img), rectangle(2,2,7,7)));
DLIB_TEST(uniform_matrix<unsigned char>(1,10, 4) == rowm(mat(img), 0));
DLIB_TEST(uniform_matrix<unsigned char>(1,10, 4) == rowm(mat(img), 1));
DLIB_TEST(uniform_matrix<unsigned char>(1,10, 4) == rowm(mat(img), 8));
DLIB_TEST(uniform_matrix<unsigned char>(1,10, 4) == rowm(mat(img), 9));
DLIB_TEST(uniform_matrix<unsigned char>(10,1, 4) == colm(array_to_matrix(img), 0));
DLIB_TEST(uniform_matrix<unsigned char>(10,1, 4) == colm(array_to_matrix(img), 1));
DLIB_TEST(uniform_matrix<unsigned char>(10,1, 4) == colm(array_to_matrix(img), 8));
DLIB_TEST(uniform_matrix<unsigned char>(10,1, 4) == colm(array_to_matrix(img), 9));
DLIB_TEST(uniform_matrix<unsigned char>(10,1, 4) == colm(mat(img), 0));
DLIB_TEST(uniform_matrix<unsigned char>(10,1, 4) == colm(mat(img), 1));
DLIB_TEST(uniform_matrix<unsigned char>(10,1, 4) == colm(mat(img), 8));
DLIB_TEST(uniform_matrix<unsigned char>(10,1, 4) == colm(mat(img), 9));
assign_border_pixels(img, 7, 7, 5);
DLIB_TEST(uniform_matrix<unsigned char>(10,10, 5) == array_to_matrix(img));
DLIB_TEST(uniform_matrix<unsigned char>(10,10, 5) == mat(img));
assign_border_pixels(img, 37, 47, 5);
DLIB_TEST(uniform_matrix<unsigned char>(10,10, 5) == array_to_matrix(img));
DLIB_TEST(uniform_matrix<unsigned char>(10,10, 5) == mat(img));
}
{
......@@ -694,21 +694,21 @@ namespace
assign_border_pixels(img, 2,2, 4);
DLIB_TEST(zeros_matrix<unsigned char>(7,7) == subm(array_to_matrix(img), rectangle(2,2,8,8)));
DLIB_TEST(uniform_matrix<unsigned char>(1,11, 4) == rowm(array_to_matrix(img), 0));
DLIB_TEST(uniform_matrix<unsigned char>(1,11, 4) == rowm(array_to_matrix(img), 1));
DLIB_TEST(uniform_matrix<unsigned char>(1,11, 4) == rowm(array_to_matrix(img), 9));
DLIB_TEST(uniform_matrix<unsigned char>(1,11, 4) == rowm(array_to_matrix(img), 10));
DLIB_TEST(zeros_matrix<unsigned char>(7,7) == subm(mat(img), rectangle(2,2,8,8)));
DLIB_TEST(uniform_matrix<unsigned char>(1,11, 4) == rowm(mat(img), 0));
DLIB_TEST(uniform_matrix<unsigned char>(1,11, 4) == rowm(mat(img), 1));
DLIB_TEST(uniform_matrix<unsigned char>(1,11, 4) == rowm(mat(img), 9));
DLIB_TEST(uniform_matrix<unsigned char>(1,11, 4) == rowm(mat(img), 10));
DLIB_TEST(uniform_matrix<unsigned char>(11,1, 4) == colm(array_to_matrix(img), 0));
DLIB_TEST(uniform_matrix<unsigned char>(11,1, 4) == colm(array_to_matrix(img), 1));
DLIB_TEST(uniform_matrix<unsigned char>(11,1, 4) == colm(array_to_matrix(img), 9));
DLIB_TEST(uniform_matrix<unsigned char>(11,1, 4) == colm(array_to_matrix(img), 10));
DLIB_TEST(uniform_matrix<unsigned char>(11,1, 4) == colm(mat(img), 0));
DLIB_TEST(uniform_matrix<unsigned char>(11,1, 4) == colm(mat(img), 1));
DLIB_TEST(uniform_matrix<unsigned char>(11,1, 4) == colm(mat(img), 9));
DLIB_TEST(uniform_matrix<unsigned char>(11,1, 4) == colm(mat(img), 10));
assign_border_pixels(img, 7, 7, 5);
DLIB_TEST(uniform_matrix<unsigned char>(11,11, 5) == array_to_matrix(img));
DLIB_TEST(uniform_matrix<unsigned char>(11,11, 5) == mat(img));
assign_border_pixels(img, 70, 57, 5);
DLIB_TEST(uniform_matrix<unsigned char>(11,11, 5) == array_to_matrix(img));
DLIB_TEST(uniform_matrix<unsigned char>(11,11, 5) == mat(img));
}
......@@ -752,9 +752,9 @@ namespace
point p1(rnd.get_random_32bit_number()%img.nc(), rnd.get_random_32bit_number()%img.nr());
point p2(rnd.get_random_32bit_number()%img.nc(), rnd.get_random_32bit_number()%img.nr());
rectangle rect(p1,p2);
DLIB_TEST(int_img.get_sum_of_area(rect) == sum(subm(matrix_cast<T>(array_to_matrix(img)), rect)));
DLIB_TEST(int_img.get_sum_of_area(rect) == sum(subm(matrix_cast<T>(mat(img)), rect)));
rect = rectangle(p1,p1);
DLIB_TEST(int_img.get_sum_of_area(rect) == sum(subm(matrix_cast<T>(array_to_matrix(img)), rect)));
DLIB_TEST(int_img.get_sum_of_area(rect) == sum(subm(matrix_cast<T>(mat(img)), rect)));
}
}
......@@ -812,7 +812,7 @@ namespace
spatially_filter_image_separable(img, img3, row_filter, col_filter);
DLIB_TEST(array_to_matrix(img2) == array_to_matrix(img3));
DLIB_TEST(mat(img2) == mat(img3));
dlib::rand rnd;
......@@ -844,7 +844,7 @@ namespace
rectangle brect1, brect2;
brect1 = spatially_filter_image(img, img2, filter, scale, use_abs);
brect2 = spatially_filter_image_separable(img, img3, row_filter, col_filter, scale, use_abs);
DLIB_TEST(array_to_matrix(img2) == array_to_matrix(img3));
DLIB_TEST(mat(img2) == mat(img3));
DLIB_TEST(brect1 == shrink_rect(get_rect(img), filter.nc()/2, filter.nr()/2));
DLIB_TEST(brect1 == brect2);
......@@ -1256,13 +1256,13 @@ namespace
spatially_filter_image_separable_down(downsample, img, out2, row_filter, col_filter);
DLIB_TEST(get_rect(out1) == get_rect(out2));
DLIB_TEST(array_to_matrix(out1) == array_to_matrix(out2));
DLIB_TEST(mat(out1) == mat(out2));
test_spatially_filter_image_separable_down_simple(downsample, img, out1, row_filter, col_filter,3, true, true );
spatially_filter_image_separable_down(downsample, img, out2, row_filter, col_filter, 3, true, true);
DLIB_TEST(get_rect(out1) == get_rect(out2));
DLIB_TEST(array_to_matrix(out1) == array_to_matrix(out2));
DLIB_TEST(mat(out1) == mat(out2));
}
}
......
......@@ -70,7 +70,7 @@ namespace
}
}
DLIB_TEST(equal(K, kernel_matrix(kern, vect1, vect2)));
DLIB_TEST(equal(K, kernel_matrix(kern, vector_to_matrix(vect1), vector_to_matrix(vect2))));
DLIB_TEST(equal(K, kernel_matrix(kern, mat(vect1), mat(vect2))));
K.set_size(vect2.size(), vect1.size());
......@@ -83,7 +83,7 @@ namespace
}
DLIB_TEST(equal(K, kernel_matrix(kern, vect2, vect1)));
DLIB_TEST(equal(K, tmp(kernel_matrix(kern, vect2, vect1))));
DLIB_TEST(equal(K, kernel_matrix(kern, vector_to_matrix(vect2), vector_to_matrix(vect1))));
DLIB_TEST(equal(K, kernel_matrix(kern, mat(vect2), mat(vect1))));
K.set_size(vect1.size(), vect1.size());
......@@ -98,10 +98,10 @@ namespace
DLIB_TEST(equal(K, tmp(kernel_matrix(kern, vect1, vect1))));
DLIB_TEST(equal(K, kernel_matrix(kern, vect1)));
DLIB_TEST(equal(K, tmp(kernel_matrix(kern, vect1))));
DLIB_TEST(equal(K, kernel_matrix(kern, vector_to_matrix(vect1), vector_to_matrix(vect1))));
DLIB_TEST(equal(K, tmp(kernel_matrix(kern, vector_to_matrix(vect1), vector_to_matrix(vect1)))));
DLIB_TEST(equal(K, kernel_matrix(kern, vector_to_matrix(vect1))));
DLIB_TEST(equal(K, tmp(kernel_matrix(kern, vector_to_matrix(vect1)))));
DLIB_TEST(equal(K, kernel_matrix(kern, mat(vect1), mat(vect1))));
DLIB_TEST(equal(K, tmp(kernel_matrix(kern, mat(vect1), mat(vect1)))));
DLIB_TEST(equal(K, kernel_matrix(kern, mat(vect1))));
DLIB_TEST(equal(K, tmp(kernel_matrix(kern, mat(vect1)))));
K.set_size(vect1.size(),1);
......@@ -113,7 +113,7 @@ namespace
}
}
DLIB_TEST(equal(K, kernel_matrix(kern, vect1, samp)));
DLIB_TEST(equal(K, kernel_matrix(kern, vector_to_matrix(vect1), samp)));
DLIB_TEST(equal(K, kernel_matrix(kern, mat(vect1), samp)));
K.set_size(1, vect1.size());
......@@ -125,9 +125,9 @@ namespace
}
}
DLIB_TEST(equal(K, kernel_matrix(kern, samp, vect1)));
DLIB_TEST(equal(K, kernel_matrix(kern, samp, vector_to_matrix(vect1))));
DLIB_TEST(equal(K, kernel_matrix(kern, samp, mat(vect1))));
DLIB_TEST(equal(K, tmp(kernel_matrix(kern, samp, vect1))));
DLIB_TEST(equal(K, tmp(kernel_matrix(kern, samp, vector_to_matrix(vect1)))));
DLIB_TEST(equal(K, tmp(kernel_matrix(kern, samp, mat(vect1)))));
......
......@@ -422,26 +422,26 @@ namespace
DLIB_TEST(rowm(array_to_matrix(a),1).nr() == 1);
DLIB_TEST(rowm(array_to_matrix(a),1).nc() == a.nc());
DLIB_TEST(colm(array_to_matrix(a),1).nr() == a.nr());
DLIB_TEST(colm(array_to_matrix(a),1).nc() == 1);
DLIB_TEST(rowm(mat(a),1).nr() == 1);
DLIB_TEST(rowm(mat(a),1).nc() == a.nc());
DLIB_TEST(colm(mat(a),1).nr() == a.nr());
DLIB_TEST(colm(mat(a),1).nc() == 1);
for (long c = 0; c < a.nc(); ++c)
{
DLIB_TEST( rowm(array_to_matrix(a),1)(c) == 1*a.nc() + c);
DLIB_TEST( rowm(mat(a),1)(c) == 1*a.nc() + c);
}
for (long r = 0; r < a.nr(); ++r)
{
DLIB_TEST( colm(array_to_matrix(a),1)(r) == r*a.nc() + 1);
DLIB_TEST( colm(mat(a),1)(r) == r*a.nc() + 1);
}
for (long r = 0; r < 2; ++r)
{
for (long c = 0; c < 3; ++c)
{
DLIB_TEST(subm(array_to_matrix(a),1,2,2,3)(r,c) == (r+1)*a.nc() + c+2);
DLIB_TEST(subm(mat(a),1,2,2,3)(r,c) == (r+1)*a.nc() + c+2);
}
}
......@@ -461,11 +461,11 @@ namespace
}
matrix<double> mi = pinv(cos(exp(array_to_matrix(m))) );
matrix<double> mi = pinv(cos(exp(mat(m))) );
DLIB_TEST(mi.nr() == m.nc());
DLIB_TEST(mi.nc() == m.nr());
DLIB_TEST((equal(round_zeros(mi*cos(exp(array_to_matrix(m))),0.000001) , identity_matrix<double,5>())));
DLIB_TEST((equal(round_zeros(cos(exp(array_to_matrix(m)))*mi,0.000001) , identity_matrix<double,5>())));
DLIB_TEST((equal(round_zeros(mi*cos(exp(mat(m))),0.000001) , identity_matrix<double,5>())));
DLIB_TEST((equal(round_zeros(cos(exp(mat(m)))*mi,0.000001) , identity_matrix<double,5>())));
}
{
......
......@@ -171,33 +171,33 @@ namespace
for (long i = 0; i < 4; ++i)
stdv[i] = stdv_c[i] = arr[i] = i+1;
DLIB_TEST(vector_to_matrix(stdv)(0) == 1);
DLIB_TEST(vector_to_matrix(stdv)(1) == 2);
DLIB_TEST(vector_to_matrix(stdv)(2) == 3);
DLIB_TEST(vector_to_matrix(stdv)(3) == 4);
DLIB_TEST(vector_to_matrix(stdv).nr() == 4);
DLIB_TEST(vector_to_matrix(stdv).nc() == 1);
DLIB_TEST(vector_to_matrix(stdv).size() == 4);
DLIB_TEST(equal(trans(vector_to_matrix(stdv))*vector_to_matrix(stdv), trans(v)*v));
DLIB_TEST(equal(trans(vector_to_matrix(stdv))*vector_to_matrix(stdv), tmp(trans(v)*v)));
DLIB_TEST(vector_to_matrix(stdv_c)(0) == 1);
DLIB_TEST(vector_to_matrix(stdv_c)(1) == 2);
DLIB_TEST(vector_to_matrix(stdv_c)(2) == 3);
DLIB_TEST(vector_to_matrix(stdv_c)(3) == 4);
DLIB_TEST(vector_to_matrix(stdv_c).nr() == 4);
DLIB_TEST(vector_to_matrix(stdv_c).nc() == 1);
DLIB_TEST(vector_to_matrix(stdv_c).size() == 4);
DLIB_TEST(equal(trans(vector_to_matrix(stdv_c))*vector_to_matrix(stdv_c), trans(v)*v));
DLIB_TEST(vector_to_matrix(arr)(0) == 1);
DLIB_TEST(vector_to_matrix(arr)(1) == 2);
DLIB_TEST(vector_to_matrix(arr)(2) == 3);
DLIB_TEST(vector_to_matrix(arr)(3) == 4);
DLIB_TEST(vector_to_matrix(arr).nr() == 4);
DLIB_TEST(vector_to_matrix(arr).nc() == 1);
DLIB_TEST(vector_to_matrix(arr).size() == 4);
DLIB_TEST(equal(trans(vector_to_matrix(arr))*vector_to_matrix(arr), trans(v)*v));
DLIB_TEST(mat(stdv)(0) == 1);
DLIB_TEST(mat(stdv)(1) == 2);
DLIB_TEST(mat(stdv)(2) == 3);
DLIB_TEST(mat(stdv)(3) == 4);
DLIB_TEST(mat(stdv).nr() == 4);
DLIB_TEST(mat(stdv).nc() == 1);
DLIB_TEST(mat(stdv).size() == 4);
DLIB_TEST(equal(trans(mat(stdv))*mat(stdv), trans(v)*v));
DLIB_TEST(equal(trans(mat(stdv))*mat(stdv), tmp(trans(v)*v)));
DLIB_TEST(mat(stdv_c)(0) == 1);
DLIB_TEST(mat(stdv_c)(1) == 2);
DLIB_TEST(mat(stdv_c)(2) == 3);
DLIB_TEST(mat(stdv_c)(3) == 4);
DLIB_TEST(mat(stdv_c).nr() == 4);
DLIB_TEST(mat(stdv_c).nc() == 1);
DLIB_TEST(mat(stdv_c).size() == 4);
DLIB_TEST(equal(trans(mat(stdv_c))*mat(stdv_c), trans(v)*v));
DLIB_TEST(mat(arr)(0) == 1);
DLIB_TEST(mat(arr)(1) == 2);
DLIB_TEST(mat(arr)(2) == 3);
DLIB_TEST(mat(arr)(3) == 4);
DLIB_TEST(mat(arr).nr() == 4);
DLIB_TEST(mat(arr).nc() == 1);
DLIB_TEST(mat(arr).size() == 4);
DLIB_TEST(equal(trans(mat(arr))*mat(arr), trans(v)*v));
DLIB_TEST(v(0) == 1);
DLIB_TEST(v(1) == 2);
......
......@@ -723,16 +723,16 @@ namespace
std::vector<double> v(34, 8);
std::vector<double> v2(34, 9);
DLIB_TEST(pointer_to_column_vector(&v[0], v.size()) == vector_to_matrix(v));
DLIB_TEST(pointer_to_column_vector(&v2[0], v.size()) != vector_to_matrix(v));
DLIB_TEST(mat(&v[0], v.size()) == mat(v));
DLIB_TEST(mat(&v2[0], v.size()) != mat(v));
}
{
std::vector<long> v(1, 3);
std::vector<long> v2(1, 2);
DLIB_TEST(pointer_to_column_vector(&v[0], v.size()) == vector_to_matrix(v));
DLIB_TEST(pointer_to_column_vector(&v2[0], v.size()) != vector_to_matrix(v));
DLIB_TEST(mat(&v[0], v.size()) == mat(v));
DLIB_TEST(mat(&v2[0], v.size()) != mat(v));
}
{
......@@ -940,7 +940,7 @@ namespace
a = 0, 1, 2,
3, 4, 5;
DLIB_TEST(pointer_to_matrix(&v[0], 2, 3) == a);
DLIB_TEST(mat(&v[0], 2, 3) == a);
}
{
......
......@@ -66,7 +66,7 @@ namespace
oca solver;
// test the version without a non-negativity constraint on w.
solver(make_oca_problem_c_svm<w_type>(2.0, 3.0, vector_to_matrix(x), vector_to_matrix(y), false, 1e-12, 40), w, 0);
solver(make_oca_problem_c_svm<w_type>(2.0, 3.0, mat(x), mat(y), false, 1e-12, 40), w, 0);
dlog << LINFO << trans(w);
true_w = -0.5, 0.5, 0;
dlog << LINFO << "error: "<< max(abs(w-true_w));
......@@ -75,7 +75,7 @@ namespace
print_spinner();
// test the version with a non-negativity constraint on w.
solver(make_oca_problem_c_svm<w_type>(2.0, 3.0, vector_to_matrix(x), vector_to_matrix(y), false, 1e-12, 40), w, 9999);
solver(make_oca_problem_c_svm<w_type>(2.0, 3.0, mat(x), mat(y), false, 1e-12, 40), w, 9999);
dlog << LINFO << trans(w);
true_w = 0, 1, 0;
dlog << LINFO << "error: "<< max(abs(w-true_w));
......@@ -91,7 +91,7 @@ namespace
print_spinner();
// test the version with a non-negativity constraint on w.
solver(make_oca_problem_c_svm<w_type>(2.0, 3.0, vector_to_matrix(x), vector_to_matrix(y), false, 1e-12, 40), w, 2);
solver(make_oca_problem_c_svm<w_type>(2.0, 3.0, mat(x), mat(y), false, 1e-12, 40), w, 2);
dlog << LINFO << trans(w);
true_w = 0, 1, 0;
dlog << LINFO << "error: "<< max(abs(w-true_w));
......@@ -101,7 +101,7 @@ namespace
// test the version with a non-negativity constraint on w.
solver(make_oca_problem_c_svm<w_type>(2.0, 3.0, vector_to_matrix(x), vector_to_matrix(y), false, 1e-12, 40), w, 1);
solver(make_oca_problem_c_svm<w_type>(2.0, 3.0, mat(x), mat(y), false, 1e-12, 40), w, 1);
dlog << LINFO << trans(w);
true_w = 0, 1, 0;
dlog << LINFO << "error: "<< max(abs(w-true_w));
......@@ -116,7 +116,7 @@ namespace
y.push_back(+1);
solver(make_oca_problem_c_svm<w_type>(2.0, 3.0, vector_to_matrix(x), vector_to_matrix(y), false, 1e-12, 40), w, 0);
solver(make_oca_problem_c_svm<w_type>(2.0, 3.0, mat(x), mat(y), false, 1e-12, 40), w, 0);
dlog << LINFO << trans(w);
true_w = 0.5, -0.5, 0;
dlog << LINFO << "error: "<< max(abs(w-true_w));
......@@ -124,7 +124,7 @@ namespace
print_spinner();
solver(make_oca_problem_c_svm<w_type>(2.0, 3.0, vector_to_matrix(x), vector_to_matrix(y), false, 1e-12, 40), w, 1);
solver(make_oca_problem_c_svm<w_type>(2.0, 3.0, mat(x), mat(y), false, 1e-12, 40), w, 1);
dlog << LINFO << trans(w);
true_w = 0.5, -0.5, 0;
dlog << LINFO << "error: "<< max(abs(w-true_w));
......@@ -132,7 +132,7 @@ namespace
print_spinner();
solver(make_oca_problem_c_svm<w_type>(2.0, 3.0, vector_to_matrix(x), vector_to_matrix(y), false, 1e-12, 40), w, 2);
solver(make_oca_problem_c_svm<w_type>(2.0, 3.0, mat(x), mat(y), false, 1e-12, 40), w, 2);
dlog << LINFO << trans(w);
true_w = 1, 0, 0;
dlog << LINFO << "error: "<< max(abs(w-true_w));
......@@ -140,7 +140,7 @@ namespace
print_spinner();
solver(make_oca_problem_c_svm<w_type>(2.0, 3.0, vector_to_matrix(x), vector_to_matrix(y), false, 1e-12, 40), w, 5);
solver(make_oca_problem_c_svm<w_type>(2.0, 3.0, mat(x), mat(y), false, 1e-12, 40), w, 5);
dlog << LINFO << trans(w);
true_w = 1, 0, 0;
dlog << LINFO << "error: "<< max(abs(w-true_w));
......
......@@ -58,8 +58,8 @@ namespace
rx.set_max_size(x.size());
ry.set_max_size(x.size());
dlog << LINFO << "pos labels: "<< sum(vector_to_matrix(y) == +1);
dlog << LINFO << "neg labels: "<< sum(vector_to_matrix(y) == -1);
dlog << LINFO << "pos labels: "<< sum(mat(y) == +1);
dlog << LINFO << "neg labels: "<< sum(mat(y) == -1);
for (unsigned long i = 0; i < x.size(); ++i)
{
......
......@@ -44,8 +44,8 @@ void test_pyramid_down_grayscale()
overlap = rect1.intersect(rect2).area() / (double)(rect1 + rect2).area();
DLIB_TEST(overlap > 0.95);
DLIB_TEST(min(array_to_matrix(down)) == 10);
DLIB_TEST(max(array_to_matrix(down)) == 10);
DLIB_TEST(min(mat(down)) == 10);
DLIB_TEST(max(mat(down)) == 10);
}
void test_pyramid_down_rgb()
......@@ -169,11 +169,11 @@ void test_pyramid_down_rgb2()
*/
DLIB_TEST(std::abs((int)mean(subm(matrix_cast<long>(array_to_matrix(img2)),rect1)) - 255/3) < 3);
DLIB_TEST(std::abs((int)mean(subm(matrix_cast<long>(array_to_matrix(img2)),rect2)) - 255/3) < 3);
DLIB_TEST(std::abs((int)mean(subm(matrix_cast<long>(array_to_matrix(img2)),rect3)) - 255/3) < 3);
DLIB_TEST(std::abs((int)mean(subm(matrix_cast<long>(mat(img2)),rect1)) - 255/3) < 3);
DLIB_TEST(std::abs((int)mean(subm(matrix_cast<long>(mat(img2)),rect2)) - 255/3) < 3);
DLIB_TEST(std::abs((int)mean(subm(matrix_cast<long>(mat(img2)),rect3)) - 255/3) < 3);
assign_image(img4, img);
DLIB_TEST(std::abs((int)mean(array_to_matrix(img4)) - mean(array_to_matrix(img2))) < 2);
DLIB_TEST(std::abs((int)mean(mat(img4)) - mean(mat(img2))) < 2);
rgb_pixel mean1 = mean_pixel(img3, rect1);
......@@ -256,11 +256,11 @@ void test_pyramid_down_grayscale2()
*/
DLIB_TEST(std::abs((int)mean(subm(matrix_cast<long>(array_to_matrix(img2)),rect1)) - 255) < 3);
DLIB_TEST(std::abs((int)mean(subm(matrix_cast<long>(array_to_matrix(img2)),rect2)) - 170) < 3);
DLIB_TEST(std::abs((int)mean(subm(matrix_cast<long>(array_to_matrix(img2)),rect3)) - 100) < 3);
DLIB_TEST(std::abs((int)mean(subm(matrix_cast<long>(mat(img2)),rect1)) - 255) < 3);
DLIB_TEST(std::abs((int)mean(subm(matrix_cast<long>(mat(img2)),rect2)) - 170) < 3);
DLIB_TEST(std::abs((int)mean(subm(matrix_cast<long>(mat(img2)),rect3)) - 100) < 3);
assign_image(img4, img);
DLIB_TEST(std::abs((int)mean(array_to_matrix(img4)) - mean(array_to_matrix(img2))) < 2);
DLIB_TEST(std::abs((int)mean(mat(img4)) - mean(mat(img2))) < 2);
//my_window.wait_until_closed();
......
......@@ -68,8 +68,8 @@ namespace
count_ranking_inversions(x, y, x_count, y_count);
brute_force_count_ranking_inversions(x, y, x_count2, y_count2);
DLIB_TEST(vector_to_matrix(x_count) == vector_to_matrix(x_count2));
DLIB_TEST(vector_to_matrix(y_count) == vector_to_matrix(y_count2));
DLIB_TEST(mat(x_count) == mat(x_count2));
DLIB_TEST(mat(y_count) == mat(y_count2));
}
}
......
......@@ -139,7 +139,7 @@ namespace
strip = strip.intersect(get_rect(img));
if (!strip.is_empty())
{
column_sums[i][j] = sum(matrix_cast<ptype>(subm(array_to_matrix(img),strip)));
column_sums[i][j] = sum(matrix_cast<ptype>(subm(mat(img),strip)));
}
++left;
......@@ -434,8 +434,8 @@ namespace
sum_filter(img, test1_i, rect);
sum_filter(img, test2_i, rect);
DLIB_TEST(array_to_matrix(test1) == array_to_matrix(test1_i));
DLIB_TEST(array_to_matrix(test2) == array_to_matrix(test2_i));
DLIB_TEST(mat(test1) == mat(test1_i));
DLIB_TEST(mat(test2) == mat(test2_i));
}
}
}
......@@ -462,7 +462,7 @@ namespace
for (long c = 0; c < img.nc(); ++c)
{
const rectangle win = centered_rect(point(c,r),width,height).intersect(area);
out[r][c] += std::max(dlib::max(subm(array_to_matrix(img),win)), thresh);
out[r][c] += std::max(dlib::max(subm(mat(img),win)), thresh);
}
}
}
......@@ -492,7 +492,7 @@ namespace
naive_max_filter(img, out2, rect.width(), rect.height(), thresh);
max_filter(img, out, rect.width(), rect.height(), thresh);
DLIB_TEST_MSG(array_to_matrix(out) == array_to_matrix(out2),
DLIB_TEST_MSG(mat(out) == mat(out2),
"rows: "<< rows
<< "\ncols: "<< rows
<< "\nwidth: "<< width
......
......@@ -307,8 +307,8 @@ namespace
// print out some of the randomly sampled sequences
for (int i = 0; i < 10; ++i)
{
dlog << LINFO << "hidden states: " << trans(vector_to_matrix(labels[i]));
dlog << LINFO << "observed states: " << trans(vector_to_matrix(samples[i].item));
dlog << LINFO << "hidden states: " << trans(mat(labels[i]));
dlog << LINFO << "observed states: " << trans(mat(samples[i].item));
dlog << LINFO << "******************************";
}
......@@ -325,10 +325,10 @@ namespace
sequence_labeler<fe_type> labeler = trainer.train(samples, labels);
std::vector<unsigned long> predicted_labels = labeler(samples[0]);
dlog << LINFO << "true hidden states: "<< trans(vector_to_matrix(labels[0]));
dlog << LINFO << "predicted hidden states: "<< trans(vector_to_matrix(predicted_labels));
dlog << LINFO << "true hidden states: "<< trans(mat(labels[0]));
dlog << LINFO << "predicted hidden states: "<< trans(mat(predicted_labels));
DLIB_TEST(vector_to_matrix(labels[0]) == vector_to_matrix(predicted_labels));
DLIB_TEST(mat(labels[0]) == mat(predicted_labels));
print_spinner();
......
......@@ -114,7 +114,7 @@ namespace
for (unsigned long i = 0; i < samples.size(); ++i)
cur_vals.push_back(df(samples[i]));
const double err = max(abs(vector_to_matrix(cur_vals) - vector_to_matrix(prev_vals)));
const double err = max(abs(mat(cur_vals) - mat(prev_vals)));
dlog << LINFO << "simplify error: "<< err;
DLIB_TEST(err < 1e-13);
......@@ -150,7 +150,7 @@ namespace
for (unsigned long i = 0; i < samples.size(); ++i)
cur_vals.push_back(df(samples[i]));
const double err = max(abs(vector_to_matrix(cur_vals) - vector_to_matrix(prev_vals)));
const double err = max(abs(mat(cur_vals) - mat(prev_vals)));
dlog << LINFO << "simplify error: "<< err;
DLIB_TEST(err < 1e-13);
......@@ -189,7 +189,7 @@ namespace
for (unsigned long i = 0; i < dense_samples.size(); ++i)
cur_vals.push_back(dense_df(dense_samples[i]));
const double err = max(abs(vector_to_matrix(cur_vals) - vector_to_matrix(prev_vals)));
const double err = max(abs(mat(cur_vals) - mat(prev_vals)));
dlog << LINFO << "simplify error: "<< err;
DLIB_TEST(err < 1e-13);
}
......@@ -228,7 +228,7 @@ namespace
for (unsigned long i = 0; i < dense_samples.size(); ++i)
cur_vals.push_back(dense_df(dense_samples[i]));
const double err = max(abs(vector_to_matrix(cur_vals) - vector_to_matrix(prev_vals)));
const double err = max(abs(mat(cur_vals) - mat(prev_vals)));
dlog << LINFO << "simplify error: "<< err;
DLIB_TEST(err < 1e-13);
}
......@@ -275,7 +275,7 @@ namespace
for (unsigned long i = 0; i < dense_samples.size(); ++i)
cur_vals.push_back(simple_df(dense_samples[i]));
const double err = max(abs(vector_to_matrix(cur_vals) - vector_to_matrix(prev_vals)));
const double err = max(abs(mat(cur_vals) - mat(prev_vals)));
dlog << LINFO << "simplify error: "<< err;
DLIB_TEST(err < 1e-13);
......
......@@ -155,9 +155,9 @@ namespace
}
DLIB_TEST(cov.in_vector_size() == (long)dims);
DLIB_TEST(equal(mean(vector_to_matrix(vects)), cov.mean()));
DLIB_TEST_MSG(equal(covariance(vector_to_matrix(vects)), cov.covariance()),
max(abs(covariance(vector_to_matrix(vects)) - cov.covariance()))
DLIB_TEST(equal(mean(mat(vects)), cov.mean()));
DLIB_TEST_MSG(equal(covariance(mat(vects)), cov.covariance()),
max(abs(covariance(mat(vects)) - cov.covariance()))
<< " dims = " << dims << " samps = " << samps
);
}
......@@ -182,9 +182,9 @@ namespace
}
DLIB_TEST((cov+cov2).in_vector_size() == (long)dims);
DLIB_TEST(equal(mean(vector_to_matrix(vects)), (cov+cov2).mean()));
DLIB_TEST_MSG(equal(covariance(vector_to_matrix(vects)), (cov+cov2).covariance()),
max(abs(covariance(vector_to_matrix(vects)) - (cov+cov2).covariance()))
DLIB_TEST(equal(mean(mat(vects)), (cov+cov2).mean()));
DLIB_TEST_MSG(equal(covariance(mat(vects)), (cov+cov2).covariance()),
max(abs(covariance(mat(vects)) - (cov+cov2).covariance()))
<< " dims = " << dims << " samps = " << samps
);
}
......@@ -298,9 +298,9 @@ namespace
a.push_back(i);
}
DLIB_TEST(std::abs(variance(vector_to_matrix(a)) - rs1.variance()) < 1e-13);
DLIB_TEST(std::abs(stddev(vector_to_matrix(a)) - rs1.stddev()) < 1e-13);
DLIB_TEST(std::abs(mean(vector_to_matrix(a)) - rs1.mean()) < 1e-13);
DLIB_TEST(std::abs(variance(mat(a)) - rs1.variance()) < 1e-13);
DLIB_TEST(std::abs(stddev(mat(a)) - rs1.stddev()) < 1e-13);
DLIB_TEST(std::abs(mean(mat(a)) - rs1.mean()) < 1e-13);
for (int i = 10; i < 20; ++i)
{
......@@ -308,8 +308,8 @@ namespace
a.push_back(i);
}
DLIB_TEST(std::abs(variance(vector_to_matrix(a)) - (rs1+rs2).variance()) < 1e-13);
DLIB_TEST(std::abs(mean(vector_to_matrix(a)) - (rs1+rs2).mean()) < 1e-13);
DLIB_TEST(std::abs(variance(mat(a)) - (rs1+rs2).variance()) < 1e-13);
DLIB_TEST(std::abs(mean(mat(a)) - (rs1+rs2).mean()) < 1e-13);
DLIB_TEST((rs1+rs2).current_n() == 20);
running_scalar_covariance<double> rc1, rc2, rc3;
......
......@@ -69,7 +69,7 @@ namespace
psi.push_back(std::make_pair(dims-1,static_cast<scalar_type>(-1)));
// Find which distinct label goes with this psi.
const long label_idx = index_of_max(vector_to_matrix(distinct_labels) == labels[idx]);
const long label_idx = index_of_max(mat(distinct_labels) == labels[idx]);
offset_feature_vector(psi, dims*label_idx);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment