summaryrefslogtreecommitdiff
path: root/libs/numeric/ublas/test
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2015-04-08 03:09:47 +0000
committer <>2015-05-05 14:37:32 +0000
commitf2541bb90af059680aa7036f315f052175999355 (patch)
treea5b214744b256f07e1dc2bd7273035a7808c659f /libs/numeric/ublas/test
parented232fdd34968697a68783b3195b1da4226915b5 (diff)
downloadboost-tarball-master.tar.gz
Imported from /home/lorry/working-area/delta_boost-tarball/boost_1_58_0.tar.bz2.HEADboost_1_58_0master
Diffstat (limited to 'libs/numeric/ublas/test')
-rw-r--r--libs/numeric/ublas/test/begin_end.cpp2
-rw-r--r--libs/numeric/ublas/test/common/testhelper.hpp64
-rw-r--r--libs/numeric/ublas/test/comp_mat_erase.cpp2
-rw-r--r--libs/numeric/ublas/test/num_columns.cpp2
-rw-r--r--libs/numeric/ublas/test/num_rows.cpp2
-rw-r--r--libs/numeric/ublas/test/size.cpp2
-rw-r--r--libs/numeric/ublas/test/test13.cpp4
-rw-r--r--libs/numeric/ublas/test/test_assignment.cpp149
-rw-r--r--libs/numeric/ublas/test/test_banded_storage_layout.cpp12
-rw-r--r--libs/numeric/ublas/test/test_complex_norms.cpp2
-rw-r--r--libs/numeric/ublas/test/test_coordinate_matrix_inplace_merge.cpp22
-rw-r--r--libs/numeric/ublas/test/test_coordinate_matrix_sort.cpp2
-rw-r--r--libs/numeric/ublas/test/test_coordinate_vector_inplace_merge.cpp21
-rw-r--r--libs/numeric/ublas/test/test_fixed_containers.cpp8
-rw-r--r--libs/numeric/ublas/test/test_matrix_vector.cpp58
-rw-r--r--libs/numeric/ublas/test/test_ticket7296.cpp2
-rw-r--r--libs/numeric/ublas/test/test_triangular.cpp10
-rw-r--r--libs/numeric/ublas/test/triangular_access.cpp2
-rw-r--r--libs/numeric/ublas/test/triangular_layout.cpp2
-rw-r--r--libs/numeric/ublas/test/utils.hpp2
20 files changed, 176 insertions, 194 deletions
diff --git a/libs/numeric/ublas/test/begin_end.cpp b/libs/numeric/ublas/test/begin_end.cpp
index 270aa4a81..769a51faf 100644
--- a/libs/numeric/ublas/test/begin_end.cpp
+++ b/libs/numeric/ublas/test/begin_end.cpp
@@ -17,7 +17,7 @@
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/vector_expression.hpp>
#include <iostream>
-#include "libs/numeric/ublas/test/utils.hpp"
+#include "utils.hpp"
static const double TOL(1.0e-5); ///< Used for comparing two real numbers.
diff --git a/libs/numeric/ublas/test/common/testhelper.hpp b/libs/numeric/ublas/test/common/testhelper.hpp
index c4a2fb060..b554511fa 100644
--- a/libs/numeric/ublas/test/common/testhelper.hpp
+++ b/libs/numeric/ublas/test/common/testhelper.hpp
@@ -54,8 +54,13 @@ std::pair<unsigned, unsigned> getResults() {
template < class M1, class M2 >
bool compare( const boost::numeric::ublas::matrix_expression<M1> & m1,
const boost::numeric::ublas::matrix_expression<M2> & m2 ) {
- size_t size1 = (std::min)(m1().size1(), m2().size1());
- size_t size2 = (std::min)(m1().size2(), m2().size2());
+ if ((m1().size1() != m2().size1()) ||
+ (m1().size2() != m2().size2())) {
+ return false;
+ }
+
+ size_t size1 = m1().size1();
+ size_t size2 = m1().size2();
for (size_t i=0; i < size1; ++i) {
for (size_t j=0; j < size2; ++j) {
if ( m1()(i,j) != m2()(i,j) ) return false;
@@ -67,11 +72,64 @@ bool compare( const boost::numeric::ublas::matrix_expression<M1> & m1,
template < class M1, class M2 >
bool compare( const boost::numeric::ublas::vector_expression<M1> & m1,
const boost::numeric::ublas::vector_expression<M2> & m2 ) {
- size_t size = (std::min)(m1().size(), m2().size());
+ if (m1().size() != m2().size()) {
+ return false;
+ }
+
+ size_t size = m1().size();
for (size_t i=0; i < size; ++i) {
if ( m1()(i) != m2()(i) ) return false;
}
return true;
}
+// Compare if two matrices or vectors are equals based on distance.
+
+template <class AE>
+typename AE::value_type mean_square(const boost::numeric::ublas::matrix_expression<AE> &me) {
+ typename AE::value_type s(0);
+ typename AE::size_type i, j;
+ for (i=0; i!= me().size1(); i++) {
+ for (j=0; j!= me().size2(); j++) {
+ s += boost::numeric::ublas::scalar_traits<typename AE::value_type>::type_abs(me()(i,j));
+ }
+ }
+ return s / (me().size1() * me().size2());
+}
+
+template <class AE>
+typename AE::value_type mean_square(const boost::numeric::ublas::vector_expression<AE> &ve) {
+ // We could have use norm2 here, but ublas' ABS does not support unsigned types.
+ typename AE::value_type s(0);
+ typename AE::size_type i;
+ for (i=0; i!= ve().size(); i++) {
+ s += boost::numeric::ublas::scalar_traits<typename AE::value_type>::type_abs(ve()(i));
+ }
+ return s / ve().size();
+}
+
+template < class M1, class M2 >
+bool compare_to( const boost::numeric::ublas::matrix_expression<M1> & m1,
+ const boost::numeric::ublas::matrix_expression<M2> & m2,
+ double tolerance = 0.0 ) {
+ if ((m1().size1() != m2().size1()) ||
+ (m1().size2() != m2().size2())) {
+ return false;
+ }
+
+ return mean_square(m2() - m1()) <= tolerance;
+}
+
+template < class M1, class M2 >
+bool compare_to( const boost::numeric::ublas::vector_expression<M1> & m1,
+ const boost::numeric::ublas::vector_expression<M2> & m2,
+ double tolerance = 0.0 ) {
+ if (m1().size() != m2().size()) {
+ return false;
+ }
+
+ return mean_square(m2() - m1()) <= tolerance;
+}
+
+
#endif
diff --git a/libs/numeric/ublas/test/comp_mat_erase.cpp b/libs/numeric/ublas/test/comp_mat_erase.cpp
index fb456c6ec..70018908d 100644
--- a/libs/numeric/ublas/test/comp_mat_erase.cpp
+++ b/libs/numeric/ublas/test/comp_mat_erase.cpp
@@ -4,7 +4,7 @@
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#include "boost/numeric/ublas/matrix_sparse.hpp"
+#include <boost/numeric/ublas/matrix_sparse.hpp>
#define BOOST_TEST_MODULE SparseMatrixErasureTest
#include <boost/test/included/unit_test.hpp>
diff --git a/libs/numeric/ublas/test/num_columns.cpp b/libs/numeric/ublas/test/num_columns.cpp
index 568d4f2e1..68c9770af 100644
--- a/libs/numeric/ublas/test/num_columns.cpp
+++ b/libs/numeric/ublas/test/num_columns.cpp
@@ -9,7 +9,7 @@
#include <boost/numeric/ublas/matrix_expression.hpp>
#include <boost/numeric/ublas/operation/num_columns.hpp>
#include <iostream>
-#include "libs/numeric/ublas/test/utils.hpp"
+#include "utils.hpp"
BOOST_UBLAS_TEST_DEF( test_row_major_matrix_container )
diff --git a/libs/numeric/ublas/test/num_rows.cpp b/libs/numeric/ublas/test/num_rows.cpp
index 4a96bd2f9..1e3a1e70a 100644
--- a/libs/numeric/ublas/test/num_rows.cpp
+++ b/libs/numeric/ublas/test/num_rows.cpp
@@ -9,7 +9,7 @@
#include <boost/numeric/ublas/matrix_expression.hpp>
#include <boost/numeric/ublas/operation/num_rows.hpp>
#include <iostream>
-#include "libs/numeric/ublas/test/utils.hpp"
+#include "utils.hpp"
BOOST_UBLAS_TEST_DEF( test_row_major_matrix_container )
diff --git a/libs/numeric/ublas/test/size.cpp b/libs/numeric/ublas/test/size.cpp
index 5976caab8..1fd2f9de6 100644
--- a/libs/numeric/ublas/test/size.cpp
+++ b/libs/numeric/ublas/test/size.cpp
@@ -12,7 +12,7 @@
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/vector_expression.hpp>
#include <iostream>
-#include "libs/numeric/ublas/test/utils.hpp"
+#include "utils.hpp"
BOOST_UBLAS_TEST_DEF( test_vector_container )
diff --git a/libs/numeric/ublas/test/test13.cpp b/libs/numeric/ublas/test/test13.cpp
index ecb8eeb72..d84f321fe 100644
--- a/libs/numeric/ublas/test/test13.cpp
+++ b/libs/numeric/ublas/test/test13.cpp
@@ -88,6 +88,10 @@ struct test_my_matrix {
std::cout << "m1 * 1. = " << m2 << std::endl;
m2 = m1 * t;
std::cout << "m1 * N = " << m2 << std::endl;
+ m2 = m1 / value_type (2.);
+ std::cout << "m1 / 2. = " << m2 << std::endl;
+ m2 = m1 / t;
+ std::cout << "m1 / N = " << m2 << std::endl;
// Some assignments
initialize_matrix (m1);
diff --git a/libs/numeric/ublas/test/test_assignment.cpp b/libs/numeric/ublas/test/test_assignment.cpp
index 894f4512d..c402ac2f8 100644
--- a/libs/numeric/ublas/test/test_assignment.cpp
+++ b/libs/numeric/ublas/test/test_assignment.cpp
@@ -13,77 +13,49 @@
#include <boost/numeric/ublas/matrix_sparse.hpp>
#include <boost/numeric/ublas/io.hpp>
#include <boost/numeric/ublas/matrix.hpp>
-#include "libs/numeric/ublas/test/utils.hpp"
#include <boost/timer.hpp>
#include <ctime>
+#include "common/testhelper.hpp"
+#include "utils.hpp"
using namespace boost::numeric::ublas;
-namespace tans {
-template <class AE>
-typename AE::value_type mean_square(const matrix_expression<AE> &me) {
- typename AE::value_type s(0);
- typename AE::size_type i, j;
- for (i=0; i!= me().size1(); i++) {
- for (j=0; j!= me().size2(); j++) {
- s+= scalar_traits<typename AE::value_type>::type_abs(me()(i,j));
- }
- }
- return s/me().size1()*me().size2();
-}
-
-
-template <class AE>
-typename AE::value_type mean_square(const vector_expression<AE> &ve) {
- // We could have use norm2 here, but ublas' ABS does not support unsigned types.
- typename AE::value_type s(0);
- typename AE::size_type i;
- for (i=0; i!= ve().size(); i++) {
- s+=scalar_traits<typename AE::value_type>::type_abs(ve()(i));
- }
- return s/ve().size();
-}
-const double TOL=0.0;
-
-}
-
template <class V>
bool test_vector() {
bool pass = true;
- using namespace tans;
V a(3), ra(3);
a <<= 1, 2, 3;
ra(0) = 1; ra(1) = 2; ra(2) = 3;
- pass &= (mean_square(a-ra)<=TOL);
+ pass &= compare_to(a, ra);
V b(7), rb(7);
b<<= a, 10, a;
rb(0) = 1; rb(1) = 2; rb(2) = 3; rb(3)=10, rb(4)= 1; rb(5)=2; rb(6)=3;
- pass &= (mean_square(b-rb)<=TOL);
+ pass &= compare_to(b, rb);
{
V c(6), rc(6);
c <<= 1, move(2), 3 ,4, 5, move(-5), 10, 10;
rc(0) = 1; rc(1) = 10; rc(2) = 10; rc(3) = 3; rc(4) = 4; rc(5) = 5;
- pass &= (mean_square(c-rc)<=TOL);
+ pass &= compare_to(c, rc);
V d(6), rd(6);
d <<= 1, move_to(3), 3 ,4, 5, move_to(1), 10, 10;
rd(0) = 1; rd(1) = 10; rd(2) = 10; rd(3) = 3; rd(4) = 4; rd(5) = 5;
- pass &= (mean_square(d-rd)<=TOL);
+ pass &= compare_to(d, rd);
}
{
V c(6), rc(6);
c <<= 1, move<2>(), 3 ,4, 5, move<-5>(), 10, 10;
rc(0) = 1; rc(1) = 10; rc(2) = 10; rc(3) = 3; rc(4) = 4; rc(5) = 5;
- pass &= (mean_square(c-rc)<=TOL);
+ pass &= compare_to(c, rc);
V d(6), rd(6);
d <<= 1, move_to<3>(), 3 ,4, 5, move_to<1>(), 10, 10;
rd(0) = 1; rd(1) = 10; rd(2) = 10; rd(3) = 3; rd(4) = 4; rd(5) = 5;
- pass &= (mean_square(d-rd)<=TOL);
+ pass &= compare_to(d, rd);
}
@@ -93,7 +65,7 @@ bool test_vector() {
V fa(3); fa<<= 1, 2, 3;
f <<= fill_policy::index_plus_assign(), fa;
rf <<= 6,7,8, 5, 5, 5;
- pass &= (mean_square(f-rf)<=TOL);
+ pass &= compare_to(f, rf);
}
{
@@ -102,7 +74,7 @@ bool test_vector() {
V fa(3); fa<<= 1, 2, 3;
f <<= fill_policy::index_minus_assign(), fa;
rf <<= 4,3,2, 5, 5, 5;
- pass &= (mean_square(f-rf)<=TOL);
+ pass &= compare_to(f, rf);
}
return pass;
@@ -111,32 +83,31 @@ bool test_vector() {
template <class V>
bool test_vector_sparse_push_back() {
bool pass = true;
- using namespace tans;
V a(3), ra(3);
a <<= fill_policy::sparse_push_back(), 1, 2, 3;
ra(0) = 1; ra(1) = 2; ra(2) = 3;
- pass &= (mean_square(a-ra)<=TOL);
+ pass &= compare_to(a, ra);
V b(7), rb(7);
b<<= fill_policy::sparse_push_back(), a, 10, a;
rb(0) = 1; rb(1) = 2; rb(2) = 3; rb(3)=10, rb(4)= 1; rb(5)=2; rb(6)=3;
- pass &= (mean_square(b-rb)<=TOL);
+ pass &= compare_to(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) = 1; rc(1) = 0; rc(2) = 0; rc(3) = 3; rc(4) = 4; rc(5) = 5;
- pass &= (mean_square(c-rc)<=TOL);
+ pass &= compare_to(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) = 1; rd(1) = 0; rd(2) = 0; rd(3) = 3; rd(4) = 4; rd(5) = 5;
- pass &= (mean_square(d-rd)<=TOL);
+ pass &= compare_to(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) = 1; re(1) = 10; re(2) = 10; re(3) = 3; re(4) = 4; re(5) = 5;
- pass &= (mean_square(e-re)<=TOL);
+ pass &= compare_to(e, re);
return pass;
}
@@ -145,28 +116,27 @@ bool test_vector_sparse_push_back() {
template <class V>
bool test_vector_sparse_insert() {
bool pass = true;
- using namespace tans;
V a(3), ra(3);
a <<= fill_policy::sparse_insert(), 1, 2, 3;
ra(0) = 1; ra(1) = 2; ra(2) = 3;
- pass &= (mean_square(a-ra)<=TOL);
+ pass &= compare_to(a, ra);
V b(7), rb(7);
b<<= fill_policy::sparse_insert(), a, 10, a;
rb(0) = 1; rb(1) = 2; rb(2) = 3; rb(3)=10, rb(4)= 1; rb(5)=2; rb(6)=3;
- pass &= (mean_square(b-rb)<=TOL);
+ pass &= compare_to(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) = 1; rc(1) = 10; rc(2) = 10; rc(3) = 3; rc(4) = 4; rc(5) = 5;
- pass &= (mean_square(c-rc)<=TOL);
+ pass &= compare_to(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) = 1; rd(1) = 10; rd(2) = 10; rd(3) = 3; rd(4) = 4; rd(5) = 5;
- pass &= (mean_square(d-rd)<=TOL);
+ pass &= compare_to(d, rd);
return pass;
@@ -176,14 +146,13 @@ bool test_vector_sparse_insert() {
template <class V>
bool test_matrix() {
bool pass = true;
- using namespace tans;
V A(3,3), RA(3,3);
A <<= 1, 2, 3, 4, 5, 6, 7, 8, 9;
RA(0,0)= 1; RA(0,1)=2; RA(0,2)=3;
RA(1,0)= 4; RA(1,1)=5; RA(1,2)=6;
RA(2,0)= 7; RA(2,1)=8; RA(2,2)=9;
- pass &= (mean_square(A-RA)<=TOL);
+ pass &= compare_to(A, RA);
{
V B(3,3), RB(3,3);
@@ -191,7 +160,7 @@ bool test_matrix() {
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 &= (mean_square(B-RB)<=TOL);
+ pass &= compare_to(B, RB);
}
{
@@ -200,7 +169,7 @@ bool test_matrix() {
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 &= (mean_square(B-RB)<=TOL);
+ pass &= compare_to(B, RB);
}
{
@@ -209,7 +178,7 @@ bool test_matrix() {
b<<= 1, 2, 3, 4, 5, 6, 7, 8, 9;
B<<=b;
RB<<=1, 2, 3, 4, 5, 6, 7, 8, 9;
- pass &= (mean_square(B-RB)<=TOL);
+ pass &= compare_to(B, RB);
}
{
@@ -223,7 +192,7 @@ bool test_matrix() {
4,5,4,5,
2,3,2,3,
4,5,4,5;
- pass &= (mean_square(B-RB)<=TOL);
+ pass &= compare_to(B, RB);
}
{
@@ -236,7 +205,7 @@ bool test_matrix() {
4,5,0,0,
0,0,2,3,
0,0,4,5;
- pass &= (mean_square(B-RB)<=TOL);
+ pass &= compare_to(B, RB);
}
{
@@ -249,7 +218,7 @@ bool test_matrix() {
4,5,0,0,
0,0,2,3,
0,0,4,5;
- pass &= (mean_square(B-RB)<=TOL);
+ pass &= compare_to(B, RB);
}
{
@@ -262,7 +231,7 @@ bool test_matrix() {
0,2,3,0,
0,4,5,0,
0,0,0,0;
- pass &= (mean_square(B-RB)<=TOL);
+ pass &= compare_to(B, RB);
}
{
@@ -273,7 +242,7 @@ bool test_matrix() {
1,2,0,0,
4,5,0,0,
0,0,0,0;
- pass &= (mean_square(B-RB)<=TOL);
+ pass &= compare_to(B, RB);
}
{
@@ -284,7 +253,7 @@ bool test_matrix() {
0,3,5,0,
0,6,0,0,
0,0,0,0;
- pass &= (mean_square(B-RB)<=TOL);
+ pass &= compare_to(B, RB);
}
{
@@ -295,7 +264,7 @@ bool test_matrix() {
0,3,0,0,
0,0,0,0,
4,5,0,0;
- pass &= (mean_square(B-RB)<=TOL);
+ pass &= compare_to(B, RB);
}
{
@@ -306,7 +275,7 @@ bool test_matrix() {
0,3,0,0,
4,5,6,7,
8,0,0,0;
- pass &= (mean_square(B-RB)<=TOL);
+ pass &= compare_to(B, RB);
}
{
@@ -317,7 +286,7 @@ bool test_matrix() {
0,3,0,0,
4,5,6,7,
8,9,0,0;
- pass &= (mean_square(B-RB)<=TOL);
+ pass &= compare_to(B, RB);
}
{
@@ -330,7 +299,7 @@ bool test_matrix() {
1,2,3,1,
1,4,5,1,
1,1,1,1;
- pass &= (mean_square(B-RB)<=TOL);
+ pass &= compare_to(B, RB);
}
{
@@ -343,7 +312,7 @@ bool test_matrix() {
5,4,3,5,
5,2,1,5,
5,5,5,5;
- pass &= (mean_square(B-RB)<=TOL);
+ pass &= compare_to(B, RB);
}
@@ -353,14 +322,13 @@ bool test_matrix() {
template <class V>
bool test_matrix_sparse_push_back() {
bool pass = true;
- using namespace tans;
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)= 1; RA(0,1)=2; RA(0,2)=3;
RA(1,0)= 4; RA(1,1)=5; RA(1,2)=6;
RA(2,0)= 7; RA(2,1)=8; RA(2,2)=9;
- pass &= (mean_square(A-RA)<=TOL);
+ pass &= compare_to(A, RA);
{
V B(3,3), RB(3,3);
@@ -368,7 +336,7 @@ bool test_matrix_sparse_push_back() {
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 &= (mean_square(B-RB)<=TOL);
+ pass &= compare_to(B, RB);
}
{
@@ -377,7 +345,7 @@ bool test_matrix_sparse_push_back() {
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 &= (mean_square(B-RB)<=TOL);
+ pass &= compare_to(B, RB);
}
{
@@ -386,7 +354,7 @@ bool test_matrix_sparse_push_back() {
b<<= 1, 2, 3, 4, 5, 6, 7, 8, 9;
B<<=b;
RB<<=1, 2, 3, 4, 5, 6, 7, 8, 9;
- pass &= (mean_square(B-RB)<=TOL);
+ pass &= compare_to(B, RB);
}
@@ -401,7 +369,7 @@ bool test_matrix_sparse_push_back() {
4,5,4,5,
2,3,2,3,
4,5,4,5;
- pass &= (mean_square(B-RB)<=TOL);
+ pass &= compare_to(B, RB);
}
@@ -414,7 +382,7 @@ bool test_matrix_sparse_push_back() {
4,5,0,0,
0,0,2,3,
0,0,4,5;
- pass &= (mean_square(B-RB)<=TOL);
+ pass &= compare_to(B, RB);
}
{
@@ -426,7 +394,7 @@ bool test_matrix_sparse_push_back() {
0,2,3,0,
0,4,5,0,
0,0,0,0;
- pass &= (mean_square(B-RB)<=TOL);
+ pass &= compare_to(B, RB);
}
{
@@ -437,7 +405,7 @@ bool test_matrix_sparse_push_back() {
1,2,0,0,
4,5,0,0,
0,0,0,0;
- pass &= (mean_square(B-RB)<=TOL);
+ pass &= compare_to(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
/*
@@ -449,7 +417,7 @@ bool test_matrix_sparse_push_back() {
0,3,5,0,
0,6,0,0,
0,0,0,0;
- pass &= (mean_square(B-RB)<=TOL);
+ pass &= compare_to(B, RB);
}
*/
{
@@ -460,7 +428,7 @@ bool test_matrix_sparse_push_back() {
0,3,0,0,
0,0,0,0,
4,5,0,0;
- pass &= (mean_square(B-RB)<=TOL);
+ pass &= compare_to(B, RB);
}
{
@@ -471,7 +439,7 @@ bool test_matrix_sparse_push_back() {
0,3,0,0,
4,5,6,7,
8,0,0,0;
- pass &= (mean_square(B-RB)<=TOL);
+ pass &= compare_to(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
@@ -484,7 +452,7 @@ bool test_matrix_sparse_push_back() {
0,3,0,0,
4,5,6,7,
8,9,0,0;
- pass &= (mean_square(B-RB)<=TOL);
+ pass &= compare_to(B, RB);
}
*/
return pass;
@@ -493,14 +461,13 @@ bool test_matrix_sparse_push_back() {
template <class V>
bool test_matrix_sparse_insert() {
bool pass = true;
- using namespace tans;
V A(3,3), RA(3,3);
A <<= fill_policy::sparse_insert(), 1, 2, 3, 4, 5, 6, 7, 8, 9;
RA(0,0)= 1; RA(0,1)=2; RA(0,2)=3;
RA(1,0)= 4; RA(1,1)=5; RA(1,2)=6;
RA(2,0)= 7; RA(2,1)=8; RA(2,2)=9;
- pass &= (mean_square(A-RA)<=TOL);
+ pass &= compare_to(A, RA);
{
V B(3,3), RB(3,3);
@@ -508,7 +475,7 @@ bool test_matrix_sparse_insert() {
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 &= (mean_square(B-RB)<=TOL);
+ pass &= compare_to(B, RB);
}
{
@@ -517,7 +484,7 @@ bool test_matrix_sparse_insert() {
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 &= (mean_square(B-RB)<=TOL);
+ pass &= compare_to(B, RB);
}
{
@@ -526,7 +493,7 @@ bool test_matrix_sparse_insert() {
b<<= 1, 2, 3, 4, 5, 6, 7, 8, 9;
B<<=b;
RB<<=1, 2, 3, 4, 5, 6, 7, 8, 9;
- pass &= (mean_square(B-RB)<=TOL);
+ pass &= compare_to(B, RB);
}
@@ -540,7 +507,7 @@ bool test_matrix_sparse_insert() {
4,5,4,5,
2,3,2,3,
4,5,4,5;
- pass &= (mean_square(B-RB)<=TOL);
+ pass &= compare_to(B, RB);
}
@@ -553,7 +520,7 @@ bool test_matrix_sparse_insert() {
4,5,0,0,
0,0,2,3,
0,0,4,5;
- pass &= (mean_square(B-RB)<=TOL);
+ pass &= compare_to(B, RB);
}
{
@@ -565,7 +532,7 @@ bool test_matrix_sparse_insert() {
0,2,3,0,
0,4,5,0,
0,0,0,0;
- pass &= (mean_square(B-RB)<=TOL);
+ pass &= compare_to(B, RB);
}
{
@@ -576,7 +543,7 @@ bool test_matrix_sparse_insert() {
1,2,0,0,
4,5,0,0,
0,0,0,0;
- pass &= (mean_square(B-RB)<=TOL);
+ pass &= compare_to(B, RB);
}
{
@@ -587,7 +554,7 @@ bool test_matrix_sparse_insert() {
0,3,5,0,
0,6,0,0,
0,0,0,0;
- pass &= (mean_square(B-RB)<=TOL);
+ pass &= compare_to(B, RB);
}
{
@@ -598,7 +565,7 @@ bool test_matrix_sparse_insert() {
0,3,0,0,
0,0,0,0,
4,5,0,0;
- pass &= (mean_square(B-RB)<=TOL);
+ pass &= compare_to(B, RB);
}
{
@@ -609,7 +576,7 @@ bool test_matrix_sparse_insert() {
0,3,0,0,
4,5,6,7,
8,0,0,0;
- pass &= (mean_square(B-RB)<=TOL);
+ pass &= compare_to(B, RB);
}
{
@@ -620,7 +587,7 @@ bool test_matrix_sparse_insert() {
0,3,0,0,
4,5,6,7,
8,9,0,0;
- pass &= (mean_square(B-RB)<=TOL);
+ pass &= compare_to(B, RB);
}
return pass;
diff --git a/libs/numeric/ublas/test/test_banded_storage_layout.cpp b/libs/numeric/ublas/test/test_banded_storage_layout.cpp
index f2d33f99a..6b4e68a7a 100644
--- a/libs/numeric/ublas/test/test_banded_storage_layout.cpp
+++ b/libs/numeric/ublas/test/test_banded_storage_layout.cpp
@@ -9,7 +9,7 @@
using namespace boost::numeric::ublas;
-int expected_index( int index, column_major tag ) {
+int expected_index( int index, column_major ) {
// this is the data shown on http://www.netlib.org/lapack/lug/node124.html
// read column-by-column, aka column_major
int mapping[] = { 0, 11, 21, 31, 12, 22, 32, 42, 23, 33, 43, 53, 34, 44, 54, 0, 45, 55, 0, 0 };
@@ -17,32 +17,32 @@ int expected_index( int index, column_major tag ) {
}
-int expected_index( int index, row_major tag ) {
+int expected_index( int index, row_major ) {
// this is the data shown on http://www.netlib.org/lapack/lug/node124.html
// read row-by-row, aka row_major
int mapping[] = { 0, 0, 11, 12, 0, 21, 22, 23, 31, 32, 33, 34, 42, 43, 44, 45, 53, 54, 55, 0 };
return mapping[ index ];
}
-int expected_index_6_by_5( int index, column_major tag ) {
+int expected_index_6_by_5( int index, column_major ) {
// read column-by-column, aka column_major
int mapping[] = { 0, 11, 21, 31, 12, 22, 32, 42, 23, 33, 43, 53, 34, 44, 54, 64, 45, 55, 65, 0 };
return mapping[ index ];
}
-int expected_index_6_by_5( int index, row_major tag ) {
+int expected_index_6_by_5( int index, row_major ) {
// read row-by-row, aka row_major
int mapping[] = { 0, 0, 11, 12, 0, 21, 22, 23, 31, 32, 33, 34, 42, 43, 44, 45, 53, 54, 55, 0, 64, 65, 0, 0 };
return mapping[ index ];
}
-int expected_index_5_by_6( int index, column_major tag ) {
+int expected_index_5_by_6( int index, column_major ) {
// read column-by-column, aka column_major
int mapping[] = { 0, 11, 21, 31, 12, 22, 32, 42, 23, 33, 43, 53, 34, 44, 54, 0, 45, 55, 0, 0, 56, 0, 0, 0 };
return mapping[ index ];
}
-int expected_index_5_by_6( int index, row_major tag ) {
+int expected_index_5_by_6( int index, row_major ) {
// read row-by-row, aka row_major
int mapping[] = { 0, 0, 11, 12, 0, 21, 22, 23, 31, 32, 33, 34, 42, 43, 44, 45, 53, 54, 55, 56};
return mapping[ index ];
diff --git a/libs/numeric/ublas/test/test_complex_norms.cpp b/libs/numeric/ublas/test/test_complex_norms.cpp
index dcd37e58d..e923d7087 100644
--- a/libs/numeric/ublas/test/test_complex_norms.cpp
+++ b/libs/numeric/ublas/test/test_complex_norms.cpp
@@ -8,7 +8,7 @@
#include <boost/numeric/ublas/matrix.hpp>
#include <complex>
-#include "libs/numeric/ublas/test/utils.hpp"
+#include "utils.hpp"
using namespace boost::numeric::ublas;
diff --git a/libs/numeric/ublas/test/test_coordinate_matrix_inplace_merge.cpp b/libs/numeric/ublas/test/test_coordinate_matrix_inplace_merge.cpp
index 9a2f8a11f..75d1f708a 100644
--- a/libs/numeric/ublas/test/test_coordinate_matrix_inplace_merge.cpp
+++ b/libs/numeric/ublas/test/test_coordinate_matrix_inplace_merge.cpp
@@ -13,26 +13,14 @@
#include <boost/numeric/ublas/matrix_sparse.hpp>
#include <boost/numeric/ublas/matrix_expression.hpp>
#include <boost/numeric/ublas/io.hpp>
-
-#include "libs/numeric/ublas/test/utils.hpp"
+#include "common/testhelper.hpp"
+#include "utils.hpp"
using std::cout;
using std::endl;
const double TOL = 1e-15;
-template <class AE>
-typename AE::value_type mean_square(const boost::numeric::ublas::matrix_expression<AE> &me) {
- typename AE::value_type s(0);
- typename AE::size_type i, j;
- for (i=0; i!= me().size1(); i++) {
- for (j=0; j!= me().size2(); j++) {
- s += boost::numeric::ublas::scalar_traits<typename AE::value_type>::type_abs(me()(i,j));
- }
- }
- return s/me().size1()*me().size2();
-}
-
template<typename T>
bool check_sortedness(const boost::numeric::ublas::coordinate_matrix<T>& matrix) {
bool result = true;
@@ -90,12 +78,12 @@ BOOST_UBLAS_TEST_DEF( test_coordinate_matrix_inplace_merge_random )
{
bool sorted = check_sortedness(matrix_coord);
- bool identical = mean_square(matrix_coord - matrix_dense) < TOL;
+ bool identical = compare_to(matrix_coord, matrix_dense, TOL);
if (!(sorted && identical)) {
print_entries(size_x, size_y, entries);
}
BOOST_UBLAS_TEST_CHECK( check_sortedness(matrix_coord) );
- BOOST_UBLAS_TEST_CHECK( mean_square(matrix_coord - matrix_dense) < TOL);
+ BOOST_UBLAS_TEST_CHECK( compare_to(matrix_coord, matrix_dense, TOL) );
}
for (size_t entry = 0; entry < nr_entries; ++ entry) {
@@ -109,7 +97,7 @@ BOOST_UBLAS_TEST_DEF( test_coordinate_matrix_inplace_merge_random )
{
bool sorted = check_sortedness(matrix_coord);
- bool identical = mean_square(matrix_coord - matrix_dense) < TOL;
+ bool identical = compare_to(matrix_coord, matrix_dense, TOL);
if (!(sorted && identical)) {
print_entries(size_x, size_y, entries);
}
diff --git a/libs/numeric/ublas/test/test_coordinate_matrix_sort.cpp b/libs/numeric/ublas/test/test_coordinate_matrix_sort.cpp
index bf927fc51..d07abb3b1 100644
--- a/libs/numeric/ublas/test/test_coordinate_matrix_sort.cpp
+++ b/libs/numeric/ublas/test/test_coordinate_matrix_sort.cpp
@@ -11,7 +11,7 @@
#include<boost/numeric/ublas/matrix_sparse.hpp>
#include<boost/numeric/ublas/io.hpp>
-#include "libs/numeric/ublas/test/utils.hpp"
+#include "utils.hpp"
using std::cout;
using std::endl;
diff --git a/libs/numeric/ublas/test/test_coordinate_vector_inplace_merge.cpp b/libs/numeric/ublas/test/test_coordinate_vector_inplace_merge.cpp
index ae0190311..9994e86ef 100644
--- a/libs/numeric/ublas/test/test_coordinate_vector_inplace_merge.cpp
+++ b/libs/numeric/ublas/test/test_coordinate_vector_inplace_merge.cpp
@@ -13,22 +13,11 @@
#include <boost/numeric/ublas/vector_sparse.hpp>
#include <boost/numeric/ublas/vector_expression.hpp>
#include <boost/numeric/ublas/io.hpp>
-
-#include "libs/numeric/ublas/test/utils.hpp"
+#include "common/testhelper.hpp"
+#include "utils.hpp"
const double TOL = 1e-15;
-
-template <class AE>
-typename AE::value_type mean_square(const boost::numeric::ublas::vector_expression<AE> &me) {
- typename AE::value_type s(0);
- typename AE::size_type i;
- for (i=0; i!= me().size(); i++) {
- s += boost::numeric::ublas::scalar_traits<typename AE::value_type>::type_abs(me()(i));
- }
- return s/me().size();
-}
-
template<typename T>
bool check_sortedness(const boost::numeric::ublas::coordinate_vector<T>& vector) {
bool result = true;
@@ -79,12 +68,12 @@ BOOST_UBLAS_TEST_DEF( test_coordinate_vector_inplace_merge_random )
{
bool sorted = check_sortedness(vector_coord);
- bool identical = mean_square(vector_coord - vector_dense) < TOL;
+ bool identical = compare_to(vector_coord, vector_dense, TOL);
if (!(sorted && identical)) {
print_entries(size_vec, entries);
}
BOOST_UBLAS_TEST_CHECK( check_sortedness(vector_coord) );
- BOOST_UBLAS_TEST_CHECK( mean_square(vector_coord - vector_dense) < TOL);
+ BOOST_UBLAS_TEST_CHECK( compare_to(vector_coord, vector_dense, TOL) );
}
for (size_t entry = 0; entry < nr_entries; ++ entry) {
@@ -97,7 +86,7 @@ BOOST_UBLAS_TEST_DEF( test_coordinate_vector_inplace_merge_random )
{
bool sorted = check_sortedness(vector_coord);
- bool identical = mean_square(vector_coord - vector_dense) < TOL;
+ bool identical = compare_to(vector_coord, vector_dense, TOL);
if (!(sorted && identical)) {
print_entries(size_vec, entries);
}
diff --git a/libs/numeric/ublas/test/test_fixed_containers.cpp b/libs/numeric/ublas/test/test_fixed_containers.cpp
index bb5cba897..23a63827e 100644
--- a/libs/numeric/ublas/test/test_fixed_containers.cpp
+++ b/libs/numeric/ublas/test/test_fixed_containers.cpp
@@ -108,8 +108,8 @@ bool test_vector( std::string type_name)
for ( std::size_t i = 0; i!= v1.size(); i++)
{
- v1( i ) = 3.14159*i*i;
- v ( i ) = 3.14159*i*i;
+ v1( i ) = 3.14159*i;
+ v ( i ) = 3.14159*i;
}
pass &= compare( v1, v );
@@ -140,7 +140,7 @@ bool test_vector( std::string type_name)
try {
T a;
a=v1( 100 );
- (void) a ;
+ BOOST_UBLAS_NOT_USED( a );
} catch ( bad_index &e) {
std::cout << " Caught (GOOD): " << e.what() << endl;
@@ -250,7 +250,7 @@ bool test_matrix( std::string type_name)
try {
T a;
a=m1( 100, 100 );
- (void) a ;
+ BOOST_UBLAS_NOT_USED( a );
} catch ( bad_index &e) {
std::cout << " Caught (GOOD): " << e.what() << endl;
diff --git a/libs/numeric/ublas/test/test_matrix_vector.cpp b/libs/numeric/ublas/test/test_matrix_vector.cpp
index 8b9a11775..a7e8796cd 100644
--- a/libs/numeric/ublas/test/test_matrix_vector.cpp
+++ b/libs/numeric/ublas/test/test_matrix_vector.cpp
@@ -10,37 +10,11 @@
#include <boost/numeric/ublas/matrix_sparse.hpp>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/matrix_vector.hpp>
-
+#include "common/testhelper.hpp"
#include "utils.hpp"
using namespace boost::numeric::ublas;
-namespace tans {
-template <class AE>
-typename AE::value_type mean_square(const matrix_expression<AE> &me) {
- typename AE::value_type s(0);
- typename AE::size_type i, j;
- for (i=0; i!= me().size1(); i++) {
- for (j=0; j!= me().size2(); j++) {
- s+= scalar_traits<typename AE::value_type>::type_abs(me()(i,j));
- }
- }
- return s/me().size1()*me().size2();
-}
-
-template <class AE>
-typename AE::value_type mean_square(const vector_expression<AE> &ve) {
- // We could have use norm2 here, but ublas' ABS does not support unsigned types.
- typename AE::value_type s(0);
- typename AE::size_type i;
- for (i=0; i!= ve().size(); i++) {
- s+=scalar_traits<typename AE::value_type>::type_abs(ve()(i));
- }
- return s/ve().size();
-}
-const double TOL=0.0;
-
-}
template <class Vector, class StorageCategory>
void guardSparsePreserveResize( Vector &vec, typename Vector::size_type new_size, StorageCategory) // Because sparse matrices don't have preserve data implemented
@@ -58,7 +32,6 @@ void guardSparsePreserveResize( Vector &vec, typename Vector::size_type new_size
template <class Matrix>
bool test_matrix_row_facade() {
bool pass = true;
- using namespace tans;
typedef matrix_row_vector<Matrix> RowVector;
@@ -97,7 +70,7 @@ bool test_matrix_row_facade() {
rows(i) = matrix_row<Matrix>(RA, i);
}
- pass &= (mean_square(A-RA)<=TOL);
+ pass &= compare_to(A, RA);
}
{ // Testing operator[]
@@ -114,7 +87,7 @@ bool test_matrix_row_facade() {
rows[i] = matrix_row<Matrix>(RA, i);
}
- pass &= (mean_square(A-RA)<=TOL);
+ pass &= compare_to(A, RA);
}
{ // Testing operator[] const
@@ -128,7 +101,7 @@ bool test_matrix_row_facade() {
7, 8, 9;
for(typename Matrix::size_type i = 0; i < RA.size1(); i++) {
- pass &= (mean_square(rows[i]-matrix_row<Matrix>(RA, i))<=TOL);
+ pass &= compare_to(rows[i], matrix_row<Matrix>(RA, i));
}
}
@@ -146,7 +119,7 @@ bool test_matrix_row_facade() {
for(typename RowVector::const_iterator iter = rows.begin();
iter != rows.end();
iter++) {
- pass &= (mean_square(*iter-matrix_row<Matrix>(RA, i++))<=TOL);
+ pass &= compare_to(*iter, matrix_row<Matrix>(RA, i++));
}
}
@@ -167,7 +140,7 @@ bool test_matrix_row_facade() {
*iter = matrix_row<Matrix>(RA, i++);
}
- pass &= (mean_square(A-RA)<=TOL);
+ pass &= compare_to(A, RA);
}
{ // Testing reserse iterator
@@ -187,7 +160,7 @@ bool test_matrix_row_facade() {
*iter = matrix_row<Matrix>(RA, --i);
}
- pass &= (mean_square(A-RA)<=TOL);
+ pass &= compare_to(A, RA);
}
{ // Testing const reverse iterator
@@ -204,7 +177,7 @@ bool test_matrix_row_facade() {
for(typename RowVector::const_reverse_iterator iter = rows.rbegin();
iter != rows.rend();
iter++) {
- pass &= (mean_square(*iter-matrix_row<Matrix>(RA, --i))<=TOL);
+ pass &= compare_to(*iter, matrix_row<Matrix>(RA, --i));
}
}
@@ -215,7 +188,6 @@ bool test_matrix_row_facade() {
template <class Matrix>
bool test_matrix_column_facade() {
bool pass = true;
- using namespace tans;
typedef matrix_column_vector<Matrix> ColumnVector;
@@ -252,7 +224,7 @@ bool test_matrix_column_facade() {
columns(i) = matrix_column<Matrix>(RA, i);
}
- pass &= (mean_square(A-RA)<=TOL);
+ pass &= compare_to(A, RA);
}
{ // Testing operator[]
@@ -269,7 +241,7 @@ bool test_matrix_column_facade() {
columns[i] = matrix_column<Matrix>(RA, i);
}
- pass &= (mean_square(A-RA)<=TOL);
+ pass &= compare_to(A, RA);
}
{ // Testing operator[] const
@@ -283,7 +255,7 @@ bool test_matrix_column_facade() {
7, 8, 9;
for(typename Matrix::size_type i = 0; i < RA.size2(); i++) {
- pass &= (mean_square(columns[i]-matrix_column<Matrix>(RA, i))<=TOL);
+ pass &= compare_to(columns[i], matrix_column<Matrix>(RA, i));
}
}
@@ -304,7 +276,7 @@ bool test_matrix_column_facade() {
*iter = matrix_column<Matrix>(RA, i++);
}
- pass &= (mean_square(A-RA)<=TOL);
+ pass &= compare_to(A, RA);
}
{ // Testing const iterator
@@ -321,7 +293,7 @@ bool test_matrix_column_facade() {
for(typename ColumnVector::const_iterator iter = columns.begin();
iter != columns.end();
iter++) {
- pass &= (mean_square(*iter-matrix_column<Matrix>(RA, i++))<=TOL);
+ pass &= compare_to(*iter, matrix_column<Matrix>(RA, i++));
}
}
@@ -342,7 +314,7 @@ bool test_matrix_column_facade() {
*iter = matrix_column<Matrix>(RA, --i);
}
- pass &= (mean_square(A-RA)<=TOL);
+ pass &= compare_to(A, RA);
}
{ // Testing const reverse iterator
@@ -359,7 +331,7 @@ bool test_matrix_column_facade() {
for(typename ColumnVector::const_reverse_iterator iter = columns.rbegin();
iter != columns.rend();
iter++) {
- pass &= (mean_square(*iter-matrix_column<Matrix>(RA, --i))<=TOL);
+ pass &= compare_to(*iter, matrix_column<Matrix>(RA, --i));
}
}
diff --git a/libs/numeric/ublas/test/test_ticket7296.cpp b/libs/numeric/ublas/test/test_ticket7296.cpp
index 05c042b6b..65fdb4ba6 100644
--- a/libs/numeric/ublas/test/test_ticket7296.cpp
+++ b/libs/numeric/ublas/test/test_ticket7296.cpp
@@ -17,7 +17,7 @@
#include <boost/numeric/ublas/vector.hpp>
#include <complex>
#include <cstddef>
-#include <libs/numeric/ublas/test/utils.hpp>
+#include "utils.hpp"
namespace ublas = boost::numeric::ublas;
diff --git a/libs/numeric/ublas/test/test_triangular.cpp b/libs/numeric/ublas/test/test_triangular.cpp
index 9a9bf48a1..c6cba9134 100644
--- a/libs/numeric/ublas/test/test_triangular.cpp
+++ b/libs/numeric/ublas/test/test_triangular.cpp
@@ -1,4 +1,6 @@
#include <iostream>
+#include <stdlib.h>
+#include <cmath>
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/matrix.hpp>
@@ -17,7 +19,7 @@ double diff(const mat& A, const vec& x, const vec& b) {
for (typename vec::size_type i=0; i<temp.size(); ++i) {
result += temp(i)*temp(i);
}
- return sqrt(result);
+ return std::sqrt(result);
}
template<class mat, class vec>
@@ -45,10 +47,10 @@ int main() {
std::cerr << "Constructing..." << std::endl;
for (int i=0; i<n; ++i) {
- b(i) = rand() % 10;
- double main = -10 + rand() % 20 ;
+ b(i) = std::rand() % 10;
+ double main = -10 + std::rand() % 20 ;
if (main == 0) main+=1;
- double side = -10 + rand() % 20 ;
+ double side = -10 + std::rand() % 20 ;
if (i-1>=0) {
mat_row_low(i, i-1) = side;
}
diff --git a/libs/numeric/ublas/test/triangular_access.cpp b/libs/numeric/ublas/test/triangular_access.cpp
index 9777632be..c2c9b7733 100644
--- a/libs/numeric/ublas/test/triangular_access.cpp
+++ b/libs/numeric/ublas/test/triangular_access.cpp
@@ -117,7 +117,7 @@ test_iterator3( const MAT & A ) {
}
-int main (int argc, char * argv[]) {
+int main () {
using namespace boost::numeric::ublas;
typedef double VALUE_TYPE;
diff --git a/libs/numeric/ublas/test/triangular_layout.cpp b/libs/numeric/ublas/test/triangular_layout.cpp
index 8bd27faa2..815643d37 100644
--- a/libs/numeric/ublas/test/triangular_layout.cpp
+++ b/libs/numeric/ublas/test/triangular_layout.cpp
@@ -12,7 +12,7 @@
using namespace std;
namespace ublas = boost::numeric::ublas;
-int main(int argc, char* argv[])
+int main()
{
int sz = 4;
ublas::symmetric_matrix<int, ublas::upper, ublas::column_major> UpCol (sz, sz);
diff --git a/libs/numeric/ublas/test/utils.hpp b/libs/numeric/ublas/test/utils.hpp
index 6eb52b029..c1b69b92a 100644
--- a/libs/numeric/ublas/test/utils.hpp
+++ b/libs/numeric/ublas/test/utils.hpp
@@ -64,6 +64,8 @@
#include <limits>
#include <stdexcept>
+#define BOOST_UBLAS_NOT_USED(x) (void)(x)
+
namespace boost { namespace numeric { namespace ublas { namespace test { namespace detail { namespace /*<unnamed>*/ {
using ::std::abs;