From 400e00e4e5aa0cfbaae97b0f970c8405315823d7 Mon Sep 17 00:00:00 2001 From: Michael Stevens Date: Sun, 1 Aug 2004 09:30:45 +0000 Subject: [PATCH] BOOST_UBLAS_SIMPLE_ET_DEBUG svn path=/trunk/boost/boost/numeric/ublas/; revision=24220 --- include/boost/numeric/ublas/blas.hpp | 10 ++-- include/boost/numeric/ublas/config.hpp | 57 ++++++++----------- .../boost/numeric/ublas/matrix_expression.hpp | 20 +++---- include/boost/numeric/ublas/symmetric.hpp | 5 -- .../boost/numeric/ublas/vector_expression.hpp | 12 ++-- 5 files changed, 46 insertions(+), 58 deletions(-) diff --git a/include/boost/numeric/ublas/blas.hpp b/include/boost/numeric/ublas/blas.hpp index 57ecb60b..0f651453 100644 --- a/include/boost/numeric/ublas/blas.hpp +++ b/include/boost/numeric/ublas/blas.hpp @@ -149,7 +149,7 @@ namespace boost { namespace numeric { namespace ublas { template M & gr (M &m, const T &t, const V1 &v1, const V2 &v2) { -#ifdef BOOST_UBLAS_USE_ET +#ifndef BOOST_UBLAS_SIMPLE_ET_DEBUG return m += t * outer_prod (v1, v2); #else return m = m + t * outer_prod (v1, v2); @@ -162,7 +162,7 @@ namespace boost { namespace numeric { namespace ublas { template M & sr (M &m, const T &t, const V &v) { -#ifdef BOOST_UBLAS_USE_ET +#ifndef BOOST_UBLAS_SIMPLE_ET_DEBUG return m += t * outer_prod (v, v); #else return m = m + t * outer_prod (v, v); @@ -174,7 +174,7 @@ namespace boost { namespace numeric { namespace ublas { template M & hr (M &m, const T &t, const V &v) { -#ifdef BOOST_UBLAS_USE_ET +#ifndef BOOST_UBLAS_SIMPLE_ET_DEBUG return m += t * outer_prod (v, conj (v)); #else return m = m + t * outer_prod (v, conj (v)); @@ -188,7 +188,7 @@ namespace boost { namespace numeric { namespace ublas { template M & sr2 (M &m, const T &t, const V1 &v1, const V2 &v2) { -#ifdef BOOST_UBLAS_USE_ET +#ifndef BOOST_UBLAS_SIMPLE_ET_DEBUG return m += t * (outer_prod (v1, v2) + outer_prod (v2, v1)); #else return m = m + t * (outer_prod (v1, v2) + outer_prod (v2, v1)); @@ -202,7 +202,7 @@ namespace boost { namespace numeric { namespace ublas { template M & hr2 (M &m, const T &t, const V1 &v1, const V2 &v2) { -#ifdef BOOST_UBLAS_USE_ET +#ifndef BOOST_UBLAS_SIMPLE_ET_DEBUG return m += t * outer_prod (v1, conj (v2)) + type_traits::conj (t) * outer_prod (v2, conj (v1)); #else return m = m + t * outer_prod (v1, conj (v2)) + type_traits::conj (t) * outer_prod (v2, conj (v1)); diff --git a/include/boost/numeric/ublas/config.hpp b/include/boost/numeric/ublas/config.hpp index 6f27202c..439f95e8 100644 --- a/include/boost/numeric/ublas/config.hpp +++ b/include/boost/numeric/ublas/config.hpp @@ -68,6 +68,14 @@ // MSVC doesn't support long double #define BOOST_UBLAS_NO_LONG_DOUBLE +#ifdef NDEBUG +// MSVC has special inlining options +#pragma inline_recursion (on) +#pragma inline_depth (255) +#pragma auto_inline (on) +// #define BOOST_UBLAS_INLINE __forceinline +#define BOOST_UBLAS_INLINE __inline +#endif // With MSVC we could perform IO via basic_stream // #define BOOST_UBLAS_USE_BASIC_STREAM @@ -238,68 +246,53 @@ namespace std { -// Enable performance options in release mode +// Enable performance options in RELEASE mode #ifdef NDEBUG -#ifdef BOOST_MSVC -// MSVC has special inlining options -#pragma inline_recursion (on) -#pragma inline_depth (255) -#pragma auto_inline (on) -// #define BOOST_UBLAS_INLINE __forceinline -#define BOOST_UBLAS_INLINE __inline -#else +#ifndef BOOST_UBLAS_INLINE #define BOOST_UBLAS_INLINE inline #endif // Do not check sizes! #define BOOST_UBLAS_USE_FAST_SAME -// Use expression templates. -#ifndef BOOST_UBLAS_USE_ET -#define BOOST_UBLAS_USE_ET -#endif // BOOST_UBLAS_USE_ET - // NO runtime error checks with BOOST_UBLAS_CHECK macro #ifndef BOOST_UBLAS_CHECK_ENABLE #define BOOST_UBLAS_CHECK_ENABLE 0 #endif -// NO numeric checks for non dense matrices -#ifndef BOOST_UBLAS_TYPE_CHECK +// NO type compatibility numeric checks +#ifndef BOOST_UBLAS_TYPE_CHECK #define BOOST_UBLAS_TYPE_CHECK 0 #endif -// Disable performance options in debug mode + +// Disable performance options in DEBUG mode #else -#ifdef BOOST_MSVC -// MSVC has special inlining options -// #pragma inline_recursion (off) -// #pragma inline_depth () -// #pragma auto_inline (off) -#endif -#define BOOST_UBLAS_INLINE +// In order to simplify debugging is is possible to simplify expression template +// so they are restricted to a single operation +// #define BOOST_UBLAS_SIMPLE_ET_DEBUG -#ifdef BOOST_MSVC -// Use expression templates (otherwise we get many ICE's) -#ifndef BOOST_UBLAS_USE_ET -#define BOOST_UBLAS_USE_ET -#endif // BOOST_UBLAS_USE_ET -#endif // BOOST_MSVC +#ifndef BOOST_UBLAS_INLINE +#define BOOST_UBLAS_INLINE +#endif // Enable runtime error checks with BOOST_UBLAS_CHECK macro. Check bounds etc #ifndef BOOST_UBLAS_CHECK_ENABLE #define BOOST_UBLAS_CHECK_ENABLE 1 #endif -// Type compatible numeric checks for non dense matrices (requires additional storage and complexity) -#ifndef BOOST_UBLAS_TYPE_CHECK +// Type compatibiltity numeric checks +#ifndef BOOST_UBLAS_TYPE_CHECK #define BOOST_UBLAS_TYPE_CHECK 1 #endif #endif + +// Control type compatibility numeric runtime checks for non dense matrices. +// Require additional storage and complexity #if BOOST_UBLAS_TYPE_CHECK template struct disable_type_check diff --git a/include/boost/numeric/ublas/matrix_expression.hpp b/include/boost/numeric/ublas/matrix_expression.hpp index b958dcc2..c6ace866 100644 --- a/include/boost/numeric/ublas/matrix_expression.hpp +++ b/include/boost/numeric/ublas/matrix_expression.hpp @@ -1137,7 +1137,7 @@ namespace boost { namespace numeric { namespace ublas { template struct vector_matrix_binary_traits { typedef vector_matrix_binary expression_type; -#ifdef BOOST_UBLAS_USE_ET +#ifndef BOOST_UBLAS_SIMPLE_ET_DEBUG typedef expression_type result_type; #else typedef matrix result_type; @@ -1562,7 +1562,7 @@ namespace boost { namespace numeric { namespace ublas { template struct matrix_unary1_traits { typedef matrix_unary1 expression_type; -#ifdef BOOST_UBLAS_USE_ET +#ifndef BOOST_UBLAS_SIMPLE_ET_DEBUG typedef expression_type result_type; #else typedef matrix result_type; @@ -2036,7 +2036,7 @@ namespace boost { namespace numeric { namespace ublas { struct matrix_unary2_traits { typedef matrix_unary2 expression_type; //FIXME -// #ifdef BOOST_UBLAS_USE_ET +// #ifndef BOOST_UBLAS_SIMPLE_ET_DEBUG typedef expression_type result_type; // #else // typedef matrix result_type; @@ -2757,7 +2757,7 @@ namespace boost { namespace numeric { namespace ublas { template struct matrix_binary_traits { typedef matrix_binary expression_type; -#ifdef BOOST_UBLAS_USE_ET +#ifndef BOOST_UBLAS_SIMPLE_ET_DEBUG typedef expression_type result_type; #else typedef matrix result_type; @@ -3244,7 +3244,7 @@ namespace boost { namespace numeric { namespace ublas { template struct matrix_binary_scalar1_traits { typedef matrix_binary_scalar1, E2, F> expression_type; -#ifdef BOOST_UBLAS_USE_ET +#ifndef BOOST_UBLAS_SIMPLE_ET_DEBUG typedef expression_type result_type; #else typedef matrix result_type; @@ -3693,7 +3693,7 @@ namespace boost { namespace numeric { namespace ublas { template struct matrix_binary_scalar2_traits { typedef matrix_binary_scalar2, F> expression_type; -#ifdef BOOST_UBLAS_USE_ET +#ifndef BOOST_UBLAS_SIMPLE_ET_DEBUG typedef expression_type result_type; #else typedef matrix result_type; @@ -4017,7 +4017,7 @@ namespace boost { namespace numeric { namespace ublas { typedef row_major_tag orientation_category; typedef typename promote_traits::promote_type promote_type; typedef matrix_vector_binary1 > expression_type; -#ifdef BOOST_UBLAS_USE_ET +#ifndef BOOST_UBLAS_SIMPLE_ET_DEBUG typedef expression_type result_type; #else typedef vector result_type; @@ -4412,7 +4412,7 @@ namespace boost { namespace numeric { namespace ublas { typedef column_major_tag orientation_category; typedef typename promote_traits::promote_type promote_type; typedef matrix_vector_binary2 > expression_type; -#ifdef BOOST_UBLAS_USE_ET +#ifndef BOOST_UBLAS_SIMPLE_ET_DEBUG typedef expression_type result_type; #else typedef vector result_type; @@ -5122,7 +5122,7 @@ namespace boost { namespace numeric { namespace ublas { typedef unknown_orientation_tag orientation_category; typedef typename promote_traits::promote_type promote_type; typedef matrix_matrix_binary > expression_type; -#ifdef BOOST_UBLAS_USE_ET +#ifndef BOOST_UBLAS_SIMPLE_ET_DEBUG typedef expression_type result_type; #else typedef matrix result_type; @@ -5254,7 +5254,7 @@ namespace boost { namespace numeric { namespace ublas { template struct matrix_scalar_unary_traits { typedef matrix_scalar_unary expression_type; -#ifdef BOOST_UBLAS_USE_ET +#ifndef BOOST_UBLAS_SIMPLE_ET_DEBUG typedef expression_type result_type; #else typedef typename F::result_type result_type; diff --git a/include/boost/numeric/ublas/symmetric.hpp b/include/boost/numeric/ublas/symmetric.hpp index 47cdd753..136402ac 100644 --- a/include/boost/numeric/ublas/symmetric.hpp +++ b/include/boost/numeric/ublas/symmetric.hpp @@ -263,11 +263,6 @@ namespace boost { namespace numeric { namespace ublas { void insert (size_type i, size_type j, const_reference t) { BOOST_UBLAS_CHECK (i < size_, bad_index ()); BOOST_UBLAS_CHECK (j < size_, bad_index ()); -// FIXME: is this ugly check still needed?! -// #ifndef BOOST_UBLAS_USE_ET -// if (t == value_type ()) -// return; -// #endif if (functor1_type::other (i, j)) { size_type k = functor1_type::element (functor2_type (), i, size_, j, size_); BOOST_UBLAS_CHECK (type_traits::equals (data () [k], value_type ()) || diff --git a/include/boost/numeric/ublas/vector_expression.hpp b/include/boost/numeric/ublas/vector_expression.hpp index 5198112a..311f0552 100644 --- a/include/boost/numeric/ublas/vector_expression.hpp +++ b/include/boost/numeric/ublas/vector_expression.hpp @@ -758,7 +758,7 @@ namespace boost { namespace numeric { namespace ublas { struct vector_unary_traits { typedef vector_unary expression_type; //FIXME -// #ifdef BOOST_UBLAS_USE_ET +// #ifndef BOOST_UBLAS_SIMPLE_ET_DEBUG typedef expression_type result_type; // #else // typedef vector result_type; @@ -1160,7 +1160,7 @@ namespace boost { namespace numeric { namespace ublas { template struct vector_binary_traits { typedef vector_binary expression_type; -#ifdef BOOST_UBLAS_USE_ET +#ifndef BOOST_UBLAS_SIMPLE_ET_DEBUG typedef expression_type result_type; #else typedef vector result_type; @@ -1439,7 +1439,7 @@ namespace boost { namespace numeric { namespace ublas { template struct vector_binary_scalar1_traits { typedef vector_binary_scalar1, E2, F> expression_type; -#ifdef BOOST_UBLAS_USE_ET +#ifndef BOOST_UBLAS_SIMPLE_ET_DEBUG typedef expression_type result_type; #else typedef vector result_type; @@ -1680,7 +1680,7 @@ namespace boost { namespace numeric { namespace ublas { template struct vector_binary_scalar2_traits { typedef vector_binary_scalar2, F> expression_type; -#ifdef BOOST_UBLAS_USE_ET +#ifndef BOOST_UBLAS_SIMPLE_ET_DEBUG typedef expression_type result_type; #else typedef vector result_type; @@ -1775,7 +1775,7 @@ namespace boost { namespace numeric { namespace ublas { template struct vector_scalar_unary_traits { typedef vector_scalar_unary expression_type; -#if defined (BOOST_UBLAS_USE_ET) && defined (BOOST_UBLAS_USE_SCALAR_ET) +#ifndef BOOST_UBLAS_SIMPLE_ET_DEBUG typedef expression_type result_type; #else typedef typename F::result_type result_type; @@ -1907,7 +1907,7 @@ namespace boost { namespace numeric { namespace ublas { template struct vector_scalar_binary_traits { typedef vector_scalar_binary expression_type; -#if defined (BOOST_UBLAS_USE_ET) && defined (BOOST_UBLAS_USE_SCALAR_ET) +#ifndef BOOST_UBLAS_SIMPLE_ET_DEBUG typedef expression_type result_type; #else typedef typename F::result_type result_type;