123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790 |
- //
- // Copyright (c) 2010 Athanasios Iliopoulos
- //
- // Distributed under the Boost Software License, Version 1.0. (See
- // accompanying file LICENSE_1_0.txt or copy at
- // http://www.boost.org/LICENSE_1_0.txt)
- //
- #include <boost/numeric/ublas/assignment.hpp>
- #include <boost/numeric/ublas/vector.hpp>
- #include <boost/numeric/ublas/vector_proxy.hpp>
- #include <boost/numeric/ublas/vector_sparse.hpp>
- #include <boost/numeric/ublas/matrix_sparse.hpp>
- #include <boost/numeric/ublas/io.hpp>
- #include <boost/numeric/ublas/matrix.hpp>
- #include <boost/timer.hpp>
- #include <ctime>
- #include "common/testhelper.hpp"
- #include "utils.hpp"
- using namespace boost::numeric::ublas;
- template <class V>
- bool test_vector() {
- bool pass = true;
- V a(3), ra(3);
- a <<= 1, 2, 3;
- ra(0) = typename V::value_type(1); ra(1) = typename V::value_type(2); ra(2) = typename V::value_type(3);
- pass &= compare_distance(a, ra);
- V b(7), rb(7);
- b<<= a, 10, a;
- rb(0) = typename V::value_type(1); rb(1) = typename V::value_type(2); rb(2) = typename V::value_type(3);
- rb(3) = typename V::value_type(10); rb(4) = typename V::value_type(1); rb(5) = typename V::value_type(2); rb(6) = typename V::value_type(3);
- pass &= compare_distance(b, rb);
- {
- V c(6), rc(6);
- c <<= 1, move(2), 3 ,4, 5, move(-5), 10, 10;
- rc(0) = typename V::value_type(1); rc(1) = typename V::value_type(10); rc(2) = typename V::value_type(10);
- rc(3) = typename V::value_type(3); rc(4) = typename V::value_type(4); rc(5) = typename V::value_type(5);
- pass &= compare_distance(c, rc);
- V d(6), rd(6);
- d <<= 1, move_to(3), 3 ,4, 5, move_to(1), 10, 10;
- rd(0) = typename V::value_type(1); rd(1) = typename V::value_type(10); rd(2) = typename V::value_type(10);
- rd(3) = typename V::value_type(3); rd(4) = typename V::value_type(4); rd(5) = typename V::value_type(5);
- pass &= compare_distance(d, rd);
- }
- {
- V c(6), rc(6);
- c <<= 1, move<2>(), 3 ,4, 5, move<-5>(), 10, 10;
- rc(0) = typename V::value_type(1); rc(1) = typename V::value_type(10); rc(2) = typename V::value_type(10);
- rc(3) = typename V::value_type(3); rc(4) = typename V::value_type(4); rc(5) = typename V::value_type(5);
- pass &= compare_distance(c, rc);
- V d(6), rd(6);
- d <<= 1, move_to<3>(), 3 ,4, 5, move_to<1>(), 10, 10;
- rd(0) = typename V::value_type(1); rd(1) = typename V::value_type(10); rd(2) = typename V::value_type(10);
- rd(3) = typename V::value_type(3); rd(4) = typename V::value_type(4); rd(5) = typename V::value_type(5);
- pass &= compare_distance(d, rd);
- }
- {
- V f(6), rf(6);
- f <<= 5, 5, 5, 5, 5, 5;
- V fa(3); fa<<= 1, 2, 3;
- f <<= fill_policy::index_plus_assign(), fa;
- rf <<= 6,7,8, 5, 5, 5;
- pass &= compare_distance(f, rf);
- }
- {
- V f(6), rf(6);
- f <<= 5, 5, 5, 5, 5, 5;
- V fa(3); fa<<= 1, 2, 3;
- f <<= fill_policy::index_minus_assign(), fa;
- rf <<= 4,3,2, 5, 5, 5;
- pass &= compare_distance(f, rf);
- }
- return pass;
- }
- template <class V>
- bool test_vector_sparse_push_back() {
- bool pass = true;
- V a(3), ra(3);
- a <<= fill_policy::sparse_push_back(), 1, 2, 3;
- ra(0) = typename V::value_type(1); ra(1) = typename V::value_type(2); ra(2) = typename V::value_type(3);
- pass &= compare_distance(a, ra);
- V b(7), rb(7);
- b<<= fill_policy::sparse_push_back(), a, 10, a;
- rb(0) = typename V::value_type(1); rb(1) = typename V::value_type(2); rb(2) = typename V::value_type(3);
- rb(3) = typename V::value_type(10), rb(4)= typename V::value_type(1); rb(5) = typename V::value_type(2); rb(6) = typename V::value_type(3);
- pass &= compare_distance(b, rb);
- V c(6), rc(6);
- c <<= fill_policy::sparse_push_back(), 1, move(2), 3 ,4, 5; // Move back (i.e. negative is dangerous for push_back)
- rc(0) = typename V::value_type(1); rc(1) = typename V::value_type(0); rc(2) = typename V::value_type(0);
- rc(3) = typename V::value_type(3); rc(4) = typename V::value_type(4); rc(5) = typename V::value_type(5);
- pass &= compare_distance(c, rc);
- V d(6), rd(6);
- d <<= fill_policy::sparse_push_back(), 1, move_to(3), 3 ,4, 5; // Move back (i.e. before current index is dangerous for push_back)
- rd(0) = typename V::value_type(1); rd(1) = typename V::value_type(0); rd(2) = typename V::value_type(0);
- rd(3) = typename V::value_type(3); rd(4) = typename V::value_type(4); rd(5) = typename V::value_type(5);
- pass &= compare_distance(d, rd);
- V e(6), re(6);
- e <<= fill_policy::sparse_push_back(), 1, move_to(3), 3 ,4, 5, fill_policy::sparse_insert(), move_to(1), 10, 10; // If you want to move back, use this
- re(0) = typename V::value_type(1); re(1) = typename V::value_type(10); re(2) = typename V::value_type(10);
- re(3) = typename V::value_type(3); re(4) = typename V::value_type(4); re(5) = typename V::value_type(5);
- pass &= compare_distance(e, re);
- return pass;
- }
- template <class V>
- bool test_vector_sparse_insert() {
- bool pass = true;
- V a(3), ra(3);
- a <<= fill_policy::sparse_insert(), 1, 2, 3;
- ra(0) = typename V::value_type(1); ra(1) = typename V::value_type(2); ra(2) = typename V::value_type(3);
- pass &= compare_distance(a, ra);
- V b(7), rb(7);
- b<<= fill_policy::sparse_insert(), a, 10, a;
- rb(0) = typename V::value_type(1); rb(1) = typename V::value_type(2); rb(2) = typename V::value_type(3);
- rb(3) = typename V::value_type(10), rb(4) = typename V::value_type(1); rb(5)= typename V::value_type(2); rb(6) = typename V::value_type(3);
- pass &= compare_distance(b, rb);
- V c(6), rc(6);
- c <<= fill_policy::sparse_insert(), 1, move(2), 3 ,4, 5, move(-5), 10, 10; // Move back (i.e. negative is dangerous for sparse)
- rc(0) = typename V::value_type(1); rc(1) = typename V::value_type(10); rc(2) = typename V::value_type(10);
- rc(3) = typename V::value_type(3); rc(4) = typename V::value_type(4); rc(5) = typename V::value_type(5);
- pass &= compare_distance(c, rc);
- V d(6), rd(6);
- d <<= fill_policy::sparse_insert(), 1, move_to(3), 3 ,4, 5, move_to(1), 10, 10; // Move back (i.e.before is dangerous for sparse)
- rd(0) = typename V::value_type(1); rd(1) = typename V::value_type(10); rd(2) = typename V::value_type(10);
- rd(3) = typename V::value_type(3); rd(4) = typename V::value_type(4); rd(5) = typename V::value_type(5);
- pass &= compare_distance(d, rd);
- return pass;
- }
- template <class V>
- bool test_matrix() {
- bool pass = true;
- V A(3,3), RA(3,3);
- A <<= 1, 2, 3, 4, 5, 6, 7, 8, 9;
- RA(0,0)= typename V::value_type(1); RA(0,1)=typename V::value_type(2); RA(0,2)=typename V::value_type(3);
- RA(1,0)= typename V::value_type(4); RA(1,1)=typename V::value_type(5); RA(1,2)=typename V::value_type(6);
- RA(2,0)= typename V::value_type(7); RA(2,1)=typename V::value_type(8); RA(2,2)=typename V::value_type(9);
- pass &= compare_distance(A, RA);
- {
- V B(3,3), RB(3,3);
- vector<typename V::value_type> b(3);
- b<<= 4,5,6;
- B<<= 1, 2, 3, b, 7, project(b, range(1,3));
- RB<<=1, 2, 3, 4, 5, 6, 7, 5, 6; // If the first worked we can now probably use it.
- pass &= compare_distance(B, RB);
- }
- {
- V B(3,3), RB(3,3);
- vector<typename V::value_type> b(3);
- b<<= 4,5,6;
- B<<= move(1,0), b, move_to(0,0), 1, 2, 3, move(1,0), 7, project(b, range(1,3));
- RB<<=1, 2, 3, 4, 5, 6, 7, 5, 6;
- pass &= compare_distance(B, RB);
- }
- {
- V B(3,3), RB(3,3);
- vector<typename V::value_type> b(9);
- b<<= 1, 2, 3, 4, 5, 6, 7, 8, 9;
- B<<=b;
- RB<<=1, 2, 3, 4, 5, 6, 7, 8, 9;
- pass &= compare_distance(B, RB);
- }
- {
- V B(4,4), RB(4,4);
- V C(2,2);
- C <<= 2, 3,
- 4, 5;
- B<<= C,C,
- C,C;
- RB <<= 2,3,2,3,
- 4,5,4,5,
- 2,3,2,3,
- 4,5,4,5;
- pass &= compare_distance(B, RB);
- }
- {
- V B(4,4), RB(4,4);
- V C(2,2);
- C <<= 2, 3, 4, 5;
- B<<= C, zero_matrix<typename V::value_type>(2,2),
- zero_matrix<typename V::value_type>(2,2), C;
- RB<<= 2,3,0,0,
- 4,5,0,0,
- 0,0,2,3,
- 0,0,4,5;
- pass &= compare_distance(B, RB);
- }
- {
- V B(4,4), RB(4,4);
- V C(2,2);
- C <<= 2, 3, 4, 5;
- B<<= C, zero_matrix<typename V::value_type>(2,2),
- zero_matrix<typename V::value_type>(2,2), C;
- RB<<= 2,3,0,0,
- 4,5,0,0,
- 0,0,2,3,
- 0,0,4,5;
- pass &= compare_distance(B, RB);
- }
- {
- V B(4,4), RB(4,4);
- B = zero_matrix<typename V::value_type>(4,4); // We need that because of the non-zero instatiation of dense types.
- V C(2,2);
- C <<= 2, 3, 4, 5;
- B<<= move(1,1), C;
- RB<<= 0,0,0,0,
- 0,2,3,0,
- 0,4,5,0,
- 0,0,0,0;
- pass &= compare_distance(B, RB);
- }
- {
- V B(4,4), RB(4,4);
- B = zero_matrix<typename V::value_type>(4,4);
- B<<= move_to(0,1), 2, 3, next_row(), 1, 2, next_row(), 4, 5;
- RB<<= 0,2,3,0,
- 1,2,0,0,
- 4,5,0,0,
- 0,0,0,0;
- pass &= compare_distance(B, RB);
- }
- {
- V B(4,4), RB(4,4);
- B = zero_matrix<typename V::value_type>(4,4);
- B<<=traverse_policy::by_column(), move_to(0,1), 2, 3, 6, next_column(), 4, 5;
- RB<<= 0,2,4,0,
- 0,3,5,0,
- 0,6,0,0,
- 0,0,0,0;
- pass &= compare_distance(B, RB);
- }
- {
- V B(4,4), RB(4,4);
- B = zero_matrix<typename V::value_type>(4,4);
- B<<=traverse_policy::by_column(), move_to(0,1), 2, 3, next_row(), traverse_policy::by_row(), 4, 5;
- RB<<= 0,2,0,0,
- 0,3,0,0,
- 0,0,0,0,
- 4,5,0,0;
- pass &= compare_distance(B, RB);
- }
- {
- V B(4,4), RB(4,4);
- B = zero_matrix<typename V::value_type>(4,4);
- B<<=traverse_policy::by_column(), move_to(0,1), 2, 3, begin2(), traverse_policy::by_row(), 4, 5, 6, 7, 8;
- RB<<= 0,2,0,0,
- 0,3,0,0,
- 4,5,6,7,
- 8,0,0,0;
- pass &= compare_distance(B, RB);
- }
- {
- V B(4,4), RB(4,4);
- B = zero_matrix<typename V::value_type>(4,4);
- B<<=traverse_policy::by_column(), move_to(0,1), 2, 3, begin2(), traverse_policy::by_row(), 4, 5, 6, 7, 8,9, begin1(), 1, 2;
- RB<<= 0,2,1,2,
- 0,3,0,0,
- 4,5,6,7,
- 8,9,0,0;
- pass &= compare_distance(B, RB);
- }
- {
- V B(4,4), RB(4,4);
- B = scalar_matrix<typename V::value_type>(4,4,1);
- V C(2,2);
- C <<= 1, 2, 3, 4;
- B<<= fill_policy::index_plus_assign(), move(1,1), C;
- RB<<= 1,1,1,1,
- 1,2,3,1,
- 1,4,5,1,
- 1,1,1,1;
- pass &= compare_distance(B, RB);
- }
- {
- V B(4,4), RB(4,4);
- B = scalar_matrix<typename V::value_type>(4,4,5);
- V C(2,2);
- C <<= 1, 2, 3, 4;
- B<<= fill_policy::index_minus_assign(), move(1,1), C;
- RB<<= 5,5,5,5,
- 5,4,3,5,
- 5,2,1,5,
- 5,5,5,5;
- pass &= compare_distance(B, RB);
- }
- return pass;
- }
- template <class V>
- bool test_matrix_sparse_push_back() {
- bool pass = true;
- V A(3,3), RA(3,3);
- A <<= fill_policy::sparse_push_back(), 1, 2, 3, 4, 5, 6, 7, 8, 9;
- RA(0,0)= typename V::value_type(1); RA(0,1)= typename V::value_type(2); RA(0,2)= typename V::value_type(3);
- RA(1,0)= typename V::value_type(4); RA(1,1)= typename V::value_type(5); RA(1,2)= typename V::value_type(6);
- RA(2,0)= typename V::value_type(7); RA(2,1)= typename V::value_type(8); RA(2,2)= typename V::value_type(9);
- pass &= compare_distance(A, RA);
- {
- V B(3,3), RB(3,3);
- vector<typename V::value_type> b(3);
- b<<= 4,5,6;
- B<<=fill_policy::sparse_push_back(), 1, 2, 3, b, 7, project(b, range(1,3));
- RB<<= 1, 2, 3, 4, 5, 6, 7, 5, 6; // If the first worked we can now probably use it.
- pass &= compare_distance(B, RB);
- }
- {
- V B(3,3), RB(3,3);
- vector<typename V::value_type> b(3);
- b<<= 4,5,6;
- B<<=fill_policy::sparse_push_back(), move(1,0), b, fill_policy::sparse_insert(), move_to(0,0), 1, 2, 3, move(1,0), 7, project(b, range(1,3));
- RB<<=1, 2, 3, 4, 5, 6, 7, 5, 6;
- pass &= compare_distance(B, RB);
- }
- {
- V B(3,3), RB(3,3);
- vector<typename V::value_type> b(9);
- b<<= 1, 2, 3, 4, 5, 6, 7, 8, 9;
- B<<=b;
- RB<<=1, 2, 3, 4, 5, 6, 7, 8, 9;
- pass &= compare_distance(B, RB);
- }
- {
- V B(4,4), RB(4,4);
- V C(2,2);
- C <<= 2, 3,
- 4, 5;
- // It might get complicated for sparse push_back, this must go into the tutorial. (This way is not convient nor fast)
- B<<=fill_policy::sparse_push_back(), C, move_to(2,2), C, fill_policy::sparse_insert(), move_to(0,2), C, C;
- RB <<= 2,3,2,3,
- 4,5,4,5,
- 2,3,2,3,
- 4,5,4,5;
- pass &= compare_distance(B, RB);
- }
- {
- V B(4,4), RB(4,4);
- V C(2,2);
- C <<= 2, 3, 4, 5;
- B<<=fill_policy::sparse_push_back(), C, move_to(2,2), C;
- RB<<= 2,3,0,0,
- 4,5,0,0,
- 0,0,2,3,
- 0,0,4,5;
- pass &= compare_distance(B, RB);
- }
- {
- V B(4,4), RB(4,4);
- V C(2,2);
- C <<= 2, 3, 4, 5;
- B<<=fill_policy::sparse_push_back(), move(1,1), C;
- RB<<= 0,0,0,0,
- 0,2,3,0,
- 0,4,5,0,
- 0,0,0,0;
- pass &= compare_distance(B, RB);
- }
- {
- V B(4,4), RB(4,4);
- B = zero_matrix<typename V::value_type>(4,4);
- B<<=fill_policy::sparse_push_back(), move_to(0,1), 2, 3, next_row(), 1, 2, next_row(), 4, 5;
- RB<<= 0,2,3,0,
- 1,2,0,0,
- 4,5,0,0,
- 0,0,0,0;
- pass &= compare_distance(B, RB);
- }
- // The next will not work with sparse push_back because elements that are prior to the ones already in are attempted to be added
- /*
- {
- V B(4,4), RB(4,4);
- B = zero_matrix<typename V::value_type>(4,4);
- B<<=fill_policy::sparse_push_back(),traverse_policy::by_column(), move_to(0,1), 2, 3, 6, next_column(), 4, 5;
- RB<<= 0,2,4,0,
- 0,3,5,0,
- 0,6,0,0,
- 0,0,0,0;
- pass &= compare_distance(B, RB);
- }
- */
- {
- V B(4,4), RB(4,4);
- B = zero_matrix<typename V::value_type>(4,4);
- B<<=fill_policy::sparse_push_back(),traverse_policy::by_column(), move_to(0,1), 2, 3, next_row(), traverse_policy::by_row(), 4, 5;
- RB<<= 0,2,0,0,
- 0,3,0,0,
- 0,0,0,0,
- 4,5,0,0;
- pass &= compare_distance(B, RB);
- }
- {
- V B(4,4), RB(4,4);
- B = zero_matrix<typename V::value_type>(4,4);
- B<<=fill_policy::sparse_push_back(),traverse_policy::by_column(), move_to(0,1), 2, 3, begin2(), traverse_policy::by_row(), 4, 5, 6, 7, 8;
- RB<<= 0,2,0,0,
- 0,3,0,0,
- 4,5,6,7,
- 8,0,0,0;
- pass &= compare_distance(B, RB);
- }
- // The next will not work with sparse push_back because elements that are prior to the ones already in are attempted to be added
- /*
- {
- V B(4,4), RB(4,4);
- B = zero_matrix<typename V::value_type>(4,4);
- B<<=fill_policy::sparse_push_back(),traverse_policy::by_column(), move_to(0,1), 2, 3, begin2(), traverse_policy::by_row(), 4, 5, 6, 7, 8,9, begin1(), 1, 2;
- RB<<= 0,2,1,2,
- 0,3,0,0,
- 4,5,6,7,
- 8,9,0,0;
- pass &= compare_distance(B, RB);
- }
- */
- return pass;
- }
- template <class V>
- bool test_matrix_sparse_insert() {
- bool pass = true;
- V A(3,3), RA(3,3);
- A <<= fill_policy::sparse_insert(), 1, 2, 3, 4, 5, 6, 7, 8, 9;
- RA(0,0)= typename V::value_type(1); RA(0,1)= typename V::value_type(2); RA(0,2)= typename V::value_type(3);
- RA(1,0)= typename V::value_type(4); RA(1,1)= typename V::value_type(5); RA(1,2)= typename V::value_type(6);
- RA(2,0)= typename V::value_type(7); RA(2,1)= typename V::value_type(8); RA(2,2)= typename V::value_type(9);
- pass &= compare_distance(A, RA);
- {
- V B(3,3), RB(3,3);
- vector<typename V::value_type> b(3);
- b<<= 4,5,6;
- B<<=fill_policy::sparse_insert(), 1, 2, 3, b, 7, project(b, range(1,3));
- RB<<=1, 2, 3, 4, 5, 6, 7, 5, 6; // If the first worked we can now probably use it.
- pass &= compare_distance(B, RB);
- }
- {
- V B(3,3), RB(3,3);
- vector<typename V::value_type> b(3);
- b<<= 4,5,6;
- B<<=fill_policy::sparse_insert(), move(1,0), b, fill_policy::sparse_insert(), move_to(0,0), 1, 2, 3, move(1,0), 7, project(b, range(1,3));
- RB<<=1, 2, 3, 4, 5, 6, 7, 5, 6;
- pass &= compare_distance(B, RB);
- }
- {
- V B(3,3), RB(3,3);
- vector<typename V::value_type> b(9);
- b<<= 1, 2, 3, 4, 5, 6, 7, 8, 9;
- B<<=b;
- RB<<=1, 2, 3, 4, 5, 6, 7, 8, 9;
- pass &= compare_distance(B, RB);
- }
- {
- V B(4,4), RB(4,4);
- V C(2,2);
- C <<= 2, 3,
- 4, 5;
- B<<=fill_policy::sparse_insert(), C, C, C, C;
- RB <<= 2,3,2,3,
- 4,5,4,5,
- 2,3,2,3,
- 4,5,4,5;
- pass &= compare_distance(B, RB);
- }
- {
- V B(4,4), RB(4,4);
- V C(2,2);
- C <<= 2, 3, 4, 5;
- B<<=fill_policy::sparse_insert(), C, move_to(2,2), C;
- RB<<= 2,3,0,0,
- 4,5,0,0,
- 0,0,2,3,
- 0,0,4,5;
- pass &= compare_distance(B, RB);
- }
- {
- V B(4,4), RB(4,4);
- V C(2,2);
- C <<= 2, 3, 4, 5;
- B<<=fill_policy::sparse_insert(), move(1,1), C;
- RB<<= 0,0,0,0,
- 0,2,3,0,
- 0,4,5,0,
- 0,0,0,0;
- pass &= compare_distance(B, RB);
- }
- {
- V B(4,4), RB(4,4);
- B = zero_matrix<typename V::value_type>(4,4);
- B<<=fill_policy::sparse_insert(), move_to(0,1), 2, 3, next_row(), 1, 2, next_row(), 4, 5;
- RB<<= 0,2,3,0,
- 1,2,0,0,
- 4,5,0,0,
- 0,0,0,0;
- pass &= compare_distance(B, RB);
- }
- {
- V B(4,4), RB(4,4);
- B = zero_matrix<typename V::value_type>(4,4);
- B<<=fill_policy::sparse_insert(),traverse_policy::by_column(), move_to(0,1), 2, 3, 6, next_column(), 4, 5;
- RB<<= 0,2,4,0,
- 0,3,5,0,
- 0,6,0,0,
- 0,0,0,0;
- pass &= compare_distance(B, RB);
- }
- {
- V B(4,4), RB(4,4);
- B = zero_matrix<typename V::value_type>(4,4);
- B<<=fill_policy::sparse_insert(),traverse_policy::by_column(), move_to(0,1), 2, 3, next_row(), traverse_policy::by_row(), 4, 5;
- RB<<= 0,2,0,0,
- 0,3,0,0,
- 0,0,0,0,
- 4,5,0,0;
- pass &= compare_distance(B, RB);
- }
- {
- V B(4,4), RB(4,4);
- B = zero_matrix<typename V::value_type>(4,4);
- B<<=fill_policy::sparse_insert(),traverse_policy::by_column(), move_to(0,1), 2, 3, begin2(), traverse_policy::by_row(), 4, 5, 6, 7, 8;
- RB<<= 0,2,0,0,
- 0,3,0,0,
- 4,5,6,7,
- 8,0,0,0;
- pass &= compare_distance(B, RB);
- }
- {
- V B(4,4), RB(4,4);
- B = zero_matrix<typename V::value_type>(4,4);
- B<<=fill_policy::sparse_insert(),traverse_policy::by_column(), move_to(0,1), 2, 3, begin2(), traverse_policy::by_row(), 4, 5, 6, 7, 8,9, begin1(), 1, 2;
- RB<<= 0,2,1,2,
- 0,3,0,0,
- 4,5,6,7,
- 8,9,0,0;
- pass &= compare_distance(B, RB);
- }
- return pass;
- }
- BOOST_UBLAS_TEST_DEF (test_vector) {
- BOOST_UBLAS_DEBUG_TRACE( "Starting operator \"<<= \" vector assignment tests" );
- BOOST_UBLAS_TEST_CHECK(test_vector<vector<double> >());
- BOOST_UBLAS_TEST_CHECK(test_vector<vector<float> >());
- BOOST_UBLAS_TEST_CHECK(test_vector<vector<long> >());
- BOOST_UBLAS_TEST_CHECK(test_vector<vector<unsigned long> >());
- BOOST_UBLAS_TEST_CHECK(test_vector<vector<int> >());
- BOOST_UBLAS_TEST_CHECK(test_vector<vector<unsigned int> >());
- BOOST_UBLAS_TEST_CHECK(test_vector<vector<std::size_t> >());
- BOOST_UBLAS_TEST_CHECK(test_vector<vector<char> >());
- BOOST_UBLAS_TEST_CHECK((test_vector<bounded_vector<double,7> >()));
- BOOST_UBLAS_TEST_CHECK((test_vector<bounded_vector<float,7> >()));
- BOOST_UBLAS_TEST_CHECK((test_vector<bounded_vector<long,7> >()));
- BOOST_UBLAS_TEST_CHECK((test_vector<bounded_vector<unsigned long,7> >()));
- BOOST_UBLAS_TEST_CHECK((test_vector<bounded_vector<int,7> >()));
- BOOST_UBLAS_TEST_CHECK((test_vector<bounded_vector<unsigned int,7> >()));
- BOOST_UBLAS_TEST_CHECK((test_vector<bounded_vector<std::size_t,7> >()));
- BOOST_UBLAS_TEST_CHECK((test_vector<bounded_vector<char,7> >()));
- BOOST_UBLAS_TEST_CHECK(test_vector<mapped_vector<double> >());
- BOOST_UBLAS_TEST_CHECK(test_vector<mapped_vector<float> >());
- BOOST_UBLAS_TEST_CHECK(test_vector<mapped_vector<long> >());
- BOOST_UBLAS_TEST_CHECK(test_vector<mapped_vector<unsigned long> >());
- BOOST_UBLAS_TEST_CHECK(test_vector<mapped_vector<int> >());
- BOOST_UBLAS_TEST_CHECK(test_vector<mapped_vector<unsigned int> >())
- BOOST_UBLAS_TEST_CHECK(test_vector<mapped_vector<std::size_t> >())
- BOOST_UBLAS_TEST_CHECK(test_vector<mapped_vector<char> >());
- BOOST_UBLAS_TEST_CHECK(test_vector<compressed_vector<double> >());
- BOOST_UBLAS_TEST_CHECK(test_vector<compressed_vector<float> >());
- BOOST_UBLAS_TEST_CHECK(test_vector<compressed_vector<long> >());
- BOOST_UBLAS_TEST_CHECK(test_vector<compressed_vector<unsigned long> >());
- BOOST_UBLAS_TEST_CHECK(test_vector<compressed_vector<int> >());
- BOOST_UBLAS_TEST_CHECK(test_vector<compressed_vector<unsigned int> >());
- BOOST_UBLAS_TEST_CHECK(test_vector<compressed_vector<std::size_t> >());
- BOOST_UBLAS_TEST_CHECK(test_vector<compressed_vector<char> >());
- BOOST_UBLAS_TEST_CHECK(test_vector<coordinate_vector<double> >());
- BOOST_UBLAS_TEST_CHECK(test_vector<coordinate_vector<float> >());
- BOOST_UBLAS_TEST_CHECK(test_vector<coordinate_vector<long> >())
- BOOST_UBLAS_TEST_CHECK(test_vector<coordinate_vector<unsigned long> >())
- BOOST_UBLAS_TEST_CHECK(test_vector<coordinate_vector<int> >());
- BOOST_UBLAS_TEST_CHECK(test_vector<coordinate_vector<unsigned int> >());
- BOOST_UBLAS_TEST_CHECK(test_vector<coordinate_vector<std::size_t> >());
- BOOST_UBLAS_TEST_CHECK(test_vector<coordinate_vector<char> >());
- BOOST_UBLAS_TEST_CHECK(test_vector_sparse_push_back<compressed_vector<double> >());
- BOOST_UBLAS_TEST_CHECK(test_vector_sparse_push_back<compressed_vector<float> >());
- BOOST_UBLAS_TEST_CHECK(test_vector_sparse_push_back<compressed_vector<long> >());
- BOOST_UBLAS_TEST_CHECK(test_vector_sparse_push_back<compressed_vector<unsigned long> >());
- BOOST_UBLAS_TEST_CHECK(test_vector_sparse_push_back<compressed_vector<int> >());
- BOOST_UBLAS_TEST_CHECK(test_vector_sparse_push_back<compressed_vector<unsigned int> >());
- BOOST_UBLAS_TEST_CHECK(test_vector_sparse_push_back<compressed_vector<std::size_t> >());
- BOOST_UBLAS_TEST_CHECK(test_vector_sparse_push_back<compressed_vector<char> >());
- BOOST_UBLAS_TEST_CHECK(test_vector_sparse_push_back<coordinate_vector<double> >());
- BOOST_UBLAS_TEST_CHECK(test_vector_sparse_push_back<coordinate_vector<float> >());
- BOOST_UBLAS_TEST_CHECK(test_vector_sparse_push_back<coordinate_vector<long> >());
- BOOST_UBLAS_TEST_CHECK(test_vector_sparse_push_back<coordinate_vector<unsigned long> >());
- BOOST_UBLAS_TEST_CHECK(test_vector_sparse_push_back<coordinate_vector<int> >());
- BOOST_UBLAS_TEST_CHECK(test_vector_sparse_push_back<coordinate_vector<unsigned int> >());
- BOOST_UBLAS_TEST_CHECK(test_vector_sparse_push_back<coordinate_vector<std::size_t> >());
- BOOST_UBLAS_TEST_CHECK(test_vector_sparse_push_back<coordinate_vector<char> >());
- BOOST_UBLAS_TEST_CHECK(test_vector_sparse_insert<compressed_vector<double> >());
- BOOST_UBLAS_TEST_CHECK(test_vector_sparse_insert<compressed_vector<float> >());
- BOOST_UBLAS_TEST_CHECK(test_vector_sparse_insert<compressed_vector<long> >());
- BOOST_UBLAS_TEST_CHECK(test_vector_sparse_insert<compressed_vector<unsigned long> >());
- BOOST_UBLAS_TEST_CHECK(test_vector_sparse_insert<compressed_vector<int> >());
- BOOST_UBLAS_TEST_CHECK(test_vector_sparse_insert<compressed_vector<unsigned int> >());
- BOOST_UBLAS_TEST_CHECK(test_vector_sparse_insert<compressed_vector<std::size_t> >());
- BOOST_UBLAS_TEST_CHECK(test_vector_sparse_insert<compressed_vector<char> >());
- BOOST_UBLAS_TEST_CHECK(test_vector_sparse_insert<coordinate_vector<double> >());
- BOOST_UBLAS_TEST_CHECK(test_vector_sparse_insert<coordinate_vector<float> >());
- BOOST_UBLAS_TEST_CHECK(test_vector_sparse_insert<coordinate_vector<long> >());
- BOOST_UBLAS_TEST_CHECK(test_vector_sparse_insert<coordinate_vector<unsigned long> >());
- BOOST_UBLAS_TEST_CHECK(test_vector_sparse_insert<coordinate_vector<int> >());
- BOOST_UBLAS_TEST_CHECK(test_vector_sparse_insert<coordinate_vector<unsigned int> >());
- BOOST_UBLAS_TEST_CHECK(test_vector_sparse_insert<coordinate_vector<std::size_t> >());
- BOOST_UBLAS_TEST_CHECK(test_vector_sparse_insert<coordinate_vector<char> >());
- }
- BOOST_UBLAS_TEST_DEF (test_matrix) {
- BOOST_UBLAS_DEBUG_TRACE( "Starting operator \"<<= \" matrix assignment tests" );
- BOOST_UBLAS_TEST_CHECK(test_matrix<matrix<double> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix<matrix<float> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix<matrix<long> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix<matrix<unsigned long> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix<matrix<int> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix<matrix<unsigned int> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix<matrix<std::size_t> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix<matrix<char> >());
- BOOST_UBLAS_TEST_CHECK((test_matrix<bounded_matrix<double,7, 7> >()));
- BOOST_UBLAS_TEST_CHECK((test_matrix<bounded_matrix<float,7, 7> >()));
- BOOST_UBLAS_TEST_CHECK((test_matrix<bounded_matrix<long,7, 7> >()));
- BOOST_UBLAS_TEST_CHECK((test_matrix<bounded_matrix<unsigned long,7, 7> >()));
- BOOST_UBLAS_TEST_CHECK((test_matrix<bounded_matrix<int,7,7 > >()));
- BOOST_UBLAS_TEST_CHECK((test_matrix<bounded_matrix<unsigned int,7, 7> >()));
- BOOST_UBLAS_TEST_CHECK((test_matrix<bounded_matrix<char,7, 7> >()));
- BOOST_UBLAS_TEST_CHECK((test_matrix<bounded_matrix<std::size_t,7, 7> >()));
- BOOST_UBLAS_TEST_CHECK(test_matrix<mapped_matrix<double> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix<mapped_matrix<float> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix<mapped_matrix<long> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix<mapped_matrix<unsigned long> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix<mapped_matrix<int> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix<mapped_matrix<unsigned int> >())
- BOOST_UBLAS_TEST_CHECK(test_matrix<mapped_matrix<std::size_t> >())
- BOOST_UBLAS_TEST_CHECK(test_matrix<mapped_matrix<char> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix<compressed_matrix<double> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix<compressed_matrix<float> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix<compressed_matrix<long> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix<compressed_matrix<unsigned long> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix<compressed_matrix<int> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix<compressed_matrix<unsigned int> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix<compressed_matrix<std::size_t> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix<compressed_matrix<char> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix<coordinate_matrix<double> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix<coordinate_matrix<float> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix<coordinate_matrix<long> >())
- BOOST_UBLAS_TEST_CHECK(test_matrix<coordinate_matrix<unsigned long> >())
- BOOST_UBLAS_TEST_CHECK(test_matrix<coordinate_matrix<int> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix<coordinate_matrix<unsigned int> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix<coordinate_matrix<std::size_t> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix<coordinate_matrix<char> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix_sparse_push_back<compressed_matrix<double> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix_sparse_push_back<compressed_matrix<float> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix_sparse_push_back<compressed_matrix<long> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix_sparse_push_back<compressed_matrix<unsigned long> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix_sparse_push_back<compressed_matrix<int> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix_sparse_push_back<compressed_matrix<unsigned int> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix_sparse_push_back<compressed_matrix<std::size_t> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix_sparse_push_back<compressed_matrix<char> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix_sparse_push_back<coordinate_matrix<double> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix_sparse_push_back<coordinate_matrix<float> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix_sparse_push_back<coordinate_matrix<long> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix_sparse_push_back<coordinate_matrix<unsigned long> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix_sparse_push_back<coordinate_matrix<int> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix_sparse_push_back<coordinate_matrix<unsigned int> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix_sparse_push_back<coordinate_matrix<std::size_t> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix_sparse_push_back<coordinate_matrix<char> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix_sparse_insert<compressed_matrix<double> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix_sparse_insert<compressed_matrix<float> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix_sparse_insert<compressed_matrix<long> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix_sparse_insert<compressed_matrix<unsigned long> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix_sparse_insert<compressed_matrix<int> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix_sparse_insert<compressed_matrix<unsigned int> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix_sparse_insert<compressed_matrix<std::size_t> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix_sparse_insert<compressed_matrix<char> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix_sparse_insert<coordinate_matrix<double> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix_sparse_insert<coordinate_matrix<float> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix_sparse_insert<coordinate_matrix<long> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix_sparse_insert<coordinate_matrix<unsigned long> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix_sparse_insert<coordinate_matrix<int> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix_sparse_insert<coordinate_matrix<unsigned int> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix_sparse_insert<coordinate_matrix<std::size_t> >());
- BOOST_UBLAS_TEST_CHECK(test_matrix_sparse_insert<coordinate_matrix<char> >());
- }
- int main () {
- BOOST_UBLAS_TEST_BEGIN();
- BOOST_UBLAS_TEST_DO( test_vector );
- BOOST_UBLAS_TEST_DO( test_matrix );
- BOOST_UBLAS_TEST_END();
- }
|