From: bangerth Date: Mon, 18 Jun 2012 10:34:23 +0000 (+0000) Subject: Add. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c4da976529d0763d56fb1a9b793ba1c595227283;p=dealii-svn.git Add. git-svn-id: https://svn.dealii.org/trunk@25635 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/bounds.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/bounds.hpp new file mode 100644 index 0000000000..e4c7c7deee --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/bounds.hpp @@ -0,0 +1,24 @@ +// (c) Copyright Fernando Luis Cacciola Carballal 2000-2004 +// Use, modification, and distribution is subject to 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) + +// See library home page at http://www.boost.org/libs/numeric/conversion +// +// Contact the author at: fernando_cacciola@hotmail.com +// +#ifndef BOOST_NUMERIC_CONVERSION_BOUNDS_12NOV2002_HPP +#define BOOST_NUMERIC_CONVERSION_BOUNDS_12NOV2002_HPP + +#include "boost/numeric/conversion/detail/bounds.hpp" + +namespace boost { namespace numeric +{ + +template +struct bounds : boundsdetail::get_impl::type +{} ; + +} } // namespace boost::numeric + +#endif diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/cast.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/cast.hpp new file mode 100644 index 0000000000..1ee02518bc --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/cast.hpp @@ -0,0 +1,61 @@ +// (c) Copyright Fernando Luis Cacciola Carballal 2000-2004 +// Use, modification, and distribution is subject to 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) + +// See library home page at http://www.boost.org/libs/numeric/conversion +// +// Contact the author at: fernando_cacciola@hotmail.com +// +// +// Revision History +// +// 19 Nov 2001 Syntatic changes as suggested by Darin Adler (Fernando Cacciola) +// 08 Nov 2001 Fixes to accommodate MSVC (Fernando Cacciola) +// 04 Nov 2001 Fixes to accommodate gcc2.92 (Fernando Cacciola) +// 30 Oct 2001 Some fixes suggested by Daryle Walker (Fernando Cacciola) +// 25 Oct 2001 Initial boostification (Fernando Cacciola) +// 23 Jan 2004 Inital add to cvs (post review)s +// 22 Jun 2011 Added support for specializing cast policies via numeric_cast_traits (Brandon Kohn). +// +#ifndef BOOST_NUMERIC_CONVERSION_CAST_25OCT2001_HPP +#define BOOST_NUMERIC_CONVERSION_CAST_25OCT2001_HPP + +#include + +#if BOOST_WORKAROUND(BOOST_MSVC, < 1300) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582)) + +# include + +#else + +#include +#include +#include + +namespace boost +{ + template + inline Target numeric_cast( Source arg ) + { + typedef numeric::conversion_traits conv_traits; + typedef numeric::numeric_cast_traits cast_traits; + typedef boost::numeric::converter + < + Target, + Source, + conv_traits, + typename cast_traits::overflow_policy, + typename cast_traits::rounding_policy, + boost::numeric::raw_converter< conv_traits >, + typename cast_traits::range_checking_policy + > converter; + return converter::convert(arg); + } + + using numeric::bad_numeric_cast; +} // namespace boost + +#endif + +#endif diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/conversion_traits.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/conversion_traits.hpp new file mode 100644 index 0000000000..6da6178ad6 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/conversion_traits.hpp @@ -0,0 +1,39 @@ +// (c) Copyright Fernando Luis Cacciola Carballal 2000-2004 +// Use, modification, and distribution is subject to 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) + +// See library home page at http://www.boost.org/libs/numeric/conversion +// +// Contact the author at: fernando_cacciola@hotmail.com +// +#ifndef BOOST_NUMERIC_CONVERSION_CONVERSION_TRAITS_FLC_12NOV2002_HPP +#define BOOST_NUMERIC_CONVERSION_CONVERSION_TRAITS_FLC_12NOV2002_HPP + +#include "boost/numeric/conversion/detail/conversion_traits.hpp" +#include "boost/detail/workaround.hpp" +#include "boost/config.hpp" + +namespace boost { namespace numeric +{ + +template +struct conversion_traits + : convdetail::get_conversion_traits::type +{ +#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) + typedef typename convdetail::get_conversion_traits::type base_; + typedef typename base_::target_type target_type; + typedef typename base_::source_type source_type; + typedef typename base_::result_type result_type; + typedef typename base_::argument_type argument_type; +#endif +} ; + +} } // namespace boost::numeric + +#endif +// +/////////////////////////////////////////////////////////////////////////////////////////////// + + diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/converter.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/converter.hpp new file mode 100644 index 0000000000..331caddea5 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/converter.hpp @@ -0,0 +1,68 @@ +// (c) Copyright Fernando Luis Cacciola Carballal 2000-2004 +// Use, modification, and distribution is subject to 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) + +// See library home page at http://www.boost.org/libs/numeric/conversion +// +// Contact the author at: fernando_cacciola@hotmail.com +// +#ifndef BOOST_NUMERIC_CONVERSION_CONVERTER_FLC_12NOV2002_HPP +#define BOOST_NUMERIC_CONVERSION_CONVERTER_FLC_12NOV2002_HPP + +#include "boost/numeric/conversion/conversion_traits.hpp" +#include "boost/numeric/conversion/converter_policies.hpp" + +#include "boost/numeric/conversion/detail/converter.hpp" + +namespace boost { namespace numeric +{ + +template, + class OverflowHandler = def_overflow_handler, + class Float2IntRounder = Trunc< BOOST_DEDUCED_TYPENAME Traits::source_type> , + class RawConverter = raw_converter, + class UserRangeChecker = UseInternalRangeChecker + > +struct converter : convdetail::get_converter_impl::type +{ + typedef Traits traits ; + + typedef typename Traits::argument_type argument_type ; + typedef typename Traits::result_type result_type ; + + result_type operator() ( argument_type s ) const { return this->convert(s) ; } +} ; + + + +template , + class UserRangeChecker = UseInternalRangeChecker + > +struct make_converter_from +{ + template, + class RawConverter = raw_converter + > + struct to + { + typedef converter type ; + } ; + +} ; + +} } // namespace boost::numeric + +#endif + + diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/converter_policies.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/converter_policies.hpp new file mode 100644 index 0000000000..b0d741b8e3 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/converter_policies.hpp @@ -0,0 +1,186 @@ +// (c) Copyright Fernando Luis Cacciola Carballal 2000-2004 +// Use, modification, and distribution is subject to 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) + +// See library home page at http://www.boost.org/libs/numeric/conversion +// +// Contact the author at: fernando_cacciola@hotmail.com +// +#ifndef BOOST_NUMERIC_CONVERSION_CONVERTER_POLICIES_FLC_12NOV2002_HPP +#define BOOST_NUMERIC_CONVERSION_CONVERTER_POLICIES_FLC_12NOV2002_HPP + +#include // for std::bad_cast + +#include // for std::floor and std::ceil + +#include + +#include "boost/type_traits/is_arithmetic.hpp" + +#include "boost/mpl/if.hpp" +#include "boost/mpl/integral_c.hpp" + +namespace boost { namespace numeric +{ + +template +struct Trunc +{ + typedef S source_type ; + + typedef typename mpl::if_< is_arithmetic,S,S const&>::type argument_type ; + + static source_type nearbyint ( argument_type s ) + { +#if !defined(BOOST_NO_STDC_NAMESPACE) + using std::floor ; + using std::ceil ; +#endif + + return s < static_cast(0) ? ceil(s) : floor(s) ; + } + + typedef mpl::integral_c< std::float_round_style, std::round_toward_zero> round_style ; +} ; + + + +template +struct Floor +{ + typedef S source_type ; + + typedef typename mpl::if_< is_arithmetic,S,S const&>::type argument_type ; + + static source_type nearbyint ( argument_type s ) + { +#if !defined(BOOST_NO_STDC_NAMESPACE) + using std::floor ; +#endif + + return floor(s) ; + } + + typedef mpl::integral_c< std::float_round_style, std::round_toward_neg_infinity> round_style ; +} ; + +template +struct Ceil +{ + typedef S source_type ; + + typedef typename mpl::if_< is_arithmetic,S,S const&>::type argument_type ; + + static source_type nearbyint ( argument_type s ) + { +#if !defined(BOOST_NO_STDC_NAMESPACE) + using std::ceil ; +#endif + + return ceil(s) ; + } + + typedef mpl::integral_c< std::float_round_style, std::round_toward_infinity> round_style ; +} ; + +template +struct RoundEven +{ + typedef S source_type ; + + typedef typename mpl::if_< is_arithmetic,S,S const&>::type argument_type ; + + static source_type nearbyint ( argument_type s ) + { + // Algorithm contributed by Guillaume Melquiond + +#if !defined(BOOST_NO_STDC_NAMESPACE) + using std::floor ; + using std::ceil ; +#endif + + // only works inside the range not at the boundaries + S prev = floor(s); + S next = ceil(s); + + S rt = (s - prev) - (next - s); // remainder type + + S const zero(0.0); + S const two(2.0); + + if ( rt < zero ) + return prev; + else if ( rt > zero ) + return next; + else + { + bool is_prev_even = two * floor(prev / two) == prev ; + return ( is_prev_even ? prev : next ) ; + } + } + + typedef mpl::integral_c< std::float_round_style, std::round_to_nearest> round_style ; +} ; + + +enum range_check_result +{ + cInRange = 0 , + cNegOverflow = 1 , + cPosOverflow = 2 +} ; + +class bad_numeric_cast : public std::bad_cast +{ + public: + + virtual const char * what() const throw() + { return "bad numeric conversion: overflow"; } +}; + +class negative_overflow : public bad_numeric_cast +{ + public: + + virtual const char * what() const throw() + { return "bad numeric conversion: negative overflow"; } +}; +class positive_overflow : public bad_numeric_cast +{ + public: + + virtual const char * what() const throw() + { return "bad numeric conversion: positive overflow"; } +}; + +struct def_overflow_handler +{ + void operator() ( range_check_result r ) // throw(negative_overflow,positive_overflow) + { + if ( r == cNegOverflow ) + throw negative_overflow() ; + else if ( r == cPosOverflow ) + throw positive_overflow() ; + } +} ; + +struct silent_overflow_handler +{ + void operator() ( range_check_result ) {} // throw() +} ; + +template +struct raw_converter +{ + typedef typename Traits::result_type result_type ; + typedef typename Traits::argument_type argument_type ; + + static result_type low_level_convert ( argument_type s ) { return static_cast(s) ; } +} ; + +struct UseInternalRangeChecker {} ; + +} } // namespace boost::numeric + +#endif diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/detail/bounds.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/detail/bounds.hpp new file mode 100644 index 0000000000..67342b8e57 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/detail/bounds.hpp @@ -0,0 +1,58 @@ +// (c) Copyright Fernando Luis Cacciola Carballal 2000-2004 +// Use, modification, and distribution is subject to 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) + +// See library home page at http://www.boost.org/libs/numeric/conversion +// +// Contact the author at: fernando_cacciola@hotmail.com +// +#ifndef BOOST_NUMERIC_CONVERSION_BOUNDS_DETAIL_FLC_12NOV2002_HPP +#define BOOST_NUMERIC_CONVERSION_BOUNDS_DETAIL_FLC_12NOV2002_HPP + +#include "boost/limits.hpp" +#include "boost/config.hpp" +#include "boost/mpl/if.hpp" + +namespace boost { namespace numeric { namespace boundsdetail +{ + template + class Integral + { + typedef std::numeric_limits limits ; + + public : + + static N lowest () { return limits::min BOOST_PREVENT_MACRO_SUBSTITUTION (); } + static N highest () { return limits::max BOOST_PREVENT_MACRO_SUBSTITUTION (); } + static N smallest() { return static_cast(1); } + } ; + + template + class Float + { + typedef std::numeric_limits limits ; + + public : + + static N lowest () { return static_cast(-limits::max BOOST_PREVENT_MACRO_SUBSTITUTION ()) ; } + static N highest () { return limits::max BOOST_PREVENT_MACRO_SUBSTITUTION (); } + static N smallest() { return limits::min BOOST_PREVENT_MACRO_SUBSTITUTION (); } + } ; + + template + struct get_impl + { + typedef mpl::bool_< ::std::numeric_limits::is_integer > is_int ; + + typedef Integral impl_int ; + typedef Float impl_float ; + + typedef typename mpl::if_::type type ; + } ; + +} } } // namespace boost::numeric::boundsdetail. + +#endif +// +/////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/detail/conversion_traits.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/detail/conversion_traits.hpp new file mode 100644 index 0000000000..ed25349c67 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/detail/conversion_traits.hpp @@ -0,0 +1,97 @@ +// (c) Copyright Fernando Luis Cacciola Carballal 2000-2004 +// Use, modification, and distribution is subject to 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) + +// See library home page at http://www.boost.org/libs/numeric/conversion +// +// Contact the author at: fernando_cacciola@hotmail.com +// +#ifndef BOOST_NUMERIC_CONVERSION_DETAIL_CONVERSION_TRAITS_FLC_12NOV2002_HPP +#define BOOST_NUMERIC_CONVERSION_DETAIL_CONVERSION_TRAITS_FLC_12NOV2002_HPP + +#include "boost/type_traits/is_arithmetic.hpp" +#include "boost/type_traits/is_same.hpp" +#include "boost/type_traits/remove_cv.hpp" + +#include "boost/numeric/conversion/detail/meta.hpp" +#include "boost/numeric/conversion/detail/int_float_mixture.hpp" +#include "boost/numeric/conversion/detail/sign_mixture.hpp" +#include "boost/numeric/conversion/detail/udt_builtin_mixture.hpp" +#include "boost/numeric/conversion/detail/is_subranged.hpp" + +namespace boost { namespace numeric { namespace convdetail +{ + //------------------------------------------------------------------- + // Implementation of the Conversion Traits for T != S + // + // This is a VISIBLE base class of the user-level conversion_traits<> class. + //------------------------------------------------------------------- + template + struct non_trivial_traits_impl + { + typedef typename get_int_float_mixture ::type int_float_mixture ; + typedef typename get_sign_mixture ::type sign_mixture ; + typedef typename get_udt_builtin_mixture ::type udt_builtin_mixture ; + + typedef typename get_is_subranged::type subranged ; + + typedef mpl::false_ trivial ; + + typedef T target_type ; + typedef S source_type ; + typedef T result_type ; + + typedef typename mpl::if_< is_arithmetic, S, S const&>::type argument_type ; + + typedef typename mpl::if_::type supertype ; + typedef typename mpl::if_::type subtype ; + } ; + + //------------------------------------------------------------------- + // Implementation of the Conversion Traits for T == S + // + // This is a VISIBLE base class of the user-level conversion_traits<> class. + //------------------------------------------------------------------- + template + struct trivial_traits_impl + { + typedef typename get_int_float_mixture ::type int_float_mixture ; + typedef typename get_sign_mixture ::type sign_mixture ; + typedef typename get_udt_builtin_mixture::type udt_builtin_mixture ; + + typedef mpl::false_ subranged ; + typedef mpl::true_ trivial ; + + typedef N target_type ; + typedef N source_type ; + typedef N const& result_type ; + typedef N const& argument_type ; + + typedef N supertype ; + typedef N subtype ; + + } ; + + //------------------------------------------------------------------- + // Top level implementation selector. + //------------------------------------------------------------------- + template + struct get_conversion_traits + { + typedef typename remove_cv::type target_type ; + typedef typename remove_cv::type source_type ; + + typedef typename is_same::type is_trivial ; + + typedef trivial_traits_impl trivial_imp ; + typedef non_trivial_traits_impl non_trivial_imp ; + + typedef typename mpl::if_::type type ; + } ; + +} } } // namespace boost::numeric::convdetail + +#endif + + diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/detail/converter.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/detail/converter.hpp new file mode 100644 index 0000000000..10550f8daa --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/detail/converter.hpp @@ -0,0 +1,602 @@ +// (c) Copyright Fernando Luis Cacciola Carballal 2000-2004 +// Use, modification, and distribution is subject to 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) + +// See library home page at http://www.boost.org/libs/numeric/conversion +// +// Contact the author at: fernando_cacciola@hotmail.com +// +#ifndef BOOST_NUMERIC_CONVERSION_DETAIL_CONVERTER_FLC_12NOV2002_HPP +#define BOOST_NUMERIC_CONVERSION_DETAIL_CONVERTER_FLC_12NOV2002_HPP + +#include + +#include "boost/numeric/conversion/detail/meta.hpp" +#include "boost/numeric/conversion/detail/conversion_traits.hpp" +#include "boost/numeric/conversion/bounds.hpp" + +#include "boost/type_traits/is_same.hpp" + +#include "boost/mpl/integral_c.hpp" + +namespace boost { namespace numeric { namespace convdetail +{ + // Integral Constants representing rounding modes + typedef mpl::integral_c round2zero_c ; + typedef mpl::integral_c round2nearest_c ; + typedef mpl::integral_c round2inf_c ; + typedef mpl::integral_c round2neg_inf_c ; + + // Metafunction: + // + // for_round_style::type + // + // {RoundStyle} Integral Constant specifying a round style as declared above. + // {RoundToZero,RoundToNearest,RoundToInf,RoundToNegInf} arbitrary types. + // + // Selects one of the 4 types according to the value of RoundStyle. + // + template + struct for_round_style + { + typedef ct_switch4 selector ; + + typedef typename selector::type type ; + } ; + + + + + + + + + + + + + + + + + + +//-------------------------------------------------------------------------- +// Range Checking Logic. +// +// The range checking logic is built up by combining 1 or 2 predicates. +// Each predicate is encapsulated in a template class and exposes +// the static member function 'apply'. +// +//-------------------------------------------------------------------------- + + + // Because a particular logic can combine either 1 or two predicates, the following + // tags are used to allow the predicate applier to receive 2 preds, but optimize away + // one of them if it is 'non-applicable' + struct non_applicable { typedef mpl::false_ do_apply ; } ; + struct applicable { typedef mpl::true_ do_apply ; } ; + + + //-------------------------------------------------------------------------- + // + // Range Checking Logic implementations. + // + // The following classes, collectivelly named 'Predicates', are instantiated within + // the corresponding range checkers. + // Their static member function 'apply' is called to perform the actual range checking logic. + //-------------------------------------------------------------------------- + + // s < Lowest(T) ? cNegOverflow : cInRange + // + template + struct LT_LoT : applicable + { + typedef typename Traits::target_type T ; + typedef typename Traits::source_type S ; + typedef typename Traits::argument_type argument_type ; + + static range_check_result apply ( argument_type s ) + { + return s < static_cast(bounds::lowest()) ? cNegOverflow : cInRange ; + } + } ; + + // s < 0 ? cNegOverflow : cInRange + // + template + struct LT_Zero : applicable + { + typedef typename Traits::source_type S ; + typedef typename Traits::argument_type argument_type ; + + static range_check_result apply ( argument_type s ) + { + return s < static_cast(0) ? cNegOverflow : cInRange ; + } + } ; + + // s <= Lowest(T)-1 ? cNegOverflow : cInRange + // + template + struct LE_PrevLoT : applicable + { + typedef typename Traits::target_type T ; + typedef typename Traits::source_type S ; + typedef typename Traits::argument_type argument_type ; + + static range_check_result apply ( argument_type s ) + { + return s <= static_cast(bounds::lowest()) - static_cast(1.0) + ? cNegOverflow : cInRange ; + } + } ; + + // s < Lowest(T)-0.5 ? cNegOverflow : cInRange + // + template + struct LT_HalfPrevLoT : applicable + { + typedef typename Traits::target_type T ; + typedef typename Traits::source_type S ; + typedef typename Traits::argument_type argument_type ; + + static range_check_result apply ( argument_type s ) + { + return s < static_cast(bounds::lowest()) - static_cast(0.5) + ? cNegOverflow : cInRange ; + } + } ; + + // s > Highest(T) ? cPosOverflow : cInRange + // + template + struct GT_HiT : applicable + { + typedef typename Traits::target_type T ; + typedef typename Traits::source_type S ; + typedef typename Traits::argument_type argument_type ; + + static range_check_result apply ( argument_type s ) + { + return s > static_cast(bounds::highest()) + ? cPosOverflow : cInRange ; + } + } ; + + // s >= Lowest(T) + 1 ? cPosOverflow : cInRange + // + template + struct GE_SuccHiT : applicable + { + typedef typename Traits::target_type T ; + typedef typename Traits::source_type S ; + typedef typename Traits::argument_type argument_type ; + + static range_check_result apply ( argument_type s ) + { + return s >= static_cast(bounds::highest()) + static_cast(1.0) + ? cPosOverflow : cInRange ; + } + } ; + + // s >= Lowest(T) + 0.5 ? cPosgOverflow : cInRange + // + template + struct GT_HalfSuccHiT : applicable + { + typedef typename Traits::target_type T ; + typedef typename Traits::source_type S ; + typedef typename Traits::argument_type argument_type ; + + static range_check_result apply ( argument_type s ) + { + return s >= static_cast(bounds::highest()) + static_cast(0.5) + ? cPosOverflow : cInRange ; + } + } ; + + + //-------------------------------------------------------------------------- + // + // Predicate Combiner. + // + // This helper classes are used to possibly combine the range checking logic + // individually performed by the predicates + // + //-------------------------------------------------------------------------- + + + // Applies both predicates: first 'PredA', and if it equals 'cInRange', 'PredB' + template + struct applyBoth + { + typedef typename PredA::argument_type argument_type ; + + static range_check_result apply ( argument_type s ) + { + range_check_result r = PredA::apply(s) ; + if ( r == cInRange ) + r = PredB::apply(s); + return r ; + } + } ; + + template + struct combine + { + typedef applyBoth Both ; + typedef void NNone ; // 'None' is defined as a macro in (/usr/X11R6/include/X11/X.h) + + typedef typename PredA::do_apply do_applyA ; + typedef typename PredB::do_apply do_applyB ; + + typedef typename for_both::type type ; + } ; + + + + + + + + + + + + +//-------------------------------------------------------------------------- +// Range Checker classes. +// +// The following classes are VISIBLE base classes of the user-level converter<> class. +// They supply the optimized 'out_of_range()' and 'validate_range()' static member functions +// visible in the user interface. +// +//-------------------------------------------------------------------------- + + // Dummy range checker. + template + struct dummy_range_checker + { + typedef typename Traits::argument_type argument_type ; + + static range_check_result out_of_range ( argument_type ) { return cInRange ; } + static void validate_range ( argument_type ) {} + } ; + + // Generic range checker. + // + // All the range checking logic for all possible combinations of source and target + // can be arranged in terms of one or two predicates, which test overflow on both neg/pos 'sides' + // of the ranges. + // + // These predicates are given here as IsNegOverflow and IsPosOverflow. + // + template + struct generic_range_checker + { + typedef OverflowHandler overflow_handler ; + + typedef typename Traits::argument_type argument_type ; + + static range_check_result out_of_range ( argument_type s ) + { + typedef typename combine::type Predicate ; + + return Predicate::apply(s); + } + + static void validate_range ( argument_type s ) + { OverflowHandler()( out_of_range(s) ) ; } + } ; + + + +//-------------------------------------------------------------------------- +// +// Selectors for the optimized Range Checker class. +// +//-------------------------------------------------------------------------- + + template + struct GetRC_Sig2Sig_or_Unsig2Unsig + { + typedef dummy_range_checker Dummy ; + + typedef LT_LoT Pred1 ; + typedef GT_HiT Pred2 ; + + typedef generic_range_checker Normal ; + + typedef typename Traits::subranged subranged ; + + typedef typename mpl::if_::type type ; + } ; + + template + struct GetRC_Sig2Unsig + { + typedef LT_Zero Pred1 ; + typedef GT_HiT Pred2 ; + + typedef generic_range_checker ChoiceA ; + + typedef generic_range_checker ChoiceB ; + + typedef typename Traits::target_type T ; + typedef typename Traits::source_type S ; + + typedef typename subranged_Unsig2Sig::type oposite_subranged ; + + typedef typename mpl::not_::type positively_subranged ; + + typedef typename mpl::if_::type type ; + } ; + + template + struct GetRC_Unsig2Sig + { + typedef GT_HiT Pred1 ; + + typedef generic_range_checker type ; + } ; + + template + struct GetRC_Int2Int + { + typedef GetRC_Sig2Sig_or_Unsig2Unsig Sig2SigQ ; + typedef GetRC_Sig2Unsig Sig2UnsigQ ; + typedef GetRC_Unsig2Sig Unsig2SigQ ; + typedef Sig2SigQ Unsig2UnsigQ ; + + typedef typename Traits::sign_mixture sign_mixture ; + + typedef typename + for_sign_mixture::type + selector ; + + typedef typename selector::type type ; + } ; + + template + struct GetRC_Int2Float + { + typedef dummy_range_checker type ; + } ; + + template + struct GetRC_Float2Int + { + typedef LE_PrevLoT Pred1 ; + typedef GE_SuccHiT Pred2 ; + typedef LT_HalfPrevLoT Pred3 ; + typedef GT_HalfSuccHiT Pred4 ; + typedef GT_HiT Pred5 ; + typedef LT_LoT Pred6 ; + + typedef generic_range_checker ToZero ; + typedef generic_range_checker ToNearest ; + typedef generic_range_checker ToInf ; + typedef generic_range_checker ToNegInf ; + + typedef typename Float2IntRounder::round_style round_style ; + + typedef typename for_round_style::type type ; + } ; + + template + struct GetRC_Float2Float + { + typedef dummy_range_checker Dummy ; + + typedef LT_LoT Pred1 ; + typedef GT_HiT Pred2 ; + + typedef generic_range_checker Normal ; + + typedef typename Traits::subranged subranged ; + + typedef typename mpl::if_::type type ; + } ; + + template + struct GetRC_BuiltIn2BuiltIn + { + typedef GetRC_Int2Int Int2IntQ ; + typedef GetRC_Int2Float Int2FloatQ ; + typedef GetRC_Float2Int Float2IntQ ; + typedef GetRC_Float2Float Float2FloatQ ; + + typedef typename Traits::int_float_mixture int_float_mixture ; + + typedef typename for_int_float_mixture::type selector ; + + typedef typename selector::type type ; + } ; + + template + struct GetRC + { + typedef GetRC_BuiltIn2BuiltIn BuiltIn2BuiltInQ ; + + typedef dummy_range_checker Dummy ; + + typedef mpl::identity DummyQ ; + + typedef typename Traits::udt_builtin_mixture udt_builtin_mixture ; + + typedef typename for_udt_builtin_mixture::type selector ; + + typedef typename selector::type type ; + } ; + + + + +//-------------------------------------------------------------------------- +// Converter classes. +// +// The following classes are VISIBLE base classes of the user-level converter<> class. +// They supply the optimized 'nearbyint()' and 'convert()' static member functions +// visible in the user interface. +// +//-------------------------------------------------------------------------- + + // + // Trivial Converter : used when (cv-unqualified) T == (cv-unqualified) S + // + template + struct trivial_converter_impl : public std::unary_function< BOOST_DEDUCED_TYPENAME Traits::argument_type + ,BOOST_DEDUCED_TYPENAME Traits::result_type + > + ,public dummy_range_checker + { + typedef Traits traits ; + + typedef typename Traits::source_type source_type ; + typedef typename Traits::argument_type argument_type ; + typedef typename Traits::result_type result_type ; + + static result_type low_level_convert ( argument_type s ) { return s ; } + static source_type nearbyint ( argument_type s ) { return s ; } + static result_type convert ( argument_type s ) { return s ; } + } ; + + + // + // Rounding Converter : used for float to integral conversions. + // + template + struct rounding_converter : public std::unary_function< BOOST_DEDUCED_TYPENAME Traits::argument_type + ,BOOST_DEDUCED_TYPENAME Traits::result_type + > + ,public RangeChecker + ,public Float2IntRounder + ,public RawConverter + { + typedef RangeChecker RangeCheckerBase ; + typedef Float2IntRounder Float2IntRounderBase ; + typedef RawConverter RawConverterBase ; + + typedef Traits traits ; + + typedef typename Traits::source_type source_type ; + typedef typename Traits::argument_type argument_type ; + typedef typename Traits::result_type result_type ; + + static result_type convert ( argument_type s ) + { + RangeCheckerBase::validate_range(s); + source_type s1 = Float2IntRounderBase::nearbyint(s); + return RawConverterBase::low_level_convert(s1); + } + } ; + + + // + // Non-Rounding Converter : used for all other conversions. + // + template + struct non_rounding_converter : public std::unary_function< BOOST_DEDUCED_TYPENAME Traits::argument_type + ,BOOST_DEDUCED_TYPENAME Traits::result_type + > + ,public RangeChecker + ,public RawConverter + { + typedef RangeChecker RangeCheckerBase ; + typedef RawConverter RawConverterBase ; + + typedef Traits traits ; + + typedef typename Traits::source_type source_type ; + typedef typename Traits::argument_type argument_type ; + typedef typename Traits::result_type result_type ; + + static source_type nearbyint ( argument_type s ) { return s ; } + + static result_type convert ( argument_type s ) + { + RangeCheckerBase::validate_range(s); + return RawConverterBase::low_level_convert(s); + } + } ; + + + + +//-------------------------------------------------------------------------- +// +// Selectors for the optimized Converter class. +// +//-------------------------------------------------------------------------- + + template + struct get_non_trivial_converter + { + typedef GetRC InternalRangeCheckerQ ; + + typedef is_same use_internal_RC ; + + typedef mpl::identity UserRangeCheckerQ ; + + typedef typename + mpl::eval_if::type + RangeChecker ; + + typedef non_rounding_converter NonRounding ; + typedef rounding_converter Rounding ; + + typedef mpl::identity NonRoundingQ ; + typedef mpl::identity RoundingQ ; + + typedef typename Traits::int_float_mixture int_float_mixture ; + + typedef typename + for_int_float_mixture::type + selector ; + + typedef typename selector::type type ; + } ; + + template< class Traits + ,class OverflowHandler + ,class Float2IntRounder + ,class RawConverter + ,class UserRangeChecker + > + struct get_converter_impl + { +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT( 0x0561 ) ) + // bcc55 prefers sometimes template parameters to be explicit local types. + // (notice that is is illegal to reuse the names like this) + typedef Traits Traits ; + typedef OverflowHandler OverflowHandler ; + typedef Float2IntRounder Float2IntRounder ; + typedef RawConverter RawConverter ; + typedef UserRangeChecker UserRangeChecker ; +#endif + + typedef trivial_converter_impl Trivial ; + typedef mpl::identity TrivialQ ; + + typedef get_non_trivial_converter< Traits + ,OverflowHandler + ,Float2IntRounder + ,RawConverter + ,UserRangeChecker + > NonTrivialQ ; + + typedef typename Traits::trivial trivial ; + + typedef typename mpl::eval_if::type type ; + } ; + +} } } // namespace boost::numeric::convdetail + +#endif + + diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/detail/int_float_mixture.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/detail/int_float_mixture.hpp new file mode 100644 index 0000000000..464e52753f --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/detail/int_float_mixture.hpp @@ -0,0 +1,72 @@ +// (c) Copyright Fernando Luis Cacciola Carballal 2000-2004 +// Use, modification, and distribution is subject to 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) + +// See library home page at http://www.boost.org/libs/numeric/conversion +// +// Contact the author at: fernando_cacciola@hotmail.com +// +#ifndef BOOST_NUMERIC_CONVERSION_DETAIL_INT_FLOAT_MIXTURE_FLC_12NOV2002_HPP +#define BOOST_NUMERIC_CONVERSION_DETAIL_INT_FLOAT_MIXTURE_FLC_12NOV2002_HPP + +#include "boost/config.hpp" +#include "boost/limits.hpp" + +#include "boost/numeric/conversion/int_float_mixture_enum.hpp" +#include "boost/numeric/conversion/detail/meta.hpp" + +#include "boost/mpl/integral_c.hpp" + +namespace boost { namespace numeric { namespace convdetail +{ + // Integral Constants for 'IntFloatMixture' + typedef mpl::integral_c int2int_c ; + typedef mpl::integral_c int2float_c ; + typedef mpl::integral_c float2int_c ; + typedef mpl::integral_c float2float_c ; + + // Metafunction: + // + // get_int_float_mixture::type + // + // Selects the appropriate Int-Float Mixture Integral Constant for the combination T,S. + // + template + struct get_int_float_mixture + { + typedef mpl::bool_< ::std::numeric_limits::is_integer > S_int ; + typedef mpl::bool_< ::std::numeric_limits::is_integer > T_int ; + + typedef typename + for_both::type + type ; + } ; + + // Metafunction: + // + // for_int_float_mixture::type + // + // {Mixture} is one of the Integral Constants for Mixture, declared above. + // {int_int,int_float,float_int,float_float} are aribtrary types. (not metafunctions) + // + // According to the value of 'IntFloatMixture', selects the corresponding type. + // + template + struct for_int_float_mixture + { + typedef typename + ct_switch4::type + type ; + } ; + +} } } // namespace boost::numeric::convdetail + +#endif +// +/////////////////////////////////////////////////////////////////////////////////////////////// + + diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/detail/is_subranged.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/detail/is_subranged.hpp new file mode 100644 index 0000000000..b5e7fe8f1e --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/detail/is_subranged.hpp @@ -0,0 +1,234 @@ +// (c) Copyright Fernando Luis Cacciola Carballal 2000-2004 +// Use, modification, and distribution is subject to 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) + +// See library home page at http://www.boost.org/libs/numeric/conversion +// +// Contact the author at: fernando_cacciola@hotmail.com +// +#ifndef BOOST_NUMERIC_CONVERSION_DETAIL_IS_SUBRANGED_FLC_12NOV2002_HPP +#define BOOST_NUMERIC_CONVERSION_DETAIL_IS_SUBRANGED_FLC_12NOV2002_HPP + +#include "boost/config.hpp" +#include "boost/limits.hpp" + +#include "boost/mpl/int.hpp" +#include "boost/mpl/multiplies.hpp" +#include "boost/mpl/less.hpp" +#include "boost/mpl/equal_to.hpp" + +#include "boost/type_traits/is_same.hpp" + +#include "boost/numeric/conversion/detail/meta.hpp" +#include "boost/numeric/conversion/detail/int_float_mixture.hpp" +#include "boost/numeric/conversion/detail/sign_mixture.hpp" +#include "boost/numeric/conversion/detail/udt_builtin_mixture.hpp" + +namespace boost { namespace numeric { namespace convdetail +{ + //--------------------------------------------------------------- + // Implementations of the compile time predicate "T is subranged" + //--------------------------------------------------------------- + + // for integral to integral conversions + template + struct subranged_Sig2Unsig + { + // Signed to unsigned conversions are 'subranged' because of possible loose + // of negative values. + typedef mpl::true_ type ; + } ; + + // for unsigned integral to signed integral conversions + template + struct subranged_Unsig2Sig + { + // IMPORTANT NOTE: + // + // This code assumes that signed/unsigned integral values are represented + // such that: + // + // numeric_limits::digits + 1 == numeric_limits::digits + // + // The '+1' is required since numeric_limits<>::digits gives 1 bit less for signed integral types. + // + // This fact is used by the following logic: + // + // if ( (numeric_limits::digits+1) < (2*numeric_limits::digits) ) + // then the conversion is subranged. + // + + typedef mpl::int_< ::std::numeric_limits::digits > S_digits ; + typedef mpl::int_< ::std::numeric_limits::digits > T_digits ; + + // T is signed, so take digits+1 + typedef typename T_digits::next u_T_digits ; + + typedef mpl::int_<2> Two ; + + typedef typename mpl::multiplies::type S_digits_times_2 ; + + typedef typename mpl::less::type type ; + } ; + + // for integral to integral conversions of the same sign. + template + struct subranged_SameSign + { + // An integral conversion of the same sign is subranged if digits(T) < digits(S). + + typedef mpl::int_< ::std::numeric_limits::digits > S_digits ; + typedef mpl::int_< ::std::numeric_limits::digits > T_digits ; + + typedef typename mpl::less::type type ; + } ; + + // for integral to float conversions + template + struct subranged_Int2Float + { + typedef mpl::false_ type ; + } ; + + // for float to integral conversions + template + struct subranged_Float2Int + { + typedef mpl::true_ type ; + } ; + + // for float to float conversions + template + struct subranged_Float2Float + { + // If both T and S are floats, + // compare exponent bits and if they match, mantisa bits. + + typedef mpl::int_< ::std::numeric_limits::digits > S_mantisa ; + typedef mpl::int_< ::std::numeric_limits::digits > T_mantisa ; + + typedef mpl::int_< ::std::numeric_limits::max_exponent > S_exponent ; + typedef mpl::int_< ::std::numeric_limits::max_exponent > T_exponent ; + + typedef typename mpl::less::type T_smaller_exponent ; + + typedef typename mpl::equal_to::type equal_exponents ; + + typedef mpl::less T_smaller_mantisa ; + + typedef mpl::eval_if not_bigger_exponent_case ; + + typedef typename + mpl::eval_if::type + type ; + } ; + + // for Udt to built-in conversions + template + struct subranged_Udt2BuiltIn + { + typedef mpl::true_ type ; + } ; + + // for built-in to Udt conversions + template + struct subranged_BuiltIn2Udt + { + typedef mpl::false_ type ; + } ; + + // for Udt to Udt conversions + template + struct subranged_Udt2Udt + { + typedef mpl::false_ type ; + } ; + + //------------------------------------------------------------------- + // Selectors for the implementations of the subranged predicate + //------------------------------------------------------------------- + + template + struct get_subranged_Int2Int + { + typedef subranged_SameSign Sig2Sig ; + typedef subranged_Sig2Unsig Sig2Unsig ; + typedef subranged_Unsig2Sig Unsig2Sig ; + typedef Sig2Sig Unsig2Unsig ; + + typedef typename get_sign_mixture::type sign_mixture ; + + typedef typename + for_sign_mixture::type + type ; + } ; + + template + struct get_subranged_BuiltIn2BuiltIn + { + typedef get_subranged_Int2Int Int2IntQ ; + + typedef subranged_Int2Float Int2Float ; + typedef subranged_Float2Int Float2Int ; + typedef subranged_Float2Float Float2Float ; + + typedef mpl::identity Int2FloatQ ; + typedef mpl::identity Float2IntQ ; + typedef mpl::identity Float2FloatQ ; + + typedef typename get_int_float_mixture::type int_float_mixture ; + + typedef for_int_float_mixture for_ ; + + typedef typename for_::type selected ; + + typedef typename selected::type type ; + } ; + + template + struct get_subranged + { + typedef get_subranged_BuiltIn2BuiltIn BuiltIn2BuiltInQ ; + + typedef subranged_BuiltIn2Udt BuiltIn2Udt ; + typedef subranged_Udt2BuiltIn Udt2BuiltIn ; + typedef subranged_Udt2Udt Udt2Udt ; + + typedef mpl::identity BuiltIn2UdtQ ; + typedef mpl::identity Udt2BuiltInQ ; + typedef mpl::identity Udt2UdtQ ; + + typedef typename get_udt_builtin_mixture::type udt_builtin_mixture ; + + typedef typename + for_udt_builtin_mixture::type + selected ; + + typedef typename selected::type selected2 ; + + typedef typename selected2::type type ; + } ; + + + //------------------------------------------------------------------- + // Top level implementation selector. + //------------------------------------------------------------------- + template + struct get_is_subranged + { + typedef get_subranged non_trivial_case ; + typedef mpl::identity trivial_case ; + + typedef is_same is_trivial ; + + typedef typename mpl::if_::type selected ; + + typedef typename selected::type type ; + } ; + +} } } // namespace boost::numeric::convdetail + +#endif + + diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/detail/meta.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/detail/meta.hpp new file mode 100644 index 0000000000..246a1b4702 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/detail/meta.hpp @@ -0,0 +1,120 @@ +// (c) Copyright Fernando Luis Cacciola Carballal 2000-2004 +// Use, modification, and distribution is subject to 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) + +// See library home page at http://www.boost.org/libs/numeric/conversion +// +// Contact the author at: fernando_cacciola@hotmail.com +// +#ifndef BOOST_NUMERIC_CONVERSION_DETAIL_META_FLC_12NOV2002_HPP +#define BOOST_NUMERIC_CONVERSION_DETAIL_META_FLC_12NOV2002_HPP + +#include "boost/type_traits/remove_cv.hpp" + +#include "boost/mpl/if.hpp" +#include "boost/mpl/eval_if.hpp" +#include "boost/mpl/equal_to.hpp" +#include "boost/mpl/not.hpp" +#include "boost/mpl/and.hpp" +#include "boost/mpl/bool.hpp" +#include "boost/mpl/identity.hpp" + +namespace boost { namespace numeric { namespace convdetail +{ + template< class T1, class T2> + struct equal_to + { + #if !defined(__BORLANDC__) + + enum { x = ( BOOST_MPL_AUX_VALUE_WKND(T1)::value == BOOST_MPL_AUX_VALUE_WKND(T2)::value ) }; + + BOOST_STATIC_CONSTANT(bool, value = x); + + typedef mpl::bool_ type; + + #else + + BOOST_STATIC_CONSTANT(bool, value = ( + BOOST_MPL_AUX_VALUE_WKND(T1)::value + == BOOST_MPL_AUX_VALUE_WKND(T2)::value + )); + + typedef mpl::bool_<( + BOOST_MPL_AUX_VALUE_WKND(T1)::value + == BOOST_MPL_AUX_VALUE_WKND(T2)::value + )> type; + #endif + }; + +// Metafunction: + // + // ct_switch4::type + // + // {Value,Case(X)Val} are Integral Constants (such as: mpl::int_<>) + // {Case(X)Type,DefaultType} are arbitrary types. (not metafunctions) + // + // Returns Case(X)Type if Val==Case(X)Val; DefaultType otherwise. + // + template + struct ct_switch4 + { + typedef mpl::identity Case0TypeQ ; + typedef mpl::identity Case1TypeQ ; + + typedef equal_to is_case0 ; + typedef equal_to is_case1 ; + typedef equal_to is_case2 ; + + typedef mpl::if_ choose_2_3Q ; + typedef mpl::eval_if choose_1_2_3Q ; + + typedef typename + mpl::eval_if::type + type ; + } ; + + + + + // Metafunction: + // + // for_both::type + // + // {exp0,expr1} are Boolean Integral Constants + // {TT,TF,FT,FF} are aribtrary types. (not metafunctions) + // + // According to the combined boolean value of 'expr0 && expr1', selects the corresponding type. + // + template + struct for_both + { + typedef mpl::identity TF_Q ; + typedef mpl::identity TT_Q ; + + typedef typename mpl::not_::type not_expr0 ; + typedef typename mpl::not_::type not_expr1 ; + + typedef typename mpl::and_::type caseTT ; + typedef typename mpl::and_::type caseTF ; + typedef typename mpl::and_::type caseFT ; + + typedef mpl::if_ choose_FT_FF_Q ; + typedef mpl::eval_if choose_TF_FT_FF_Q ; + + typedef typename mpl::eval_if::type type ; + } ; + +} } } // namespace boost::numeric::convdetail + +#endif + + diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/detail/numeric_cast_traits.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/detail/numeric_cast_traits.hpp new file mode 100644 index 0000000000..150490d935 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/detail/numeric_cast_traits.hpp @@ -0,0 +1,138 @@ +// +//! Copyright (c) 2011-2012 +//! Brandon Kohn +// +// 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) +// + +#if !defined(BOOST_NUMERIC_CONVERSION_DONT_USE_PREPROCESSED_FILES) + + #include + + #if !defined(BOOST_NO_LONG_LONG) + #include + #endif + +#else +#if !BOOST_PP_IS_ITERATING + + #include + #include + #include + + #if defined(__WAVE__) && defined(BOOST_NUMERIC_CONVERSION_CREATE_PREPROCESSED_FILES) + #pragma wave option(preserve: 2, line: 0, output: "preprocessed/numeric_cast_traits_common.hpp") + #endif +// +//! Copyright (c) 2011-2012 +//! Brandon Kohn +// +// 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) +// + #if defined(__WAVE__) && defined(BOOST_NUMERIC_CONVERSION_CREATE_PREPROCESSED_FILES) + #pragma wave option(preserve: 1) + #endif + + //! These are the assumed common built in fundamental types (not typedefs/macros.) + #define BOOST_NUMERIC_CONVERSION_BASE_BUILTIN_TYPES() \ + (char) \ + (signed char) \ + (unsigned char) \ + (short) \ + (unsigned short) \ + (int) \ + (unsigned int) \ + (long) \ + (unsigned long) \ + (float) \ + (double) \ + (long double) \ + /***/ + + #define BOOST_NUMERIC_CONVERSION_SEQ_A() BOOST_NUMERIC_CONVERSION_BASE_BUILTIN_TYPES() + #define BOOST_NUMERIC_CONVERSION_SEQ_B() BOOST_NUMERIC_CONVERSION_BASE_BUILTIN_TYPES() + +namespace boost { namespace numeric { + + #define BOOST_PP_ITERATION_PARAMS_1 (3, (0, BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(BOOST_NUMERIC_CONVERSION_SEQ_A())), )) + #include BOOST_PP_ITERATE() + +}}//namespace boost::numeric; + + #if defined(__WAVE__) && defined(BOOST_NUMERIC_CONVERSION_CREATE_PREPROCESSED_FILES) + #pragma wave option(output: null) + #endif + + #if ( defined(__WAVE__) && defined(BOOST_NUMERIC_CONVERSION_CREATE_PREPROCESSED_FILES) ) || !defined(BOOST_NO_LONG_LONG) + + #undef BOOST_NUMERIC_CONVERSION_SEQ_A + #undef BOOST_NUMERIC_CONVERSION_SEQ_B + + #if defined(__WAVE__) && defined(BOOST_NUMERIC_CONVERSION_CREATE_PREPROCESSED_FILES) + #pragma wave option(preserve: 2, line: 0, output: "preprocessed/numeric_cast_traits_long_long.hpp") + #endif + +// +//! Copyright (c) 2011-2012 +//! Brandon Kohn +// +// 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) +// + #if defined(__WAVE__) && defined(BOOST_NUMERIC_CONVERSION_CREATE_PREPROCESSED_FILES) + #pragma wave option(preserve: 1) + #endif + +namespace boost { namespace numeric { + + #define BOOST_NUMERIC_CONVERSION_SEQ_A() BOOST_NUMERIC_CONVERSION_BASE_BUILTIN_TYPES()(boost::long_long_type)(boost::ulong_long_type) + #define BOOST_NUMERIC_CONVERSION_SEQ_B() (boost::long_long_type)(boost::ulong_long_type) + + #define BOOST_PP_ITERATION_PARAMS_1 (3, (0, BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(BOOST_NUMERIC_CONVERSION_SEQ_A())), )) + #include BOOST_PP_ITERATE() + +}}//namespace boost::numeric; + + #if defined(__WAVE__) && defined(BOOST_NUMERIC_CONVERSION_CREATE_PREPROCESSED_FILES) + #pragma wave option(output: null) + #endif + + #endif + + #undef BOOST_NUMERIC_CONVERSION_BASE_BUILTIN_TYPES + #undef BOOST_NUMERIC_CONVERSION_SEQ_A + #undef BOOST_NUMERIC_CONVERSION_SEQ_B + +#elif BOOST_PP_ITERATION_DEPTH() == 1 + + #define BOOST_PP_ITERATION_PARAMS_2 (3, (0, BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(BOOST_NUMERIC_CONVERSION_SEQ_B())), )) + #include BOOST_PP_ITERATE() + +#elif BOOST_PP_ITERATION_DEPTH() == 2 + + //! Generate default traits for the specified source and target. + #define BOOST_NUMERIC_CONVERSION_A BOOST_PP_FRAME_ITERATION(1) + #define BOOST_NUMERIC_CONVERSION_B BOOST_PP_FRAME_ITERATION(2) + + template <> + struct numeric_cast_traits + < + BOOST_PP_SEQ_ELEM(BOOST_NUMERIC_CONVERSION_A, BOOST_NUMERIC_CONVERSION_SEQ_A()) + , BOOST_PP_SEQ_ELEM(BOOST_NUMERIC_CONVERSION_B, BOOST_NUMERIC_CONVERSION_SEQ_B()) + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + #undef BOOST_NUMERIC_CONVERSION_A + #undef BOOST_NUMERIC_CONVERSION_B + +#endif//! Depth 2. +#endif// BOOST_NUMERIC_CONVERSION_DONT_USE_PREPROCESSED_FILES diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/detail/old_numeric_cast.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/detail/old_numeric_cast.hpp new file mode 100644 index 0000000000..47b86d2c8c --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/detail/old_numeric_cast.hpp @@ -0,0 +1,339 @@ +// boost cast.hpp header file ----------------------------------------------// + +// (C) Copyright Kevlin Henney and Dave Abrahams 1999. +// 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) + +// See http://www.boost.org/libs/conversion for Documentation. + +// Revision History +// 23 JUN 05 Code extracted from /boost/cast.hpp into this new header. +// Keeps this legacy version of numeric_cast<> for old compilers +// wich can't compile the new version in /boost/numeric/conversion/cast.hpp +// (Fernando Cacciola) +// 02 Apr 01 Removed BOOST_NO_LIMITS workarounds and included +// instead (the workaround did not +// actually compile when BOOST_NO_LIMITS was defined in +// any case, so we loose nothing). (John Maddock) +// 21 Jan 01 Undid a bug I introduced yesterday. numeric_cast<> never +// worked with stock GCC; trying to get it to do that broke +// vc-stlport. +// 20 Jan 01 Moved BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS to config.hpp. +// Removed unused BOOST_EXPLICIT_TARGET macro. Moved +// boost::detail::type to boost/type.hpp. Made it compile with +// stock gcc again (Dave Abrahams) +// 29 Nov 00 Remove nested namespace cast, cleanup spacing before Formal +// Review (Beman Dawes) +// 19 Oct 00 Fix numeric_cast for floating-point types (Dave Abrahams) +// 15 Jul 00 Suppress numeric_cast warnings for GCC, Borland and MSVC +// (Dave Abrahams) +// 30 Jun 00 More MSVC6 wordarounds. See comments below. (Dave Abrahams) +// 28 Jun 00 Removed implicit_cast<>. See comment below. (Beman Dawes) +// 27 Jun 00 More MSVC6 workarounds +// 15 Jun 00 Add workarounds for MSVC6 +// 2 Feb 00 Remove bad_numeric_cast ";" syntax error (Doncho Angelov) +// 26 Jan 00 Add missing throw() to bad_numeric_cast::what(0 (Adam Levar) +// 29 Dec 99 Change using declarations so usages in other namespaces work +// correctly (Dave Abrahams) +// 23 Sep 99 Change polymorphic_downcast assert to also detect M.I. errors +// as suggested Darin Adler and improved by Valentin Bonnard. +// 2 Sep 99 Remove controversial asserts, simplify, rename. +// 30 Aug 99 Move to cast.hpp, replace value_cast with numeric_cast, +// place in nested namespace. +// 3 Aug 99 Initial version + +#ifndef BOOST_OLD_NUMERIC_CAST_HPP +#define BOOST_OLD_NUMERIC_CAST_HPP + +# include +# include +# include +# include +# include +# include + +// It has been demonstrated numerous times that MSVC 6.0 fails silently at link +// time if you use a template function which has template parameters that don't +// appear in the function's argument list. +// +// TODO: Add this to config.hpp? +// FLC: This macro is repeated in boost/cast.hpp but only locally (is undefined at the bottom) +// so is OK to reproduce it here. +# if defined(BOOST_MSVC) && BOOST_MSVC < 1300 +# define BOOST_EXPLICIT_DEFAULT_TARGET , ::boost::type* = 0 +# else +# define BOOST_EXPLICIT_DEFAULT_TARGET +# endif + +namespace boost +{ + using numeric::bad_numeric_cast; + +// LEGACY numeric_cast [only for some old broken compilers] --------------------------------------// + +// Contributed by Kevlin Henney + +// numeric_cast ------------------------------------------------------------// + +#if !defined(BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS) || defined(BOOST_SGI_CPP_LIMITS) + + namespace detail + { + template + struct signed_numeric_limits : std::numeric_limits + { + static inline T min BOOST_PREVENT_MACRO_SUBSTITUTION () + { + return (std::numeric_limits::min)() >= 0 + // unary minus causes integral promotion, thus the static_cast<> + ? static_cast(-(std::numeric_limits::max)()) + : (std::numeric_limits::min)(); + }; + }; + + // Move to namespace boost in utility.hpp? + template + struct fixed_numeric_limits_base + : public if_true< std::numeric_limits::is_signed > + ::BOOST_NESTED_TEMPLATE then< signed_numeric_limits, + std::numeric_limits + >::type + {}; + + template + struct fixed_numeric_limits + : fixed_numeric_limits_base::is_specialized)> + {}; + +# ifdef BOOST_HAS_LONG_LONG + // cover implementations which supply no specialization for long + // long / unsigned long long. Not intended to be full + // numeric_limits replacements, but good enough for numeric_cast<> + template <> + struct fixed_numeric_limits_base< ::boost::long_long_type, false> + { + BOOST_STATIC_CONSTANT(bool, is_specialized = true); + BOOST_STATIC_CONSTANT(bool, is_signed = true); + static ::boost::long_long_type max BOOST_PREVENT_MACRO_SUBSTITUTION () + { +# ifdef LONGLONG_MAX + return LONGLONG_MAX; +# else + return 9223372036854775807LL; // hope this is portable +# endif + } + + static ::boost::long_long_type min BOOST_PREVENT_MACRO_SUBSTITUTION () + { +# ifdef LONGLONG_MIN + return LONGLONG_MIN; +# else + return -( 9223372036854775807LL )-1; // hope this is portable +# endif + } + }; + + template <> + struct fixed_numeric_limits_base< ::boost::ulong_long_type, false> + { + BOOST_STATIC_CONSTANT(bool, is_specialized = true); + BOOST_STATIC_CONSTANT(bool, is_signed = false); + static ::boost::ulong_long_type max BOOST_PREVENT_MACRO_SUBSTITUTION () + { +# ifdef ULONGLONG_MAX + return ULONGLONG_MAX; +# else + return 0xffffffffffffffffULL; // hope this is portable +# endif + } + + static ::boost::ulong_long_type min BOOST_PREVENT_MACRO_SUBSTITUTION () { return 0; } + }; +# endif + } // namespace detail + +// less_than_type_min - + // x_is_signed should be numeric_limits::is_signed + // y_is_signed should be numeric_limits::is_signed + // y_min should be numeric_limits::min() + // + // check(x, y_min) returns true iff x < y_min without invoking comparisons + // between signed and unsigned values. + // + // "poor man's partial specialization" is in use here. + template + struct less_than_type_min + { + template + static bool check(X x, Y y_min) + { return x < y_min; } + }; + + template <> + struct less_than_type_min + { + template + static bool check(X, Y) + { return false; } + }; + + template <> + struct less_than_type_min + { + template + static bool check(X x, Y) + { return x < 0; } + }; + + // greater_than_type_max - + // same_sign should be: + // numeric_limits::is_signed == numeric_limits::is_signed + // y_max should be numeric_limits::max() + // + // check(x, y_max) returns true iff x > y_max without invoking comparisons + // between signed and unsigned values. + // + // "poor man's partial specialization" is in use here. + template + struct greater_than_type_max; + + template<> + struct greater_than_type_max + { + template + static inline bool check(X x, Y y_max) + { return x > y_max; } + }; + + template <> + struct greater_than_type_max + { + // What does the standard say about this? I think it's right, and it + // will work with every compiler I know of. + template + static inline bool check(X x, Y) + { return x >= 0 && static_cast(static_cast(x)) != x; } + +# if defined(BOOST_MSVC) && BOOST_MSVC < 1300 + // MSVC6 can't static_cast unsigned __int64 -> floating types +# define BOOST_UINT64_CAST(src_type) \ + static inline bool check(src_type x, unsigned __int64) \ + { \ + if (x < 0) return false; \ + unsigned __int64 y = static_cast(x); \ + bool odd = y & 0x1; \ + __int64 div2 = static_cast<__int64>(y >> 1); \ + return ((static_cast(div2) * 2.0) + odd) != x; \ + } + + BOOST_UINT64_CAST(long double); + BOOST_UINT64_CAST(double); + BOOST_UINT64_CAST(float); +# undef BOOST_UINT64_CAST +# endif + }; + + template<> + struct greater_than_type_max + { + template + static inline bool check(X x, Y y_max) + { return x > y_max; } + }; + + template <> + struct greater_than_type_max + { + // What does the standard say about this? I think it's right, and it + // will work with every compiler I know of. + template + static inline bool check(X x, Y) + { return static_cast(static_cast(x)) != x; } + }; + +#else // use #pragma hacks if available + + namespace detail + { +# if BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4018) +# pragma warning(disable : 4146) +#elif defined(__BORLANDC__) +# pragma option push -w-8041 +# endif + + // Move to namespace boost in utility.hpp? + template + struct fixed_numeric_limits : public std::numeric_limits + { + static inline T min BOOST_PREVENT_MACRO_SUBSTITUTION () + { + return std::numeric_limits::is_signed && (std::numeric_limits::min)() >= 0 + ? T(-(std::numeric_limits::max)()) : (std::numeric_limits::min)(); + } + }; + +# if BOOST_MSVC +# pragma warning(pop) +#elif defined(__BORLANDC__) +# pragma option pop +# endif + } // namespace detail + +#endif + + template + inline Target numeric_cast(Source arg BOOST_EXPLICIT_DEFAULT_TARGET) + { + // typedefs abbreviating respective trait classes + typedef detail::fixed_numeric_limits arg_traits; + typedef detail::fixed_numeric_limits result_traits; + +#if defined(BOOST_STRICT_CONFIG) \ + || (!defined(__HP_aCC) || __HP_aCC > 33900) \ + && (!defined(BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS) \ + || defined(BOOST_SGI_CPP_LIMITS)) + // typedefs that act as compile time assertions + // (to be replaced by boost compile time assertions + // as and when they become available and are stable) + typedef bool argument_must_be_numeric[arg_traits::is_specialized]; + typedef bool result_must_be_numeric[result_traits::is_specialized]; + + const bool arg_is_signed = arg_traits::is_signed; + const bool result_is_signed = result_traits::is_signed; + const bool same_sign = arg_is_signed == result_is_signed; + + if (less_than_type_min::check(arg, (result_traits::min)()) + || greater_than_type_max::check(arg, (result_traits::max)()) + ) + +#else // We need to use #pragma hacks if available + +# if BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4018) +#elif defined(__BORLANDC__) +#pragma option push -w-8012 +# endif + if ((arg < 0 && !result_traits::is_signed) // loss of negative range + || (arg_traits::is_signed && arg < (result_traits::min)()) // underflow + || arg > (result_traits::max)()) // overflow +# if BOOST_MSVC +# pragma warning(pop) +#elif defined(__BORLANDC__) +#pragma option pop +# endif +#endif + { + throw bad_numeric_cast(); + } + return static_cast(arg); + } // numeric_cast + +# undef BOOST_EXPLICIT_DEFAULT_TARGET + +} // namespace boost + +#endif // BOOST_OLD_NUMERIC_CAST_HPP diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/detail/preprocessed/numeric_cast_traits_common.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/detail/preprocessed/numeric_cast_traits_common.hpp new file mode 100644 index 0000000000..01dc9321b3 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/detail/preprocessed/numeric_cast_traits_common.hpp @@ -0,0 +1,1741 @@ +// +//! Copyright (c) 2011-2012 +//! Brandon Kohn +// +// 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) +// + + + +namespace boost { namespace numeric { + + template <> + struct numeric_cast_traits + < + char + , char + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + char + , signed char + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + char + , unsigned char + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + char + , short + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + char + , unsigned short + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + char + , int + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + char + , unsigned int + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + char + , long + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + char + , unsigned long + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + char + , float + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + char + , double + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + char + , long double + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + signed char + , char + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + signed char + , signed char + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + signed char + , unsigned char + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + signed char + , short + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + signed char + , unsigned short + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + signed char + , int + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + signed char + , unsigned int + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + signed char + , long + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + signed char + , unsigned long + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + signed char + , float + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + signed char + , double + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + signed char + , long double + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned char + , char + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned char + , signed char + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned char + , unsigned char + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned char + , short + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned char + , unsigned short + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned char + , int + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned char + , unsigned int + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned char + , long + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned char + , unsigned long + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned char + , float + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned char + , double + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned char + , long double + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + short + , char + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + short + , signed char + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + short + , unsigned char + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + short + , short + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + short + , unsigned short + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + short + , int + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + short + , unsigned int + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + short + , long + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + short + , unsigned long + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + short + , float + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + short + , double + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + short + , long double + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned short + , char + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned short + , signed char + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned short + , unsigned char + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned short + , short + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned short + , unsigned short + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned short + , int + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned short + , unsigned int + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned short + , long + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned short + , unsigned long + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned short + , float + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned short + , double + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned short + , long double + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + int + , char + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + int + , signed char + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + int + , unsigned char + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + int + , short + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + int + , unsigned short + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + int + , int + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + int + , unsigned int + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + int + , long + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + int + , unsigned long + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + int + , float + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + int + , double + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + int + , long double + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned int + , char + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned int + , signed char + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned int + , unsigned char + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned int + , short + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned int + , unsigned short + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned int + , int + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned int + , unsigned int + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned int + , long + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned int + , unsigned long + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned int + , float + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned int + , double + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned int + , long double + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + long + , char + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + long + , signed char + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + long + , unsigned char + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + long + , short + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + long + , unsigned short + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + long + , int + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + long + , unsigned int + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + long + , long + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + long + , unsigned long + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + long + , float + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + long + , double + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + long + , long double + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned long + , char + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned long + , signed char + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned long + , unsigned char + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned long + , short + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned long + , unsigned short + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned long + , int + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned long + , unsigned int + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned long + , long + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned long + , unsigned long + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned long + , float + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned long + , double + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned long + , long double + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + float + , char + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + float + , signed char + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + float + , unsigned char + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + float + , short + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + float + , unsigned short + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + float + , int + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + float + , unsigned int + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + float + , long + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + float + , unsigned long + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + float + , float + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + float + , double + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + float + , long double + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + double + , char + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + double + , signed char + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + double + , unsigned char + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + double + , short + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + double + , unsigned short + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + double + , int + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + double + , unsigned int + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + double + , long + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + double + , unsigned long + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + double + , float + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + double + , double + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + double + , long double + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + long double + , char + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + long double + , signed char + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + long double + , unsigned char + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + long double + , short + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + long double + , unsigned short + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + long double + , int + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + long double + , unsigned int + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + long double + , long + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + long double + , unsigned long + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + long double + , float + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + long double + , double + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + long double + , long double + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; +}} diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/detail/preprocessed/numeric_cast_traits_long_long.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/detail/preprocessed/numeric_cast_traits_long_long.hpp new file mode 100644 index 0000000000..b358b9c41f --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/detail/preprocessed/numeric_cast_traits_long_long.hpp @@ -0,0 +1,347 @@ +// +//! Copyright (c) 2011-2012 +//! Brandon Kohn +// +// 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) +// +namespace boost { namespace numeric { + + + template <> + struct numeric_cast_traits + < + char + , boost::long_long_type + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + char + , boost::ulong_long_type + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + signed char + , boost::long_long_type + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + signed char + , boost::ulong_long_type + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned char + , boost::long_long_type + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned char + , boost::ulong_long_type + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + short + , boost::long_long_type + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + short + , boost::ulong_long_type + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned short + , boost::long_long_type + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned short + , boost::ulong_long_type + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + int + , boost::long_long_type + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + int + , boost::ulong_long_type + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned int + , boost::long_long_type + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned int + , boost::ulong_long_type + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + long + , boost::long_long_type + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + long + , boost::ulong_long_type + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned long + , boost::long_long_type + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + unsigned long + , boost::ulong_long_type + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + float + , boost::long_long_type + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + float + , boost::ulong_long_type + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + double + , boost::long_long_type + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + double + , boost::ulong_long_type + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + long double + , boost::long_long_type + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + long double + , boost::ulong_long_type + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + boost::long_long_type + , boost::long_long_type + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + boost::long_long_type + , boost::ulong_long_type + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + boost::ulong_long_type + , boost::long_long_type + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + + template <> + struct numeric_cast_traits + < + boost::ulong_long_type + , boost::ulong_long_type + > + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; +}} diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/detail/sign_mixture.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/detail/sign_mixture.hpp new file mode 100644 index 0000000000..c7f9e42afe --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/detail/sign_mixture.hpp @@ -0,0 +1,72 @@ +// (c) Copyright Fernando Luis Cacciola Carballal 2000-2004 +// Use, modification, and distribution is subject to 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) + +// See library home page at http://www.boost.org/libs/numeric/conversion +// +// Contact the author at: fernando_cacciola@hotmail.com +// +#ifndef BOOST_NUMERIC_CONVERSION_DETAIL_SIGN_MIXTURE_FLC_12NOV2002_HPP +#define BOOST_NUMERIC_CONVERSION_DETAIL_SIGN_MIXTURE_FLC_12NOV2002_HPP + +#include "boost/config.hpp" +#include "boost/limits.hpp" + +#include "boost/numeric/conversion/sign_mixture_enum.hpp" +#include "boost/numeric/conversion/detail/meta.hpp" + +#include "boost/mpl/integral_c.hpp" + +namespace boost { namespace numeric { namespace convdetail +{ + // Integral Constants for 'SignMixture' + typedef mpl::integral_c unsig2unsig_c ; + typedef mpl::integral_c sig2sig_c ; + typedef mpl::integral_c sig2unsig_c ; + typedef mpl::integral_c unsig2sig_c ; + + // Metafunction: + // + // get_sign_mixture::type + // + // Selects the appropriate SignMixture Integral Constant for the combination T,S. + // + template + struct get_sign_mixture + { + typedef mpl::bool_< ::std::numeric_limits::is_signed > S_signed ; + typedef mpl::bool_< ::std::numeric_limits::is_signed > T_signed ; + + typedef typename + for_both::type + type ; + } ; + + // Metafunction: + // + // for_sign_mixture::type + // + // {SignMixture} is one of the Integral Constants for SignMixture, declared above. + // {Sig2Sig,Sig2Unsig,Unsig2Sig,Unsig2Unsig} are aribtrary types. (not metafunctions) + // + // According to the value of 'SignMixture', selects the corresponding type. + // + template + struct for_sign_mixture + { + typedef typename + ct_switch4::type + type ; + } ; + +} } } // namespace boost::numeric::convdetail + +#endif +// +/////////////////////////////////////////////////////////////////////////////////////////////// + + diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/detail/udt_builtin_mixture.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/detail/udt_builtin_mixture.hpp new file mode 100644 index 0000000000..36dbc491b5 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/detail/udt_builtin_mixture.hpp @@ -0,0 +1,69 @@ +// (c) Copyright Fernando Luis Cacciola Carballal 2000-2004 +// Use, modification, and distribution is subject to 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) + +// See library home page at http://www.boost.org/libs/numeric/conversion +// +// Contact the author at: fernando_cacciola@hotmail.com +// +#ifndef BOOST_NUMERIC_CONVERSION_DETAIL_UDT_BUILTIN_MIXTURE_FLC_12NOV2002_HPP +#define BOOST_NUMERIC_CONVERSION_DETAIL_UDT_BUILTIN_MIXTURE_FLC_12NOV2002_HPP + +#include "boost/type_traits/is_arithmetic.hpp" + +#include "boost/numeric/conversion/udt_builtin_mixture_enum.hpp" +#include "boost/numeric/conversion/detail/meta.hpp" + +#include "boost/mpl/integral_c.hpp" + +namespace boost { namespace numeric { namespace convdetail +{ + // Integral Constants for 'UdtMixture' + typedef mpl::integral_c builtin2builtin_c ; + typedef mpl::integral_c builtin2udt_c ; + typedef mpl::integral_c udt2builtin_c ; + typedef mpl::integral_c udt2udt_c ; + + // Metafunction: + // + // for_udt_mixture::type + // + // {UdtMixture} is one of the Integral Constants for UdMixture, declared above. + // {BuiltIn2BuiltIn,BuiltIn2Udt,Udt2BuiltIn,Udt2Udt} are aribtrary types. (not metafunctions) + // + // According to the value of 'UdtMixture', selects the corresponding type. + // + template + struct for_udt_builtin_mixture + { + typedef typename + ct_switch4::type + type ; + } ; + + // Metafunction: + // + // get_udt_mixture::type + // + // Selects the appropriate UdtMixture Integral Constant for the combination T,S. + // + template + struct get_udt_builtin_mixture + { + typedef is_arithmetic S_builtin ; + typedef is_arithmetic T_builtin ; + + typedef typename + for_both::type + type ; + } ; + +} } } // namespace boost::numeric::convdetail + +#endif + + diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/int_float_mixture.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/int_float_mixture.hpp new file mode 100644 index 0000000000..d6dd5ab7c2 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/int_float_mixture.hpp @@ -0,0 +1,30 @@ +// (c) Copyright Fernando Luis Cacciola Carballal 2000-2004 +// Use, modification, and distribution is subject to 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) + +// See library home page at http://www.boost.org/libs/numeric/conversion +// +// Contact the author at: fernando_cacciola@hotmail.com +// +#ifndef BOOST_NUMERIC_CONVERSION_INT_FLOAT_MIXTURE_FLC_12NOV2002_HPP +#define BOOST_NUMERIC_CONVERSION_INT_FLOAT_MIXTURE_FLC_12NOV2002_HPP + +#include "boost/numeric/conversion/detail/int_float_mixture.hpp" + +namespace boost { namespace numeric +{ + +template +struct int_float_mixture + : convdetail::get_int_float_mixture< BOOST_DEDUCED_TYPENAME remove_cv::type + ,BOOST_DEDUCED_TYPENAME remove_cv::type + >::type {} ; + +} } // namespace boost::numeric + +#endif +// +/////////////////////////////////////////////////////////////////////////////////////////////// + + diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/int_float_mixture_enum.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/int_float_mixture_enum.hpp new file mode 100644 index 0000000000..d0c2daacfc --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/int_float_mixture_enum.hpp @@ -0,0 +1,29 @@ +// (c) Copyright Fernando Luis Cacciola Carballal 2000-2004 +// Use, modification, and distribution is subject to 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) + +// See library home page at http://www.boost.org/libs/numeric/conversion +// +// Contact the author at: fernando_cacciola@hotmail.com +// +#ifndef BOOST_NUMERIC_CONVERSION_INT_FLOAT_MIXTURE_ENUM_FLC_12NOV2002_HPP +#define BOOST_NUMERIC_CONVERSION_INT_FLOAT_MIXTURE_ENUM_FLC_12NOV2002_HPP + +namespace boost { namespace numeric +{ + enum int_float_mixture_enum + { + integral_to_integral + ,integral_to_float + ,float_to_integral + ,float_to_float + } ; + +} } // namespace boost::numeric + +#endif +// +/////////////////////////////////////////////////////////////////////////////////////////////// + + diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/is_subranged.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/is_subranged.hpp new file mode 100644 index 0000000000..c5fa0dd103 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/is_subranged.hpp @@ -0,0 +1,27 @@ +// (c) Copyright Fernando Luis Cacciola Carballal 2000-2004 +// Use, modification, and distribution is subject to 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) + +// See library home page at http://www.boost.org/libs/numeric/conversion +// +// Contact the author at: fernando_cacciola@hotmail.com +// +#ifndef BOOST_NUMERIC_CONVERSION_IS_SUBRANGED_FLC_12NOV2002_HPP +#define BOOST_NUMERIC_CONVERSION_IS_SUBRANGED_FLC_12NOV2002_HPP + +#include "boost/numeric/conversion/detail/is_subranged.hpp" + +namespace boost { namespace numeric { + +template +struct is_subranged + : convdetail::get_is_subranged< BOOST_DEDUCED_TYPENAME remove_cv::type + ,BOOST_DEDUCED_TYPENAME remove_cv::type + >::type {} ; + +} } // namespace boost::numeric + +#endif + + diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/numeric_cast_traits.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/numeric_cast_traits.hpp new file mode 100644 index 0000000000..e24296bc7e --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/numeric_cast_traits.hpp @@ -0,0 +1,31 @@ +// +//! Copyright (c) 2011 +//! Brandon Kohn +// +// 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) +// +#ifndef BOOST_NUMERIC_CAST_TRAITS_HPP +#define BOOST_NUMERIC_CAST_TRAITS_HPP + +#include + +namespace boost { namespace numeric { + + template + struct numeric_cast_traits + { + typedef def_overflow_handler overflow_policy; + typedef UseInternalRangeChecker range_checking_policy; + typedef Trunc rounding_policy; + }; + +}}//namespace boost::numeric; + +#if !defined( BOOST_NUMERIC_CONVERSION_RELAX_BUILT_IN_CAST_TRAITS ) +#include +#include +#endif//!defined BOOST_NUMERIC_CONVERSION_RELAX_BUILT_IN_CAST_TRAITS + +#endif//BOOST_NUMERIC_CAST_TRAITS_HPP diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/sign_mixture.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/sign_mixture.hpp new file mode 100644 index 0000000000..12018141c3 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/sign_mixture.hpp @@ -0,0 +1,30 @@ +// (c) Copyright Fernando Luis Cacciola Carballal 2000-2004 +// Use, modification, and distribution is subject to 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) + +// See library home page at http://www.boost.org/libs/numeric/conversion +// +// Contact the author at: fernando_cacciola@hotmail.com +// +#ifndef BOOST_NUMERIC_CONVERSION_SIGN_MIXTURE_FLC_12NOV2002_HPP +#define BOOST_NUMERIC_CONVERSION_SIGN_MIXTURE_FLC_12NOV2002_HPP + +#include "boost/numeric/conversion/detail/sign_mixture.hpp" + +namespace boost { namespace numeric +{ + +template +struct sign_mixture + : convdetail::get_sign_mixture< BOOST_DEDUCED_TYPENAME remove_cv::type + ,BOOST_DEDUCED_TYPENAME remove_cv::type + >::type {} ; + +} } // namespace boost::numeric + +#endif +// +/////////////////////////////////////////////////////////////////////////////////////////////// + + diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/sign_mixture_enum.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/sign_mixture_enum.hpp new file mode 100644 index 0000000000..1525f8d33c --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/sign_mixture_enum.hpp @@ -0,0 +1,29 @@ +// (c) Copyright Fernando Luis Cacciola Carballal 2000-2004 +// Use, modification, and distribution is subject to 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) + +// See library home page at http://www.boost.org/libs/numeric/conversion +// +// Contact the author at: fernando_cacciola@hotmail.com +// +#ifndef BOOST_NUMERIC_CONVERSION_SIGN_MIXTURE_ENUM_FLC_12NOV2002_HPP +#define BOOST_NUMERIC_CONVERSION_SIGN_MIXTURE_ENUM_FLC_12NOV2002_HPP + +namespace boost { namespace numeric +{ + enum sign_mixture_enum + { + unsigned_to_unsigned + ,signed_to_signed + ,signed_to_unsigned + ,unsigned_to_signed + } ; + +} } // namespace boost::numeric + +#endif +// +/////////////////////////////////////////////////////////////////////////////////////////////// + + diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/udt_builtin_mixture.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/udt_builtin_mixture.hpp new file mode 100644 index 0000000000..a62e37d8e0 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/udt_builtin_mixture.hpp @@ -0,0 +1,28 @@ +// (c) Copyright Fernando Luis Cacciola Carballal 2000-2004 +// Use, modification, and distribution is subject to 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) + +// See library home page at http://www.boost.org/libs/numeric/conversion +// +// Contact the author at: fernando_cacciola@hotmail.com +// +#ifndef BOOST_NUMERIC_CONVERSION_UDT_BUILTIN_MIXTURE_FLC_12NOV2002_HPP +#define BOOST_NUMERIC_CONVERSION_UDT_BUILTIN_MIXTURE_FLC_12NOV2002_HPP + +#include "boost/numeric/conversion/detail/udt_builtin_mixture.hpp" + +namespace boost { namespace numeric +{ + +template +struct udt_builtin_mixture + : convdetail::get_udt_builtin_mixture< BOOST_DEDUCED_TYPENAME remove_cv::type + ,BOOST_DEDUCED_TYPENAME remove_cv::type + >::type {} ; + +} } // namespace boost::numeric + +#endif + + diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/udt_builtin_mixture_enum.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/udt_builtin_mixture_enum.hpp new file mode 100644 index 0000000000..2540e80630 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/conversion/udt_builtin_mixture_enum.hpp @@ -0,0 +1,26 @@ +// (c) Copyright Fernando Luis Cacciola Carballal 2000-2004 +// Use, modification, and distribution is subject to 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) + +// See library home page at http://www.boost.org/libs/numeric/conversion +// +// Contact the author at: fernando_cacciola@hotmail.com +// +#ifndef BOOST_NUMERIC_CONVERSION_UDT_BUILTIN_MIXTURE_ENUM_FLC_12NOV2002_HPP +#define BOOST_NUMERIC_CONVERSION_UDT_BUILTIN_MIXTURE_ENUM_FLC_12NOV2002_HPP + +namespace boost { namespace numeric +{ + enum udt_builtin_mixture_enum + { + builtin_to_builtin + ,builtin_to_udt + ,udt_to_builtin + ,udt_to_udt + } ; + +} } // namespace boost::numeric + +#endif + diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval.hpp new file mode 100644 index 0000000000..e6f976df03 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval.hpp @@ -0,0 +1,32 @@ +/* Boost interval.hpp header file + * + * Copyright 2000 Jens Maurer + * Copyright 2002 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion + * + * 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) + */ + +#ifndef BOOST_NUMERIC_INTERVAL_HPP +#define BOOST_NUMERIC_INTERVAL_HPP + +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +#endif // BOOST_NUMERIC_INTERVAL_HPP diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/arith.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/arith.hpp new file mode 100644 index 0000000000..c0320c45ef --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/arith.hpp @@ -0,0 +1,305 @@ +/* Boost interval/arith.hpp template implementation file + * + * Copyright 2000 Jens Maurer + * Copyright 2002-2003 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion + * + * 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) + */ + +#ifndef BOOST_NUMERIC_INTERVAL_ARITH_HPP +#define BOOST_NUMERIC_INTERVAL_ARITH_HPP + +#include +#include +#include +#include +#include +#include + +namespace boost { +namespace numeric { + +/* + * Basic arithmetic operators + */ + +template inline +const interval& operator+(const interval& x) +{ + return x; +} + +template inline +interval operator-(const interval& x) +{ + if (interval_lib::detail::test_input(x)) + return interval::empty(); + return interval(-x.upper(), -x.lower(), true); +} + +template inline +interval& interval::operator+=(const interval& r) +{ + if (interval_lib::detail::test_input(*this, r)) + set_empty(); + else { + typename Policies::rounding rnd; + set(rnd.add_down(low, r.low), rnd.add_up(up, r.up)); + } + return *this; +} + +template inline +interval& interval::operator+=(const T& r) +{ + if (interval_lib::detail::test_input(*this, r)) + set_empty(); + else { + typename Policies::rounding rnd; + set(rnd.add_down(low, r), rnd.add_up(up, r)); + } + return *this; +} + +template inline +interval& interval::operator-=(const interval& r) +{ + if (interval_lib::detail::test_input(*this, r)) + set_empty(); + else { + typename Policies::rounding rnd; + set(rnd.sub_down(low, r.up), rnd.sub_up(up, r.low)); + } + return *this; +} + +template inline +interval& interval::operator-=(const T& r) +{ + if (interval_lib::detail::test_input(*this, r)) + set_empty(); + else { + typename Policies::rounding rnd; + set(rnd.sub_down(low, r), rnd.sub_up(up, r)); + } + return *this; +} + +template inline +interval& interval::operator*=(const interval& r) +{ + return *this = *this * r; +} + +template inline +interval& interval::operator*=(const T& r) +{ + return *this = r * *this; +} + +template inline +interval& interval::operator/=(const interval& r) +{ + return *this = *this / r; +} + +template inline +interval& interval::operator/=(const T& r) +{ + return *this = *this / r; +} + +template inline +interval operator+(const interval& x, + const interval& y) +{ + if (interval_lib::detail::test_input(x, y)) + return interval::empty(); + typename Policies::rounding rnd; + return interval(rnd.add_down(x.lower(), y.lower()), + rnd.add_up (x.upper(), y.upper()), true); +} + +template inline +interval operator+(const T& x, const interval& y) +{ + if (interval_lib::detail::test_input(x, y)) + return interval::empty(); + typename Policies::rounding rnd; + return interval(rnd.add_down(x, y.lower()), + rnd.add_up (x, y.upper()), true); +} + +template inline +interval operator+(const interval& x, const T& y) +{ return y + x; } + +template inline +interval operator-(const interval& x, + const interval& y) +{ + if (interval_lib::detail::test_input(x, y)) + return interval::empty(); + typename Policies::rounding rnd; + return interval(rnd.sub_down(x.lower(), y.upper()), + rnd.sub_up (x.upper(), y.lower()), true); +} + +template inline +interval operator-(const T& x, const interval& y) +{ + if (interval_lib::detail::test_input(x, y)) + return interval::empty(); + typename Policies::rounding rnd; + return interval(rnd.sub_down(x, y.upper()), + rnd.sub_up (x, y.lower()), true); +} + +template inline +interval operator-(const interval& x, const T& y) +{ + if (interval_lib::detail::test_input(x, y)) + return interval::empty(); + typename Policies::rounding rnd; + return interval(rnd.sub_down(x.lower(), y), + rnd.sub_up (x.upper(), y), true); +} + +template inline +interval operator*(const interval& x, + const interval& y) +{ + BOOST_USING_STD_MIN(); + BOOST_USING_STD_MAX(); + typedef interval I; + if (interval_lib::detail::test_input(x, y)) + return I::empty(); + typename Policies::rounding rnd; + const T& xl = x.lower(); + const T& xu = x.upper(); + const T& yl = y.lower(); + const T& yu = y.upper(); + + if (interval_lib::user::is_neg(xl)) + if (interval_lib::user::is_pos(xu)) + if (interval_lib::user::is_neg(yl)) + if (interval_lib::user::is_pos(yu)) // M * M + return I(min BOOST_PREVENT_MACRO_SUBSTITUTION(rnd.mul_down(xl, yu), rnd.mul_down(xu, yl)), + max BOOST_PREVENT_MACRO_SUBSTITUTION(rnd.mul_up (xl, yl), rnd.mul_up (xu, yu)), true); + else // M * N + return I(rnd.mul_down(xu, yl), rnd.mul_up(xl, yl), true); + else + if (interval_lib::user::is_pos(yu)) // M * P + return I(rnd.mul_down(xl, yu), rnd.mul_up(xu, yu), true); + else // M * Z + return I(static_cast(0), static_cast(0), true); + else + if (interval_lib::user::is_neg(yl)) + if (interval_lib::user::is_pos(yu)) // N * M + return I(rnd.mul_down(xl, yu), rnd.mul_up(xl, yl), true); + else // N * N + return I(rnd.mul_down(xu, yu), rnd.mul_up(xl, yl), true); + else + if (interval_lib::user::is_pos(yu)) // N * P + return I(rnd.mul_down(xl, yu), rnd.mul_up(xu, yl), true); + else // N * Z + return I(static_cast(0), static_cast(0), true); + else + if (interval_lib::user::is_pos(xu)) + if (interval_lib::user::is_neg(yl)) + if (interval_lib::user::is_pos(yu)) // P * M + return I(rnd.mul_down(xu, yl), rnd.mul_up(xu, yu), true); + else // P * N + return I(rnd.mul_down(xu, yl), rnd.mul_up(xl, yu), true); + else + if (interval_lib::user::is_pos(yu)) // P * P + return I(rnd.mul_down(xl, yl), rnd.mul_up(xu, yu), true); + else // P * Z + return I(static_cast(0), static_cast(0), true); + else // Z * ? + return I(static_cast(0), static_cast(0), true); +} + +template inline +interval operator*(const T& x, const interval& y) +{ + typedef interval I; + if (interval_lib::detail::test_input(x, y)) + return I::empty(); + typename Policies::rounding rnd; + const T& yl = y.lower(); + const T& yu = y.upper(); + // x is supposed not to be infinite + if (interval_lib::user::is_neg(x)) + return I(rnd.mul_down(x, yu), rnd.mul_up(x, yl), true); + else if (interval_lib::user::is_zero(x)) + return I(static_cast(0), static_cast(0), true); + else + return I(rnd.mul_down(x, yl), rnd.mul_up(x, yu), true); +} + +template inline +interval operator*(const interval& x, const T& y) +{ return y * x; } + +template inline +interval operator/(const interval& x, + const interval& y) +{ + if (interval_lib::detail::test_input(x, y)) + return interval::empty(); + if (zero_in(y)) + if (!interval_lib::user::is_zero(y.lower())) + if (!interval_lib::user::is_zero(y.upper())) + return interval_lib::detail::div_zero(x); + else + return interval_lib::detail::div_negative(x, y.lower()); + else + if (!interval_lib::user::is_zero(y.upper())) + return interval_lib::detail::div_positive(x, y.upper()); + else + return interval::empty(); + else + return interval_lib::detail::div_non_zero(x, y); +} + +template inline +interval operator/(const T& x, const interval& y) +{ + if (interval_lib::detail::test_input(x, y)) + return interval::empty(); + if (zero_in(y)) + if (!interval_lib::user::is_zero(y.lower())) + if (!interval_lib::user::is_zero(y.upper())) + return interval_lib::detail::div_zero(x); + else + return interval_lib::detail::div_negative(x, y.lower()); + else + if (!interval_lib::user::is_zero(y.upper())) + return interval_lib::detail::div_positive(x, y.upper()); + else + return interval::empty(); + else + return interval_lib::detail::div_non_zero(x, y); +} + +template inline +interval operator/(const interval& x, const T& y) +{ + if (interval_lib::detail::test_input(x, y) || interval_lib::user::is_zero(y)) + return interval::empty(); + typename Policies::rounding rnd; + const T& xl = x.lower(); + const T& xu = x.upper(); + if (interval_lib::user::is_neg(y)) + return interval(rnd.div_down(xu, y), rnd.div_up(xl, y), true); + else + return interval(rnd.div_down(xl, y), rnd.div_up(xu, y), true); +} + +} // namespace numeric +} // namespace boost + +#endif // BOOST_NUMERIC_INTERVAL_ARITH_HPP diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/arith2.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/arith2.hpp new file mode 100644 index 0000000000..5501929e4b --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/arith2.hpp @@ -0,0 +1,305 @@ +/* Boost interval/arith2.hpp template implementation file + * + * This header provides some auxiliary arithmetic + * functions: fmod, sqrt, square, pov, inverse and + * a multi-interval division. + * + * Copyright 2002-2003 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion + * + * 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) + */ + +#ifndef BOOST_NUMERIC_INTERVAL_ARITH2_HPP +#define BOOST_NUMERIC_INTERVAL_ARITH2_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost { +namespace numeric { + +template inline +interval fmod(const interval& x, + const interval& y) +{ + if (interval_lib::detail::test_input(x, y)) + return interval::empty(); + typename Policies::rounding rnd; + typedef typename interval_lib::unprotect >::type I; + T const &yb = interval_lib::user::is_neg(x.lower()) ? y.lower() : y.upper(); + T n = rnd.int_down(rnd.div_down(x.lower(), yb)); + return (const I&)x - n * (const I&)y; +} + +template inline +interval fmod(const interval& x, const T& y) +{ + if (interval_lib::detail::test_input(x, y)) + return interval::empty(); + typename Policies::rounding rnd; + typedef typename interval_lib::unprotect >::type I; + T n = rnd.int_down(rnd.div_down(x.lower(), y)); + return (const I&)x - n * I(y); +} + +template inline +interval fmod(const T& x, const interval& y) +{ + if (interval_lib::detail::test_input(x, y)) + return interval::empty(); + typename Policies::rounding rnd; + typedef typename interval_lib::unprotect >::type I; + T const &yb = interval_lib::user::is_neg(x) ? y.lower() : y.upper(); + T n = rnd.int_down(rnd.div_down(x, yb)); + return x - n * (const I&)y; +} + +namespace interval_lib { + +template inline +interval division_part1(const interval& x, + const interval& y, bool& b) +{ + typedef interval I; + b = false; + if (detail::test_input(x, y)) + return I::empty(); + if (zero_in(y)) + if (!user::is_zero(y.lower())) + if (!user::is_zero(y.upper())) + return detail::div_zero_part1(x, y, b); + else + return detail::div_negative(x, y.lower()); + else + if (!user::is_zero(y.upper())) + return detail::div_positive(x, y.upper()); + else + return I::empty(); + else + return detail::div_non_zero(x, y); +} + +template inline +interval division_part2(const interval& x, + const interval& y, bool b = true) +{ + if (!b) return interval::empty(); + return detail::div_zero_part2(x, y); +} + +template inline +interval multiplicative_inverse(const interval& x) +{ + typedef interval I; + if (detail::test_input(x)) + return I::empty(); + T one = static_cast(1); + typename Policies::rounding rnd; + if (zero_in(x)) { + typedef typename Policies::checking checking; + if (!user::is_zero(x.lower())) + if (!user::is_zero(x.upper())) + return I::whole(); + else + return I(checking::neg_inf(), rnd.div_up(one, x.lower()), true); + else + if (!user::is_zero(x.upper())) + return I(rnd.div_down(one, x.upper()), checking::pos_inf(), true); + else + return I::empty(); + } else + return I(rnd.div_down(one, x.upper()), rnd.div_up(one, x.lower()), true); +} + +namespace detail { + +template inline +T pow_dn(const T& x_, int pwr, Rounding& rnd) // x and pwr are positive +{ + T x = x_; + T y = (pwr & 1) ? x_ : static_cast(1); + pwr >>= 1; + while (pwr > 0) { + x = rnd.mul_down(x, x); + if (pwr & 1) y = rnd.mul_down(x, y); + pwr >>= 1; + } + return y; +} + +template inline +T pow_up(const T& x_, int pwr, Rounding& rnd) // x and pwr are positive +{ + T x = x_; + T y = (pwr & 1) ? x_ : static_cast(1); + pwr >>= 1; + while (pwr > 0) { + x = rnd.mul_up(x, x); + if (pwr & 1) y = rnd.mul_up(x, y); + pwr >>= 1; + } + return y; +} + +} // namespace detail +} // namespace interval_lib + +template inline +interval pow(const interval& x, int pwr) +{ + BOOST_USING_STD_MAX(); + using interval_lib::detail::pow_dn; + using interval_lib::detail::pow_up; + typedef interval I; + + if (interval_lib::detail::test_input(x)) + return I::empty(); + + if (pwr == 0) + if (interval_lib::user::is_zero(x.lower()) + && interval_lib::user::is_zero(x.upper())) + return I::empty(); + else + return I(static_cast(1)); + else if (pwr < 0) + return interval_lib::multiplicative_inverse(pow(x, -pwr)); + + typename Policies::rounding rnd; + + if (interval_lib::user::is_neg(x.upper())) { // [-2,-1] + T yl = pow_dn(static_cast(-x.upper()), pwr, rnd); + T yu = pow_up(static_cast(-x.lower()), pwr, rnd); + if (pwr & 1) // [-2,-1]^1 + return I(-yu, -yl, true); + else // [-2,-1]^2 + return I(yl, yu, true); + } else if (interval_lib::user::is_neg(x.lower())) { // [-1,1] + if (pwr & 1) { // [-1,1]^1 + return I(-pow_up(static_cast(-x.lower()), pwr, rnd), pow_up(x.upper(), pwr, rnd), true); + } else { // [-1,1]^2 + return I(static_cast(0), pow_up(max BOOST_PREVENT_MACRO_SUBSTITUTION(static_cast(-x.lower()), x.upper()), pwr, rnd), true); + } + } else { // [1,2] + return I(pow_dn(x.lower(), pwr, rnd), pow_up(x.upper(), pwr, rnd), true); + } +} + +template inline +interval sqrt(const interval& x) +{ + typedef interval I; + if (interval_lib::detail::test_input(x) || interval_lib::user::is_neg(x.upper())) + return I::empty(); + typename Policies::rounding rnd; + T l = !interval_lib::user::is_pos(x.lower()) ? static_cast(0) : rnd.sqrt_down(x.lower()); + return I(l, rnd.sqrt_up(x.upper()), true); +} + +template inline +interval square(const interval& x) +{ + typedef interval I; + if (interval_lib::detail::test_input(x)) + return I::empty(); + typename Policies::rounding rnd; + const T& xl = x.lower(); + const T& xu = x.upper(); + if (interval_lib::user::is_neg(xu)) + return I(rnd.mul_down(xu, xu), rnd.mul_up(xl, xl), true); + else if (interval_lib::user::is_pos(x.lower())) + return I(rnd.mul_down(xl, xl), rnd.mul_up(xu, xu), true); + else + return I(static_cast(0), (-xl > xu ? rnd.mul_up(xl, xl) : rnd.mul_up(xu, xu)), true); +} + +namespace interval_lib { +namespace detail { + +template< class I > inline +I root_aux(typename I::base_type const &x, int k) // x and k are bigger than one +{ + typedef typename I::base_type T; + T tk(k); + I y(static_cast(1), x, true); + for(;;) { + T y0 = median(y); + I yy = intersect(y, y0 - (pow(I(y0, y0, true), k) - x) / (tk * pow(y, k - 1))); + if (equal(y, yy)) return y; + y = yy; + } +} + +template< class I > inline // x is positive and k bigger than one +typename I::base_type root_aux_dn(typename I::base_type const &x, int k) +{ + typedef typename I::base_type T; + typedef typename I::traits_type Policies; + typename Policies::rounding rnd; + T one(1); + if (x > one) return root_aux(x, k).lower(); + if (x == one) return one; + return rnd.div_down(one, root_aux(rnd.div_up(one, x), k).upper()); +} + +template< class I > inline // x is positive and k bigger than one +typename I::base_type root_aux_up(typename I::base_type const &x, int k) +{ + typedef typename I::base_type T; + typedef typename I::traits_type Policies; + typename Policies::rounding rnd; + T one(1); + if (x > one) return root_aux(x, k).upper(); + if (x == one) return one; + return rnd.div_up(one, root_aux(rnd.div_down(one, x), k).lower()); +} + +} // namespace detail +} // namespace interval_lib + +template< class T, class Policies > inline +interval nth_root(interval const &x, int k) +{ + typedef interval I; + if (interval_lib::detail::test_input(x)) return I::empty(); + assert(k > 0); + if (k == 1) return x; + typename Policies::rounding rnd; + typedef typename interval_lib::unprotect::type R; + if (!interval_lib::user::is_pos(x.upper())) { + if (interval_lib::user::is_zero(x.upper())) { + T zero(0); + if (!(k & 1) || interval_lib::user::is_zero(x.lower())) // [-1,0]^/2 or [0,0] + return I(zero, zero, true); + else // [-1,0]^/3 + return I(-interval_lib::detail::root_aux_up(-x.lower(), k), zero, true); + } else if (!(k & 1)) // [-2,-1]^/2 + return I::empty(); + else { // [-2,-1]^/3 + return I(-interval_lib::detail::root_aux_up(-x.lower(), k), + -interval_lib::detail::root_aux_dn(-x.upper(), k), true); + } + } + T u = interval_lib::detail::root_aux_up(x.upper(), k); + if (!interval_lib::user::is_pos(x.lower())) + if (!(k & 1) || interval_lib::user::is_zero(x.lower())) // [-1,1]^/2 or [0,1] + return I(static_cast(0), u, true); + else // [-1,1]^/3 + return I(-interval_lib::detail::root_aux_up(-x.lower(), k), u, true); + else // [1,2] + return I(interval_lib::detail::root_aux_dn(x.lower(), k), u, true); +} + +} // namespace numeric +} // namespace boost + +#endif // BOOST_NUMERIC_INTERVAL_ARITH2_HPP diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/arith3.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/arith3.hpp new file mode 100644 index 0000000000..518e6182f3 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/arith3.hpp @@ -0,0 +1,69 @@ +/* Boost interval/arith3.hpp template implementation file + * + * This headers provides arithmetical functions + * which compute an interval given some base + * numbers. The resulting interval encloses the + * real result of the arithmetic operation. + * + * Copyright 2003 Guillaume Melquiond + * + * 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) + */ + +#ifndef BOOST_NUMERIC_INTERVAL_ARITH3_HPP +#define BOOST_NUMERIC_INTERVAL_ARITH3_HPP + +#include +#include + +namespace boost { +namespace numeric { +namespace interval_lib { + +template inline +I add(const typename I::base_type& x, const typename I::base_type& y) +{ + typedef typename I::traits_type Policies; + if (detail::test_input(x, y)) + return I::empty(); + typename Policies::rounding rnd; + return I(rnd.add_down(x, y), rnd.add_up(x, y), true); +} + +template inline +I sub(const typename I::base_type& x, const typename I::base_type& y) +{ + typedef typename I::traits_type Policies; + if (detail::test_input(x, y)) + return I::empty(); + typename Policies::rounding rnd; + return I(rnd.sub_down(x, y), rnd.sub_up(x, y), true); +} + +template inline +I mul(const typename I::base_type& x, const typename I::base_type& y) +{ + typedef typename I::traits_type Policies; + if (detail::test_input(x, y)) + return I::empty(); + typename Policies::rounding rnd; + return I(rnd.mul_down(x, y), rnd.mul_up(x, y), true); +} + +template inline +I div(const typename I::base_type& x, const typename I::base_type& y) +{ + typedef typename I::traits_type Policies; + if (detail::test_input(x, y) || user::is_zero(y)) + return I::empty(); + typename Policies::rounding rnd; + return I(rnd.div_down(x, y), rnd.div_up(x, y), true); +} + +} // namespace interval_lib +} // namespace numeric +} // namespace boost + +#endif // BOOST_NUMERIC_INTERVAL_ARITH3_HPP diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/checking.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/checking.hpp new file mode 100644 index 0000000000..2db486a0be --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/checking.hpp @@ -0,0 +1,130 @@ +/* Boost interval/checking.hpp template implementation file + * + * Copyright 2002 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion + * + * 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) + */ + +#ifndef BOOST_NUMERIC_INTERVAL_CHECKING_HPP +#define BOOST_NUMERIC_INTERVAL_CHECKING_HPP + +#include +#include +#include +#include + +namespace boost { +namespace numeric { +namespace interval_lib { + +struct exception_create_empty +{ + void operator()() + { + throw std::runtime_error("boost::interval: empty interval created"); + } +}; + +struct exception_invalid_number +{ + void operator()() + { + throw std::invalid_argument("boost::interval: invalid number"); + } +}; + +template +struct checking_base +{ + static T pos_inf() + { + assert(std::numeric_limits::has_infinity); + return std::numeric_limits::infinity(); + } + static T neg_inf() + { + assert(std::numeric_limits::has_infinity); + return -std::numeric_limits::infinity(); + } + static T nan() + { + assert(std::numeric_limits::has_quiet_NaN); + return std::numeric_limits::quiet_NaN(); + } + static bool is_nan(const T& x) + { + return std::numeric_limits::has_quiet_NaN && (x != x); + } + static T empty_lower() + { + return (std::numeric_limits::has_quiet_NaN ? + std::numeric_limits::quiet_NaN() : static_cast(1)); + } + static T empty_upper() + { + return (std::numeric_limits::has_quiet_NaN ? + std::numeric_limits::quiet_NaN() : static_cast(0)); + } + static bool is_empty(const T& l, const T& u) + { + return !(l <= u); // safety for partial orders + } +}; + +template, + class Exception = exception_create_empty> +struct checking_no_empty: Checking +{ + static T nan() + { + assert(false); + return Checking::nan(); + } + static T empty_lower() + { + Exception()(); + return Checking::empty_lower(); + } + static T empty_upper() + { + Exception()(); + return Checking::empty_upper(); + } + static bool is_empty(const T&, const T&) + { + return false; + } +}; + +template > +struct checking_no_nan: Checking +{ + static bool is_nan(const T&) + { + return false; + } +}; + +template, + class Exception = exception_invalid_number> +struct checking_catch_nan: Checking +{ + static bool is_nan(const T& x) + { + if (Checking::is_nan(x)) Exception()(); + return false; + } +}; + +template +struct checking_strict: + checking_no_nan > +{}; + +} // namespace interval_lib +} // namespace numeric +} // namespace boost + +#endif // BOOST_NUMERIC_INTERVAL_CHECKING_HPP diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/compare.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/compare.hpp new file mode 100644 index 0000000000..f21753e711 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/compare.hpp @@ -0,0 +1,19 @@ +/* Boost interval/compare.hpp template implementation file + * + * Copyright 2002 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion + * + * 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) + */ + +#ifndef BOOST_NUMERIC_INTERVAL_COMPARE_HPP +#define BOOST_NUMERIC_INTERVAL_COMPARE_HPP + +#include +#include +#include +#include +#include + +#endif // BOOST_NUMERIC_INTERVAL_COMPARE_HPP diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/compare/certain.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/compare/certain.hpp new file mode 100644 index 0000000000..9232d5cd88 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/compare/certain.hpp @@ -0,0 +1,113 @@ +/* Boost interval/compare/certain.hpp template implementation file + * + * Copyright 2003 Guillaume Melquiond + * + * 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) + */ + +#ifndef BOOST_NUMERIC_INTERVAL_COMPARE_CERTAIN_HPP +#define BOOST_NUMERIC_INTERVAL_COMPARE_CERTAIN_HPP + +#include +#include + +namespace boost { +namespace numeric { +namespace interval_lib { +namespace compare { +namespace certain { + +template inline +bool operator<(const interval& x, const interval& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + return x.upper() < y.lower(); +} + +template inline +bool operator<(const interval& x, const T& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + return x.upper() < y; +} + +template inline +bool operator<=(const interval& x, const interval& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + return x.upper() <= y.lower(); +} + +template inline +bool operator<=(const interval& x, const T& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + return x.upper() <= y; +} + +template inline +bool operator>(const interval& x, const interval& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + return x.lower() > y.upper(); +} + +template inline +bool operator>(const interval& x, const T& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + return x.lower() > y; +} + +template inline +bool operator>=(const interval& x, const interval& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + return x.lower() >= y.upper(); +} + +template inline +bool operator>=(const interval& x, const T& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + return x.lower() >= y; +} + +template inline +bool operator==(const interval& x, const interval& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + return x.upper() == y.lower() && x.lower() == y.upper(); +} + +template inline +bool operator==(const interval& x, const T& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + return x.upper() == y && x.lower() == y; +} + +template inline +bool operator!=(const interval& x, const interval& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + return x.upper() < y.lower() || x.lower() > y.upper(); +} + +template inline +bool operator!=(const interval& x, const T& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + return x.upper() < y || x.lower() > y; +} + +} // namespace certain +} // namespace compare +} // namespace interval_lib +} // namespace numeric +} // namespace boost + + +#endif // BOOST_NUMERIC_INTERVAL_COMPARE_CERTAIN_HPP diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/compare/explicit.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/compare/explicit.hpp new file mode 100644 index 0000000000..8c68be8916 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/compare/explicit.hpp @@ -0,0 +1,248 @@ +/* Boost interval/compare/explicit.hpp template implementation file + * + * Copyright 2000 Jens Maurer + * Copyright 2002 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion + * + * 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) + */ + +#ifndef BOOST_NUMERIC_INTERVAL_COMPARE_EXPLICIT_HPP +#define BOOST_NUMERIC_INTERVAL_COMPARE_EXPLICIT_HPP + +#include + +namespace boost { +namespace numeric { +namespace interval_lib { + +/* + * Certainly... operations + */ + +template inline +bool cerlt(const interval& x, const interval& y) +{ + return x.upper() < y.lower(); +} + +template inline +bool cerlt(const interval& x, const T& y) +{ + return x.upper() < y; +} + +template inline +bool cerlt(const T& x, const interval& y) +{ + return x < y.lower(); +} + +template inline +bool cerle(const interval& x, const interval& y) +{ + return x.upper() <= y.lower(); +} + +template inline +bool cerle(const interval& x, const T& y) +{ + return x.upper() <= y; +} + +template inline +bool cerle(const T& x, const interval& y) +{ + return x <= y.lower(); +} + +template inline +bool cergt(const interval& x, const interval& y) +{ + return x.lower() > y.upper(); +} + +template inline +bool cergt(const interval& x, const T& y) +{ + return x.lower() > y; +} + +template inline +bool cergt(const T& x, const interval& y) +{ + return x > y.upper(); +} + +template inline +bool cerge(const interval& x, const interval& y) +{ + return x.lower() >= y.upper(); +} + +template inline +bool cerge(const interval& x, const T& y) +{ + return x.lower() >= y; +} + +template inline +bool cerge(const T& x, const interval& y) +{ + return x >= y.upper(); +} + +template inline +bool cereq(const interval& x, const interval& y) +{ + return x.lower() == y.upper() && y.lower() == x.upper(); +} + +template inline +bool cereq(const interval& x, const T& y) +{ + return x.lower() == y && x.upper() == y; +} + +template inline +bool cereq(const T& x, const interval& y) +{ + return x == y.lower() && x == y.upper(); +} + +template inline +bool cerne(const interval& x, const interval& y) +{ + return x.upper() < y.lower() || y.upper() < x.lower(); +} + +template inline +bool cerne(const interval& x, const T& y) +{ + return x.upper() < y || y < x.lower(); +} + +template inline +bool cerne(const T& x, const interval& y) +{ + return x < y.lower() || y.upper() < x; +} + +/* + * Possibly... comparisons + */ + +template inline +bool poslt(const interval& x, const interval& y) +{ + return x.lower() < y.upper(); +} + +template inline +bool poslt(const interval& x, const T& y) +{ + return x.lower() < y; +} + +template inline +bool poslt(const T& x, const interval& y) +{ + return x < y.upper(); +} + +template inline +bool posle(const interval& x, const interval& y) +{ + return x.lower() <= y.upper(); +} + +template inline +bool posle(const interval& x, const T& y) +{ + return x.lower() <= y; +} + +template inline +bool posle(const T& x, const interval& y) +{ + return x <= y.upper(); +} + +template inline +bool posgt(const interval& x, const interval& y) +{ + return x.upper() > y.lower(); +} + +template inline +bool posgt(const interval& x, const T& y) +{ + return x.upper() > y; +} + +template inline +bool posgt(const T& x, const interval & y) +{ + return x > y.lower(); +} + +template inline +bool posge(const interval& x, const interval& y) +{ + return x.upper() >= y.lower(); +} + +template inline +bool posge(const interval& x, const T& y) +{ + return x.upper() >= y; +} + +template inline +bool posge(const T& x, const interval& y) +{ + return x >= y.lower(); +} + +template inline +bool poseq(const interval& x, const interval& y) +{ + return x.upper() >= y.lower() && y.upper() >= x.lower(); +} + +template inline +bool poseq(const interval& x, const T& y) +{ + return x.upper() >= y && y >= x.lower(); +} + +template inline +bool poseq(const T& x, const interval& y) +{ + return x >= y.lower() && y.upper() >= x; +} + +template inline +bool posne(const interval& x, const interval& y) +{ + return x.upper() != y.lower() || y.upper() != x.lower(); +} + +template inline +bool posne(const interval& x, const T& y) +{ + return x.upper() != y || y != x.lower(); +} + +template inline +bool posne(const T& x, const interval& y) +{ + return x != y.lower() || y.upper() != x; +} + +} // namespace interval_lib +} // namespace numeric +} //namespace boost + +#endif // BOOST_NUMERIC_INTERVAL_COMPARE_EXPLICIT_HPP diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/compare/lexicographic.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/compare/lexicographic.hpp new file mode 100644 index 0000000000..03f6036d2b --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/compare/lexicographic.hpp @@ -0,0 +1,122 @@ +/* Boost interval/compare/lexicographic.hpp template implementation file + * + * Copyright 2002-2003 Guillaume Melquiond + * + * 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) + */ + +#ifndef BOOST_NUMERIC_INTERVAL_COMPARE_LEXICOGRAPHIC_HPP +#define BOOST_NUMERIC_INTERVAL_COMPARE_LEXICOGRAPHIC_HPP + +#include +#include + +namespace boost { +namespace numeric { +namespace interval_lib { +namespace compare { +namespace lexicographic { + +template inline +bool operator<(const interval& x, const interval& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + const T& xl = x.lower(); + const T& yl = y.lower(); + return xl < yl || (xl == yl && x.upper() < y.upper()); +} + +template inline +bool operator<(const interval& x, const T& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + return x.lower() < y; +} + +template inline +bool operator<=(const interval& x, const interval& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + const T& xl = x.lower(); + const T& yl = y.lower(); + return xl < yl || (xl == yl && x.upper() <= y.upper()); +} + +template inline +bool operator<=(const interval& x, const T& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + const T& xl = x.lower(); + return xl < y || (xl == y && x.upper() <= y); +} + +template inline +bool operator>(const interval& x, const interval& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + const T& xl = x.lower(); + const T& yl = y.lower(); + return xl > yl || (xl == yl && x.upper() > y.upper()); +} + +template inline +bool operator>(const interval& x, const T& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + const T& xl = x.lower(); + return xl > y || (xl == y && x.upper() > y); +} + +template inline +bool operator>=(const interval& x, const interval& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + const T& xl = x.lower(); + const T& yl = y.lower(); + return xl > yl || (xl == yl && x.upper() >= y.upper()); +} + +template inline +bool operator>=(const interval& x, const T& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + return x.lower() >= y; +} + +template inline +bool operator==(const interval& x, const interval& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + return x.lower() == y.lower() && x.upper() == y.upper(); +} + +template inline +bool operator==(const interval& x, const T& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + return x.lower() == y && x.upper() == y; +} + +template inline +bool operator!=(const interval& x, const interval& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + return x.lower() != y.lower() || x.upper() != y.upper(); +} + +template inline +bool operator!=(const interval& x, const T& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + return x.lower() != y || x.upper() != y; +} + +} // namespace lexicographic +} // namespace compare +} // namespace interval_lib +} // namespace numeric +} // namespace boost + +#endif // BOOST_NUMERIC_INTERVAL_COMPARE_LEXICOGRAPHIC_HPP diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/compare/possible.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/compare/possible.hpp new file mode 100644 index 0000000000..59bec31b9f --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/compare/possible.hpp @@ -0,0 +1,113 @@ +/* Boost interval/compare/possible.hpp template implementation file + * + * Copyright 2003 Guillaume Melquiond + * + * 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) + */ + +#ifndef BOOST_NUMERIC_INTERVAL_COMPARE_POSSIBLE_HPP +#define BOOST_NUMERIC_INTERVAL_COMPARE_POSSIBLE_HPP + +#include +#include + +namespace boost { +namespace numeric { +namespace interval_lib { +namespace compare { +namespace possible { + +template inline +bool operator<(const interval& x, const interval& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + return x.lower() < y.upper(); +} + +template inline +bool operator<(const interval& x, const T& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + return x.lower() < y; +} + +template inline +bool operator<=(const interval& x, const interval& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + return x.lower() <= y.upper(); +} + +template inline +bool operator<=(const interval& x, const T& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + return x.lower() <= y; +} + +template inline +bool operator>(const interval& x, const interval& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + return x.upper() > y.lower(); +} + +template inline +bool operator>(const interval& x, const T& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + return x.upper() > y; +} + +template inline +bool operator>=(const interval& x, const interval& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + return x.upper() >= y.lower(); +} + +template inline +bool operator>=(const interval& x, const T& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + return x.upper() >= y; +} + +template inline +bool operator==(const interval& x, const interval& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + return x.lower() <= y.upper() && x.upper() >= y.lower(); +} + +template inline +bool operator==(const interval& x, const T& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + return x.lower() <= y && x.upper() >= y; +} + +template inline +bool operator!=(const interval& x, const interval& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + return x.lower() != y.upper() || x.upper() != y.lower(); +} + +template inline +bool operator!=(const interval& x, const T& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + return x.lower() != y || x.upper() != y; +} + +} // namespace possible +} // namespace compare +} // namespace interval_lib +} // namespace numeric +} // namespace boost + + +#endif // BOOST_NUMERIC_INTERVAL_COMPARE_POSSIBLE_HPP diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/compare/set.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/compare/set.hpp new file mode 100644 index 0000000000..aa4f1716b2 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/compare/set.hpp @@ -0,0 +1,101 @@ +/* Boost interval/compare/set.hpp template implementation file + * + * Copyright 2002-2003 Guillaume Melquiond + * + * 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) + */ + +#ifndef BOOST_NUMERIC_INTERVAL_COMPARE_SET_HPP +#define BOOST_NUMERIC_INTERVAL_COMPARE_SET_HPP + +#include +#include +#include + +namespace boost { +namespace numeric { +namespace interval_lib { +namespace compare { +namespace set { + +template inline +bool operator<(const interval& x, const interval& y) +{ + return proper_subset(x, y); +} + +template inline +bool operator<(const interval& x, const T& y) +{ + throw comparison_error(); +} + +template inline +bool operator<=(const interval& x, const interval& y) +{ + return subset(x, y); +} + +template inline +bool operator<=(const interval& x, const T& y) +{ + throw comparison_error(); +} + +template inline +bool operator>(const interval& x, const interval& y) +{ + return proper_subset(y, x); +} + +template inline +bool operator>(const interval& x, const T& y) +{ + throw comparison_error(); +} + +template inline +bool operator>=(const interval& x, const interval& y) +{ + return subset(y, x); +} + +template inline +bool operator>=(const interval& x, const T& y) +{ + throw comparison_error(); +} + +template inline +bool operator==(const interval& x, const interval& y) +{ + return equal(y, x); +} + +template inline +bool operator==(const interval& x, const T& y) +{ + throw comparison_error(); +} + +template inline +bool operator!=(const interval& x, const interval& y) +{ + return !equal(y, x); +} + +template inline +bool operator!=(const interval& x, const T& y) +{ + throw comparison_error(); +} + +} // namespace set +} // namespace compare +} // namespace interval_lib +} // namespace numeric +} // namespace boost + +#endif // BOOST_NUMERIC_INTERVAL_COMPARE_SET_HPP diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/compare/tribool.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/compare/tribool.hpp new file mode 100644 index 0000000000..6e4a83e275 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/compare/tribool.hpp @@ -0,0 +1,138 @@ +/* Boost interval/compare/tribool.hpp template implementation file + * + * Copyright 2002-2003 Guillaume Melquiond + * + * 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) + */ + +#ifndef BOOST_NUMERIC_INTERVAL_COMPARE_TRIBOOL_HPP +#define BOOST_NUMERIC_INTERVAL_COMPARE_TRIBOOL_HPP + +#include +#include +#include + +namespace boost { +namespace numeric { +namespace interval_lib { +namespace compare { +namespace tribool { + +template inline +logic::tribool operator<(const interval& x, const interval& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + if (x.upper() < y.lower()) return true; + if (x.lower() >= y.upper()) return false; + return logic::indeterminate; +} + +template inline +logic::tribool operator<(const interval& x, const T& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + if (x.upper() < y) return true; + if (x.lower() >= y) return false; + return logic::indeterminate; +} + +template inline +logic::tribool operator<=(const interval& x, const interval& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + if (x.upper() <= y.lower()) return true; + if (x.lower() > y.upper()) return false; + return logic::indeterminate; +} + +template inline +logic::tribool operator<=(const interval& x, const T& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + if (x.upper() <= y) return true; + if (x.lower() > y) return false; + return logic::indeterminate; +} + +template inline +logic::tribool operator>(const interval& x, const interval& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + if (x.lower() > y.upper()) return true; + if (x.upper() <= y.lower()) return false; + return logic::indeterminate; +} + +template inline +logic::tribool operator>(const interval& x, const T& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + if (x.lower() > y) return true; + if (x.upper() <= y) return false; + return logic::indeterminate; +} + +template inline +logic::tribool operator>=(const interval& x, const interval& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + if (x.lower() >= y.upper()) return true; + if (x.upper() < y.lower()) return false; + return logic::indeterminate; +} + +template inline +logic::tribool operator>=(const interval& x, const T& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + if (x.lower() >= y) return true; + if (x.upper() < y) return false; + return logic::indeterminate; +} + +template inline +logic::tribool operator==(const interval& x, const interval& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + if (x.upper() == y.lower() && x.lower() == y.upper()) return true; + if (x.upper() < y.lower() || x.lower() > y.upper()) return false; + return logic::indeterminate; +} + +template inline +logic::tribool operator==(const interval& x, const T& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + if (x.upper() == y && x.lower() == y) return true; + if (x.upper() < y || x.lower() > y) return false; + return logic::indeterminate; +} + +template inline +logic::tribool operator!=(const interval& x, const interval& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + if (x.upper() < y.lower() || x.lower() > y.upper()) return true; + if (x.upper() == y.lower() && x.lower() == y.upper()) return false; + return logic::indeterminate; +} + +template inline +logic::tribool operator!=(const interval& x, const T& y) +{ + if (detail::test_input(x, y)) throw comparison_error(); + if (x.upper() < y || x.lower() > y) return true; + if (x.upper() == y && x.lower() == y) return false; + return logic::indeterminate; +} + +} // namespace tribool +} // namespace compare +} // namespace interval_lib +} // namespace numeric +} // namespace boost + + +#endif // BOOST_NUMERIC_INTERVAL_COMPARE_TRIBOOL_HPP diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/constants.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/constants.hpp new file mode 100644 index 0000000000..a3a42efece --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/constants.hpp @@ -0,0 +1,85 @@ +/* Boost interval/constants.hpp template implementation file + * + * Copyright 2002 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion + * + * 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) + */ + +#ifndef BOOST_NUMERIC_INTERVAL_CONSTANTS_HPP +#define BOOST_NUMERIC_INTERVAL_CONSTANTS_HPP + +namespace boost { +namespace numeric { +namespace interval_lib { +namespace constants { + +// These constants should be exactly computed. +// Decimal representations wouldn't do it since the standard doesn't +// specify the rounding (even nearest) that should be used. + +static const float pi_f_l = 13176794.0f/(1<<22); +static const float pi_f_u = 13176795.0f/(1<<22); +static const double pi_d_l = (3373259426.0 + 273688.0 / (1<<21)) / (1<<30); +static const double pi_d_u = (3373259426.0 + 273689.0 / (1<<21)) / (1<<30); + +template inline T pi_lower() { return 3; } +template inline T pi_upper() { return 4; } +template inline T pi_half_lower() { return 1; } +template inline T pi_half_upper() { return 2; } +template inline T pi_twice_lower() { return 6; } +template inline T pi_twice_upper() { return 7; } + +template<> inline float pi_lower() { return pi_f_l; } +template<> inline float pi_upper() { return pi_f_u; } +template<> inline float pi_half_lower() { return pi_f_l / 2; } +template<> inline float pi_half_upper() { return pi_f_u / 2; } +template<> inline float pi_twice_lower() { return pi_f_l * 2; } +template<> inline float pi_twice_upper() { return pi_f_u * 2; } + +template<> inline double pi_lower() { return pi_d_l; } +template<> inline double pi_upper() { return pi_d_u; } +template<> inline double pi_half_lower() { return pi_d_l / 2; } +template<> inline double pi_half_upper() { return pi_d_u / 2; } +template<> inline double pi_twice_lower() { return pi_d_l * 2; } +template<> inline double pi_twice_upper() { return pi_d_u * 2; } + +template<> inline long double pi_lower() { return pi_d_l; } +template<> inline long double pi_upper() { return pi_d_u; } +template<> inline long double pi_half_lower() { return pi_d_l / 2; } +template<> inline long double pi_half_upper() { return pi_d_u / 2; } +template<> inline long double pi_twice_lower() { return pi_d_l * 2; } +template<> inline long double pi_twice_upper() { return pi_d_u * 2; } + +} // namespace constants + +template inline +I pi() +{ + typedef typename I::base_type T; + return I(constants::pi_lower(), + constants::pi_upper(), true); +} + +template inline +I pi_half() +{ + typedef typename I::base_type T; + return I(constants::pi_half_lower(), + constants::pi_half_upper(), true); +} + +template inline +I pi_twice() +{ + typedef typename I::base_type T; + return I(constants::pi_twice_lower(), + constants::pi_twice_upper(), true); +} + +} // namespace interval_lib +} // namespace numeric +} // namespace boost + +#endif // BOOST_NUMERIC_INTERVAL_CONSTANTS_HPP diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/alpha_rounding_control.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/alpha_rounding_control.hpp new file mode 100644 index 0000000000..d9a6079e1b --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/alpha_rounding_control.hpp @@ -0,0 +1,113 @@ +/* Boost interval/detail/alpha_rounding_control.hpp file + * + * Copyright 2005 Felix Höfling, Guillaume Melquiond + * + * 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) + */ + +#ifndef BOOST_NUMERIC_INTERVAL_DETAIL_ALPHA_ROUNDING_CONTROL_HPP +#define BOOST_NUMERIC_INTERVAL_DETAIL_ALPHA_ROUNDING_CONTROL_HPP + +#if !defined(alpha) && !defined(__alpha__) +#error This header only works on Alpha CPUs. +#endif + +#if defined(__GNUC__) || defined(__digital__) || defined(__DECCXX) + +#include // write_rnd() and read_rnd() + +namespace boost { +namespace numeric { +namespace interval_lib { + +namespace detail { +#if defined(__GNUC__ ) + typedef union { + ::boost::long_long_type imode; + double dmode; + } rounding_mode_struct; + + // set bits 59-58 (DYN), + // clear all exception bits and disable overflow (51) and inexact exceptions (62) + static const rounding_mode_struct mode_upward = { 0x4C08000000000000LL }; + static const rounding_mode_struct mode_downward = { 0x4408000000000000LL }; + static const rounding_mode_struct mode_to_nearest = { 0x4808000000000000LL }; + static const rounding_mode_struct mode_toward_zero = { 0x4008000000000000LL }; + + struct alpha_rounding_control + { + typedef double rounding_mode; + + static void set_rounding_mode(const rounding_mode mode) + { __asm__ __volatile__ ("mt_fpcr %0" : : "f"(mode)); } + + static void get_rounding_mode(rounding_mode& mode) + { __asm__ __volatile__ ("mf_fpcr %0" : "=f"(mode)); } + + static void downward() { set_rounding_mode(mode_downward.dmode); } + static void upward() { set_rounding_mode(mode_upward.dmode); } + static void to_nearest() { set_rounding_mode(mode_to_nearest.dmode); } + static void toward_zero() { set_rounding_mode(mode_toward_zero.dmode); } + }; +#elif defined(__digital__) || defined(__DECCXX) + +#if defined(__DECCXX) && !(defined(__FLT_ROUNDS) && __FLT_ROUNDS == -1) +#error Dynamic rounding mode not enabled. See cxx man page for details. +#endif + + struct alpha_rounding_control + { + typedef unsigned int rounding_mode; + + static void set_rounding_mode(const rounding_mode& mode) { write_rnd(mode); } + static void get_rounding_mode(rounding_mode& mode) { mode = read_rnd(); } + + static void downward() { set_rounding_mode(FP_RND_RM); } + static void upward() { set_rounding_mode(FP_RND_RP); } + static void to_nearest() { set_rounding_mode(FP_RND_RN); } + static void toward_zero() { set_rounding_mode(FP_RND_RZ); } + }; +#endif +} // namespace detail + +extern "C" { + float rintf(float); + double rint(double); + long double rintl(long double); +} + +template<> +struct rounding_control: + detail::alpha_rounding_control +{ + static float force_rounding(const float r) + { volatile float _r = r; return _r; } + static float to_int(const float& x) { return rintf(x); } +}; + +template<> +struct rounding_control: + detail::alpha_rounding_control +{ + static const double & force_rounding(const double& r) { return r; } + static double to_int(const double& r) { return rint(r); } +}; + +template<> +struct rounding_control: + detail::alpha_rounding_control +{ + static const long double & force_rounding(const long double& r) { return r; } + static long double to_int(const long double& r) { return rintl(r); } +}; + +} // namespace interval_lib +} // namespace numeric +} // namespace boost + +#undef BOOST_NUMERIC_INTERVAL_NO_HARDWARE +#endif + +#endif /* BOOST_NUMERIC_INTERVAL_DETAIL_ALPHA_ROUNDING_CONTROL_HPP */ diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/bcc_rounding_control.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/bcc_rounding_control.hpp new file mode 100644 index 0000000000..e3aaf046c5 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/bcc_rounding_control.hpp @@ -0,0 +1,57 @@ +/* Boost interval/detail/bcc_rounding_control.hpp file + * + * Copyright 2000 Jens Maurer + * Copyright 2002 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion + * + * 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) + */ + +#ifndef BOOST_NUMERIC_INTERVAL_DETAIL_BCC_ROUNDING_CONTROL_HPP +#define BOOST_NUMERIC_INTERVAL_DETAIL_BCC_ROUNDING_CONTROL_HPP + +#ifndef __BORLANDC__ +# error This header is only intended for Borland C++. +#endif + +#ifndef _M_IX86 +# error This header only works on x86 CPUs. +#endif + +#include // Borland C++ rounding control + +namespace boost { +namespace numeric { +namespace interval_lib { +namespace detail { + +#ifndef BOOST_NUMERIC_INTERVAL_KEEP_EXCEPTIONS_FOR_BCC +extern "C" { unsigned int _RTLENTRY _fm_init(void); } + +struct borland_workaround { + borland_workaround() { _fm_init(); } +}; + +static borland_workaround borland_workaround_exec; +#endif // BOOST_NUMERIC_INTERVAL_KEEP_EXCEPTIONS_FOR_BCC + +__inline double rint(double) +{ __emit__(0xD9); __emit__(0xFC); /* asm FRNDINT */ } + +struct x86_rounding +{ + typedef unsigned int rounding_mode; + static void get_rounding_mode(rounding_mode& mode) + { mode = _control87(0, 0); } + static void set_rounding_mode(const rounding_mode mode) + { _control87(mode, 0xffff); } + static double to_int(const double& x) { return rint(x); } +}; + +} // namespace detail +} // namespace interval_lib +} // namespace numeric +} // namespace boost + +#endif /* BOOST_NUMERIC_INTERVAL_DETAIL_BCC_ROUNDING_CONTROL_HPP */ diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/bugs.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/bugs.hpp new file mode 100644 index 0000000000..cc37988d71 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/bugs.hpp @@ -0,0 +1,79 @@ +/* Boost interval/detail/bugs.hpp file + * + * Copyright 2000 Jens Maurer + * Copyright 2002 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion + * + * 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) + */ + +#ifndef BOOST_NUMERIC_INTERVAL_DETAIL_BUGS +#define BOOST_NUMERIC_INTERVAL_DETAIL_BUGS + +#include + +#if defined(__GLIBC__) && (defined(__USE_MISC) || defined(__USE_XOPEN_EXTENDED) || defined(__USE_ISOC99)) && !defined(__ICC) +# define BOOST_HAS_INV_HYPERBOLIC +#endif + +#ifdef BOOST_NO_STDC_NAMESPACE +# define BOOST_NUMERIC_INTERVAL_using_math(a) using ::a +# ifdef BOOST_HAS_INV_HYPERBOLIC +# define BOOST_NUMERIC_INTERVAL_using_ahyp(a) using ::a +# endif +#else +# define BOOST_NUMERIC_INTERVAL_using_math(a) using std::a +# if defined(BOOST_HAS_INV_HYPERBOLIC) +# if defined(__GLIBCPP__) || defined(__GLIBCXX__) +# define BOOST_NUMERIC_INTERVAL_using_ahyp(a) using ::a +# else +# define BOOST_NUMERIC_INTERVAL_using_ahyp(a) using std::a +# endif +# endif +#endif + +#if defined(__COMO__) || defined(BOOST_INTEL) +# define BOOST_NUMERIC_INTERVAL_using_max(a) using std::a +#elif defined(BOOST_NO_STDC_NAMESPACE) +# define BOOST_NUMERIC_INTERVAL_using_max(a) using ::a +#else +# define BOOST_NUMERIC_INTERVAL_using_max(a) using std::a +#endif + +#ifndef BOOST_NUMERIC_INTERVAL_using_ahyp +# define BOOST_NUMERIC_INTERVAL_using_ahyp(a) +#endif + +#if defined(__GNUC__) && (__GNUC__ <= 2) +// cf PR c++/1981 for a description of the bug +#include +#include +namespace boost { +namespace numeric { + using std::min; + using std::max; + using std::sqrt; + using std::exp; + using std::log; + using std::cos; + using std::tan; + using std::asin; + using std::acos; + using std::atan; + using std::ceil; + using std::floor; + using std::sinh; + using std::cosh; + using std::tanh; +# undef BOOST_NUMERIC_INTERVAL_using_max +# undef BOOST_NUMERIC_INTERVAL_using_math +# define BOOST_NUMERIC_INTERVAL_using_max(a) +# define BOOST_NUMERIC_INTERVAL_using_math(a) +# undef BOOST_NUMERIC_INTERVAL_using_ahyp +# define BOOST_NUMERIC_INTERVAL_using_ahyp(a) +} // namespace numeric +} // namespace boost +#endif + +#endif // BOOST_NUMERIC_INTERVAL_DETAIL_BUGS diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/c99_rounding_control.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/c99_rounding_control.hpp new file mode 100644 index 0000000000..71d13e787a --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/c99_rounding_control.hpp @@ -0,0 +1,50 @@ +/* Boost interval/detail/c99_rounding_control.hpp file + * + * Copyright 2000 Jens Maurer + * Copyright 2002 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion + * + * 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) + */ + +#ifndef BOOST_NUMERIC_INTERVAL_DETAIL_C99_ROUNDING_CONTROL_HPP +#define BOOST_NUMERIC_INTERVAL_DETAIL_C99_ROUNDING_CONTROL_HPP + +#include + +namespace boost { +namespace numeric { +namespace interval_lib { + +template<> +struct rounding_control: + detail::c99_rounding_control +{ + static float force_rounding(float const &r) + { volatile float r_ = r; return r_; } +}; + +template<> +struct rounding_control: + detail::c99_rounding_control +{ + static double force_rounding(double const &r) + { volatile double r_ = r; return r_; } +}; + +template<> +struct rounding_control: + detail::c99_rounding_control +{ + static long double force_rounding(long double const &r) + { volatile long double r_ = r; return r_; } +}; + +} // namespace interval_lib +} // namespace numeric +} // namespace boost + +#undef BOOST_NUMERIC_INTERVAL_NO_HARDWARE + +#endif // BOOST_NUMERIC_INTERVAL_DETAIL_C99_ROUNDING_CONTROL_HPP diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/c99sub_rounding_control.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/c99sub_rounding_control.hpp new file mode 100644 index 0000000000..92c9b5c8a8 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/c99sub_rounding_control.hpp @@ -0,0 +1,43 @@ +/* Boost interval/detail/c99sub_rounding_control.hpp file + * + * Copyright 2000 Jens Maurer + * Copyright 2002 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion + * + * 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) + */ + +#ifndef BOOST_NUMERIC_INTERVAL_DETAIL_C99SUB_ROUNDING_CONTROL_HPP +#define BOOST_NUMERIC_INTERVAL_DETAIL_C99SUB_ROUNDING_CONTROL_HPP + +#include // ISO C 99 rounding mode control + +namespace boost { +namespace numeric { +namespace interval_lib { +namespace detail { + +extern "C" { double rint(double); } + +struct c99_rounding_control +{ + typedef int rounding_mode; + + static void set_rounding_mode(rounding_mode mode) { fesetround(mode); } + static void get_rounding_mode(rounding_mode &mode) { mode = fegetround(); } + static void downward() { set_rounding_mode(FE_DOWNWARD); } + static void upward() { set_rounding_mode(FE_UPWARD); } + static void to_nearest() { set_rounding_mode(FE_TONEAREST); } + static void toward_zero() { set_rounding_mode(FE_TOWARDZERO); } + + template + static T to_int(const T& r) { return rint(r); } +}; + +} // namespace detail +} // namespace interval_lib +} // namespace numeric +} // namespace boost + +#endif // BOOST_NUMERIC_INTERVAL_DETAIL_C99SUB_ROUBDING_CONTROL_HPP diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/division.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/division.hpp new file mode 100644 index 0000000000..24fb025ada --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/division.hpp @@ -0,0 +1,194 @@ +/* Boost interval/detail/division.hpp file + * + * Copyright 2003 Guillaume Melquiond, Sylvain Pion + * + * 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) + */ + +#ifndef BOOST_NUMERIC_INTERVAL_DETAIL_DIVISION_HPP +#define BOOST_NUMERIC_INTERVAL_DETAIL_DIVISION_HPP + +#include +#include +#include +#include +#include + +namespace boost { +namespace numeric { +namespace interval_lib { +namespace detail { + +template inline +interval div_non_zero(const interval& x, + const interval& y) +{ + // assert(!in_zero(y)); + typename Policies::rounding rnd; + typedef interval I; + const T& xl = x.lower(); + const T& xu = x.upper(); + const T& yl = y.lower(); + const T& yu = y.upper(); + if (::boost::numeric::interval_lib::user::is_neg(xu)) + if (::boost::numeric::interval_lib::user::is_neg(yu)) + return I(rnd.div_down(xu, yl), rnd.div_up(xl, yu), true); + else + return I(rnd.div_down(xl, yl), rnd.div_up(xu, yu), true); + else if (::boost::numeric::interval_lib::user::is_neg(xl)) + if (::boost::numeric::interval_lib::user::is_neg(yu)) + return I(rnd.div_down(xu, yu), rnd.div_up(xl, yu), true); + else + return I(rnd.div_down(xl, yl), rnd.div_up(xu, yl), true); + else + if (::boost::numeric::interval_lib::user::is_neg(yu)) + return I(rnd.div_down(xu, yu), rnd.div_up(xl, yl), true); + else + return I(rnd.div_down(xl, yu), rnd.div_up(xu, yl), true); +} + +template inline +interval div_non_zero(const T& x, const interval& y) +{ + // assert(!in_zero(y)); + typename Policies::rounding rnd; + typedef interval I; + const T& yl = y.lower(); + const T& yu = y.upper(); + if (::boost::numeric::interval_lib::user::is_neg(x)) + return I(rnd.div_down(x, yl), rnd.div_up(x, yu), true); + else + return I(rnd.div_down(x, yu), rnd.div_up(x, yl), true); +} + +template inline +interval div_positive(const interval& x, const T& yu) +{ + // assert(::boost::numeric::interval_lib::user::is_pos(yu)); + if (::boost::numeric::interval_lib::user::is_zero(x.lower()) && + ::boost::numeric::interval_lib::user::is_zero(x.upper())) + return x; + typename Policies::rounding rnd; + typedef interval I; + const T& xl = x.lower(); + const T& xu = x.upper(); + typedef typename Policies::checking checking; + if (::boost::numeric::interval_lib::user::is_neg(xu)) + return I(checking::neg_inf(), rnd.div_up(xu, yu), true); + else if (::boost::numeric::interval_lib::user::is_neg(xl)) + return I(checking::neg_inf(), checking::pos_inf(), true); + else + return I(rnd.div_down(xl, yu), checking::pos_inf(), true); +} + +template inline +interval div_positive(const T& x, const T& yu) +{ + // assert(::boost::numeric::interval_lib::user::is_pos(yu)); + typedef interval I; + if (::boost::numeric::interval_lib::user::is_zero(x)) + return I(static_cast(0), static_cast(0), true); + typename Policies::rounding rnd; + typedef typename Policies::checking checking; + if (::boost::numeric::interval_lib::user::is_neg(x)) + return I(checking::neg_inf(), rnd.div_up(x, yu), true); + else + return I(rnd.div_down(x, yu), checking::pos_inf(), true); +} + +template inline +interval div_negative(const interval& x, const T& yl) +{ + // assert(::boost::numeric::interval_lib::user::is_neg(yl)); + if (::boost::numeric::interval_lib::user::is_zero(x.lower()) && + ::boost::numeric::interval_lib::user::is_zero(x.upper())) + return x; + typename Policies::rounding rnd; + typedef interval I; + const T& xl = x.lower(); + const T& xu = x.upper(); + typedef typename Policies::checking checking; + if (::boost::numeric::interval_lib::user::is_neg(xu)) + return I(rnd.div_down(xu, yl), checking::pos_inf(), true); + else if (::boost::numeric::interval_lib::user::is_neg(xl)) + return I(checking::neg_inf(), checking::pos_inf(), true); + else + return I(checking::neg_inf(), rnd.div_up(xl, yl), true); +} + +template inline +interval div_negative(const T& x, const T& yl) +{ + // assert(::boost::numeric::interval_lib::user::is_neg(yl)); + typedef interval I; + if (::boost::numeric::interval_lib::user::is_zero(x)) + return I(static_cast(0), static_cast(0), true); + typename Policies::rounding rnd; + typedef typename Policies::checking checking; + if (::boost::numeric::interval_lib::user::is_neg(x)) + return I(rnd.div_down(x, yl), checking::pos_inf(), true); + else + return I(checking::neg_inf(), rnd.div_up(x, yl), true); +} + +template inline +interval div_zero(const interval& x) +{ + if (::boost::numeric::interval_lib::user::is_zero(x.lower()) && + ::boost::numeric::interval_lib::user::is_zero(x.upper())) + return x; + else return interval::whole(); +} + +template inline +interval div_zero(const T& x) +{ + if (::boost::numeric::interval_lib::user::is_zero(x)) + return interval(static_cast(0), static_cast(0), true); + else return interval::whole(); +} + +template inline +interval div_zero_part1(const interval& x, + const interval& y, bool& b) +{ + // assert(::boost::numeric::interval_lib::user::is_neg(y.lower()) && ::boost::numeric::interval_lib::user::is_pos(y.upper())); + if (::boost::numeric::interval_lib::user::is_zero(x.lower()) && ::boost::numeric::interval_lib::user::is_zero(x.upper())) + { b = false; return x; } + typename Policies::rounding rnd; + typedef interval I; + const T& xl = x.lower(); + const T& xu = x.upper(); + const T& yl = y.lower(); + const T& yu = y.upper(); + typedef typename Policies::checking checking; + if (::boost::numeric::interval_lib::user::is_neg(xu)) + { b = true; return I(checking::neg_inf(), rnd.div_up(xu, yu), true); } + else if (::boost::numeric::interval_lib::user::is_neg(xl)) + { b = false; return I(checking::neg_inf(), checking::pos_inf(), true); } + else + { b = true; return I(checking::neg_inf(), rnd.div_up(xl, yl), true); } +} + +template inline +interval div_zero_part2(const interval& x, + const interval& y) +{ + // assert(::boost::numeric::interval_lib::user::is_neg(y.lower()) && ::boost::numeric::interval_lib::user::is_pos(y.upper()) && (div_zero_part1(x, y, b), b)); + typename Policies::rounding rnd; + typedef interval I; + typedef typename Policies::checking checking; + if (::boost::numeric::interval_lib::user::is_neg(x.upper())) + return I(rnd.div_down(x.upper(), y.lower()), checking::pos_inf(), true); + else + return I(rnd.div_down(x.lower(), y.upper()), checking::pos_inf(), true); +} + +} // namespace detail +} // namespace interval_lib +} // namespace numeric +} // namespace boost + +#endif // BOOST_NUMERIC_INTERVAL_DETAIL_DIVISION_HPP diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/ia64_rounding_control.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/ia64_rounding_control.hpp new file mode 100644 index 0000000000..be26168cae --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/ia64_rounding_control.hpp @@ -0,0 +1,83 @@ +/* Boost interval/detail/ia64_rounding_control.hpp file + * + * Copyright 2006-2007 Boris Gubenko + * + * 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) + */ + +#ifndef BOOST_NUMERIC_INTERVAL_DETAIL_IA64_ROUNDING_CONTROL_HPP +#define BOOST_NUMERIC_INTERVAL_DETAIL_IA64_ROUNDING_CONTROL_HPP + +#if !defined(ia64) && !defined(__ia64) && !defined(__ia64__) +#error This header only works on ia64 CPUs. +#endif + +#if defined(__hpux) + +# include + +namespace boost { +namespace numeric { +namespace interval_lib { +namespace detail { + + + struct ia64_rounding_control + { + typedef unsigned int rounding_mode; + + static void set_rounding_mode(const rounding_mode& mode) { +fesetround(mode); } + static void get_rounding_mode(rounding_mode& mode) { mode = fegetround(); } + + static void downward() { set_rounding_mode(FE_DOWNWARD); } + static void upward() { set_rounding_mode(FE_UPWARD); } + static void to_nearest() { set_rounding_mode(FE_TONEAREST); } + static void toward_zero() { set_rounding_mode(FE_TOWARDZERO); } + }; + +} // namespace detail + +extern "C" { + float rintf(float); + double rint(double); + long double rintl(long double); +} + +template<> +struct rounding_control: + detail::ia64_rounding_control +{ + static float force_rounding(const float r) + { volatile float _r = r; return _r; } + static float to_int(const float& x) { return rintf(x); } +}; + +template<> +struct rounding_control: + detail::ia64_rounding_control +{ + static const double & force_rounding(const double& r) { return r; } + static double to_int(const double& r) { return rint(r); } +}; + +template<> +struct rounding_control: + detail::ia64_rounding_control +{ + static const long double & force_rounding(const long double& r) { return r; } + static long double to_int(const long double& r) { return rintl(r); } +}; + +} // namespace interval_lib +} // namespace numeric +} // namespace boost + +#undef BOOST_NUMERIC_INTERVAL_NO_HARDWARE + +#endif /* __hpux */ + +#endif /* BOOST_NUMERIC_INTERVAL_DETAIL_IA64_ROUNDING_CONTROL_HPP */ + diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/interval_prototype.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/interval_prototype.hpp new file mode 100644 index 0000000000..ac9029b70b --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/interval_prototype.hpp @@ -0,0 +1,41 @@ +/* Boost interval/detail/interval_prototype.hpp file + * + * Copyright 2002 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion + * + * 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) + */ + +#ifndef BOOST_NUMERIC_INTERVAL_DETAIL_INTERVAL_PROTOTYPE_HPP +#define BOOST_NUMERIC_INTERVAL_DETAIL_INTERVAL_PROTOTYPE_HPP + +namespace boost { +namespace numeric { + +namespace interval_lib { + +template struct rounded_math; +template struct checking_strict; +class comparison_error; +template struct policies; + +/* + * default policies class + */ + +template +struct default_policies +{ + typedef policies, checking_strict > type; +}; + +} // namespace interval_lib + +template::type > +class interval; + +} // namespace numeric +} // namespace boost + +#endif // BOOST_NUMERIC_INTERVAL_DETAIL_INTERVAL_PROTOTYPE_HPP diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/msvc_rounding_control.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/msvc_rounding_control.hpp new file mode 100644 index 0000000000..95c790fe72 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/msvc_rounding_control.hpp @@ -0,0 +1,100 @@ +/* Boost interval/detail/msvc_rounding_control.hpp file + * + * Copyright 2000 Maarten Keijzer + * Copyright 2002 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion + * + * 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) + */ + +#ifndef BOOST_NUMERIC_INTERVAL_DETAIL_MSVC_ROUNDING_CONTROL_HPP +#define BOOST_NUMERIC_INTERVAL_DETAIL_MSVC_ROUNDING_CONTROL_HPP + +#ifndef _MSC_VER +# error This header is only intended for MSVC, but might work for Borland as well +#endif + +#include // MSVC rounding control + +// Although the function is called _control87, it seems to work for +// other FPUs too, so it does not have to be changed to _controlfp. + +namespace boost { +namespace numeric { +namespace interval_lib { +namespace detail { + +#if BOOST_MSVC < 1400 || defined(WIN64) +extern "C" { double rint(double); } +#else +inline double rint(double x) +{ +_asm FLD [x] ; +_asm FRNDINT ; +//_asm RET ; +} +#endif + +struct x86_rounding +{ + static unsigned int hard2msvc(unsigned short m) { + unsigned int n = 0; + if (m & 0x01) n |= _EM_INVALID; + if (m & 0x02) n |= _EM_DENORMAL; + if (m & 0x04) n |= _EM_ZERODIVIDE; + if (m & 0x08) n |= _EM_OVERFLOW; + if (m & 0x10) n |= _EM_UNDERFLOW; + if (m & 0x20) n |= _EM_INEXACT; + switch (m & 0x300) { + case 0x000: n |= _PC_24; break; + case 0x200: n |= _PC_53; break; + case 0x300: n |= _PC_64; break; + } + switch (m & 0xC00) { + case 0x000: n |= _RC_NEAR; break; + case 0x400: n |= _RC_DOWN; break; + case 0x800: n |= _RC_UP; break; + case 0xC00: n |= _RC_CHOP; break; + } + if (m & 0x1000) n |= _IC_AFFINE; // only useful on 287 + return n; + } + + static unsigned short msvc2hard(unsigned int n) { + unsigned short m = 0; + if (n & _EM_INVALID) m |= 0x01; + if (n & _EM_DENORMAL) m |= 0x02; + if (n & _EM_ZERODIVIDE) m |= 0x04; + if (n & _EM_OVERFLOW) m |= 0x08; + if (n & _EM_UNDERFLOW) m |= 0x10; + if (n & _EM_INEXACT) m |= 0x20; + switch (n & _MCW_RC) { + case _RC_NEAR: m |= 0x000; break; + case _RC_DOWN: m |= 0x400; break; + case _RC_UP: m |= 0x800; break; + case _RC_CHOP: m |= 0xC00; break; + } + switch (n & _MCW_PC) { + case _PC_24: m |= 0x000; break; + case _PC_53: m |= 0x200; break; + case _PC_64: m |= 0x300; break; + } + if ((n & _MCW_IC) == _IC_AFFINE) m |= 0x1000; + return m; + } + + typedef unsigned short rounding_mode; + static void get_rounding_mode(rounding_mode& mode) + { mode = msvc2hard(_control87(0, 0)); } + static void set_rounding_mode(const rounding_mode mode) + { _control87(hard2msvc(mode), _MCW_EM | _MCW_RC | _MCW_PC | _MCW_IC); } + static double to_int(const double& x) { return rint(x); } +}; + +} // namespace detail +} // namespace interval_lib +} // namespace numeric +} // namespace boost + +#endif /* BOOST_NUMERIC_INTERVAL_DETAIL_MSVC_ROUNDING_CONTROL_HPP */ diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/ppc_rounding_control.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/ppc_rounding_control.hpp new file mode 100644 index 0000000000..d2cf4c80f3 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/ppc_rounding_control.hpp @@ -0,0 +1,99 @@ +/* Boost interval/detail/ppc_rounding_control.hpp file + * + * Copyright 2000 Jens Maurer + * Copyright 2002 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion + * Copyright 2005 Guillaume Melquiond + * + * 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) + */ + +#ifndef BOOST_NUMERIC_INTERVAL_DETAIL_PPC_ROUNDING_CONTROL_HPP +#define BOOST_NUMERIC_INTERVAL_DETAIL_PPC_ROUNDING_CONTROL_HPP + +#if !defined(powerpc) && !defined(__powerpc__) && !defined(__ppc__) +#error This header only works on PPC CPUs. +#endif + +#if defined(__GNUC__ ) || (__IBMCPP__ >= 700) + +namespace boost { +namespace numeric { +namespace interval_lib { +namespace detail { + +typedef union { + ::boost::long_long_type imode; + double dmode; +} rounding_mode_struct; + +static const rounding_mode_struct mode_upward = { 0xFFF8000000000002LL }; +static const rounding_mode_struct mode_downward = { 0xFFF8000000000003LL }; +static const rounding_mode_struct mode_to_nearest = { 0xFFF8000000000000LL }; +static const rounding_mode_struct mode_toward_zero = { 0xFFF8000000000001LL }; + +struct ppc_rounding_control +{ + typedef double rounding_mode; + + static void set_rounding_mode(const rounding_mode mode) + { __asm__ __volatile__ ("mtfsf 255,%0" : : "f"(mode)); } + + static void get_rounding_mode(rounding_mode& mode) + { __asm__ __volatile__ ("mffs %0" : "=f"(mode)); } + + static void downward() { set_rounding_mode(mode_downward.dmode); } + static void upward() { set_rounding_mode(mode_upward.dmode); } + static void to_nearest() { set_rounding_mode(mode_to_nearest.dmode); } + static void toward_zero() { set_rounding_mode(mode_toward_zero.dmode); } +}; + +} // namespace detail + +// Do not declare the following C99 symbols if provides them. +// Otherwise, conflicts may occur, due to differences between prototypes. +#if !defined(_ISOC99_SOURCE) && !defined(__USE_ISOC99) +extern "C" { + float rintf(float); + double rint(double); +} +#endif + +template<> +struct rounding_control: + detail::ppc_rounding_control +{ + static float force_rounding(const float r) + { + float tmp; + __asm__ __volatile__ ("frsp %0, %1" : "=f" (tmp) : "f" (r)); + return tmp; + } + static float to_int(const float& x) { return rintf(x); } +}; + +template<> +struct rounding_control: + detail::ppc_rounding_control +{ + static const double & force_rounding(const double& r) { return r; } + static double to_int(const double& r) { return rint(r); } +}; + +template<> +struct rounding_control: + detail::ppc_rounding_control +{ + static const long double & force_rounding(const long double& r) { return r; } + static long double to_int(const long double& r) { return rint(r); } +}; + +} // namespace interval_lib +} // namespace numeric +} // namespace boost + +#undef BOOST_NUMERIC_INTERVAL_NO_HARDWARE +#endif + +#endif /* BOOST_NUMERIC_INTERVAL_DETAIL_PPC_ROUNDING_CONTROL_HPP */ diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/sparc_rounding_control.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/sparc_rounding_control.hpp new file mode 100644 index 0000000000..6ba5baf038 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/sparc_rounding_control.hpp @@ -0,0 +1,112 @@ +/* Boost interval/detail/sparc_rounding_control.hpp file + * + * Copyright 2000 Jens Maurer + * Copyright 2002 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion + * + * 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) + * + * The basic code in this file was kindly provided by Jeremy Siek. + */ + +#ifndef BOOST_NUMERIC_INTERVAL_DETAIL_SPARC_ROUNDING_CONTROL_HPP +#define BOOST_NUMERIC_INTERVAL_DETAIL_SPARC_ROUNDING_CONTROL_HPP + +#if !defined(sparc) && !defined(__sparc__) +# error This header is only intended for SPARC CPUs. +#endif + +#ifdef __SUNPRO_CC +# include +#endif + + +namespace boost { +namespace numeric { +namespace interval_lib { +namespace detail { + +struct sparc_rounding_control +{ + typedef unsigned int rounding_mode; + + static void set_rounding_mode(const rounding_mode& mode) + { +# if defined(__GNUC__) + __asm__ __volatile__("ld %0, %%fsr" : : "m"(mode)); +# elif defined (__SUNPRO_CC) + fpsetround(fp_rnd(mode)); +# elif defined(__KCC) + asm("sethi %hi(mode), %o1"); + asm("ld [%o1+%lo(mode)], %fsr"); +# else +# error Unsupported compiler for Sparc rounding control. +# endif + } + + static void get_rounding_mode(rounding_mode& mode) + { +# if defined(__GNUC__) + __asm__ __volatile__("st %%fsr, %0" : "=m"(mode)); +# elif defined (__SUNPRO_CC) + mode = fpgetround(); +# elif defined(__KCC) +# error KCC on Sun SPARC get_round_mode: please fix me + asm("st %fsr, [mode]"); +# else +# error Unsupported compiler for Sparc rounding control. +# endif + } + +#if defined(__SUNPRO_CC) + static void downward() { set_rounding_mode(FP_RM); } + static void upward() { set_rounding_mode(FP_RP); } + static void to_nearest() { set_rounding_mode(FP_RN); } + static void toward_zero() { set_rounding_mode(FP_RZ); } +#else + static void downward() { set_rounding_mode(0xc0000000); } + static void upward() { set_rounding_mode(0x80000000); } + static void to_nearest() { set_rounding_mode(0x00000000); } + static void toward_zero() { set_rounding_mode(0x40000000); } +#endif +}; + +} // namespace detail + +extern "C" { + float rintf(float); + double rint(double); +} + +template<> +struct rounding_control: + detail::sparc_rounding_control +{ + static const float& force_rounding(const float& x) { return x; } + static float to_int(const float& x) { return rintf(x); } +}; + +template<> +struct rounding_control: + detail::sparc_rounding_control +{ + static const double& force_rounding(const double& x) { return x; } + static double to_int(const double& x) { return rint(x); } +}; + +template<> +struct rounding_control: + detail::sparc_rounding_control +{ + static const long double& force_rounding(const long double& x) { return x; } + static long double to_int(const long double& x) { return rint(x); } +}; + +} // namespace interval_lib +} // namespace numeric +} // namespace boost + +#undef BOOST_NUMERIC_INTERVAL_NO_HARDWARE + +#endif /* BOOST_NUMERIC_INTERVAL_DETAIL_SPARC_ROUNDING_CONTROL_HPP */ diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/test_input.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/test_input.hpp new file mode 100644 index 0000000000..58695fec3c --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/test_input.hpp @@ -0,0 +1,76 @@ +/* Boost interval/detail/test_input.hpp file + * + * Copyright 2002 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion + * + * 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) + */ + +#ifndef BOOST_NUMERIC_INTERVAL_DETAIL_TEST_INPUT_HPP +#define BOOST_NUMERIC_INTERVAL_DETAIL_TEST_INPUT_HPP + +#include + +namespace boost { +namespace numeric { +namespace interval_lib { +namespace user { + +template inline +bool is_zero(T const &v) { return v == static_cast(0); } + +template inline +bool is_neg (T const &v) { return v < static_cast(0); } + +template inline +bool is_pos (T const &v) { return v > static_cast(0); } + +} // namespace user + +namespace detail { + +template inline +bool test_input(const interval& x) { + typedef typename Policies::checking checking; + return checking::is_empty(x.lower(), x.upper()); +} + +template inline +bool test_input(const interval& x, const interval& y) { + typedef typename Policies1::checking checking1; + typedef typename Policies2::checking checking2; + return checking1::is_empty(x.lower(), x.upper()) || + checking2::is_empty(y.lower(), y.upper()); +} + +template inline +bool test_input(const T& x, const interval& y) { + typedef typename Policies::checking checking; + return checking::is_nan(x) || checking::is_empty(y.lower(), y.upper()); +} + +template inline +bool test_input(const interval& x, const T& y) { + typedef typename Policies::checking checking; + return checking::is_empty(x.lower(), x.upper()) || checking::is_nan(y); +} + +template inline +bool test_input(const T& x) { + typedef typename Policies::checking checking; + return checking::is_nan(x); +} + +template inline +bool test_input(const T& x, const T& y) { + typedef typename Policies::checking checking; + return checking::is_nan(x) || checking::is_nan(y); +} + +} // namespace detail +} // namespace interval_lib +} // namespace numeric +} // namespace boost + +#endif // BOOST_NUMERIC_INTERVAL_DETAIL_TEST_INPUT_HPP diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/x86_rounding_control.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/x86_rounding_control.hpp new file mode 100644 index 0000000000..c35f16d914 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/x86_rounding_control.hpp @@ -0,0 +1,108 @@ +/* Boost interval/detail/x86_rounding_control.hpp file + * + * Copyright 2000 Jens Maurer + * Copyright 2002 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion + * + * 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) + */ + +#ifndef BOOST_NUMERIC_INTERVAL_DETAIL_X86_ROUNDING_CONTROL_HPP +#define BOOST_NUMERIC_INTERVAL_DETAIL_X86_ROUNDING_CONTROL_HPP + +#ifdef __GNUC__ +# include +#elif defined(__BORLANDC__) +# include +#elif defined(_MSC_VER) +# include +#elif defined(__MWERKS__) || defined(__ICC) || defined (__SUNPRO_CC) +# define BOOST_NUMERIC_INTERVAL_USE_C99_SUBSYSTEM +# include +#else +# error Unsupported C++ compiler. +#endif + +namespace boost { +namespace numeric { +namespace interval_lib { + +namespace detail { + +#ifdef BOOST_NUMERIC_INTERVAL_USE_C99_SUBSYSTEM +typedef c99_rounding_control x86_rounding_control; +#undef BOOST_NUMERIC_INTERVAL_USE_C99_SUBSYSTEM +#else +struct fpu_rounding_modes +{ + unsigned short to_nearest; + unsigned short downward; + unsigned short upward; + unsigned short toward_zero; +}; + +// exceptions masked, extended precision +// hardware default is 0x037f (0x1000 only has a meaning on 287) +static const fpu_rounding_modes rnd_mode = { 0x137f, 0x177f, 0x1b7f, 0x1f7f }; + +struct x86_rounding_control: x86_rounding +{ + static void to_nearest() { set_rounding_mode(rnd_mode.to_nearest); } + static void downward() { set_rounding_mode(rnd_mode.downward); } + static void upward() { set_rounding_mode(rnd_mode.upward); } + static void toward_zero() { set_rounding_mode(rnd_mode.toward_zero); } +}; +#endif // BOOST_NUMERIC_INTERVAL_USE_C99_SUBSYSTEM + +} // namespace detail + +template<> +struct rounding_control: detail::x86_rounding_control +{ + static float force_rounding(const float& r) + { volatile float r_ = r; return r_; } +}; + +template<> +struct rounding_control: detail::x86_rounding_control +{ + /*static double force_rounding(double r) + { asm volatile ("" : "+m"(r) : ); return r; }*/ + static double force_rounding(const double& r) + { volatile double r_ = r; return r_; } +}; + +namespace detail { + +template +struct x86_rounding_control_long_double; + +template<> +struct x86_rounding_control_long_double: x86_rounding_control +{ + static long double force_rounding(long double const &r) + { volatile long double r_ = r; return r_; } +}; + +template<> +struct x86_rounding_control_long_double: x86_rounding_control +{ + static long double const &force_rounding(long double const &r) + { return r; } +}; + +} // namespace detail + +template<> +struct rounding_control: + detail::x86_rounding_control_long_double< (sizeof(long double) >= 10) > +{}; + +} // namespace interval_lib +} // namespace numeric +} // namespace boost + +#undef BOOST_NUMERIC_INTERVAL_NO_HARDWARE + +#endif /* BOOST_NUMERIC_INTERVAL_DETAIL_X86_ROUNDING_CONTROL_HPP */ diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/x86gcc_rounding_control.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/x86gcc_rounding_control.hpp new file mode 100644 index 0000000000..079d681df9 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/detail/x86gcc_rounding_control.hpp @@ -0,0 +1,51 @@ +/* Boost interval/detail/x86gcc_rounding_control.hpp file + * + * Copyright 2000 Jens Maurer + * Copyright 2002 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion + * + * 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) + */ + +#ifndef BOOST_NUMERIC_INTERVAL_DETAIL_X86GCC_ROUNDING_CONTROL_HPP +#define BOOST_NUMERIC_INTERVAL_DETAIL_X86GCC_ROUNDING_CONTROL_HPP + +#ifndef __GNUC__ +# error This header only works with GNU CC. +#endif + +#ifndef __i386__ +# error This header only works on x86 CPUs. +#endif + +namespace boost { +namespace numeric { +namespace interval_lib { +namespace detail { + +struct x86_rounding +{ + typedef unsigned short rounding_mode; + + static void set_rounding_mode(const rounding_mode& mode) + { __asm__ __volatile__ ("fldcw %0" : : "m"(mode)); } + + static void get_rounding_mode(rounding_mode& mode) + { __asm__ __volatile__ ("fnstcw %0" : "=m"(mode)); } + + template + static T to_int(T r) + { + T r_; + __asm__ ("frndint" : "=&t"(r_) : "0"(r)); + return r_; + } +}; + +} // namespace detail +} // namespace interval_lib +} // namespace numeric +} // namespace boost + +#endif /* BOOST_NUMERIC_INTERVAL_DETAIL_X86GCC_ROUNDING_CONTROL_HPP */ diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/ext/integer.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/ext/integer.hpp new file mode 100644 index 0000000000..628a343ac8 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/ext/integer.hpp @@ -0,0 +1,70 @@ +/* Boost interval/ext/integer.hpp template implementation file + * + * Copyright 2003 Guillaume Melquiond + * + * 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) + */ + +#ifndef BOOST_NUMERIC_INTERVAL_EXT_INTEGER_HPP +#define BOOST_NUMERIC_INTERVAL_EXT_INTEGER_HPP + +#include +#include + +namespace boost { +namespace numeric { + +template inline +interval operator+ (const interval& x, int y) +{ + return x + static_cast(y); +} + +template inline +interval operator+ (int x, const interval& y) +{ + return static_cast(x) + y; +} + +template inline +interval operator- (const interval& x, int y) +{ + return x - static_cast(y); +} + +template inline +interval operator- (int x, const interval& y) +{ + return static_cast(x) - y; +} + +template inline +interval operator* (const interval& x, int y) +{ + return x * static_cast(y); +} + +template inline +interval operator* (int x, const interval& y) +{ + return static_cast(x) * y; +} + +template inline +interval operator/ (const interval& x, int y) +{ + return x / static_cast(y); +} + +template inline +interval operator/ (int x, const interval& y) +{ + return static_cast(x) / y; +} + +} // namespace numeric +} // namespace boost + +#endif // BOOST_NUMERIC_INTERVAL_EXT_INTEGER_HPP diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/ext/x86_fast_rounding_control.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/ext/x86_fast_rounding_control.hpp new file mode 100644 index 0000000000..7f89a4e549 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/ext/x86_fast_rounding_control.hpp @@ -0,0 +1,70 @@ +/* Boost interval/detail/x86gcc_rounding_control.hpp file + * + * This header provides a rounding control policy + * that avoids flushing results to memory. In + * order for this optimization to be reliable, it + * should be used only when no underflow or + * overflow would happen without it. Indeed, only + * values in range are correctly rounded. + * + * Copyright 2002 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion + * + * 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) + */ + +#ifndef BOOST_NUMERIC_INTERVAL_EXT_X86_FAST_ROUNDING_CONTROL_HPP +#define BOOST_NUMERIC_INTERVAL_EXT_X86_FAST_ROUNDING_CONTROL_HPP + +namespace boost { +namespace numeric { +namespace interval_lib { + +namespace detail { + +// exceptions masked, expected precision (the mask is 0x0300) +static const fpu_rounding_modes rnd_mode_f = { 0x107f, 0x147f, 0x187f, 0x1c7f }; +static const fpu_rounding_modes rnd_mode_d = { 0x127f, 0x167f, 0x1a7f, 0x1e7f }; +static const fpu_rounding_modes rnd_mode_l = { 0x137f, 0x177f, 0x1b7f, 0x1f7f }; + +} // namespace detail + +template +struct x86_fast_rounding_control; + +template<> +struct x86_fast_rounding_control: detail::x86_rounding +{ + static void to_nearest() { set_rounding_mode(detail::rnd_mode_f.to_nearest); } + static void downward() { set_rounding_mode(detail::rnd_mode_f.downward); } + static void upward() { set_rounding_mode(detail::rnd_mode_f.upward); } + static void toward_zero() { set_rounding_mode(detail::rnd_mode_f.toward_zero); } + static const float& force_rounding(const float& r) { return r; } +}; + +template<> +struct x86_fast_rounding_control: detail::x86_rounding +{ + static void to_nearest() { set_rounding_mode(detail::rnd_mode_d.to_nearest); } + static void downward() { set_rounding_mode(detail::rnd_mode_d.downward); } + static void upward() { set_rounding_mode(detail::rnd_mode_d.upward); } + static void toward_zero() { set_rounding_mode(detail::rnd_mode_d.toward_zero); } + static const double& force_rounding(const double& r) { return r; } +}; + +template<> +struct x86_fast_rounding_control: detail::x86_rounding +{ + static void to_nearest() { set_rounding_mode(detail::rnd_mode_l.to_nearest); } + static void downward() { set_rounding_mode(detail::rnd_mode_l.downward); } + static void upward() { set_rounding_mode(detail::rnd_mode_l.upward); } + static void toward_zero() { set_rounding_mode(detail::rnd_mode_l.toward_zero); } + static const long double& force_rounding(const long double& r) { return r; } +}; + +} // namespace interval_lib +} // namespace numeric +} // namespace boost + +#endif // BOOST_NUMERIC_INTERVAL_EXT_X86_FAST_ROUNDING_CONTROL_HPP diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/hw_rounding.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/hw_rounding.hpp new file mode 100644 index 0000000000..d0062567f8 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/hw_rounding.hpp @@ -0,0 +1,70 @@ +/* Boost interval/hw_rounding.hpp template implementation file + * + * Copyright 2002 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion + * Copyright 2005 Guillaume Melquiond + * + * 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) + */ + +#ifndef BOOST_NUMERIC_INTERVAL_HW_ROUNDING_HPP +#define BOOST_NUMERIC_INTERVAL_HW_ROUNDING_HPP + +#include +#include + +#define BOOST_NUMERIC_INTERVAL_NO_HARDWARE + +// define appropriate specialization of rounding_control for built-in types +#if defined(__x86_64__) && (defined(__USE_ISOC99) || defined(__APPLE__)) +# include +#elif defined(__i386__) || defined(_M_IX86) || defined(__BORLANDC__) || defined(_M_X64) +# include +#elif defined(powerpc) || defined(__powerpc__) || defined(__ppc__) +# include +#elif defined(sparc) || defined(__sparc__) +# include +#elif defined(alpha) || defined(__alpha__) +# include +#elif defined(ia64) || defined(__ia64) || defined(__ia64__) +# include +#endif + +#if defined(BOOST_NUMERIC_INTERVAL_NO_HARDWARE) && (defined(__USE_ISOC99) || defined(__MSL__)) +# include +#endif + +#if defined(BOOST_NUMERIC_INTERVAL_NO_HARDWARE) +# undef BOOST_NUMERIC_INTERVAL_NO_HARDWARE +# error Boost.Numeric.Interval: Please specify rounding control mechanism. +#endif + +namespace boost { +namespace numeric { +namespace interval_lib { + +/* + * Three specializations of rounded_math + */ + +template<> +struct rounded_math + : save_state > +{}; + +template<> +struct rounded_math + : save_state > +{}; + +template<> +struct rounded_math + : save_state > +{}; + +} // namespace interval_lib +} // namespace numeric +} // namespace boost + +#endif // BOOST_NUMERIC_INTERVAL_HW_ROUNDING_HPP diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/interval.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/interval.hpp new file mode 100644 index 0000000000..0b2d0eec6e --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/interval.hpp @@ -0,0 +1,450 @@ +/* Boost interval/interval.hpp header file + * + * Copyright 2002-2003 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion + * + * 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) + */ + +#ifndef BOOST_NUMERIC_INTERVAL_INTERVAL_HPP +#define BOOST_NUMERIC_INTERVAL_INTERVAL_HPP + +#include +#include +#include + +namespace boost { +namespace numeric { + +namespace interval_lib { + +class comparison_error + : public std::runtime_error +{ +public: + comparison_error() + : std::runtime_error("boost::interval: uncertain comparison") + { } +}; + +} // namespace interval_lib + +/* + * interval class + */ + +template +class interval +{ +private: + struct interval_holder; + struct number_holder; +public: + typedef T base_type; + typedef Policies traits_type; + + T const &lower() const; + T const &upper() const; + + interval(); + interval(T const &v); + template interval(T1 const &v); + interval(T const &l, T const &u); + template interval(T1 const &l, T2 const &u); + interval(interval const &r); + template interval(interval const &r); + template interval(interval const &r); + + interval &operator=(T const &v); + template interval &operator=(T1 const &v); + interval &operator=(interval const &r); + template interval &operator=(interval const &r); + template interval &operator=(interval const &r); + + void assign(const T& l, const T& u); + + static interval empty(); + static interval whole(); + static interval hull(const T& x, const T& y); + + interval& operator+= (const T& r); + interval& operator+= (const interval& r); + interval& operator-= (const T& r); + interval& operator-= (const interval& r); + interval& operator*= (const T& r); + interval& operator*= (const interval& r); + interval& operator/= (const T& r); + interval& operator/= (const interval& r); + + bool operator< (const interval_holder& r) const; + bool operator> (const interval_holder& r) const; + bool operator<= (const interval_holder& r) const; + bool operator>= (const interval_holder& r) const; + bool operator== (const interval_holder& r) const; + bool operator!= (const interval_holder& r) const; + + bool operator< (const number_holder& r) const; + bool operator> (const number_holder& r) const; + bool operator<= (const number_holder& r) const; + bool operator>= (const number_holder& r) const; + bool operator== (const number_holder& r) const; + bool operator!= (const number_holder& r) const; + + // the following is for internal use only, it is not a published interface + // nevertheless, it's public because friends don't always work correctly. + interval(const T& l, const T& u, bool): low(l), up(u) {} + void set_empty(); + void set_whole(); + void set(const T& l, const T& u); + +private: + struct interval_holder { + template + interval_holder(const interval& r) + : low(r.lower()), up(r.upper()) + { + typedef typename Policies2::checking checking2; + if (checking2::is_empty(low, up)) + throw interval_lib::comparison_error(); + } + + const T& low; + const T& up; + }; + + struct number_holder { + number_holder(const T& r) : val(r) + { + typedef typename Policies::checking checking; + if (checking::is_nan(r)) + throw interval_lib::comparison_error(); + } + + const T& val; + }; + + typedef typename Policies::checking checking; + typedef typename Policies::rounding rounding; + + T low; + T up; +}; + +template inline +interval::interval(): + low(static_cast(0)), up(static_cast(0)) +{} + +template inline +interval::interval(T const &v): low(v), up(v) +{ + if (checking::is_nan(v)) set_empty(); +} + +template template inline +interval::interval(T1 const &v) +{ + if (checking::is_nan(v)) set_empty(); + else { + rounding rnd; + low = rnd.conv_down(v); + up = rnd.conv_up (v); + } +} + +template template inline +interval::interval(T1 const &l, T2 const &u) +{ + if (checking::is_nan(l) || checking::is_nan(u) || !(l <= u)) set_empty(); + else { + rounding rnd; + low = rnd.conv_down(l); + up = rnd.conv_up (u); + } +} + +template inline +interval::interval(T const &l, T const &u): low(l), up(u) +{ + if (checking::is_nan(l) || checking::is_nan(u) || !(l <= u)) + set_empty(); +} + + +template inline +interval::interval(interval const &r): low(r.lower()), up(r.upper()) +{} + +template template inline +interval::interval(interval const &r): low(r.lower()), up(r.upper()) +{ + typedef typename Policies1::checking checking1; + if (checking1::is_empty(r.lower(), r.upper())) set_empty(); +} + +template template inline +interval::interval(interval const &r) +{ + typedef typename Policies1::checking checking1; + if (checking1::is_empty(r.lower(), r.upper())) set_empty(); + else { + rounding rnd; + low = rnd.conv_down(r.lower()); + up = rnd.conv_up (r.upper()); + } +} + +template inline +interval &interval::operator=(T const &v) +{ + if (checking::is_nan(v)) set_empty(); + else low = up = v; + return *this; +} + +template template inline +interval &interval::operator=(T1 const &v) +{ + if (checking::is_nan(v)) set_empty(); + else { + rounding rnd; + low = rnd.conv_down(v); + up = rnd.conv_up (v); + } + return *this; +} + +template inline +interval &interval::operator=(interval const &r) +{ + low = r.lower(); + up = r.upper(); + return *this; +} + +template template inline +interval &interval::operator=(interval const &r) +{ + typedef typename Policies1::checking checking1; + if (checking1::is_empty(r.lower(), r.upper())) set_empty(); + else { + low = r.lower(); + up = r.upper(); + } + return *this; +} + +template template inline +interval &interval::operator=(interval const &r) +{ + typedef typename Policies1::checking checking1; + if (checking1::is_empty(r.lower(), r.upper())) set_empty(); + else { + rounding rnd; + low = rnd.conv_down(r.lower()); + up = rnd.conv_up (r.upper()); + } + return *this; +} + +template inline +void interval::assign(const T& l, const T& u) +{ + if (checking::is_nan(l) || checking::is_nan(u) || !(l <= u)) + set_empty(); + else set(l, u); +} + +template inline +void interval::set(const T& l, const T& u) +{ + low = l; + up = u; +} + +template inline +void interval::set_empty() +{ + low = checking::empty_lower(); + up = checking::empty_upper(); +} + +template inline +void interval::set_whole() +{ + low = checking::neg_inf(); + up = checking::pos_inf(); +} + +template inline +interval interval::hull(const T& x, const T& y) +{ + bool bad_x = checking::is_nan(x); + bool bad_y = checking::is_nan(y); + if (bad_x) + if (bad_y) return interval::empty(); + else return interval(y, y, true); + else + if (bad_y) return interval(x, x, true); + if (x <= y) return interval(x, y, true); + else return interval(y, x, true); +} + +template inline +interval interval::empty() +{ + return interval(checking::empty_lower(), + checking::empty_upper(), true); +} + +template inline +interval interval::whole() +{ + return interval(checking::neg_inf(), checking::pos_inf(), true); +} + +template inline +const T& interval::lower() const +{ + return low; +} + +template inline +const T& interval::upper() const +{ + return up; +} + +/* + * interval/interval comparisons + */ + +template inline +bool interval::operator< (const interval_holder& r) const +{ + if (!checking::is_empty(low, up)) { + if (up < r.low) return true; + else if (low >= r.up) return false; + } + throw interval_lib::comparison_error(); +} + +template inline +bool interval::operator> (const interval_holder& r) const +{ + if (!checking::is_empty(low, up)) { + if (low > r.up) return true; + else if (up <= r.low) return false; + } + throw interval_lib::comparison_error(); +} + +template inline +bool interval::operator<= (const interval_holder& r) const +{ + if (!checking::is_empty(low, up)) { + if (up <= r.low) return true; + else if (low > r.up) return false; + } + throw interval_lib::comparison_error(); +} + +template inline +bool interval::operator>= (const interval_holder& r) const +{ + if (!checking::is_empty(low, up)) { + if (low >= r.up) return true; + else if (up < r.low) return false; + } + throw interval_lib::comparison_error(); +} + +template inline +bool interval::operator== (const interval_holder& r) const +{ + if (!checking::is_empty(low, up)) { + if (up == r.low && low == r.up) return true; + else if (up < r.low || low > r.up) return false; + } + throw interval_lib::comparison_error(); +} + +template inline +bool interval::operator!= (const interval_holder& r) const +{ + if (!checking::is_empty(low, up)) { + if (up < r.low || low > r.up) return true; + else if (up == r.low && low == r.up) return false; + } + throw interval_lib::comparison_error(); +} + +/* + * interval/number comparisons + */ + +template inline +bool interval::operator< (const number_holder& r) const +{ + if (!checking::is_empty(low, up)) { + if (up < r.val) return true; + else if (low >= r.val) return false; + } + throw interval_lib::comparison_error(); +} + +template inline +bool interval::operator> (const number_holder& r) const +{ + if (!checking::is_empty(low, up)) { + if (low > r.val) return true; + else if (up <= r.val) return false; + } + throw interval_lib::comparison_error(); +} + +template inline +bool interval::operator<= (const number_holder& r) const +{ + if (!checking::is_empty(low, up)) { + if (up <= r.val) return true; + else if (low > r.val) return false; + } + throw interval_lib::comparison_error(); +} + +template inline +bool interval::operator>= (const number_holder& r) const +{ + if (!checking::is_empty(low, up)) { + if (low >= r.val) return true; + else if (up < r.val) return false; + } + throw interval_lib::comparison_error(); +} + +template inline +bool interval::operator== (const number_holder& r) const +{ + if (!checking::is_empty(low, up)) { + if (up == r.val && low == r.val) return true; + else if (up < r.val || low > r.val) return false; + } + throw interval_lib::comparison_error(); +} + +template inline +bool interval::operator!= (const number_holder& r) const +{ + if (!checking::is_empty(low, up)) { + if (up < r.val || low > r.val) return true; + else if (up == r.val && low == r.val) return false; + } + throw interval_lib::comparison_error(); +} + +} // namespace numeric +} // namespace boost + +#endif // BOOST_NUMERIC_INTERVAL_INTERVAL_HPP diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/io.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/io.hpp new file mode 100644 index 0000000000..dc4179e52c --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/io.hpp @@ -0,0 +1,41 @@ +/* Boost interval/io.hpp header file + * + * This file is only meant to provide a quick + * implementation of the output operator. It is + * provided for test programs that aren't even + * interested in the precision of the results. + * A real progam should define its own operators + * and never include this header. + * + * Copyright 2003 Guillaume Melquiond + * + * 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) + */ + +#ifndef BOOST_NUMERIC_INTERVAL_IO_HPP +#define BOOST_NUMERIC_INTERVAL_IO_HPP + +#include +#include +#include + +namespace boost { +namespace numeric { + +template +std::basic_ostream &operator<< + (std::basic_ostream &stream, + interval const &value) +{ + if (empty(value)) + return stream << "[]"; + else + return stream << '[' << lower(value) << ',' << upper(value) << ']'; +} + +} // namespace numeric +} // namespace boost + +#endif // BOOST_NUMERIC_INTERVAL_IO_HPP diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/limits.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/limits.hpp new file mode 100644 index 0000000000..d691ccee22 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/limits.hpp @@ -0,0 +1,51 @@ +/* Boost interval/limits.hpp template implementation file + * + * Copyright 2000 Jens Maurer + * Copyright 2002-2003 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion + * + * 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) + */ + +#ifndef BOOST_NUMERIC_INTERVAL_LIMITS_HPP +#define BOOST_NUMERIC_INTERVAL_LIMITS_HPP + +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + +#include +#include +#include + +namespace std { + +template +class numeric_limits > + : public numeric_limits +{ +private: + typedef boost::numeric::interval I; + typedef numeric_limits bl; +public: + static I min BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return I((bl::min)(), (bl::min)()); } + static I max BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return I((bl::max)(), (bl::max)()); } + static I epsilon() throw() { return I(bl::epsilon(), bl::epsilon()); } + + BOOST_STATIC_CONSTANT(float_round_style, round_style = round_indeterminate); + BOOST_STATIC_CONSTANT(bool, is_iec559 = false); + + static I infinity () throw() { return I::whole(); } + static I quiet_NaN() throw() { return I::empty(); } + static I signaling_NaN() throw() + { return I(bl::signaling_NaN(), bl::signaling_Nan()); } + static I denorm_min() throw() + { return I(bl::denorm_min(), bl::denorm_min()); } +private: + static I round_error(); // hide this on purpose, not yet implemented +}; + +} // namespace std + +#endif + +#endif // BOOST_NUMERIC_INTERVAL_LIMITS_HPP diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/policies.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/policies.hpp new file mode 100644 index 0000000000..70ad220d9a --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/policies.hpp @@ -0,0 +1,75 @@ +/* Boost interval/policies.hpp template implementation file + * + * Copyright 2003 Guillaume Melquiond + * + * 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) + */ + +#ifndef BOOST_NUMERIC_INTERVAL_POLICIES_HPP +#define BOOST_NUMERIC_INTERVAL_POLICIES_HPP + +#include + +namespace boost { +namespace numeric { +namespace interval_lib { + +/* + * policies class + */ + +template +struct policies +{ + typedef Rounding rounding; + typedef Checking checking; +}; + +/* + * policies switching classes + */ + +template +class change_rounding +{ + typedef typename OldInterval::base_type T; + typedef typename OldInterval::traits_type p; + typedef typename p::checking checking; +public: + typedef interval > type; +}; + +template +class change_checking +{ + typedef typename OldInterval::base_type T; + typedef typename OldInterval::traits_type p; + typedef typename p::rounding rounding; +public: + typedef interval > type; +}; + +/* + * Protect / unprotect: control whether the rounding mode is set/reset + * at each operation, rather than once and for all. + */ + +template +class unprotect +{ + typedef typename OldInterval::base_type T; + typedef typename OldInterval::traits_type p; + typedef typename p::rounding r; + typedef typename r::unprotected_rounding newRounding; +public: + typedef typename change_rounding::type type; +}; + +} // namespace interval_lib +} // namespace numeric +} // namespace boost + + +#endif // BOOST_NUMERIC_INTERVAL_POLICIES_HPP diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/rounded_arith.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/rounded_arith.hpp new file mode 100644 index 0000000000..8b2d9a7187 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/rounded_arith.hpp @@ -0,0 +1,120 @@ +/* Boost interval/rounded_arith.hpp template implementation file + * + * Copyright 2002-2003 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion + * + * 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) + */ + +#ifndef BOOST_NUMERIC_INTERVAL_ROUNDED_ARITH_HPP +#define BOOST_NUMERIC_INTERVAL_ROUNDED_ARITH_HPP + +#include +#include +#include + +namespace boost { +namespace numeric { +namespace interval_lib { + +/* + * Three classes of rounding: exact, std, opp + * See documentation for details. + */ + +template +struct rounded_arith_exact: Rounding { + void init() { } + template T conv_down(U const &v) { return v; } + template T conv_up (U const &v) { return v; } + T add_down (const T& x, const T& y) { return x + y; } + T add_up (const T& x, const T& y) { return x + y; } + T sub_down (const T& x, const T& y) { return x - y; } + T sub_up (const T& x, const T& y) { return x - y; } + T mul_down (const T& x, const T& y) { return x * y; } + T mul_up (const T& x, const T& y) { return x * y; } + T div_down (const T& x, const T& y) { return x / y; } + T div_up (const T& x, const T& y) { return x / y; } + T median (const T& x, const T& y) { return (x + y) / 2; } + T sqrt_down(const T& x) + { BOOST_NUMERIC_INTERVAL_using_math(sqrt); return sqrt(x); } + T sqrt_up (const T& x) + { BOOST_NUMERIC_INTERVAL_using_math(sqrt); return sqrt(x); } + T int_down (const T& x) + { BOOST_NUMERIC_INTERVAL_using_math(floor); return floor(x); } + T int_up (const T& x) + { BOOST_NUMERIC_INTERVAL_using_math(ceil); return ceil(x); } +}; + +template +struct rounded_arith_std: Rounding { +# define BOOST_DN(EXPR) this->downward(); return this->force_rounding(EXPR) +# define BOOST_NR(EXPR) this->to_nearest(); return this->force_rounding(EXPR) +# define BOOST_UP(EXPR) this->upward(); return this->force_rounding(EXPR) + void init() { } + template T conv_down(U const &v) { BOOST_DN(v); } + template T conv_up (U const &v) { BOOST_UP(v); } + T add_down(const T& x, const T& y) { BOOST_DN(x + y); } + T sub_down(const T& x, const T& y) { BOOST_DN(x - y); } + T mul_down(const T& x, const T& y) { BOOST_DN(x * y); } + T div_down(const T& x, const T& y) { BOOST_DN(x / y); } + T add_up (const T& x, const T& y) { BOOST_UP(x + y); } + T sub_up (const T& x, const T& y) { BOOST_UP(x - y); } + T mul_up (const T& x, const T& y) { BOOST_UP(x * y); } + T div_up (const T& x, const T& y) { BOOST_UP(x / y); } + T median(const T& x, const T& y) { BOOST_NR((x + y) / 2); } + T sqrt_down(const T& x) + { BOOST_NUMERIC_INTERVAL_using_math(sqrt); BOOST_DN(sqrt(x)); } + T sqrt_up (const T& x) + { BOOST_NUMERIC_INTERVAL_using_math(sqrt); BOOST_UP(sqrt(x)); } + T int_down(const T& x) { this->downward(); return to_int(x); } + T int_up (const T& x) { this->upward(); return to_int(x); } +# undef BOOST_DN +# undef BOOST_NR +# undef BOOST_UP +}; + +template +struct rounded_arith_opp: Rounding { + void init() { this->upward(); } +# define BOOST_DN(EXPR) \ + this->downward(); \ + T r = this->force_rounding(EXPR); \ + this->upward(); \ + return r +# define BOOST_NR(EXPR) \ + this->to_nearest(); \ + T r = this->force_rounding(EXPR); \ + this->upward(); \ + return r +# define BOOST_UP(EXPR) return this->force_rounding(EXPR) +# define BOOST_UP_NEG(EXPR) return -this->force_rounding(EXPR) + template T conv_down(U const &v) { BOOST_UP_NEG(-v); } + template T conv_up (U const &v) { BOOST_UP(v); } + T add_down(const T& x, const T& y) { BOOST_UP_NEG((-x) - y); } + T sub_down(const T& x, const T& y) { BOOST_UP_NEG(y - x); } + T mul_down(const T& x, const T& y) { BOOST_UP_NEG(x * (-y)); } + T div_down(const T& x, const T& y) { BOOST_UP_NEG(x / (-y)); } + T add_up (const T& x, const T& y) { BOOST_UP(x + y); } + T sub_up (const T& x, const T& y) { BOOST_UP(x - y); } + T mul_up (const T& x, const T& y) { BOOST_UP(x * y); } + T div_up (const T& x, const T& y) { BOOST_UP(x / y); } + T median (const T& x, const T& y) { BOOST_NR((x + y) / 2); } + T sqrt_down(const T& x) + { BOOST_NUMERIC_INTERVAL_using_math(sqrt); BOOST_DN(sqrt(x)); } + T sqrt_up (const T& x) + { BOOST_NUMERIC_INTERVAL_using_math(sqrt); BOOST_UP(sqrt(x)); } + T int_down(const T& x) { return -to_int(-x); } + T int_up (const T& x) { return to_int(x); } +# undef BOOST_DN +# undef BOOST_NR +# undef BOOST_UP +# undef BOOST_UP_NEG +}; + +} // namespace interval_lib +} // namespace numeric +} // namespace boost + +#endif // BOOST_NUMERIC_INTERVAL_ROUNDED_ARITH_HPP diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/rounded_transc.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/rounded_transc.hpp new file mode 100644 index 0000000000..ac4982e31c --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/rounded_transc.hpp @@ -0,0 +1,140 @@ +/* Boost interval/rounded_transc.hpp template implementation file + * + * Copyright 2002-2003 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion + * + * 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) + */ + +#ifndef BOOST_NUMERIC_INTERVAL_ROUNDED_TRANSC_HPP +#define BOOST_NUMERIC_INTERVAL_ROUNDED_TRANSC_HPP + +#include +#include +#include + +namespace boost { +namespace numeric { +namespace interval_lib { + +template +struct rounded_transc_exact: Rounding +{ +# define BOOST_NUMERIC_INTERVAL_new_func(f) \ + T f##_down(const T& x) { BOOST_NUMERIC_INTERVAL_using_math(f); return f(x); } \ + T f##_up (const T& x) { BOOST_NUMERIC_INTERVAL_using_math(f); return f(x); } + BOOST_NUMERIC_INTERVAL_new_func(exp) + BOOST_NUMERIC_INTERVAL_new_func(log) + BOOST_NUMERIC_INTERVAL_new_func(sin) + BOOST_NUMERIC_INTERVAL_new_func(cos) + BOOST_NUMERIC_INTERVAL_new_func(tan) + BOOST_NUMERIC_INTERVAL_new_func(asin) + BOOST_NUMERIC_INTERVAL_new_func(acos) + BOOST_NUMERIC_INTERVAL_new_func(atan) + BOOST_NUMERIC_INTERVAL_new_func(sinh) + BOOST_NUMERIC_INTERVAL_new_func(cosh) + BOOST_NUMERIC_INTERVAL_new_func(tanh) +# undef BOOST_NUMERIC_INTERVAL_new_func +# define BOOST_NUMERIC_INTERVAL_new_func(f) \ + T f##_down(const T& x) { BOOST_NUMERIC_INTERVAL_using_ahyp(f); return f(x); } \ + T f##_up (const T& x) { BOOST_NUMERIC_INTERVAL_using_ahyp(f); return f(x); } + BOOST_NUMERIC_INTERVAL_new_func(asinh) + BOOST_NUMERIC_INTERVAL_new_func(acosh) + BOOST_NUMERIC_INTERVAL_new_func(atanh) +# undef BOOST_NUMERIC_INTERVAL_new_func +}; + +template +struct rounded_transc_std: Rounding +{ +# define BOOST_NUMERIC_INTERVAL_new_func(f) \ + T f##_down(const T& x) \ + { BOOST_NUMERIC_INTERVAL_using_math(f); \ + this->downward(); return this->force_rounding(f(x)); } \ + T f##_up (const T& x) \ + { BOOST_NUMERIC_INTERVAL_using_math(f); \ + this->upward(); return this->force_rounding(f(x)); } + BOOST_NUMERIC_INTERVAL_new_func(exp) + BOOST_NUMERIC_INTERVAL_new_func(log) + BOOST_NUMERIC_INTERVAL_new_func(sin) + BOOST_NUMERIC_INTERVAL_new_func(cos) + BOOST_NUMERIC_INTERVAL_new_func(tan) + BOOST_NUMERIC_INTERVAL_new_func(asin) + BOOST_NUMERIC_INTERVAL_new_func(acos) + BOOST_NUMERIC_INTERVAL_new_func(atan) + BOOST_NUMERIC_INTERVAL_new_func(sinh) + BOOST_NUMERIC_INTERVAL_new_func(cosh) + BOOST_NUMERIC_INTERVAL_new_func(tanh) +# undef BOOST_NUMERIC_INTERVAL_new_func +# define BOOST_NUMERIC_INTERVAL_new_func(f) \ + T f##_down(const T& x) \ + { BOOST_NUMERIC_INTERVAL_using_ahyp(f); \ + this->downward(); return this->force_rounding(f(x)); } \ + T f##_up (const T& x) \ + { BOOST_NUMERIC_INTERVAL_using_ahyp(f); \ + this->upward(); return this->force_rounding(f(x)); } + BOOST_NUMERIC_INTERVAL_new_func(asinh) + BOOST_NUMERIC_INTERVAL_new_func(acosh) + BOOST_NUMERIC_INTERVAL_new_func(atanh) +# undef BOOST_NUMERIC_INTERVAL_new_func +}; + +template +struct rounded_transc_opp: Rounding +{ +# define BOOST_NUMERIC_INTERVAL_new_func(f) \ + T f##_down(const T& x) \ + { BOOST_NUMERIC_INTERVAL_using_math(f); \ + this->downward(); T y = this->force_rounding(f(x)); \ + this->upward(); return y; } \ + T f##_up (const T& x) \ + { BOOST_NUMERIC_INTERVAL_using_math(f); \ + return this->force_rounding(f(x)); } + BOOST_NUMERIC_INTERVAL_new_func(exp) + BOOST_NUMERIC_INTERVAL_new_func(log) + BOOST_NUMERIC_INTERVAL_new_func(cos) + BOOST_NUMERIC_INTERVAL_new_func(acos) + BOOST_NUMERIC_INTERVAL_new_func(cosh) +# undef BOOST_NUMERIC_INTERVAL_new_func +# define BOOST_NUMERIC_INTERVAL_new_func(f) \ + T f##_down(const T& x) \ + { BOOST_NUMERIC_INTERVAL_using_math(f); \ + return -this->force_rounding(-f(x)); } \ + T f##_up (const T& x) \ + { BOOST_NUMERIC_INTERVAL_using_math(f); \ + return this->force_rounding(f(x)); } + BOOST_NUMERIC_INTERVAL_new_func(sin) + BOOST_NUMERIC_INTERVAL_new_func(tan) + BOOST_NUMERIC_INTERVAL_new_func(asin) + BOOST_NUMERIC_INTERVAL_new_func(atan) + BOOST_NUMERIC_INTERVAL_new_func(sinh) + BOOST_NUMERIC_INTERVAL_new_func(tanh) +# undef BOOST_NUMERIC_INTERVAL_new_func +# define BOOST_NUMERIC_INTERVAL_new_func(f) \ + T f##_down(const T& x) \ + { BOOST_NUMERIC_INTERVAL_using_ahyp(f); \ + this->downward(); T y = this->force_rounding(f(x)); \ + this->upward(); return y; } \ + T f##_up (const T& x) \ + { BOOST_NUMERIC_INTERVAL_using_ahyp(f); \ + return this->force_rounding(f(x)); } + BOOST_NUMERIC_INTERVAL_new_func(asinh) + BOOST_NUMERIC_INTERVAL_new_func(atanh) +# undef BOOST_NUMERIC_INTERVAL_new_func +# define BOOST_NUMERIC_INTERVAL_new_func(f) \ + T f##_down(const T& x) \ + { BOOST_NUMERIC_INTERVAL_using_ahyp(f); \ + return -this->force_rounding(-f(x)); } \ + T f##_up (const T& x) \ + { BOOST_NUMERIC_INTERVAL_using_ahyp(f); \ + return this->force_rounding(f(x)); } + BOOST_NUMERIC_INTERVAL_new_func(acosh) +# undef BOOST_NUMERIC_INTERVAL_new_func +}; + +} // namespace interval_lib +} // namespace numeric +} // namespace boost + +#endif // BOOST_NUMERIC_INTERVAL_ROUNDED_TRANSC_HPP diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/rounding.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/rounding.hpp new file mode 100644 index 0000000000..f69e2e4b53 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/rounding.hpp @@ -0,0 +1,101 @@ +/* Boost interval/rounding.hpp template implementation file + * + * Copyright 2002-2003 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion + * + * 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) + */ + +#ifndef BOOST_NUMERIC_INTERVAL_ROUNDING_HPP +#define BOOST_NUMERIC_INTERVAL_ROUNDING_HPP + +namespace boost { +namespace numeric { +namespace interval_lib { + +/* + * Default rounding_control class (does nothing) + */ + +template +struct rounding_control +{ + typedef int rounding_mode; + static void get_rounding_mode(rounding_mode&) {} + static void set_rounding_mode(rounding_mode) {} + static void upward() {} + static void downward() {} + static void to_nearest() {} + static const T& to_int(const T& x) { return x; } + static const T& force_rounding(const T& x) { return x; } +}; + +/* + * A few rounding control classes (exact/std/opp: see documentation) + * rounded_arith_* control the rounding of the arithmetic operators + * rounded_transc_* control the rounding of the transcendental functions + */ + +template > +struct rounded_arith_exact; + +template > +struct rounded_arith_std; + +template > +struct rounded_arith_opp; + +template +struct rounded_transc_dummy; + +template > +struct rounded_transc_exact; + +template > +struct rounded_transc_std; + +template > +struct rounded_transc_opp; + +/* + * State-saving classes: allow to set and reset rounding control + */ + +namespace detail { + +template +struct save_state_unprotected: Rounding +{ + typedef save_state_unprotected unprotected_rounding; +}; + +} // namespace detail + +template +struct save_state: Rounding +{ + typename Rounding::rounding_mode mode; + save_state() { + this->get_rounding_mode(mode); + this->init(); + } + ~save_state() { this->set_rounding_mode(mode); } + typedef detail::save_state_unprotected unprotected_rounding; +}; + +template +struct save_state_nothing: Rounding +{ + typedef save_state_nothing unprotected_rounding; +}; + +template +struct rounded_math: save_state_nothing > +{}; + +} // namespace interval_lib +} // namespace numeric +} // namespace boost + +#endif // BOOST_NUMERIC_INTERVAL_ROUNDING_HPP diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/transc.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/transc.hpp new file mode 100644 index 0000000000..8d7a7a1acd --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/transc.hpp @@ -0,0 +1,232 @@ +/* Boost interval/transc.hpp template implementation file + * + * Copyright 2000 Jens Maurer + * Copyright 2002 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion + * + * 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) + */ + +#ifndef BOOST_NUMERIC_INTERVAL_TRANSC_HPP +#define BOOST_NUMERIC_INTERVAL_TRANSC_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost { +namespace numeric { + +template inline +interval exp(const interval& x) +{ + typedef interval I; + if (interval_lib::detail::test_input(x)) + return I::empty(); + typename Policies::rounding rnd; + return I(rnd.exp_down(x.lower()), rnd.exp_up(x.upper()), true); +} + +template inline +interval log(const interval& x) +{ + typedef interval I; + if (interval_lib::detail::test_input(x) || + !interval_lib::user::is_pos(x.upper())) + return I::empty(); + typename Policies::rounding rnd; + typedef typename Policies::checking checking; + T l = !interval_lib::user::is_pos(x.lower()) + ? checking::neg_inf() : rnd.log_down(x.lower()); + return I(l, rnd.log_up(x.upper()), true); +} + +template inline +interval cos(const interval& x) +{ + if (interval_lib::detail::test_input(x)) + return interval::empty(); + typename Policies::rounding rnd; + typedef interval I; + typedef typename interval_lib::unprotect::type R; + + // get lower bound within [0, pi] + const R pi2 = interval_lib::pi_twice(); + R tmp = fmod((const R&)x, pi2); + if (width(tmp) >= pi2.lower()) + return I(static_cast(-1), static_cast(1), true); // we are covering a full period + if (tmp.lower() >= interval_lib::constants::pi_upper()) + return -cos(tmp - interval_lib::pi()); + T l = tmp.lower(); + T u = tmp.upper(); + + BOOST_USING_STD_MIN(); + // separate into monotone subintervals + if (u <= interval_lib::constants::pi_lower()) + return I(rnd.cos_down(u), rnd.cos_up(l), true); + else if (u <= pi2.lower()) + return I(static_cast(-1), rnd.cos_up(min BOOST_PREVENT_MACRO_SUBSTITUTION(rnd.sub_down(pi2.lower(), u), l)), true); + else + return I(static_cast(-1), static_cast(1), true); +} + +template inline +interval sin(const interval& x) +{ + typedef interval I; + if (interval_lib::detail::test_input(x)) + return I::empty(); + typename Policies::rounding rnd; + typedef typename interval_lib::unprotect::type R; + I r = cos((const R&)x - interval_lib::pi_half()); + (void)&rnd; + return r; +} + +template inline +interval tan(const interval& x) +{ + typedef interval I; + if (interval_lib::detail::test_input(x)) + return I::empty(); + typename Policies::rounding rnd; + typedef typename interval_lib::unprotect::type R; + + // get lower bound within [-pi/2, pi/2] + const R pi = interval_lib::pi(); + R tmp = fmod((const R&)x, pi); + const T pi_half_d = interval_lib::constants::pi_half_lower(); + if (tmp.lower() >= pi_half_d) + tmp -= pi; + if (tmp.lower() <= -pi_half_d || tmp.upper() >= pi_half_d) + return I::whole(); + return I(rnd.tan_down(tmp.lower()), rnd.tan_up(tmp.upper()), true); +} + +template inline +interval asin(const interval& x) +{ + typedef interval I; + if (interval_lib::detail::test_input(x) + || x.upper() < static_cast(-1) || x.lower() > static_cast(1)) + return I::empty(); + typename Policies::rounding rnd; + T l = (x.lower() <= static_cast(-1)) + ? -interval_lib::constants::pi_half_upper() + : rnd.asin_down(x.lower()); + T u = (x.upper() >= static_cast(1) ) + ? interval_lib::constants::pi_half_upper() + : rnd.asin_up (x.upper()); + return I(l, u, true); +} + +template inline +interval acos(const interval& x) +{ + typedef interval I; + if (interval_lib::detail::test_input(x) + || x.upper() < static_cast(-1) || x.lower() > static_cast(1)) + return I::empty(); + typename Policies::rounding rnd; + T l = (x.upper() >= static_cast(1) ) + ? static_cast(0) + : rnd.acos_down(x.upper()); + T u = (x.lower() <= static_cast(-1)) + ? interval_lib::constants::pi_upper() + : rnd.acos_up (x.lower()); + return I(l, u, true); +} + +template inline +interval atan(const interval& x) +{ + typedef interval I; + if (interval_lib::detail::test_input(x)) + return I::empty(); + typename Policies::rounding rnd; + return I(rnd.atan_down(x.lower()), rnd.atan_up(x.upper()), true); +} + +template inline +interval sinh(const interval& x) +{ + typedef interval I; + if (interval_lib::detail::test_input(x)) + return I::empty(); + typename Policies::rounding rnd; + return I(rnd.sinh_down(x.lower()), rnd.sinh_up(x.upper()), true); +} + +template inline +interval cosh(const interval& x) +{ + typedef interval I; + if (interval_lib::detail::test_input(x)) + return I::empty(); + typename Policies::rounding rnd; + if (interval_lib::user::is_neg(x.upper())) + return I(rnd.cosh_down(x.upper()), rnd.cosh_up(x.lower()), true); + else if (!interval_lib::user::is_neg(x.lower())) + return I(rnd.cosh_down(x.lower()), rnd.cosh_up(x.upper()), true); + else + return I(static_cast(1), rnd.cosh_up(-x.lower() > x.upper() ? x.lower() : x.upper()), true); +} + +template inline +interval tanh(const interval& x) +{ + typedef interval I; + if (interval_lib::detail::test_input(x)) + return I::empty(); + typename Policies::rounding rnd; + return I(rnd.tanh_down(x.lower()), rnd.tanh_up(x.upper()), true); +} + +template inline +interval asinh(const interval& x) +{ + typedef interval I; + if (interval_lib::detail::test_input(x)) + return I::empty(); + typename Policies::rounding rnd; + return I(rnd.asinh_down(x.lower()), rnd.asinh_up(x.upper()), true); +} + +template inline +interval acosh(const interval& x) +{ + typedef interval I; + if (interval_lib::detail::test_input(x) || x.upper() < static_cast(1)) + return I::empty(); + typename Policies::rounding rnd; + T l = x.lower() <= static_cast(1) ? static_cast(0) : rnd.acosh_down(x.lower()); + return I(l, rnd.acosh_up(x.upper()), true); +} + +template inline +interval atanh(const interval& x) +{ + typedef interval I; + if (interval_lib::detail::test_input(x) + || x.upper() < static_cast(-1) || x.lower() > static_cast(1)) + return I::empty(); + typename Policies::rounding rnd; + typedef typename Policies::checking checking; + T l = (x.lower() <= static_cast(-1)) + ? checking::neg_inf() : rnd.atanh_down(x.lower()); + T u = (x.upper() >= static_cast(1) ) + ? checking::pos_inf() : rnd.atanh_up (x.upper()); + return I(l, u, true); +} + +} // namespace numeric +} // namespace boost + +#endif // BOOST_NUMERIC_INTERVAL_TRANSC_HPP diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/utility.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/utility.hpp new file mode 100644 index 0000000000..c89cdb1e93 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/interval/utility.hpp @@ -0,0 +1,337 @@ +/* Boost interval/utility.hpp template implementation file + * + * Copyright 2000 Jens Maurer + * Copyright 2002-2003 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion + * + * 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) + */ + +#ifndef BOOST_NUMERIC_INTERVAL_UTILITY_HPP +#define BOOST_NUMERIC_INTERVAL_UTILITY_HPP + +#include +#include +#include +#include +#include +#include + +/* + * Implementation of simple functions + */ + +namespace boost { +namespace numeric { + +/* + * Utility Functions + */ + +template inline +const T& lower(const interval& x) +{ + return x.lower(); +} + +template inline +const T& upper(const interval& x) +{ + return x.upper(); +} + +template inline +T checked_lower(const interval& x) +{ + if (empty(x)) { + typedef typename Policies::checking checking; + return checking::nan(); + } + return x.lower(); +} + +template inline +T checked_upper(const interval& x) +{ + if (empty(x)) { + typedef typename Policies::checking checking; + return checking::nan(); + } + return x.upper(); +} + +template inline +T width(const interval& x) +{ + if (interval_lib::detail::test_input(x)) return static_cast(0); + typename Policies::rounding rnd; + return rnd.sub_up(x.upper(), x.lower()); +} + +template inline +T median(const interval& x) +{ + if (interval_lib::detail::test_input(x)) { + typedef typename Policies::checking checking; + return checking::nan(); + } + typename Policies::rounding rnd; + return rnd.median(x.lower(), x.upper()); +} + +template inline +interval widen(const interval& x, const T& v) +{ + if (interval_lib::detail::test_input(x)) + return interval::empty(); + typename Policies::rounding rnd; + return interval(rnd.sub_down(x.lower(), v), + rnd.add_up (x.upper(), v), true); +} + +/* + * Set-like operations + */ + +template inline +bool empty(const interval& x) +{ + return interval_lib::detail::test_input(x); +} + +template inline +bool zero_in(const interval& x) +{ + if (interval_lib::detail::test_input(x)) return false; + return (!interval_lib::user::is_pos(x.lower())) && + (!interval_lib::user::is_neg(x.upper())); +} + +template inline +bool in_zero(const interval& x) // DEPRECATED +{ + return zero_in(x); +} + +template inline +bool in(const T& x, const interval& y) +{ + if (interval_lib::detail::test_input(x, y)) return false; + return y.lower() <= x && x <= y.upper(); +} + +template inline +bool subset(const interval& x, + const interval& y) +{ + if (empty(x)) return true; + return !empty(y) && y.lower() <= x.lower() && x.upper() <= y.upper(); +} + +template inline +bool proper_subset(const interval& x, + const interval& y) +{ + if (empty(y)) return false; + if (empty(x)) return true; + return y.lower() <= x.lower() && x.upper() <= y.upper() && + (y.lower() != x.lower() || x.upper() != y.upper()); +} + +template inline +bool overlap(const interval& x, + const interval& y) +{ + if (interval_lib::detail::test_input(x, y)) return false; + return (x.lower() <= y.lower() && y.lower() <= x.upper()) || + (y.lower() <= x.lower() && x.lower() <= y.upper()); +} + +template inline +bool singleton(const interval& x) +{ + return !empty(x) && x.lower() == x.upper(); +} + +template inline +bool equal(const interval& x, const interval& y) +{ + if (empty(x)) return empty(y); + return !empty(y) && x.lower() == y.lower() && x.upper() == y.upper(); +} + +template inline +interval intersect(const interval& x, + const interval& y) +{ + BOOST_USING_STD_MIN(); + BOOST_USING_STD_MAX(); + if (interval_lib::detail::test_input(x, y)) + return interval::empty(); + const T& l = max BOOST_PREVENT_MACRO_SUBSTITUTION(x.lower(), y.lower()); + const T& u = min BOOST_PREVENT_MACRO_SUBSTITUTION(x.upper(), y.upper()); + if (l <= u) return interval(l, u, true); + else return interval::empty(); +} + +template inline +interval hull(const interval& x, + const interval& y) +{ + BOOST_USING_STD_MIN(); + BOOST_USING_STD_MAX(); + bool bad_x = interval_lib::detail::test_input(x); + bool bad_y = interval_lib::detail::test_input(y); + if (bad_x) + if (bad_y) return interval::empty(); + else return y; + else + if (bad_y) return x; + return interval(min BOOST_PREVENT_MACRO_SUBSTITUTION(x.lower(), y.lower()), + max BOOST_PREVENT_MACRO_SUBSTITUTION(x.upper(), y.upper()), true); +} + +template inline +interval hull(const interval& x, const T& y) +{ + BOOST_USING_STD_MIN(); + BOOST_USING_STD_MAX(); + bool bad_x = interval_lib::detail::test_input(x); + bool bad_y = interval_lib::detail::test_input(y); + if (bad_y) + if (bad_x) return interval::empty(); + else return x; + else + if (bad_x) return interval(y, y, true); + return interval(min BOOST_PREVENT_MACRO_SUBSTITUTION(x.lower(), y), + max BOOST_PREVENT_MACRO_SUBSTITUTION(x.upper(), y), true); +} + +template inline +interval hull(const T& x, const interval& y) +{ + BOOST_USING_STD_MIN(); + BOOST_USING_STD_MAX(); + bool bad_x = interval_lib::detail::test_input(x); + bool bad_y = interval_lib::detail::test_input(y); + if (bad_x) + if (bad_y) return interval::empty(); + else return y; + else + if (bad_y) return interval(x, x, true); + return interval(min BOOST_PREVENT_MACRO_SUBSTITUTION(x, y.lower()), + max BOOST_PREVENT_MACRO_SUBSTITUTION(x, y.upper()), true); +} + +template inline +interval hull(const T& x, const T& y) +{ + return interval::hull(x, y); +} + +template inline +std::pair, interval > +bisect(const interval& x) +{ + typedef interval I; + if (interval_lib::detail::test_input(x)) + return std::pair(I::empty(), I::empty()); + const T m = median(x); + return std::pair(I(x.lower(), m, true), I(m, x.upper(), true)); +} + +/* + * Elementary functions + */ + +template inline +T norm(const interval& x) +{ + typedef interval I; + if (interval_lib::detail::test_input(x)) { + typedef typename Policies::checking checking; + return checking::nan(); + } + BOOST_USING_STD_MAX(); + return max BOOST_PREVENT_MACRO_SUBSTITUTION(static_cast(-x.lower()), x.upper()); +} + +template inline +interval abs(const interval& x) +{ + typedef interval I; + if (interval_lib::detail::test_input(x)) + return I::empty(); + if (!interval_lib::user::is_neg(x.lower())) return x; + if (!interval_lib::user::is_pos(x.upper())) return -x; + BOOST_USING_STD_MAX(); + return I(static_cast(0), max BOOST_PREVENT_MACRO_SUBSTITUTION(static_cast(-x.lower()), x.upper()), true); +} + +template inline +interval max BOOST_PREVENT_MACRO_SUBSTITUTION (const interval& x, + const interval& y) +{ + typedef interval I; + if (interval_lib::detail::test_input(x, y)) + return I::empty(); + BOOST_USING_STD_MAX(); + return I(max BOOST_PREVENT_MACRO_SUBSTITUTION(x.lower(), y.lower()), max BOOST_PREVENT_MACRO_SUBSTITUTION(x.upper(), y.upper()), true); +} + +template inline +interval max BOOST_PREVENT_MACRO_SUBSTITUTION (const interval& x, const T& y) +{ + typedef interval I; + if (interval_lib::detail::test_input(x, y)) + return I::empty(); + BOOST_USING_STD_MAX(); + return I(max BOOST_PREVENT_MACRO_SUBSTITUTION(x.lower(), y), max BOOST_PREVENT_MACRO_SUBSTITUTION(x.upper(), y), true); +} + +template inline +interval max BOOST_PREVENT_MACRO_SUBSTITUTION (const T& x, const interval& y) +{ + typedef interval I; + if (interval_lib::detail::test_input(x, y)) + return I::empty(); + BOOST_USING_STD_MAX(); + return I(max BOOST_PREVENT_MACRO_SUBSTITUTION(x, y.lower()), max BOOST_PREVENT_MACRO_SUBSTITUTION(x, y.upper()), true); +} + +template inline +interval min BOOST_PREVENT_MACRO_SUBSTITUTION (const interval& x, + const interval& y) +{ + typedef interval I; + if (interval_lib::detail::test_input(x, y)) + return I::empty(); + BOOST_USING_STD_MIN(); + return I(min BOOST_PREVENT_MACRO_SUBSTITUTION(x.lower(), y.lower()), min BOOST_PREVENT_MACRO_SUBSTITUTION(x.upper(), y.upper()), true); +} + +template inline +interval min BOOST_PREVENT_MACRO_SUBSTITUTION (const interval& x, const T& y) +{ + typedef interval I; + if (interval_lib::detail::test_input(x, y)) + return I::empty(); + BOOST_USING_STD_MIN(); + return I(min BOOST_PREVENT_MACRO_SUBSTITUTION(x.lower(), y), min BOOST_PREVENT_MACRO_SUBSTITUTION(x.upper(), y), true); +} + +template inline +interval min BOOST_PREVENT_MACRO_SUBSTITUTION (const T& x, const interval& y) +{ + typedef interval I; + if (interval_lib::detail::test_input(x, y)) + return I::empty(); + BOOST_USING_STD_MIN(); + return I(min BOOST_PREVENT_MACRO_SUBSTITUTION(x, y.lower()), min BOOST_PREVENT_MACRO_SUBSTITUTION(x, y.upper()), true); +} + +} // namespace numeric +} // namespace boost + +#endif // BOOST_NUMERIC_INTERVAL_UTILITY_HPP diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/ublas/assignment.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/ublas/assignment.hpp new file mode 100644 index 0000000000..65ae12d513 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/ublas/assignment.hpp @@ -0,0 +1,1281 @@ +// +// 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) +// + +#ifndef ASSIGNMENT_HPP +#define ASSIGNMENT_HPP +#include +#include + +/*! \file assignment.hpp + \brief uBlas assignment operator <<=. +*/ + +namespace boost { namespace numeric { namespace ublas { + +/** \brief A CRTP and Barton-Nackman trick index manipulator wrapper class. + * + * This class is not meant to be used directly. + */ +template +class index_manipulator { +public: + typedef TV type; + BOOST_UBLAS_INLINE + const type &operator () () const { + return *static_cast (this); + } + BOOST_UBLAS_INLINE + type &operator () () { + return *static_cast (this); + } +}; + +/** \brief A move_to vector index manipulator. + * + * When member function \c manip is called the referenced + * index will be set to the manipulators' index. + * + * \sa move_to(T i) + */ +template +class vector_move_to_manip: public index_manipulator > { +public: + BOOST_UBLAS_INLINE + vector_move_to_manip(const T &k): i(k) { } + + template + BOOST_UBLAS_INLINE + void manip(V &k) const { k=i; } +private: + T i; +}; + +/** \brief An object generator that returns a move_to vector index manipulator + * + * \param i The element number the manipulator will move to when \c manip member function is called + * \return A move_to vector manipulator + * + * Example usage: + * \code + * vector a(6, 0); + * a <<= 1, 2, move_to(5), 3; + * \endcode + * will result in: + * \code + * 1 2 0 0 0 3 + * \endcode + * + * \tparam T Size type + * \sa move_to() + */ +template +BOOST_UBLAS_INLINE vector_move_to_manip move_to(T i) { + return vector_move_to_manip(i); +} + +/** \brief A static move to vector manipulator. + * + * When member function \c manip is called the referenced + * index will be set to the manipulators' index + * + * \sa move_to(T i) and move_to() +*/ +template +class static_vector_move_to_manip: public index_manipulator > { +public: + template + BOOST_UBLAS_INLINE + void manip(V &k) const { k=I; } +}; + +/** \brief An object generator that returns a static move_to vector index manipulator. + * + * Typically faster than the dynamic version, but can be used only when the + * values are known at compile time. + * + * \return A static move_to vector manipulator + * + * Example usage: + * \code + * vector a(6, 0); + * a <<= 1, 2, move_to<5>(), 3; + * \endcode + * will result in: + * \code + * 1 2 0 0 0 3 + * \endcode + * + * \tparam I The number of elements the manipulator will traverse the index when \c manip function is called + */ +template +BOOST_UBLAS_INLINE static_vector_move_to_manip move_to() { + return static_vector_move_to_manip(); +} + +/** \brief A move vector index manipulator. + * + * When member function traverse is called the manipulators' + * index will be added to the referenced index. + * + * \see move(T i) + */ +template +class vector_move_manip: public index_manipulator > { +public: + BOOST_UBLAS_INLINE + vector_move_manip(const T &k): i(k) { } + + template + BOOST_UBLAS_INLINE void manip(V &k) const { k+=i; } +private: + T i; +}; + +/** +* \brief An object generator that returns a move vector index manipulator +* +* \tparam T Size type +* \param i The number of elements the manipulator will traverse the index when \c manip +* member function is called. Negative values can be used. +* \return A move vector manipulator +* +* Example usage: +* \code +* vector a(6, 0); +* a <<= 1, 2, move(3), 3; +* \endcode +* will result in: +* \code +* 1 2 0 0 0 3 +* \endcode +* +*/ +template +BOOST_UBLAS_INLINE vector_move_manip move(T i) { + return vector_move_manip(i); +} + +/** +* \brief A static move vector manipulator +* +* When member function \c manip is called the manipulators +* index will be added to the referenced index +* +* \sa move() +* +* \todo Doxygen has some problems with similar template functions. Correct that. +*/ +template +class static_vector_move_manip: public index_manipulator > { +public: + template + BOOST_UBLAS_INLINE void manip(V &k) const { k+=I; } +}; + +/** +* \brief An object generator that returns a static move vector index manipulator. +* +* Typically faster than the dynamic version, but can be used only when the +* values are known at compile time. +* \tparam I The Number of elements the manipulator will traverse the index when \c manip +* function is called.Negative values can be used. +* \return A static move vector manipulator +* +* Example usage: +* \code +* vector a(6, 0); +* a <<= 1, 2, move<3>(), 3; +* \endcode +* will result in: +* \code +* 1 2 0 0 0 3 +* \endcode +* +* \todo Doxygen has some problems with similar template functions. Correct that. +*/ +template +BOOST_UBLAS_INLINE static_vector_move_manip move() { + return static_vector_move_manip(); +} + +/** +* \brief A move_to matrix manipulator +* +* When member function \c manip is called the referenced +* index will be set to the manipulators' index +* +* \sa move_to(T i, T j) +* +* \todo Doxygen has some problems with similar template functions. Correct that. +*/ +template +class matrix_move_to_manip: public index_manipulator > { +public: + BOOST_UBLAS_INLINE + matrix_move_to_manip(T k, T l): i(k), j(l) { } + + template + BOOST_UBLAS_INLINE + void manip(V1 &k, V2 &l) const { + k=i; + l=j; + } +private: + T i, j; +}; + +/** +* \brief An object generator that returns a "move_to" matrix index manipulator +* +* \tparam size type +* \param i The row number the manipulator will move to when \c manip +* member function is called +* \param j The column number the manipulator will move to when \c manip +* member function is called +* \return A move matrix manipulator +* +* Example usage: +* \code: +* matrix A(3, 3, 0); +* A <<= 1, 2, move_to(A.size1()-1, A.size1()-1), 3; +* \endcode +* will result in: +* \code +* 1 2 0 +* 0 0 0 +* 0 0 3 +* \endcode +* \sa move_to(T i, T j) and static_matrix_move_to_manip +* +* \todo Doxygen has some problems with similar template functions. Correct that. +*/ +template +BOOST_UBLAS_INLINE matrix_move_to_manip move_to(T i, T j) { + return matrix_move_to_manip(i, j); +} + + +/** +* \brief A static move_to matrix manipulator +* When member function traverse is called the referenced +* index will be set to the manipulators' index +* +* \sa move_to() +* +* \todo Doxygen has some problems with similar template functions. Correct that. +*/ +template +class static_matrix_move_to_manip: public index_manipulator > { +public: + template + BOOST_UBLAS_INLINE + void manip(V &k, K &l) const { + k=I; + l=J; + } +}; + +/** +* \brief An object generator that returns a static move_to matrix index manipulator. +* +* Typically faster than the dynamic version, but can be used only when the +* values are known at compile time. +* \tparam I The row number the manipulator will set the matrix assigner index to. +* \tparam J The column number the manipulator will set the matrix assigner index to. +* \return A static move_to matrix manipulator +* +* Example usage: +* \code: +* matrix A(3, 3, 0); +* A <<= 1, 2, move_to<2,2>, 3; +* \endcode +* will result in: +* \code +* 1 2 0 +* 0 0 0 +* 0 0 3 +* \endcode +* \sa move_to(T i, T j) and static_matrix_move_to_manip +*/ +template +BOOST_UBLAS_INLINE static_matrix_move_to_manip move_to() { + return static_matrix_move_to_manip(); +} + +/** +* \brief A move matrix index manipulator. +* +* When member function \c manip is called the manipulator's +* index will be added to the referenced' index. +* +* \sa move(T i, T j) +*/ +template +class matrix_move_manip: public index_manipulator > { +public: + BOOST_UBLAS_INLINE + matrix_move_manip(T k, T l): i(k), j(l) { } + + template + BOOST_UBLAS_INLINE + void manip(V &k, K &l) const { + k+=i; + l+=j; + } +private: + T i, j; +}; + +/** +* \brief An object generator that returns a move matrix index manipulator +* +* \tparam size type +* \param i The number of rows the manipulator will traverse the index when "manip" +* member function is called +* \param j The number of columns the manipulator will traverse the index when "manip" +* member function is called +* \return A move matrix manipulator +* +* Example: +* \code: +* matrix A(3, 3, 0); +* A <<= 1, 2, move(1,0), +* 3,; +* \endcode +* will result in: +* \code +* 1 2 0 +* 0 0 3 +* 0 0 0 +* \endcode +*/ +template +BOOST_UBLAS_INLINE matrix_move_manip move(T i, T j) { + return matrix_move_manip(i, j); +} + +/** +* \brief A static move matrix index manipulator. +* +* When member function traverse is called the manipulator's +* index will be added to the referenced' index. +* +* \sa move() +* +* \todo Doxygen has some problems with similar template functions. Correct that. +*/ +template +class static_matrix_move_manip: public index_manipulator > { +public: + template + BOOST_UBLAS_INLINE + void manip(V &k, K &l) const { + k+=I; + l+=J; + } +}; + +/** +* \brief An object generator that returns a static "move" matrix index manipulator. +* +* Typically faster than the dynamic version, but can be used only when the +* values are known at compile time. Negative values can be used. +* \tparam I The number of rows the manipulator will trasverse the matrix assigner index. +* \tparam J The number of columns the manipulator will trasverse the matrix assigner index. +* \tparam size type +* \return A static move matrix manipulator +* +* Example: +* \code: +* matrix A(3, 3, 0); +* A <<= 1, 2, move<1,0>(), +* 3,; +* \endcode +* will result in: +* \code +* 1 2 0 +* 0 0 3 +* 0 0 0 +* \endcode +* +* \sa move_to() +* +* \todo Doxygen has some problems with similar template functions. Correct that. +*/ +template +BOOST_UBLAS_INLINE static_matrix_move_manip move() { + return static_matrix_move_manip(); +} + +/** +* \brief A begining of row manipulator +* +* When member function \c manip is called the referenced +* index will be be set to the begining of the row (i.e. column = 0) +* +* \sa begin1() +*/ +class begin1_manip: public index_manipulator { +public: + template + BOOST_UBLAS_INLINE + void manip(V & k, K &/*l*/) const { + k=0; + } +}; + +/** +* \brief An object generator that returns a begin1 manipulator. +* +* The resulted manipulator will traverse the index to the begining +* of the current column when its' \c manip member function is called. +* +* \return A begin1 matrix index manipulator +* +* Example usage: +* \code: +* matrix A(3, 3, 0); +* A <<= 1, 2, next_row(), +* 3, 4, begin1(), 1; +* \endcode +* will result in: +* \code +* 1 2 1 +* 3 4 0 +* 0 0 0 +* \endcode +* \sa begin2() +*/ +BOOST_UBLAS_INLINE begin1_manip begin1() { + return begin1_manip(); +} + +/** +* \brief A begining of column manipulator +* +* When member function \c manip is called the referenced +* index will be be set to the begining of the column (i.e. row = 0). +* +* +* \sa begin2() +*/ +class begin2_manip: public index_manipulator { +public: + template + BOOST_UBLAS_INLINE + void manip(V &/*k*/, K &l) const { + l=0; + } +}; + +/** +* \brief An object generator that returns a begin2 manipulator to be used to traverse a matrix. +* +* The resulted manipulator will traverse the index to the begining +* of the current row when its' \c manip member function is called. +* +* \return A begin2 matrix manipulator +* +* Example: +* \code: +* matrix A(3, 3, 0); +* A <<= 1, 2, move<1,0>(), +* 3, begin2(), 1; +* \endcode +* will result in: +* \code +* 1 2 0 +* 1 0 3 +* 0 0 0 +* \endcode +* \sa begin1() begin2_manip +*/ +BOOST_UBLAS_INLINE begin2_manip begin2() { + return begin2_manip(); +} + + +/** +* \brief A next row matrix manipulator. +* +* When member function traverse is called the referenced +* index will be traveresed to the begining of next row. +* +* \sa next_row() +*/ +class next_row_manip: public index_manipulator { +public: + template + BOOST_UBLAS_INLINE + void manip(V &k, K &l) const { + k++; + l=0; + } +}; + +/** +* \brief An object generator that returns a next_row manipulator. +* +* The resulted manipulator will traverse the index to the begining +* of the next row when it's manip member function is called. +* +* \return A next_row matrix manipulator. +* +* Example: +* \code: +* matrix A(3, 3, 0); +* A <<= 1, 2, next_row(), +* 3, 4; +* \endcode +* will result in: +* \code +* 1 2 0 +* 3 4 0 +* 0 0 0 +* \endcode +* \sa next_column() +*/ +BOOST_UBLAS_INLINE next_row_manip next_row() { + return next_row_manip(); +} + +/** +* \brief A next column matrix manipulator. +* +* When member function traverse is called the referenced +* index will be traveresed to the begining of next column. +* +* \sa next_column() +*/ +class next_column_manip: public index_manipulator { +public: + template + BOOST_UBLAS_INLINE + void manip(V &k, K &l) const { + k=0; + l++; + } +}; + +/** +* \brief An object generator that returns a next_row manipulator. +* +* The resulted manipulator will traverse the index to the begining +* of the next column when it's manip member function is called. +* +* \return A next_column matrix manipulator. +* +* Example: +* \code: +* matrix A(3, 3, 0); +* A <<= 1, 2, 0, +* 3, next_column(), 4; +* \endcode +* will result in: +* \code +* 1 2 4 +* 3 0 0 +* 0 0 0 +* \endcode +* +*/ +BOOST_UBLAS_INLINE next_column_manip next_column() { + return next_column_manip(); +} + +/** +* \brief A wrapper for fill policy classes +* +*/ +template +class fill_policy_wrapper { +public: + typedef T type; +}; + +// Collection of the fill policies +namespace fill_policy { + + /** + * \brief An index assign policy + * + * This policy is used to for the simplified ublas assign through + * normal indexing. + * + * + */ + class index_assign :public fill_policy_wrapper { + public: + template + BOOST_UBLAS_INLINE + static void apply(T &e, const S &i, const V &v) { + e()(i) = v; + } + template + BOOST_UBLAS_INLINE + static void apply(T &e, const S &i, const S &j, const V &v) { + e()(i, j) = v; + } + }; + + /** + * \brief An index plus assign policy + * + * This policy is used when the assignment is desired to be followed + * by an addition. + * + * + */ + class index_plus_assign :public fill_policy_wrapper { + public: + template + BOOST_UBLAS_INLINE + static void apply(T &e, const S &i, const V &v) { + e()(i) += v; + } + template + BOOST_UBLAS_INLINE + static void apply(T &e, const S &i, const S &j, const V &v) { + e()(i, j) += v; + } + }; + + /** + * \brief An index minus assign policy + * + * This policy is used when the assignment is desired to be followed + * by a substraction. + * + * + */ + class index_minus_assign :public fill_policy_wrapper { + public: + template + BOOST_UBLAS_INLINE + static void apply(T &e, const S &i, const V &v) { + e()(i) -= v; + } + template + BOOST_UBLAS_INLINE + static void apply(T &e, const S &i, const S &j, const V &v) { + e()(i, j) -= v; + } + }; + + /** + * \brief The sparse push_back fill policy. + * + * This policy is adequate for sparse types, when fast filling is required, where indexing + * assign is pretty slow. + + * It is important to note that push_back assign cannot be used to add elements before elements + * already existing in a sparse container. To achieve that please use the sparse_insert fill policy. + */ + class sparse_push_back :public fill_policy_wrapper { + public: + template + BOOST_UBLAS_INLINE + static void apply(T &e, const S &i, const V &v) { + e().push_back(i, v); + } + template + BOOST_UBLAS_INLINE + static void apply(T &e, const S &i, const S &j, const V &v) { + e().push_back(i,j, v); + } + }; + + /** + * \brief The sparse insert fill policy. + * + * This policy is adequate for sparse types, when fast filling is required, where indexing + * assign is pretty slow. It is slower than sparse_push_back fill policy, but it can be used to + * insert elements anywhere inside the container. + */ + class sparse_insert :public fill_policy_wrapper { + public: + template + BOOST_UBLAS_INLINE + static void apply(T &e, const S &i, const V &v) { + e().insert_element(i, v); + } + template + BOOST_UBLAS_INLINE + static void apply(T &e, const S &i, const S &j, const V &v) { + e().insert_element(i,j, v); + } + }; + +} + +/** \brief A wrapper for traverse policy classes +* +*/ +template +class traverse_policy_wrapper { +public: + typedef T type; +}; + +// Collection of the traverse policies +namespace traverse_policy { + + + /** + * \brief The no wrap policy. + * + * The no wrap policy does not allow wrapping when assigning to a matrix + */ + struct no_wrap { + /** + * \brief Element wrap method + */ + template + BOOST_UBLAS_INLINE + static void apply1(const S1 &/*s*/, S2 &/*i*/, S3 &/*j*/) { + } + + /** + * \brief Matrix block wrap method + */ + template + BOOST_UBLAS_INLINE + static void apply2(const S1 &/*s1*/, const S1 &/*s2*/, S2 &/*i1*/, S3 &/*i2*/) { + } + }; + + /** + * \brief The wrap policy. + * + * The wrap policy enables element wrapping when assigning to a matrix + */ + struct wrap { + /** + * \brief Element wrap method + */ + template + BOOST_UBLAS_INLINE + static void apply1(const S1 &s, S2 &i1, S3 &i2) { + if (i2>=s) { + i1++; + i2=0; + } + } + + /** + * \brief Matrix block wrap method + */ + template + BOOST_UBLAS_INLINE + static void apply2(const S1 &s1, const S1 &s2, S2 &i1, S3 &i2) { + if (i2>=s2) i2=0; // Wrap to the next block + else i1-=s1; // Move up (or right) one block + } + }; + + /** + * \brief The row_by_row traverse policy + * + * This policy is used when the assignment is desired to happen + * row_major wise for performance or other reasons. + * + * This is the default behaviour. To change it globally please define BOOST_UBLAS_DEFAULT_ASSIGN_BY_COLUMN + * in the compilation options or in an adequate header file. + * + * Please see EXAMPLES_LINK for usage information. + * + * \todo Add examples link + */ + template + class by_row_policy :public traverse_policy_wrapper > { + public: + template + BOOST_UBLAS_INLINE + static void advance(S1 &/*i*/, S2 &j) { j++;} + + template + BOOST_UBLAS_INLINE + static bool next(const E1 &e, const E2 &me, S1 &i, S2 &j, const S3 &/*i0*/, const S3 &j0, S4 &k, S5 &l) { + l++; j++; + if (l>=e().size2()) { + l=0; k++; j=j0; i++; + // It is assumed that the iteration starts from 0 and happens only using this function from within + // an assigner object. + // Otherwise (i.e. if it is called outside the assigner object) apply2 should have been + // outside the if statement. + if (k>=e().size1()) { + j=j0+e().size2(); + Wrap::apply2(e().size1(), me().size2(), i, j); + return false; + } + } + return true; + } + + template + BOOST_UBLAS_INLINE + static void apply_wrap(const E& e, S1 &i, S2 &j) { + Wrap::apply1(e().size2(), i, j); + } + }; + + /** + * \brief The column_by_column traverse policy + * + * This policy is used when the assignment is desired to happen + * column_major wise, for performance or other reasons. + * + * This is the NOT the default behaviour. To set this as the default define BOOST_UBLAS_DEFAULT_ASSIGN_BY_COLUMN + * in the compilation options or in an adequate header file. + * + * Please see EXAMPLES_LINK for usage information. + * + * \todo Add examples link + */ + template + class by_column_policy :public traverse_policy_wrapper > { + public: + template + BOOST_UBLAS_INLINE + static void advance(S1 &i, S2 &/*j*/) { i++;} + + template + BOOST_UBLAS_INLINE + static bool next(const E1 &e, const E2 &me, S1 &i, S2 &j, const S3 &i0, const S3 &/*j0*/, S4 &k, S5 &l) { + k++; i++; + if (k>=e().size1()) { + k=0; l++; i=i0; j++; + // It is assumed that the iteration starts from 0 and happens only using this function from within + // an assigner object. + // Otherwise (i.e. if it is called outside the assigner object) apply2 should have been + // outside the if statement. + if (l>=e().size2()) { + i=i0+e().size1(); + Wrap::apply2(e().size2(), me().size1(), j, i); + return false; + } + } + return true; + } + + template + BOOST_UBLAS_INLINE + static void apply_wrap(const E& e, S1 &i, S2 &j) { + Wrap::apply1(e().size1(), j, i); + } + }; +} +#ifndef BOOST_UBLAS_DEFAULT_NO_WRAP_POLICY + typedef traverse_policy::wrap DEFAULT_WRAP_POLICY; +#else + typedef traverse_policy::no_wrap DEFAULT_WRAP_POLICY; +#endif + +#ifndef BOOST_UBLAS_DEFAULT_ASSIGN_BY_COLUMN + typedef traverse_policy::by_row_policy DEFAULT_TRAVERSE_POLICY; +#else + typedef traverse_policy::by_column DEFAULT_TRAVERSE_POLICY; +#endif + + // Traverse policy namespace +namespace traverse_policy { + + by_row_policy by_row() { + return by_row_policy(); + } + + by_row_policy by_row_wrap() { + return by_row_policy(); + } + + by_row_policy by_row_no_wrap() { + return by_row_policy(); + } + + by_column_policy by_column() { + return by_column_policy(); + } + + by_column_policy by_column_wrap() { + return by_column_policy(); + } + + by_column_policy by_column_no_wrap() { + return by_column_policy(); + } + +} + +/** +* \brief An assigner object used to fill a vector using operator <<= and operator, (comma) +* +* This object is meant to be created by appropriate object generators. +* Please see EXAMPLES_LINK for usage information. +* +* \todo Add examples link +*/ +template +class vector_expression_assigner { +public: + typedef typename E::expression_type::value_type value_type; + typedef typename E::expression_type::size_type size_type; + + BOOST_UBLAS_INLINE + vector_expression_assigner(E &e):ve(e), i(0) { + } + + BOOST_UBLAS_INLINE + vector_expression_assigner(size_type k, E &e):ve(e), i(k) { + // Overloaded like that so it can be differentiated from (E, val). + // Otherwise there would be an ambiquity when value_type == size_type. + } + + BOOST_UBLAS_INLINE + vector_expression_assigner(E &e, value_type val):ve(e), i(0) { + operator,(val); + } + + template + BOOST_UBLAS_INLINE + vector_expression_assigner(E &e, const vector_expression &nve):ve(e), i(0) { + operator,(nve); + } + + template + BOOST_UBLAS_INLINE + vector_expression_assigner(E &e, const index_manipulator &ta):ve(e), i(0) { + operator,(ta); + } + + BOOST_UBLAS_INLINE + vector_expression_assigner &operator, (const value_type& val) { + apply(val); + return *this; + } + + template + BOOST_UBLAS_INLINE + vector_expression_assigner &operator, (const vector_expression &nve) { + for (typename AE::size_type k = 0; k!= nve().size(); k++) + operator,(nve()(k)); + return *this; + } + + template + BOOST_UBLAS_INLINE + vector_expression_assigner &operator, (const index_manipulator &ta) { + ta().manip(i); + return *this; + } + + template + BOOST_UBLAS_INLINE + vector_expression_assigner operator, (fill_policy_wrapper) const { + return vector_expression_assigner(i, ve); + } + +private: + BOOST_UBLAS_INLINE + vector_expression_assigner &apply(const typename E::expression_type::value_type& val) { + Fill_Policy::apply(ve, i++, val); + return *this; + } + +private: + E &ve; + size_type i; +}; + +/* +// The following static assigner is about 30% slower than the dynamic one, probably due to the recursive creation of assigner objects. +// It remains commented here for future reference. + +template +class static_vector_expression_assigner { +public: + typedef typename E::expression_type::value_type value_type; + typedef typename E::expression_type::size_type size_type; + + BOOST_UBLAS_INLINE + static_vector_expression_assigner(E &e):ve(e) { + } + + BOOST_UBLAS_INLINE + static_vector_expression_assigner(E &e, value_type val):ve(e) { + operator,(val); + } + + BOOST_UBLAS_INLINE + static_vector_expression_assigner operator, (const value_type& val) { + return apply(val); + } + +private: + BOOST_UBLAS_INLINE + static_vector_expression_assigner apply(const typename E::expression_type::value_type& val) { + ve()(I)=val; + return static_vector_expression_assigner(ve); + } + +private: + E &ve; +}; + +template +BOOST_UBLAS_INLINE +static_vector_expression_assigner, 1 > test_static(vector_expression &v, const typename E::value_type &val) { + v()(0)=val; + return static_vector_expression_assigner, 1 >(v); +} +*/ + + +/** +* \brief A vector_expression_assigner generator used with operator<<= for simple types +* +* Please see EXAMPLES_LINK for usage information. +* +* \todo Add examples link +*/ +template +BOOST_UBLAS_INLINE +vector_expression_assigner > operator<<=(vector_expression &v, const typename E::value_type &val) { + return vector_expression_assigner >(v,val); +} + +/** +* \brief ! A vector_expression_assigner generator used with operator<<= for vector expressions +* +* Please see EXAMPLES_LINK for usage information. +* +* \todo Add examples link +*/ +template +BOOST_UBLAS_INLINE +vector_expression_assigner > operator<<=(vector_expression &v, const vector_expression &ve) { + return vector_expression_assigner >(v,ve); +} + +/** +* \brief A vector_expression_assigner generator used with operator<<= for traverse manipulators +* +* Please see EXAMPLES_LINK for usage information. +* +* \todo Add examples link +*/ +template +BOOST_UBLAS_INLINE +vector_expression_assigner > operator<<=(vector_expression &v, const index_manipulator &nv) { + return vector_expression_assigner >(v,nv); +} + +/** +* \brief A vector_expression_assigner generator used with operator<<= for choice of fill policy +* +* Please see EXAMPLES_LINK for usage information. +* +* \todo Add examples link +*/ +template +BOOST_UBLAS_INLINE +vector_expression_assigner, T> operator<<=(vector_expression &v, fill_policy_wrapper) { + return vector_expression_assigner, T>(v); +} + +/** +* \brief An assigner object used to fill a vector using operator <<= and operator, (comma) +* +* This object is meant to be created by appropriate object generators. +* Please see EXAMPLES_LINK for usage information. +* +* \todo Add examples link +*/ +template +class matrix_expression_assigner { +public: + typedef typename E::expression_type::size_type size_type; + + BOOST_UBLAS_INLINE + matrix_expression_assigner(E &e): me(e), i(0), j(0) { + } + + BOOST_UBLAS_INLINE + matrix_expression_assigner(E &e, size_type k, size_type l): me(e), i(k), j(l) { + } + + BOOST_UBLAS_INLINE + matrix_expression_assigner(E &e, typename E::expression_type::value_type val): me(e), i(0), j(0) { + operator,(val); + } + + template + BOOST_UBLAS_INLINE + matrix_expression_assigner(E &e, const vector_expression &nve):me(e), i(0), j(0) { + operator,(nve); + } + + template + BOOST_UBLAS_INLINE + matrix_expression_assigner(E &e, const matrix_expression &nme):me(e), i(0), j(0) { + operator,(nme); + } + + template + BOOST_UBLAS_INLINE + matrix_expression_assigner(E &e, const index_manipulator &ta):me(e), i(0), j(0) { + operator,(ta); + } + + BOOST_UBLAS_INLINE + matrix_expression_assigner &operator, (const typename E::expression_type::value_type& val) { + Traverse_Policy::apply_wrap(me, i ,j); + return apply(val); + } + + template + BOOST_UBLAS_INLINE + matrix_expression_assigner &operator, (const vector_expression &nve) { + for (typename AE::size_type k = 0; k!= nve().size(); k++) { + operator,(nve()(k)); + } + return *this; + } + + template + BOOST_UBLAS_INLINE + matrix_expression_assigner &operator, (const matrix_expression &nme) { + return apply(nme); + } + + template + BOOST_UBLAS_INLINE + matrix_expression_assigner &operator, (const index_manipulator &ta) { + ta().manip(i, j); + return *this; + } + + template + BOOST_UBLAS_INLINE + matrix_expression_assigner operator, (fill_policy_wrapper) const { + return matrix_expression_assigner(me, i, j); + } + + + template + BOOST_UBLAS_INLINE + matrix_expression_assigner operator, (traverse_policy_wrapper) { + Traverse_Policy::apply_wrap(me, i ,j); + return matrix_expression_assigner(me, i, j); + } + +private: + BOOST_UBLAS_INLINE + matrix_expression_assigner &apply(const typename E::expression_type::value_type& val) { + Fill_Policy::apply(me, i, j, val); + Traverse_Policy::advance(i,j); + return *this; + } + + template + BOOST_UBLAS_INLINE + matrix_expression_assigner &apply(const matrix_expression &nme) { + size_type bi = i; + size_type bj = j; + typename AE::size_type k=0, l=0; + Fill_Policy::apply(me, i, j, nme()(k, l)); + while (Traverse_Policy::next(nme, me, i, j, bi, bj, k, l)) + Fill_Policy::apply(me, i, j, nme()(k, l)); + return *this; + } + +private: + E &me; + size_type i, j; +}; + +/** +* \brief A matrix_expression_assigner generator used with operator<<= for simple types +* +* Please see EXAMPLES_LINK for usage information. +* +* \todo Add examples link +*/ +template +BOOST_UBLAS_INLINE +matrix_expression_assigner > operator<<=(matrix_expression &me, const typename E::value_type &val) { + return matrix_expression_assigner >(me,val); +} + +/** +* \brief A matrix_expression_assigner generator used with operator<<= for choice of fill policy +* +* Please see EXAMPLES_LINK for usage information. +* +* \todo Add examples link +*/ +template +BOOST_UBLAS_INLINE +matrix_expression_assigner, T> operator<<=(matrix_expression &me, fill_policy_wrapper) { + return matrix_expression_assigner, T>(me); +} + +/** +* \brief A matrix_expression_assigner generator used with operator<<= for traverse manipulators +* +* Please see EXAMPLES_LINK for usage information. +* +* \todo Add examples link +*/ +template +BOOST_UBLAS_INLINE +matrix_expression_assigner > operator<<=(matrix_expression &me, const index_manipulator &ta) { + return matrix_expression_assigner >(me,ta); +} + +/** +* \brief A matrix_expression_assigner generator used with operator<<= for traverse manipulators +* +* Please see EXAMPLES_LINK for usage information. +* +* \todo Add examples link +*/ +template +BOOST_UBLAS_INLINE +matrix_expression_assigner, fill_policy::index_assign, T> operator<<=(matrix_expression &me, traverse_policy_wrapper) { + return matrix_expression_assigner, fill_policy::index_assign, T>(me); +} + +/** +* \brief A matrix_expression_assigner generator used with operator<<= for vector expressions +* +* Please see EXAMPLES_LINK for usage information. +* +* \todo Add examples link +*/ +template +BOOST_UBLAS_INLINE +matrix_expression_assigner > operator<<=(matrix_expression &me, const vector_expression &ve) { + return matrix_expression_assigner >(me,ve); +} + +/** +* \brief A matrix_expression_assigner generator used with operator<<= for matrix expressions +* +* Please see EXAMPLES_LINK for usage information. +* +* \todo Add examples link +*/ +template +BOOST_UBLAS_INLINE +matrix_expression_assigner > operator<<=(matrix_expression &me1, const matrix_expression &me2) { + return matrix_expression_assigner >(me1,me2); +} + +} } } + +#endif // ASSIGNMENT_HPP diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/ublas/banded.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/ublas/banded.hpp new file mode 100644 index 0000000000..e36c1f0d4a --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/ublas/banded.hpp @@ -0,0 +1,2071 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// 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) +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + +#ifndef _BOOST_UBLAS_BANDED_ +#define _BOOST_UBLAS_BANDED_ + +#include +#include + +// Iterators based on ideas of Jeremy Siek + +namespace boost { namespace numeric { namespace ublas { + + /** \brief A banded matrix of values of type \c T. + * + * For a \f$(mxn)\f$-dimensional banded matrix with \f$l\f$ lower and \f$u\f$ upper diagonals and + * \f$0 \leq i < m\f$ and \f$0 \leq j < n\f$, if \f$i>j+l\f$ or \f$i + class banded_matrix: + public matrix_container > { + + typedef T *pointer; + typedef L layout_type; + typedef banded_matrix self_type; + public: +#ifdef BOOST_UBLAS_ENABLE_PROXY_SHORTCUTS + using matrix_container::operator (); +#endif + typedef typename A::size_type size_type; + typedef typename A::difference_type difference_type; + typedef T value_type; + typedef const T &const_reference; + typedef T &reference; + typedef A array_type; + typedef const matrix_reference const_closure_type; + typedef matrix_reference closure_type; + typedef vector vector_temporary_type; + typedef matrix matrix_temporary_type; // general sub-matrix + typedef packed_tag storage_category; + typedef typename L::orientation_category orientation_category; + + // Construction and destruction + BOOST_UBLAS_INLINE + banded_matrix (): + matrix_container (), + size1_ (0), size2_ (0), + lower_ (0), upper_ (0), data_ (0) {} + BOOST_UBLAS_INLINE + banded_matrix (size_type size1, size_type size2, size_type lower = 0, size_type upper = 0): + matrix_container (), + size1_ (size1), size2_ (size2), + lower_ (lower), upper_ (upper), data_ ((std::max) (size1, size2) * (lower + 1 + upper)) { + } + BOOST_UBLAS_INLINE + banded_matrix (size_type size1, size_type size2, size_type lower, size_type upper, const array_type &data): + matrix_container (), + size1_ (size1), size2_ (size2), + lower_ (lower), upper_ (upper), data_ (data) {} + BOOST_UBLAS_INLINE + banded_matrix (const banded_matrix &m): + matrix_container (), + size1_ (m.size1_), size2_ (m.size2_), + lower_ (m.lower_), upper_ (m.upper_), data_ (m.data_) {} + template + BOOST_UBLAS_INLINE + banded_matrix (const matrix_expression &ae, size_type lower = 0, size_type upper = 0): + matrix_container (), + size1_ (ae ().size1 ()), size2_ (ae ().size2 ()), + lower_ (lower), upper_ (upper), + data_ ((std::max) (size1_, size2_) * (lower_ + 1 + upper_)) { + matrix_assign (*this, ae); + } + + // Accessors + BOOST_UBLAS_INLINE + size_type size1 () const { + return size1_; + } + BOOST_UBLAS_INLINE + size_type size2 () const { + return size2_; + } + BOOST_UBLAS_INLINE + size_type lower () const { + return lower_; + } + BOOST_UBLAS_INLINE + size_type upper () const { + return upper_; + } + + // Storage accessors + BOOST_UBLAS_INLINE + const array_type &data () const { + return data_; + } + BOOST_UBLAS_INLINE + array_type &data () { + return data_; + } + + // Resizing + BOOST_UBLAS_INLINE + void resize (size_type size1, size_type size2, size_type lower = 0, size_type upper = 0, bool preserve = true) { + if (preserve) { + self_type temporary (size1, size2, lower, upper); + detail::matrix_resize_preserve (*this, temporary); + } + else { + data ().resize ((std::max) (size1, size2) * (lower + 1 + upper)); + size1_ = size1; + size2_ = size2; + lower_ = lower; + upper_ = upper; + } + } + + BOOST_UBLAS_INLINE + void resize_packed_preserve (size_type size1, size_type size2, size_type lower = 0, size_type upper = 0) { + size1_ = size1; + size2_ = size2; + lower_ = lower; + upper_ = upper; + data ().resize ((std::max) (size1, size2) * (lower + 1 + upper), value_type ()); + } + + // Element access + BOOST_UBLAS_INLINE + const_reference operator () (size_type i, size_type j) const { + BOOST_UBLAS_CHECK (i < size1_, bad_index ()); + BOOST_UBLAS_CHECK (j < size2_, bad_index ()); +#ifdef BOOST_UBLAS_OWN_BANDED + const size_type k = (std::max) (i, j); + const size_type l = lower_ + j - i; + if (k < (std::max) (size1_, size2_) && + l < lower_ + 1 + upper_) + return data () [layout_type::element (k, (std::max) (size1_, size2_), + l, lower_ + 1 + upper_)]; +#else + const size_type k = j; + const size_type l = upper_ + i - j; + if (k < size2_ && + l < lower_ + 1 + upper_) + return data () [layout_type::element (k, size2_, + l, lower_ + 1 + upper_)]; +#endif + return zero_; + } + BOOST_UBLAS_INLINE + reference at_element (size_type i, size_type j) { + BOOST_UBLAS_CHECK (i < size1_, bad_index ()); + BOOST_UBLAS_CHECK (j < size2_, bad_index ()); +#ifdef BOOST_UBLAS_OWN_BANDED + const size_type k = (std::max) (i, j); + const size_type l = lower_ + j - i; + return data () [layout_type::element (k, (std::max) (size1_, size2_), + l, lower_ + 1 + upper_)]; +#else + const size_type k = j; + const size_type l = upper_ + i - j; + return data () [layout_type::element (k, size2_, + l, lower_ + 1 + upper_)]; +#endif + } + BOOST_UBLAS_INLINE + reference operator () (size_type i, size_type j) { + BOOST_UBLAS_CHECK (i < size1_, bad_index ()); + BOOST_UBLAS_CHECK (j < size2_, bad_index ()); +#ifdef BOOST_UBLAS_OWN_BANDED + const size_type k = (std::max) (i, j); + const size_type l = lower_ + j - i; + if (! (k < (std::max) (size1_, size2_) && + l < lower_ + 1 + upper_) ) { + bad_index ().raise (); + // NEVER reached + } + return data () [layout_type::element (k, (std::max) (size1_, size2_), + l, lower_ + 1 + upper_)]; +#else + const size_type k = j; + const size_type l = upper_ + i - j; + if (! (k < size2_ && + l < lower_ + 1 + upper_) ) { + bad_index ().raise (); + // NEVER reached + } + return data () [layout_type::element (k, size2_, + l, lower_ + 1 + upper_)]; +#endif + } + + // Element assignment + BOOST_UBLAS_INLINE + reference insert_element (size_type i, size_type j, const_reference t) { + return (operator () (i, j) = t); + } + BOOST_UBLAS_INLINE + void erase_element (size_type i, size_type j) { + operator () (i, j) = value_type/*zero*/(); + } + + // Zeroing + BOOST_UBLAS_INLINE + void clear () { + std::fill (data ().begin (), data ().end (), value_type/*zero*/()); + } + + // Assignment + BOOST_UBLAS_INLINE + banded_matrix &operator = (const banded_matrix &m) { + size1_ = m.size1_; + size2_ = m.size2_; + lower_ = m.lower_; + upper_ = m.upper_; + data () = m.data (); + return *this; + } + BOOST_UBLAS_INLINE + banded_matrix &assign_temporary (banded_matrix &m) { + swap (m); + return *this; + } + template + BOOST_UBLAS_INLINE + banded_matrix &operator = (const matrix_expression &ae) { + self_type temporary (ae, lower_, upper_); + return assign_temporary (temporary); + } + template + BOOST_UBLAS_INLINE + banded_matrix &assign (const matrix_expression &ae) { + matrix_assign (*this, ae); + return *this; + } + template + BOOST_UBLAS_INLINE + banded_matrix& operator += (const matrix_expression &ae) { + self_type temporary (*this + ae, lower_, upper_); + return assign_temporary (temporary); + } + template + BOOST_UBLAS_INLINE + banded_matrix &plus_assign (const matrix_expression &ae) { + matrix_assign (*this, ae); + return *this; + } + template + BOOST_UBLAS_INLINE + banded_matrix& operator -= (const matrix_expression &ae) { + self_type temporary (*this - ae, lower_, upper_); + return assign_temporary (temporary); + } + template + BOOST_UBLAS_INLINE + banded_matrix &minus_assign (const matrix_expression &ae) { + matrix_assign (*this, ae); + return *this; + } + template + BOOST_UBLAS_INLINE + banded_matrix& operator *= (const AT &at) { + matrix_assign_scalar (*this, at); + return *this; + } + template + BOOST_UBLAS_INLINE + banded_matrix& operator /= (const AT &at) { + matrix_assign_scalar (*this, at); + return *this; + } + + // Swapping + BOOST_UBLAS_INLINE + void swap (banded_matrix &m) { + if (this != &m) { + std::swap (size1_, m.size1_); + std::swap (size2_, m.size2_); + std::swap (lower_, m.lower_); + std::swap (upper_, m.upper_); + data ().swap (m.data ()); + } + } + BOOST_UBLAS_INLINE + friend void swap (banded_matrix &m1, banded_matrix &m2) { + m1.swap (m2); + } + + // Iterator types +#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR + typedef indexed_iterator1 iterator1; + typedef indexed_iterator2 iterator2; + typedef indexed_const_iterator1 const_iterator1; + typedef indexed_const_iterator2 const_iterator2; +#else + class const_iterator1; + class iterator1; + class const_iterator2; + class iterator2; +#endif + typedef reverse_iterator_base1 const_reverse_iterator1; + typedef reverse_iterator_base1 reverse_iterator1; + typedef reverse_iterator_base2 const_reverse_iterator2; + typedef reverse_iterator_base2 reverse_iterator2; + + // Element lookup + BOOST_UBLAS_INLINE + const_iterator1 find1 (int rank, size_type i, size_type j) const { + if (rank == 1) { + size_type lower_i = (std::max) (difference_type (j - upper_), difference_type (0)); + i = (std::max) (i, lower_i); + size_type upper_i = (std::min) (j + 1 + lower_, size1_); + i = (std::min) (i, upper_i); + } + return const_iterator1 (*this, i, j); + } + BOOST_UBLAS_INLINE + iterator1 find1 (int rank, size_type i, size_type j) { + if (rank == 1) { + size_type lower_i = (std::max) (difference_type (j - upper_), difference_type (0)); + i = (std::max) (i, lower_i); + size_type upper_i = (std::min) (j + 1 + lower_, size1_); + i = (std::min) (i, upper_i); + } + return iterator1 (*this, i, j); + } + BOOST_UBLAS_INLINE + const_iterator2 find2 (int rank, size_type i, size_type j) const { + if (rank == 1) { + size_type lower_j = (std::max) (difference_type (i - lower_), difference_type (0)); + j = (std::max) (j, lower_j); + size_type upper_j = (std::min) (i + 1 + upper_, size2_); + j = (std::min) (j, upper_j); + } + return const_iterator2 (*this, i, j); + } + BOOST_UBLAS_INLINE + iterator2 find2 (int rank, size_type i, size_type j) { + if (rank == 1) { + size_type lower_j = (std::max) (difference_type (i - lower_), difference_type (0)); + j = (std::max) (j, lower_j); + size_type upper_j = (std::min) (i + 1 + upper_, size2_); + j = (std::min) (j, upper_j); + } + return iterator2 (*this, i, j); + } + + // Iterators simply are indices. + +#ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR + class const_iterator1: + public container_const_reference, + public random_access_iterator_base { + public: + typedef typename banded_matrix::value_type value_type; + typedef typename banded_matrix::difference_type difference_type; + typedef typename banded_matrix::const_reference reference; + typedef const typename banded_matrix::pointer pointer; + + typedef const_iterator2 dual_iterator_type; + typedef const_reverse_iterator2 dual_reverse_iterator_type; + + // Construction and destruction + BOOST_UBLAS_INLINE + const_iterator1 (): + container_const_reference (), it1_ (), it2_ () {} + BOOST_UBLAS_INLINE + const_iterator1 (const self_type &m, size_type it1, size_type it2): + container_const_reference (m), it1_ (it1), it2_ (it2) {} + BOOST_UBLAS_INLINE + const_iterator1 (const iterator1 &it): + container_const_reference (it ()), it1_ (it.it1_), it2_ (it.it2_) {} + + // Arithmetic + BOOST_UBLAS_INLINE + const_iterator1 &operator ++ () { + ++ it1_; + return *this; + } + BOOST_UBLAS_INLINE + const_iterator1 &operator -- () { + -- it1_; + return *this; + } + BOOST_UBLAS_INLINE + const_iterator1 &operator += (difference_type n) { + it1_ += n; + return *this; + } + BOOST_UBLAS_INLINE + const_iterator1 &operator -= (difference_type n) { + it1_ -= n; + return *this; + } + BOOST_UBLAS_INLINE + difference_type operator - (const const_iterator1 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK (it2_ == it.it2_, external_logic ()); + return it1_ - it.it1_; + } + + // Dereference + BOOST_UBLAS_INLINE + const_reference operator * () const { + return (*this) () (it1_, it2_); + } + BOOST_UBLAS_INLINE + const_reference operator [] (difference_type n) const { + return *(*this + n); + } + +#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_iterator2 begin () const { + return (*this) ().find2 (1, it1_, 0); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_iterator2 end () const { + return (*this) ().find2 (1, it1_, (*this) ().size2 ()); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_reverse_iterator2 rbegin () const { + return const_reverse_iterator2 (end ()); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_reverse_iterator2 rend () const { + return const_reverse_iterator2 (begin ()); + } +#endif + + // Indices + BOOST_UBLAS_INLINE + size_type index1 () const { + return it1_; + } + BOOST_UBLAS_INLINE + size_type index2 () const { + return it2_; + } + + // Assignment + BOOST_UBLAS_INLINE + const_iterator1 &operator = (const const_iterator1 &it) { + container_const_reference::assign (&it ()); + it1_ = it.it1_; + it2_ = it.it2_; + return *this; + } + + // Comparison + BOOST_UBLAS_INLINE + bool operator == (const const_iterator1 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK (it2_ == it.it2_, external_logic ()); + return it1_ == it.it1_; + } + BOOST_UBLAS_INLINE + bool operator < (const const_iterator1 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK (it2_ == it.it2_, external_logic ()); + return it1_ < it.it1_; + } + + private: + size_type it1_; + size_type it2_; + }; +#endif + + BOOST_UBLAS_INLINE + const_iterator1 begin1 () const { + return find1 (0, 0, 0); + } + BOOST_UBLAS_INLINE + const_iterator1 end1 () const { + return find1 (0, size1_, 0); + } + +#ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR + class iterator1: + public container_reference, + public random_access_iterator_base { + public: + typedef typename banded_matrix::value_type value_type; + typedef typename banded_matrix::difference_type difference_type; + typedef typename banded_matrix::reference reference; + typedef typename banded_matrix::pointer pointer; + + typedef iterator2 dual_iterator_type; + typedef reverse_iterator2 dual_reverse_iterator_type; + + // Construction and destruction + BOOST_UBLAS_INLINE + iterator1 (): + container_reference (), it1_ (), it2_ () {} + BOOST_UBLAS_INLINE + iterator1 (self_type &m, size_type it1, size_type it2): + container_reference (m), it1_ (it1), it2_ (it2) {} + + // Arithmetic + BOOST_UBLAS_INLINE + iterator1 &operator ++ () { + ++ it1_; + return *this; + } + BOOST_UBLAS_INLINE + iterator1 &operator -- () { + -- it1_; + return *this; + } + BOOST_UBLAS_INLINE + iterator1 &operator += (difference_type n) { + it1_ += n; + return *this; + } + BOOST_UBLAS_INLINE + iterator1 &operator -= (difference_type n) { + it1_ -= n; + return *this; + } + BOOST_UBLAS_INLINE + difference_type operator - (const iterator1 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK (it2_ == it.it2_, external_logic ()); + return it1_ - it.it1_; + } + + // Dereference + BOOST_UBLAS_INLINE + reference operator * () const { + return (*this) ().at_element (it1_, it2_); + } + BOOST_UBLAS_INLINE + reference operator [] (difference_type n) const { + return *(*this + n); + } + +#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + iterator2 begin () const { + return (*this) ().find2 (1, it1_, 0); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + iterator2 end () const { + return (*this) ().find2 (1, it1_, (*this) ().size2 ()); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + reverse_iterator2 rbegin () const { + return reverse_iterator2 (end ()); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + reverse_iterator2 rend () const { + return reverse_iterator2 (begin ()); + } +#endif + + // Indices + BOOST_UBLAS_INLINE + size_type index1 () const { + return it1_; + } + BOOST_UBLAS_INLINE + size_type index2 () const { + return it2_; + } + + // Assignment + BOOST_UBLAS_INLINE + iterator1 &operator = (const iterator1 &it) { + container_reference::assign (&it ()); + it1_ = it.it1_; + it2_ = it.it2_; + return *this; + } + + // Comparison + BOOST_UBLAS_INLINE + bool operator == (const iterator1 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK (it2_ == it.it2_, external_logic ()); + return it1_ == it.it1_; + } + BOOST_UBLAS_INLINE + bool operator < (const iterator1 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK (it2_ == it.it2_, external_logic ()); + return it1_ < it.it1_; + } + + private: + size_type it1_; + size_type it2_; + + friend class const_iterator1; + }; +#endif + + BOOST_UBLAS_INLINE + iterator1 begin1 () { + return find1 (0, 0, 0); + } + BOOST_UBLAS_INLINE + iterator1 end1 () { + return find1 (0, size1_, 0); + } + +#ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR + class const_iterator2: + public container_const_reference, + public random_access_iterator_base { + public: + typedef typename banded_matrix::value_type value_type; + typedef typename banded_matrix::difference_type difference_type; + typedef typename banded_matrix::const_reference reference; + typedef const typename banded_matrix::pointer pointer; + + typedef const_iterator1 dual_iterator_type; + typedef const_reverse_iterator1 dual_reverse_iterator_type; + + // Construction and destruction + BOOST_UBLAS_INLINE + const_iterator2 (): + container_const_reference (), it1_ (), it2_ () {} + BOOST_UBLAS_INLINE + const_iterator2 (const self_type &m, size_type it1, size_type it2): + container_const_reference (m), it1_ (it1), it2_ (it2) {} + BOOST_UBLAS_INLINE + const_iterator2 (const iterator2 &it): + container_const_reference (it ()), it1_ (it.it1_), it2_ (it.it2_) {} + + // Arithmetic + BOOST_UBLAS_INLINE + const_iterator2 &operator ++ () { + ++ it2_; + return *this; + } + BOOST_UBLAS_INLINE + const_iterator2 &operator -- () { + -- it2_; + return *this; + } + BOOST_UBLAS_INLINE + const_iterator2 &operator += (difference_type n) { + it2_ += n; + return *this; + } + BOOST_UBLAS_INLINE + const_iterator2 &operator -= (difference_type n) { + it2_ -= n; + return *this; + } + BOOST_UBLAS_INLINE + difference_type operator - (const const_iterator2 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ()); + return it2_ - it.it2_; + } + + // Dereference + BOOST_UBLAS_INLINE + const_reference operator * () const { + return (*this) () (it1_, it2_); + } + BOOST_UBLAS_INLINE + const_reference operator [] (difference_type n) const { + return *(*this + n); + } + +#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_iterator1 begin () const { + return (*this) ().find1 (1, 0, it2_); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_iterator1 end () const { + return (*this) ().find1 (1, (*this) ().size1 (), it2_); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_reverse_iterator1 rbegin () const { + return const_reverse_iterator1 (end ()); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_reverse_iterator1 rend () const { + return const_reverse_iterator1 (begin ()); + } +#endif + + // Indices + BOOST_UBLAS_INLINE + size_type index1 () const { + return it1_; + } + BOOST_UBLAS_INLINE + size_type index2 () const { + return it2_; + } + + // Assignment + BOOST_UBLAS_INLINE + const_iterator2 &operator = (const const_iterator2 &it) { + container_const_reference::assign (&it ()); + it1_ = it.it1_; + it2_ = it.it2_; + return *this; + } + + // Comparison + BOOST_UBLAS_INLINE + bool operator == (const const_iterator2 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ()); + return it2_ == it.it2_; + } + BOOST_UBLAS_INLINE + bool operator < (const const_iterator2 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ()); + return it2_ < it.it2_; + } + + private: + size_type it1_; + size_type it2_; + }; +#endif + + BOOST_UBLAS_INLINE + const_iterator2 begin2 () const { + return find2 (0, 0, 0); + } + BOOST_UBLAS_INLINE + const_iterator2 end2 () const { + return find2 (0, 0, size2_); + } + +#ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR + class iterator2: + public container_reference, + public random_access_iterator_base { + public: + typedef typename banded_matrix::value_type value_type; + typedef typename banded_matrix::difference_type difference_type; + typedef typename banded_matrix::reference reference; + typedef typename banded_matrix::pointer pointer; + + typedef iterator1 dual_iterator_type; + typedef reverse_iterator1 dual_reverse_iterator_type; + + // Construction and destruction + BOOST_UBLAS_INLINE + iterator2 (): + container_reference (), it1_ (), it2_ () {} + BOOST_UBLAS_INLINE + iterator2 (self_type &m, size_type it1, size_type it2): + container_reference (m), it1_ (it1), it2_ (it2) {} + + // Arithmetic + BOOST_UBLAS_INLINE + iterator2 &operator ++ () { + ++ it2_; + return *this; + } + BOOST_UBLAS_INLINE + iterator2 &operator -- () { + -- it2_; + return *this; + } + BOOST_UBLAS_INLINE + iterator2 &operator += (difference_type n) { + it2_ += n; + return *this; + } + BOOST_UBLAS_INLINE + iterator2 &operator -= (difference_type n) { + it2_ -= n; + return *this; + } + BOOST_UBLAS_INLINE + difference_type operator - (const iterator2 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ()); + return it2_ - it.it2_; + } + + // Dereference + BOOST_UBLAS_INLINE + reference operator * () const { + return (*this) ().at_element (it1_, it2_); + } + BOOST_UBLAS_INLINE + reference operator [] (difference_type n) const { + return *(*this + n); + } + +#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + iterator1 begin () const { + return (*this) ().find1 (1, 0, it2_); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + iterator1 end () const { + return (*this) ().find1 (1, (*this) ().size1 (), it2_); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + reverse_iterator1 rbegin () const { + return reverse_iterator1 (end ()); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + reverse_iterator1 rend () const { + return reverse_iterator1 (begin ()); + } +#endif + + // Indices + BOOST_UBLAS_INLINE + size_type index1 () const { + return it1_; + } + BOOST_UBLAS_INLINE + size_type index2 () const { + return it2_; + } + + // Assignment + BOOST_UBLAS_INLINE + iterator2 &operator = (const iterator2 &it) { + container_reference::assign (&it ()); + it1_ = it.it1_; + it2_ = it.it2_; + return *this; + } + + // Comparison + BOOST_UBLAS_INLINE + bool operator == (const iterator2 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ()); + return it2_ == it.it2_; + } + BOOST_UBLAS_INLINE + bool operator < (const iterator2 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ()); + return it2_ < it.it2_; + } + + private: + size_type it1_; + size_type it2_; + + friend class const_iterator2; + }; +#endif + + BOOST_UBLAS_INLINE + iterator2 begin2 () { + return find2 (0, 0, 0); + } + BOOST_UBLAS_INLINE + iterator2 end2 () { + return find2 (0, 0, size2_); + } + + // Reverse iterators + + BOOST_UBLAS_INLINE + const_reverse_iterator1 rbegin1 () const { + return const_reverse_iterator1 (end1 ()); + } + BOOST_UBLAS_INLINE + const_reverse_iterator1 rend1 () const { + return const_reverse_iterator1 (begin1 ()); + } + + BOOST_UBLAS_INLINE + reverse_iterator1 rbegin1 () { + return reverse_iterator1 (end1 ()); + } + BOOST_UBLAS_INLINE + reverse_iterator1 rend1 () { + return reverse_iterator1 (begin1 ()); + } + + BOOST_UBLAS_INLINE + const_reverse_iterator2 rbegin2 () const { + return const_reverse_iterator2 (end2 ()); + } + BOOST_UBLAS_INLINE + const_reverse_iterator2 rend2 () const { + return const_reverse_iterator2 (begin2 ()); + } + + BOOST_UBLAS_INLINE + reverse_iterator2 rbegin2 () { + return reverse_iterator2 (end2 ()); + } + BOOST_UBLAS_INLINE + reverse_iterator2 rend2 () { + return reverse_iterator2 (begin2 ()); + } + + private: + size_type size1_; + size_type size2_; + size_type lower_; + size_type upper_; + array_type data_; + typedef const value_type const_value_type; + static const_value_type zero_; + }; + + template + typename banded_matrix::const_value_type banded_matrix::zero_ = value_type/*zero*/(); + + + /** \brief A diagonal matrix of values of type \c T, which is a specialization of a banded matrix + * + * For a \f$(m\times m)\f$-dimensional diagonal matrix, \f$0 \leq i < m\f$ and \f$0 \leq j < m\f$, + * if \f$i\neq j\f$ then \f$b_{i,j}=0\f$. The default storage for diagonal matrices is packed. + * Orientation and storage can also be specified. Default is \c row major \c unbounded_array. + * + * As a specialization of a banded matrix, the constructor of the diagonal matrix creates + * a banded matrix with 0 upper and lower diagonals around the main diagonal and the matrix is + * obviously a square matrix. Operations are optimized based on these 2 assumptions. It is + * \b not required by the storage to initialize elements of the matrix. + * + * \tparam T the type of object stored in the matrix (like double, float, complex, etc...) + * \tparam L the storage organization. It can be either \c row_major or \c column_major. Default is \c row_major + * \tparam A the type of Storage array. Default is \c unbounded_array + */ + template + class diagonal_matrix: + public banded_matrix { + public: + typedef typename A::size_type size_type; + typedef banded_matrix matrix_type; + typedef A array_type; + + // Construction and destruction + BOOST_UBLAS_INLINE + diagonal_matrix (): + matrix_type () {} + BOOST_UBLAS_INLINE + diagonal_matrix (size_type size): + matrix_type (size, size) {} + BOOST_UBLAS_INLINE + diagonal_matrix (size_type size, const array_type& data): + matrix_type (size, size, 0, 0, data) {} + BOOST_UBLAS_INLINE + diagonal_matrix (size_type size1, size_type size2): + matrix_type (size1, size2) {} + template + BOOST_UBLAS_INLINE + diagonal_matrix (const matrix_expression &ae): + matrix_type (ae) {} + BOOST_UBLAS_INLINE + ~diagonal_matrix () {} + + // Assignment + BOOST_UBLAS_INLINE + diagonal_matrix &operator = (const diagonal_matrix &m) { + matrix_type::operator = (m); + return *this; + } + template + BOOST_UBLAS_INLINE + diagonal_matrix &operator = (const matrix_expression &ae) { + matrix_type::operator = (ae); + return *this; + } + }; + + /** \brief A banded matrix adaptator: convert a any matrix into a banded matrix expression + * + * For a \f$(m\times n)\f$-dimensional matrix, the \c banded_adaptor will provide a banded matrix + * with \f$l\f$ lower and \f$u\f$ upper diagonals and \f$0 \leq i < m\f$ and \f$0 \leq j < n\f$, + * if \f$i>j+l\f$ or \f$i + class banded_adaptor: + public matrix_expression > { + + typedef banded_adaptor self_type; + public: +#ifdef BOOST_UBLAS_ENABLE_PROXY_SHORTCUTS + using matrix_expression::operator (); +#endif + typedef const M const_matrix_type; + typedef M matrix_type; + typedef typename M::size_type size_type; + typedef typename M::difference_type difference_type; + typedef typename M::value_type value_type; + typedef typename M::const_reference const_reference; + typedef typename boost::mpl::if_, + typename M::const_reference, + typename M::reference>::type reference; + typedef typename boost::mpl::if_, + typename M::const_closure_type, + typename M::closure_type>::type matrix_closure_type; + typedef const self_type const_closure_type; + typedef self_type closure_type; + // Replaced by _temporary_traits to avoid type requirements on M + //typedef typename M::vector_temporary_type vector_temporary_type; + //typedef typename M::matrix_temporary_type matrix_temporary_type; + typedef typename storage_restrict_traits::storage_category storage_category; + typedef typename M::orientation_category orientation_category; + + // Construction and destruction + BOOST_UBLAS_INLINE + banded_adaptor (matrix_type &data, size_type lower = 0, size_type upper = 0): + matrix_expression (), + data_ (data), lower_ (lower), upper_ (upper) {} + BOOST_UBLAS_INLINE + banded_adaptor (const banded_adaptor &m): + matrix_expression (), + data_ (m.data_), lower_ (m.lower_), upper_ (m.upper_) {} + + // Accessors + BOOST_UBLAS_INLINE + size_type size1 () const { + return data_.size1 (); + } + BOOST_UBLAS_INLINE + size_type size2 () const { + return data_.size2 (); + } + BOOST_UBLAS_INLINE + size_type lower () const { + return lower_; + } + BOOST_UBLAS_INLINE + size_type upper () const { + return upper_; + } + + // Storage accessors + BOOST_UBLAS_INLINE + const matrix_closure_type &data () const { + return data_; + } + BOOST_UBLAS_INLINE + matrix_closure_type &data () { + return data_; + } + + // Element access +#ifndef BOOST_UBLAS_PROXY_CONST_MEMBER + BOOST_UBLAS_INLINE + const_reference operator () (size_type i, size_type j) const { + BOOST_UBLAS_CHECK (i < size1 (), bad_index ()); + BOOST_UBLAS_CHECK (j < size2 (), bad_index ()); +#ifdef BOOST_UBLAS_OWN_BANDED + size_type k = (std::max) (i, j); + size_type l = lower_ + j - i; + if (k < (std::max) (size1 (), size2 ()) && + l < lower_ + 1 + upper_) + return data () (i, j); +#else + size_type k = j; + size_type l = upper_ + i - j; + if (k < size2 () && + l < lower_ + 1 + upper_) + return data () (i, j); +#endif + return zero_; + } + BOOST_UBLAS_INLINE + reference operator () (size_type i, size_type j) { + BOOST_UBLAS_CHECK (i < size1 (), bad_index ()); + BOOST_UBLAS_CHECK (j < size2 (), bad_index ()); +#ifdef BOOST_UBLAS_OWN_BANDED + size_type k = (std::max) (i, j); + size_type l = lower_ + j - i; + if (k < (std::max) (size1 (), size2 ()) && + l < lower_ + 1 + upper_) + return data () (i, j); +#else + size_type k = j; + size_type l = upper_ + i - j; + if (k < size2 () && + l < lower_ + 1 + upper_) + return data () (i, j); +#endif +#ifndef BOOST_UBLAS_REFERENCE_CONST_MEMBER + bad_index ().raise (); +#endif + return const_cast(zero_); + } +#else + BOOST_UBLAS_INLINE + reference operator () (size_type i, size_type j) const { + BOOST_UBLAS_CHECK (i < size1 (), bad_index ()); + BOOST_UBLAS_CHECK (j < size2 (), bad_index ()); +#ifdef BOOST_UBLAS_OWN_BANDED + size_type k = (std::max) (i, j); + size_type l = lower_ + j - i; + if (k < (std::max) (size1 (), size2 ()) && + l < lower_ + 1 + upper_) + return data () (i, j); +#else + size_type k = j; + size_type l = upper_ + i - j; + if (k < size2 () && + l < lower_ + 1 + upper_) + return data () (i, j); +#endif +#ifndef BOOST_UBLAS_REFERENCE_CONST_MEMBER + bad_index ().raise (); +#endif + return const_cast(zero_); + } +#endif + + // Assignment + BOOST_UBLAS_INLINE + banded_adaptor &operator = (const banded_adaptor &m) { + matrix_assign (*this, m); + return *this; + } + BOOST_UBLAS_INLINE + banded_adaptor &assign_temporary (banded_adaptor &m) { + *this = m; + return *this; + } + template + BOOST_UBLAS_INLINE + banded_adaptor &operator = (const matrix_expression &ae) { + matrix_assign (*this, matrix (ae)); + return *this; + } + template + BOOST_UBLAS_INLINE + banded_adaptor &assign (const matrix_expression &ae) { + matrix_assign (*this, ae); + return *this; + } + template + BOOST_UBLAS_INLINE + banded_adaptor& operator += (const matrix_expression &ae) { + matrix_assign (*this, matrix (*this + ae)); + return *this; + } + template + BOOST_UBLAS_INLINE + banded_adaptor &plus_assign (const matrix_expression &ae) { + matrix_assign (*this, ae); + return *this; + } + template + BOOST_UBLAS_INLINE + banded_adaptor& operator -= (const matrix_expression &ae) { + matrix_assign (*this, matrix (*this - ae)); + return *this; + } + template + BOOST_UBLAS_INLINE + banded_adaptor &minus_assign (const matrix_expression &ae) { + matrix_assign (*this, ae); + return *this; + } + template + BOOST_UBLAS_INLINE + banded_adaptor& operator *= (const AT &at) { + matrix_assign_scalar (*this, at); + return *this; + } + template + BOOST_UBLAS_INLINE + banded_adaptor& operator /= (const AT &at) { + matrix_assign_scalar (*this, at); + return *this; + } + + // Closure comparison + BOOST_UBLAS_INLINE + bool same_closure (const banded_adaptor &ba) const { + return (*this).data ().same_closure (ba.data ()); + } + + // Swapping + BOOST_UBLAS_INLINE + void swap (banded_adaptor &m) { + if (this != &m) { + BOOST_UBLAS_CHECK (lower_ == m.lower_, bad_size ()); + BOOST_UBLAS_CHECK (upper_ == m.upper_, bad_size ()); + matrix_swap (*this, m); + } + } + BOOST_UBLAS_INLINE + friend void swap (banded_adaptor &m1, banded_adaptor &m2) { + m1.swap (m2); + } + + // Iterator types + private: + // Use the matrix iterator + typedef typename M::const_iterator1 const_subiterator1_type; + typedef typename boost::mpl::if_, + typename M::const_iterator1, + typename M::iterator1>::type subiterator1_type; + typedef typename M::const_iterator2 const_subiterator2_type; + typedef typename boost::mpl::if_, + typename M::const_iterator2, + typename M::iterator2>::type subiterator2_type; + + public: +#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR + typedef indexed_iterator1 iterator1; + typedef indexed_iterator2 iterator2; + typedef indexed_const_iterator1 const_iterator1; + typedef indexed_const_iterator2 const_iterator2; +#else + class const_iterator1; + class iterator1; + class const_iterator2; + class iterator2; +#endif + typedef reverse_iterator_base1 const_reverse_iterator1; + typedef reverse_iterator_base1 reverse_iterator1; + typedef reverse_iterator_base2 const_reverse_iterator2; + typedef reverse_iterator_base2 reverse_iterator2; + + // Element lookup + BOOST_UBLAS_INLINE + const_iterator1 find1 (int rank, size_type i, size_type j) const { + if (rank == 1) { + size_type lower_i = (std::max) (difference_type (j - upper_), difference_type (0)); + i = (std::max) (i, lower_i); + size_type upper_i = (std::min) (j + 1 + lower_, size1 ()); + i = (std::min) (i, upper_i); + } + return const_iterator1 (*this, data ().find1 (rank, i, j)); + } + BOOST_UBLAS_INLINE + iterator1 find1 (int rank, size_type i, size_type j) { + if (rank == 1) { + size_type lower_i = (std::max) (difference_type (j - upper_), difference_type (0)); + i = (std::max) (i, lower_i); + size_type upper_i = (std::min) (j + 1 + lower_, size1 ()); + i = (std::min) (i, upper_i); + } + return iterator1 (*this, data ().find1 (rank, i, j)); + } + BOOST_UBLAS_INLINE + const_iterator2 find2 (int rank, size_type i, size_type j) const { + if (rank == 1) { + size_type lower_j = (std::max) (difference_type (i - lower_), difference_type (0)); + j = (std::max) (j, lower_j); + size_type upper_j = (std::min) (i + 1 + upper_, size2 ()); + j = (std::min) (j, upper_j); + } + return const_iterator2 (*this, data ().find2 (rank, i, j)); + } + BOOST_UBLAS_INLINE + iterator2 find2 (int rank, size_type i, size_type j) { + if (rank == 1) { + size_type lower_j = (std::max) (difference_type (i - lower_), difference_type (0)); + j = (std::max) (j, lower_j); + size_type upper_j = (std::min) (i + 1 + upper_, size2 ()); + j = (std::min) (j, upper_j); + } + return iterator2 (*this, data ().find2 (rank, i, j)); + } + + // Iterators simply are indices. + +#ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR + class const_iterator1: + public container_const_reference, + public random_access_iterator_base::iterator_category, + const_iterator1, value_type> { + public: + typedef typename const_subiterator1_type::value_type value_type; + typedef typename const_subiterator1_type::difference_type difference_type; + typedef typename const_subiterator1_type::reference reference; + typedef typename const_subiterator1_type::pointer pointer; + + typedef const_iterator2 dual_iterator_type; + typedef const_reverse_iterator2 dual_reverse_iterator_type; + + // Construction and destruction + BOOST_UBLAS_INLINE + const_iterator1 (): + container_const_reference (), it1_ () {} + BOOST_UBLAS_INLINE + const_iterator1 (const self_type &m, const const_subiterator1_type &it1): + container_const_reference (m), it1_ (it1) {} + BOOST_UBLAS_INLINE + const_iterator1 (const iterator1 &it): + container_const_reference (it ()), it1_ (it.it1_) {} + + // Arithmetic + BOOST_UBLAS_INLINE + const_iterator1 &operator ++ () { + ++ it1_; + return *this; + } + BOOST_UBLAS_INLINE + const_iterator1 &operator -- () { + -- it1_; + return *this; + } + BOOST_UBLAS_INLINE + const_iterator1 &operator += (difference_type n) { + it1_ += n; + return *this; + } + BOOST_UBLAS_INLINE + const_iterator1 &operator -= (difference_type n) { + it1_ -= n; + return *this; + } + BOOST_UBLAS_INLINE + difference_type operator - (const const_iterator1 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + return it1_ - it.it1_; + } + + // Dereference + BOOST_UBLAS_INLINE + const_reference operator * () const { + size_type i = index1 (); + size_type j = index2 (); + BOOST_UBLAS_CHECK (i < (*this) ().size1 (), bad_index ()); + BOOST_UBLAS_CHECK (j < (*this) ().size2 (), bad_index ()); +#ifdef BOOST_UBLAS_OWN_BANDED + size_type k = (std::max) (i, j); + size_type l = (*this) ().lower () + j - i; + if (k < (std::max) ((*this) ().size1 (), (*this) ().size2 ()) && + l < (*this) ().lower () + 1 + (*this) ().upper ()) + return *it1_; +#else + size_type k = j; + size_type l = (*this) ().upper () + i - j; + if (k < (*this) ().size2 () && + l < (*this) ().lower () + 1 + (*this) ().upper ()) + return *it1_; +#endif + return (*this) () (i, j); + } + BOOST_UBLAS_INLINE + const_reference operator [] (difference_type n) const { + return *(*this + n); + } + +#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_iterator2 begin () const { + return (*this) ().find2 (1, index1 (), 0); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_iterator2 end () const { + return (*this) ().find2 (1, index1 (), (*this) ().size2 ()); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_reverse_iterator2 rbegin () const { + return const_reverse_iterator2 (end ()); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_reverse_iterator2 rend () const { + return const_reverse_iterator2 (begin ()); + } +#endif + + // Indices + BOOST_UBLAS_INLINE + size_type index1 () const { + return it1_.index1 (); + } + BOOST_UBLAS_INLINE + size_type index2 () const { + return it1_.index2 (); + } + + // Assignment + BOOST_UBLAS_INLINE + const_iterator1 &operator = (const const_iterator1 &it) { + container_const_reference::assign (&it ()); + it1_ = it.it1_; + return *this; + } + + // Comparison + BOOST_UBLAS_INLINE + bool operator == (const const_iterator1 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + return it1_ == it.it1_; + } + BOOST_UBLAS_INLINE + bool operator < (const const_iterator1 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + return it1_ < it.it1_; + } + + private: + const_subiterator1_type it1_; + }; +#endif + + BOOST_UBLAS_INLINE + const_iterator1 begin1 () const { + return find1 (0, 0, 0); + } + BOOST_UBLAS_INLINE + const_iterator1 end1 () const { + return find1 (0, size1 (), 0); + } + +#ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR + class iterator1: + public container_reference, + public random_access_iterator_base::iterator_category, + iterator1, value_type> { + public: + typedef typename subiterator1_type::value_type value_type; + typedef typename subiterator1_type::difference_type difference_type; + typedef typename subiterator1_type::reference reference; + typedef typename subiterator1_type::pointer pointer; + + typedef iterator2 dual_iterator_type; + typedef reverse_iterator2 dual_reverse_iterator_type; + + // Construction and destruction + BOOST_UBLAS_INLINE + iterator1 (): + container_reference (), it1_ () {} + BOOST_UBLAS_INLINE + iterator1 (self_type &m, const subiterator1_type &it1): + container_reference (m), it1_ (it1) {} + + // Arithmetic + BOOST_UBLAS_INLINE + iterator1 &operator ++ () { + ++ it1_; + return *this; + } + BOOST_UBLAS_INLINE + iterator1 &operator -- () { + -- it1_; + return *this; + } + BOOST_UBLAS_INLINE + iterator1 &operator += (difference_type n) { + it1_ += n; + return *this; + } + BOOST_UBLAS_INLINE + iterator1 &operator -= (difference_type n) { + it1_ -= n; + return *this; + } + BOOST_UBLAS_INLINE + difference_type operator - (const iterator1 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + return it1_ - it.it1_; + } + + // Dereference + BOOST_UBLAS_INLINE + reference operator * () const { + size_type i = index1 (); + size_type j = index2 (); + BOOST_UBLAS_CHECK (i < (*this) ().size1 (), bad_index ()); + BOOST_UBLAS_CHECK (j < (*this) ().size2 (), bad_index ()); +#ifdef BOOST_UBLAS_OWN_BANDED + size_type k = (std::max) (i, j); + size_type l = (*this) ().lower () + j - i; + if (k < (std::max) ((*this) ().size1 (), (*this) ().size2 ()) && + l < (*this) ().lower () + 1 + (*this) ().upper ()) + return *it1_; +#else + size_type k = j; + size_type l = (*this) ().upper () + i - j; + if (k < (*this) ().size2 () && + l < (*this) ().lower () + 1 + (*this) ().upper ()) + return *it1_; +#endif + return (*this) () (i, j); + } + BOOST_UBLAS_INLINE + reference operator [] (difference_type n) const { + return *(*this + n); + } + +#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + iterator2 begin () const { + return (*this) ().find2 (1, index1 (), 0); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + iterator2 end () const { + return (*this) ().find2 (1, index1 (), (*this) ().size2 ()); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + reverse_iterator2 rbegin () const { + return reverse_iterator2 (end ()); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + reverse_iterator2 rend () const { + return reverse_iterator2 (begin ()); + } +#endif + + // Indices + BOOST_UBLAS_INLINE + size_type index1 () const { + return it1_.index1 (); + } + BOOST_UBLAS_INLINE + size_type index2 () const { + return it1_.index2 (); + } + + // Assignment + BOOST_UBLAS_INLINE + iterator1 &operator = (const iterator1 &it) { + container_reference::assign (&it ()); + it1_ = it.it1_; + return *this; + } + + // Comparison + BOOST_UBLAS_INLINE + bool operator == (const iterator1 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + return it1_ == it.it1_; + } + BOOST_UBLAS_INLINE + bool operator < (const iterator1 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + return it1_ < it.it1_; + } + + private: + subiterator1_type it1_; + + friend class const_iterator1; + }; +#endif + + BOOST_UBLAS_INLINE + iterator1 begin1 () { + return find1 (0, 0, 0); + } + BOOST_UBLAS_INLINE + iterator1 end1 () { + return find1 (0, size1 (), 0); + } + +#ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR + class const_iterator2: + public container_const_reference, + public random_access_iterator_base { + public: + typedef typename iterator_restrict_traits::iterator_category iterator_category; + typedef typename const_subiterator2_type::value_type value_type; + typedef typename const_subiterator2_type::difference_type difference_type; + typedef typename const_subiterator2_type::reference reference; + typedef typename const_subiterator2_type::pointer pointer; + + typedef const_iterator1 dual_iterator_type; + typedef const_reverse_iterator1 dual_reverse_iterator_type; + + // Construction and destruction + BOOST_UBLAS_INLINE + const_iterator2 (): + container_const_reference (), it2_ () {} + BOOST_UBLAS_INLINE + const_iterator2 (const self_type &m, const const_subiterator2_type &it2): + container_const_reference (m), it2_ (it2) {} + BOOST_UBLAS_INLINE + const_iterator2 (const iterator2 &it): + container_const_reference (it ()), it2_ (it.it2_) {} + + // Arithmetic + BOOST_UBLAS_INLINE + const_iterator2 &operator ++ () { + ++ it2_; + return *this; + } + BOOST_UBLAS_INLINE + const_iterator2 &operator -- () { + -- it2_; + return *this; + } + BOOST_UBLAS_INLINE + const_iterator2 &operator += (difference_type n) { + it2_ += n; + return *this; + } + BOOST_UBLAS_INLINE + const_iterator2 &operator -= (difference_type n) { + it2_ -= n; + return *this; + } + BOOST_UBLAS_INLINE + difference_type operator - (const const_iterator2 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + return it2_ - it.it2_; + } + + // Dereference + BOOST_UBLAS_INLINE + const_reference operator * () const { + size_type i = index1 (); + size_type j = index2 (); + BOOST_UBLAS_CHECK (i < (*this) ().size1 (), bad_index ()); + BOOST_UBLAS_CHECK (j < (*this) ().size2 (), bad_index ()); +#ifdef BOOST_UBLAS_OWN_BANDED + size_type k = (std::max) (i, j); + size_type l = (*this) ().lower () + j - i; + if (k < (std::max) ((*this) ().size1 (), (*this) ().size2 ()) && + l < (*this) ().lower () + 1 + (*this) ().upper ()) + return *it2_; +#else + size_type k = j; + size_type l = (*this) ().upper () + i - j; + if (k < (*this) ().size2 () && + l < (*this) ().lower () + 1 + (*this) ().upper ()) + return *it2_; +#endif + return (*this) () (i, j); + } + BOOST_UBLAS_INLINE + const_reference operator [] (difference_type n) const { + return *(*this + n); + } + +#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_iterator1 begin () const { + return (*this) ().find1 (1, 0, index2 ()); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_iterator1 end () const { + return (*this) ().find1 (1, (*this) ().size1 (), index2 ()); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_reverse_iterator1 rbegin () const { + return const_reverse_iterator1 (end ()); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_reverse_iterator1 rend () const { + return const_reverse_iterator1 (begin ()); + } +#endif + + // Indices + BOOST_UBLAS_INLINE + size_type index1 () const { + return it2_.index1 (); + } + BOOST_UBLAS_INLINE + size_type index2 () const { + return it2_.index2 (); + } + + // Assignment + BOOST_UBLAS_INLINE + const_iterator2 &operator = (const const_iterator2 &it) { + container_const_reference::assign (&it ()); + it2_ = it.it2_; + return *this; + } + + // Comparison + BOOST_UBLAS_INLINE + bool operator == (const const_iterator2 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + return it2_ == it.it2_; + } + BOOST_UBLAS_INLINE + bool operator < (const const_iterator2 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + return it2_ < it.it2_; + } + + private: + const_subiterator2_type it2_; + }; +#endif + + BOOST_UBLAS_INLINE + const_iterator2 begin2 () const { + return find2 (0, 0, 0); + } + BOOST_UBLAS_INLINE + const_iterator2 end2 () const { + return find2 (0, 0, size2 ()); + } + +#ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR + class iterator2: + public container_reference, + public random_access_iterator_base::iterator_category, + iterator2, value_type> { + public: + typedef typename subiterator2_type::value_type value_type; + typedef typename subiterator2_type::difference_type difference_type; + typedef typename subiterator2_type::reference reference; + typedef typename subiterator2_type::pointer pointer; + + typedef iterator1 dual_iterator_type; + typedef reverse_iterator1 dual_reverse_iterator_type; + + // Construction and destruction + BOOST_UBLAS_INLINE + iterator2 (): + container_reference (), it2_ () {} + BOOST_UBLAS_INLINE + iterator2 (self_type &m, const subiterator2_type &it2): + container_reference (m), it2_ (it2) {} + + // Arithmetic + BOOST_UBLAS_INLINE + iterator2 &operator ++ () { + ++ it2_; + return *this; + } + BOOST_UBLAS_INLINE + iterator2 &operator -- () { + -- it2_; + return *this; + } + BOOST_UBLAS_INLINE + iterator2 &operator += (difference_type n) { + it2_ += n; + return *this; + } + BOOST_UBLAS_INLINE + iterator2 &operator -= (difference_type n) { + it2_ -= n; + return *this; + } + BOOST_UBLAS_INLINE + difference_type operator - (const iterator2 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + return it2_ - it.it2_; + } + + // Dereference + BOOST_UBLAS_INLINE + reference operator * () const { + size_type i = index1 (); + size_type j = index2 (); + BOOST_UBLAS_CHECK (i < (*this) ().size1 (), bad_index ()); + BOOST_UBLAS_CHECK (j < (*this) ().size2 (), bad_index ()); +#ifdef BOOST_UBLAS_OWN_BANDED + size_type k = (std::max) (i, j); + size_type l = (*this) ().lower () + j - i; + if (k < (std::max) ((*this) ().size1 (), (*this) ().size2 ()) && + l < (*this) ().lower () + 1 + (*this) ().upper ()) + return *it2_; +#else + size_type k = j; + size_type l = (*this) ().upper () + i - j; + if (k < (*this) ().size2 () && + l < (*this) ().lower () + 1 + (*this) ().upper ()) + return *it2_; +#endif + return (*this) () (i, j); + } + BOOST_UBLAS_INLINE + reference operator [] (difference_type n) const { + return *(*this + n); + } + +#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + iterator1 begin () const { + return (*this) ().find1 (1, 0, index2 ()); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + iterator1 end () const { + return (*this) ().find1 (1, (*this) ().size1 (), index2 ()); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + reverse_iterator1 rbegin () const { + return reverse_iterator1 (end ()); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + reverse_iterator1 rend () const { + return reverse_iterator1 (begin ()); + } +#endif + + // Indices + BOOST_UBLAS_INLINE + size_type index1 () const { + return it2_.index1 (); + } + BOOST_UBLAS_INLINE + size_type index2 () const { + return it2_.index2 (); + } + + // Assignment + BOOST_UBLAS_INLINE + iterator2 &operator = (const iterator2 &it) { + container_reference::assign (&it ()); + it2_ = it.it2_; + return *this; + } + + // Comparison + BOOST_UBLAS_INLINE + bool operator == (const iterator2 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + return it2_ == it.it2_; + } + BOOST_UBLAS_INLINE + bool operator < (const iterator2 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + return it2_ < it.it2_; + } + + private: + subiterator2_type it2_; + + friend class const_iterator2; + }; +#endif + + BOOST_UBLAS_INLINE + iterator2 begin2 () { + return find2 (0, 0, 0); + } + BOOST_UBLAS_INLINE + iterator2 end2 () { + return find2 (0, 0, size2 ()); + } + + // Reverse iterators + + BOOST_UBLAS_INLINE + const_reverse_iterator1 rbegin1 () const { + return const_reverse_iterator1 (end1 ()); + } + BOOST_UBLAS_INLINE + const_reverse_iterator1 rend1 () const { + return const_reverse_iterator1 (begin1 ()); + } + + BOOST_UBLAS_INLINE + reverse_iterator1 rbegin1 () { + return reverse_iterator1 (end1 ()); + } + BOOST_UBLAS_INLINE + reverse_iterator1 rend1 () { + return reverse_iterator1 (begin1 ()); + } + + BOOST_UBLAS_INLINE + const_reverse_iterator2 rbegin2 () const { + return const_reverse_iterator2 (end2 ()); + } + BOOST_UBLAS_INLINE + const_reverse_iterator2 rend2 () const { + return const_reverse_iterator2 (begin2 ()); + } + + BOOST_UBLAS_INLINE + reverse_iterator2 rbegin2 () { + return reverse_iterator2 (end2 ()); + } + BOOST_UBLAS_INLINE + reverse_iterator2 rend2 () { + return reverse_iterator2 (begin2 ()); + } + + private: + matrix_closure_type data_; + size_type lower_; + size_type upper_; + typedef const value_type const_value_type; + static const_value_type zero_; + }; + + // Specialization for temporary_traits + template + struct vector_temporary_traits< banded_adaptor > + : vector_temporary_traits< M > {} ; + template + struct vector_temporary_traits< const banded_adaptor > + : vector_temporary_traits< M > {} ; + + template + struct matrix_temporary_traits< banded_adaptor > + : matrix_temporary_traits< M > {} ; + template + struct matrix_temporary_traits< const banded_adaptor > + : matrix_temporary_traits< M > {} ; + + + template + typename banded_adaptor::const_value_type banded_adaptor::zero_ = value_type/*zero*/(); + + /** \brief A diagonal matrix adaptator: convert a any matrix into a diagonal matrix expression + * + * For a \f$(m\times m)\f$-dimensional matrix, the \c diagonal_adaptor will provide a diagonal matrix + * with \f$0 \leq i < m\f$ and \f$0 \leq j < m\f$, if \f$i\neq j\f$ then \f$b_{i,j}=0\f$. + * + * Storage and location are based on those of the underlying matrix. This is important because + * a \c diagonal_adaptor does not copy the matrix data to a new place. Therefore, modifying values + * in a \c diagonal_adaptor matrix will also modify the underlying matrix too. + * + * \tparam M the type of matrix used to generate the diagonal matrix + */ + + template + class diagonal_adaptor: + public banded_adaptor { + public: + typedef M matrix_type; + typedef banded_adaptor adaptor_type; + + // Construction and destruction + BOOST_UBLAS_INLINE + diagonal_adaptor (): + adaptor_type () {} + BOOST_UBLAS_INLINE + diagonal_adaptor (matrix_type &data): + adaptor_type (data) {} + BOOST_UBLAS_INLINE + ~diagonal_adaptor () {} + + // Assignment + BOOST_UBLAS_INLINE + diagonal_adaptor &operator = (const diagonal_adaptor &m) { + adaptor_type::operator = (m); + return *this; + } + template + BOOST_UBLAS_INLINE + diagonal_adaptor &operator = (const matrix_expression &ae) { + adaptor_type::operator = (ae); + return *this; + } + }; + +}}} + +#endif diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/ublas/blas.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/ublas/blas.hpp new file mode 100644 index 0000000000..5032d3cd2b --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/ublas/blas.hpp @@ -0,0 +1,502 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// 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) +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + +#ifndef _BOOST_UBLAS_BLAS_ +#define _BOOST_UBLAS_BLAS_ + +#include + +namespace boost { namespace numeric { namespace ublas { + + + /** Interface and implementation of BLAS level 1 + * This includes functions which perform \b vector-vector operations. + * More information about BLAS can be found at + * http://en.wikipedia.org/wiki/BLAS + */ + namespace blas_1 { + + /** 1-Norm: \f$\sum_i |x_i|\f$ (also called \f$\mathcal{L}_1\f$ or Manhattan norm) + * + * \param v a vector or vector expression + * \return the 1-Norm with type of the vector's type + * + * \tparam V type of the vector (not needed by default) + */ + template + typename type_traits::real_type + asum (const V &v) { + return norm_1 (v); + } + + /** 2-Norm: \f$\sum_i |x_i|^2\f$ (also called \f$\mathcal{L}_2\f$ or Euclidean norm) + * + * \param v a vector or vector expression + * \return the 2-Norm with type of the vector's type + * + * \tparam V type of the vector (not needed by default) + */ + template + typename type_traits::real_type + nrm2 (const V &v) { + return norm_2 (v); + } + + /** Infinite-norm: \f$\max_i |x_i|\f$ (also called \f$\mathcal{L}_\infty\f$ norm) + * + * \param v a vector or vector expression + * \return the Infinite-Norm with type of the vector's type + * + * \tparam V type of the vector (not needed by default) + */ + template + typename type_traits::real_type + amax (const V &v) { + return norm_inf (v); + } + + /** Inner product of vectors \f$v_1\f$ and \f$v_2\f$ + * + * \param v1 first vector of the inner product + * \param v2 second vector of the inner product + * \return the inner product of the type of the most generic type of the 2 vectors + * + * \tparam V1 type of first vector (not needed by default) + * \tparam V2 type of second vector (not needed by default) + */ + template + typename promote_traits::promote_type + dot (const V1 &v1, const V2 &v2) { + return inner_prod (v1, v2); + } + + /** Copy vector \f$v_2\f$ to \f$v_1\f$ + * + * \param v1 target vector + * \param v2 source vector + * \return a reference to the target vector + * + * \tparam V1 type of first vector (not needed by default) + * \tparam V2 type of second vector (not needed by default) + */ + template + V1 & copy (V1 &v1, const V2 &v2) + { + return v1.assign (v2); + } + + /** Swap vectors \f$v_1\f$ and \f$v_2\f$ + * + * \param v1 first vector + * \param v2 second vector + * + * \tparam V1 type of first vector (not needed by default) + * \tparam V2 type of second vector (not needed by default) + */ + template + void swap (V1 &v1, V2 &v2) + { + v1.swap (v2); + } + + /** scale vector \f$v\f$ with scalar \f$t\f$ + * + * \param v vector to be scaled + * \param t the scalar + * \return \c t*v + * + * \tparam V type of the vector (not needed by default) + * \tparam T type of the scalar (not needed by default) + */ + template + V & scal (V &v, const T &t) + { + return v *= t; + } + + /** Compute \f$v_1= v_1 + t.v_2\f$ + * + * \param v1 target and first vector + * \param t the scalar + * \param v2 second vector + * \return a reference to the first and target vector + * + * \tparam V1 type of the first vector (not needed by default) + * \tparam T type of the scalar (not needed by default) + * \tparam V2 type of the second vector (not needed by default) + */ + template + V1 & axpy (V1 &v1, const T &t, const V2 &v2) + { + return v1.plus_assign (t * v2); + } + + /** Performs rotation of points in the plane and assign the result to the first vector + * + * Each point is defined as a pair \c v1(i) and \c v2(i), being respectively + * the \f$x\f$ and \f$y\f$ coordinates. The parameters \c t1 and \t2 are respectively + * the cosine and sine of the angle of the rotation. + * Results are not returned but directly written into \c v1. + * + * \param t1 cosine of the rotation + * \param v1 vector of \f$x\f$ values + * \param t2 sine of the rotation + * \param v2 vector of \f$y\f$ values + * + * \tparam T1 type of the cosine value (not needed by default) + * \tparam V1 type of the \f$x\f$ vector (not needed by default) + * \tparam T2 type of the sine value (not needed by default) + * \tparam V2 type of the \f$y\f$ vector (not needed by default) + */ + template + void rot (const T1 &t1, V1 &v1, const T2 &t2, V2 &v2) + { + typedef typename promote_traits::promote_type promote_type; + vector vt (t1 * v1 + t2 * v2); + v2.assign (- t2 * v1 + t1 * v2); + v1.assign (vt); + } + + } + + /** \brief Interface and implementation of BLAS level 2 + * This includes functions which perform \b matrix-vector operations. + * More information about BLAS can be found at + * http://en.wikipedia.org/wiki/BLAS + */ + namespace blas_2 { + + /** \brief multiply vector \c v with triangular matrix \c m + * + * \param v a vector + * \param m a triangular matrix + * \return the result of the product + * + * \tparam V type of the vector (not needed by default) + * \tparam M type of the matrix (not needed by default) + */ + template + V & tmv (V &v, const M &m) + { + return v = prod (m, v); + } + + /** \brief solve \f$m.x = v\f$ in place, where \c m is a triangular matrix + * + * \param v a vector + * \param m a matrix + * \param C (this parameter is not needed) + * \return a result vector from the above operation + * + * \tparam V type of the vector (not needed by default) + * \tparam M type of the matrix (not needed by default) + * \tparam C n/a + */ + template + V & tsv (V &v, const M &m, C) + { + return v = solve (m, v, C ()); + } + + /** \brief compute \f$ v_1 = t_1.v_1 + t_2.(m.v_2)\f$, a general matrix-vector product + * + * \param v1 a vector + * \param t1 a scalar + * \param t2 another scalar + * \param m a matrix + * \param v2 another vector + * \return the vector \c v1 with the result from the above operation + * + * \tparam V1 type of first vector (not needed by default) + * \tparam T1 type of first scalar (not needed by default) + * \tparam T2 type of second scalar (not needed by default) + * \tparam M type of matrix (not needed by default) + * \tparam V2 type of second vector (not needed by default) + */ + template + V1 & gmv (V1 &v1, const T1 &t1, const T2 &t2, const M &m, const V2 &v2) + { + return v1 = t1 * v1 + t2 * prod (m, v2); + } + + /** \brief Rank 1 update: \f$ m = m + t.(v_1.v_2^T)\f$ + * + * \param m a matrix + * \param t a scalar + * \param v1 a vector + * \param v2 another vector + * \return a matrix with the result from the above operation + * + * \tparam M type of matrix (not needed by default) + * \tparam T type of scalar (not needed by default) + * \tparam V1 type of first vector (not needed by default) + * \tparam V2type of second vector (not needed by default) + */ + template + M & gr (M &m, const T &t, const V1 &v1, const V2 &v2) + { +#ifndef BOOST_UBLAS_SIMPLE_ET_DEBUG + return m += t * outer_prod (v1, v2); +#else + return m = m + t * outer_prod (v1, v2); +#endif + } + + /** \brief symmetric rank 1 update: \f$m = m + t.(v.v^T)\f$ + * + * \param m a matrix + * \param t a scalar + * \param v a vector + * \return a matrix with the result from the above operation + * + * \tparam M type of matrix (not needed by default) + * \tparam T type of scalar (not needed by default) + * \tparam V type of vector (not needed by default) + */ + template + M & sr (M &m, const T &t, const V &v) + { +#ifndef BOOST_UBLAS_SIMPLE_ET_DEBUG + return m += t * outer_prod (v, v); +#else + return m = m + t * outer_prod (v, v); +#endif + } + + /** \brief hermitian rank 1 update: \f$m = m + t.(v.v^H)\f$ + * + * \param m a matrix + * \param t a scalar + * \param v a vector + * \return a matrix with the result from the above operation + * + * \tparam M type of matrix (not needed by default) + * \tparam T type of scalar (not needed by default) + * \tparam V type of vector (not needed by default) + */ + template + M & hr (M &m, const T &t, const V &v) + { +#ifndef BOOST_UBLAS_SIMPLE_ET_DEBUG + return m += t * outer_prod (v, conj (v)); +#else + return m = m + t * outer_prod (v, conj (v)); +#endif + } + + /** \brief symmetric rank 2 update: \f$ m=m+ t.(v_1.v_2^T + v_2.v_1^T)\f$ + * + * \param m a matrix + * \param t a scalar + * \param v1 a vector + * \param v2 another vector + * \return a matrix with the result from the above operation + * + * \tparam M type of matrix (not needed by default) + * \tparam T type of scalar (not needed by default) + * \tparam V1 type of first vector (not needed by default) + * \tparam V2type of second vector (not needed by default) + */ + template + M & sr2 (M &m, const T &t, const V1 &v1, const V2 &v2) + { +#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)); +#endif + } + + /** \brief hermitian rank 2 update: \f$m=m+t.(v_1.v_2^H) + v_2.(t.v_1)^H)\f$ + * + * \param m a matrix + * \param t a scalar + * \param v1 a vector + * \param v2 another vector + * \return a matrix with the result from the above operation + * + * \tparam M type of matrix (not needed by default) + * \tparam T type of scalar (not needed by default) + * \tparam V1 type of first vector (not needed by default) + * \tparam V2type of second vector (not needed by default) + */ + template + M & hr2 (M &m, const T &t, const V1 &v1, const V2 &v2) + { +#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)); +#endif + } + + } + + /** \brief Interface and implementation of BLAS level 3 + * This includes functions which perform \b matrix-matrix operations. + * More information about BLAS can be found at + * http://en.wikipedia.org/wiki/BLAS + */ + namespace blas_3 { + + /** \brief triangular matrix multiplication \f$m_1=t.m_2.m_3\f$ where \f$m_2\f$ and \f$m_3\f$ are triangular + * + * \param m1 a matrix for storing result + * \param t a scalar + * \param m2 a triangular matrix + * \param m3 a triangular matrix + * \return the matrix \c m1 + * + * \tparam M1 type of the result matrix (not needed by default) + * \tparam T type of the scalar (not needed by default) + * \tparam M2 type of the first triangular matrix (not needed by default) + * \tparam M3 type of the second triangular matrix (not needed by default) + * + */ + template + M1 & tmm (M1 &m1, const T &t, const M2 &m2, const M3 &m3) + { + return m1 = t * prod (m2, m3); + } + + /** \brief triangular solve \f$ m_2.x = t.m_1\f$ in place, \f$m_2\f$ is a triangular matrix + * + * \param m1 a matrix + * \param t a scalar + * \param m2 a triangular matrix + * \param C (not used) + * \return the \f$m_1\f$ matrix + * + * \tparam M1 type of the first matrix (not needed by default) + * \tparam T type of the scalar (not needed by default) + * \tparam M2 type of the triangular matrix (not needed by default) + * \tparam C (n/a) + */ + template + M1 & tsm (M1 &m1, const T &t, const M2 &m2, C) + { + return m1 = solve (m2, t * m1, C ()); + } + + /** \brief general matrix multiplication \f$m_1=t_1.m_1 + t_2.m_2.m_3\f$ + * + * \param m1 first matrix + * \param t1 first scalar + * \param t2 second scalar + * \param m2 second matrix + * \param m3 third matrix + * \return the matrix \c m1 + * + * \tparam M1 type of the first matrix (not needed by default) + * \tparam T1 type of the first scalar (not needed by default) + * \tparam T2 type of the second scalar (not needed by default) + * \tparam M2 type of the second matrix (not needed by default) + * \tparam M3 type of the third matrix (not needed by default) + */ + template + M1 & gmm (M1 &m1, const T1 &t1, const T2 &t2, const M2 &m2, const M3 &m3) + { + return m1 = t1 * m1 + t2 * prod (m2, m3); + } + + /** \brief symmetric rank \a k update: \f$m_1=t.m_1+t_2.(m_2.m_2^T)\f$ + * + * \param m1 first matrix + * \param t1 first scalar + * \param t2 second scalar + * \param m2 second matrix + * \return matrix \c m1 + * + * \tparam M1 type of the first matrix (not needed by default) + * \tparam T1 type of the first scalar (not needed by default) + * \tparam T2 type of the second scalar (not needed by default) + * \tparam M2 type of the second matrix (not needed by default) + * \todo use opb_prod() + */ + template + M1 & srk (M1 &m1, const T1 &t1, const T2 &t2, const M2 &m2) + { + return m1 = t1 * m1 + t2 * prod (m2, trans (m2)); + } + + /** \brief hermitian rank \a k update: \f$m_1=t.m_1+t_2.(m_2.m2^H)\f$ + * + * \param m1 first matrix + * \param t1 first scalar + * \param t2 second scalar + * \param m2 second matrix + * \return matrix \c m1 + * + * \tparam M1 type of the first matrix (not needed by default) + * \tparam T1 type of the first scalar (not needed by default) + * \tparam T2 type of the second scalar (not needed by default) + * \tparam M2 type of the second matrix (not needed by default) + * \todo use opb_prod() + */ + template + M1 & hrk (M1 &m1, const T1 &t1, const T2 &t2, const M2 &m2) + { + return m1 = t1 * m1 + t2 * prod (m2, herm (m2)); + } + + /** \brief generalized symmetric rank \a k update: \f$m_1=t_1.m_1+t_2.(m_2.m3^T)+t_2.(m_3.m2^T)\f$ + * + * \param m1 first matrix + * \param t1 first scalar + * \param t2 second scalar + * \param m2 second matrix + * \param m3 third matrix + * \return matrix \c m1 + * + * \tparam M1 type of the first matrix (not needed by default) + * \tparam T1 type of the first scalar (not needed by default) + * \tparam T2 type of the second scalar (not needed by default) + * \tparam M2 type of the second matrix (not needed by default) + * \tparam M3 type of the third matrix (not needed by default) + * \todo use opb_prod() + */ + template + M1 & sr2k (M1 &m1, const T1 &t1, const T2 &t2, const M2 &m2, const M3 &m3) + { + return m1 = t1 * m1 + t2 * (prod (m2, trans (m3)) + prod (m3, trans (m2))); + } + + /** \brief generalized hermitian rank \a k update: * \f$m_1=t_1.m_1+t_2.(m_2.m_3^H)+(m_3.(t_2.m_2)^H)\f$ + * + * \param m1 first matrix + * \param t1 first scalar + * \param t2 second scalar + * \param m2 second matrix + * \param m3 third matrix + * \return matrix \c m1 + * + * \tparam M1 type of the first matrix (not needed by default) + * \tparam T1 type of the first scalar (not needed by default) + * \tparam T2 type of the second scalar (not needed by default) + * \tparam M2 type of the second matrix (not needed by default) + * \tparam M3 type of the third matrix (not needed by default) + * \todo use opb_prod() + */ + template + M1 & hr2k (M1 &m1, const T1 &t1, const T2 &t2, const M2 &m2, const M3 &m3) + { + return m1 = + t1 * m1 + + t2 * prod (m2, herm (m3)) + + type_traits::conj (t2) * prod (m3, herm (m2)); + } + + } + +}}} + +#endif diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/ublas/detail/concepts.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/ublas/detail/concepts.hpp new file mode 100644 index 0000000000..45134e3a19 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/ublas/detail/concepts.hpp @@ -0,0 +1,1540 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// 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) +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + +#ifndef _BOOST_UBLAS_CONCEPTS_ +#define _BOOST_UBLAS_CONCEPTS_ + +#include + +// Concept checks based on ideas of Jeremy Siek + +namespace boost { namespace numeric { namespace ublas { + + + template + struct Indexed1DIteratorConcept { + typedef I iterator_type; + + void constraints () { + iterator_type it = iterator_type (); + // Index + it.index (); + } + }; + + template + struct IndexedBidirectional1DIteratorConcept { + typedef I iterator_type; + + void constraints () { + function_requires< BidirectionalIteratorConcept >(); + function_requires< Indexed1DIteratorConcept >(); + } + }; + + template + struct Mutable_IndexedBidirectional1DIteratorConcept { + typedef I iterator_type; + + void constraints () { + function_requires< Mutable_BidirectionalIteratorConcept >(); + function_requires< Indexed1DIteratorConcept >(); + } + }; + + template + struct IndexedRandomAccess1DIteratorConcept { + typedef I iterator_type; + + void constraints () { + function_requires< RandomAccessIteratorConcept >(); + function_requires< Indexed1DIteratorConcept >(); + } + }; + + template + struct Mutable_IndexedRandomAccess1DIteratorConcept { + typedef I iterator_type; + + void constraints () { + function_requires< Mutable_RandomAccessIteratorConcept >(); + function_requires< Indexed1DIteratorConcept >(); + } + }; + + template + struct Indexed2DIteratorConcept { + typedef I iterator_type; + typedef typename I::dual_iterator_type dual_iterator_type; + typedef typename I::dual_reverse_iterator_type dual_reverse_iterator_type; + + void constraints () { + iterator_type it = iterator_type (); + // Indices + it.index1 (); + it.index2 (); + // Iterator begin/end + dual_iterator_type it_begin (it.begin ()); + dual_iterator_type it_end (it.end ()); + // Reverse iterator begin/end + dual_reverse_iterator_type it_rbegin (it.rbegin ()); + dual_reverse_iterator_type it_rend (it.rend ()); + ignore_unused_variable_warning (it_begin); + ignore_unused_variable_warning (it_end); + ignore_unused_variable_warning (it_rbegin); + ignore_unused_variable_warning (it_rend); + } + }; + + template + struct IndexedBidirectional2DIteratorConcept { + typedef I1 subiterator1_type; + typedef I2 subiterator2_type; + + void constraints () { + function_requires< BidirectionalIteratorConcept >(); + function_requires< BidirectionalIteratorConcept >(); + function_requires< Indexed2DIteratorConcept >(); + function_requires< Indexed2DIteratorConcept >(); + } + }; + + template + struct Mutable_IndexedBidirectional2DIteratorConcept { + typedef I1 subiterator1_type; + typedef I2 subiterator2_type; + + void constraints () { + function_requires< Mutable_BidirectionalIteratorConcept >(); + function_requires< Mutable_BidirectionalIteratorConcept >(); + function_requires< Indexed2DIteratorConcept >(); + function_requires< Indexed2DIteratorConcept >(); + } + }; + + template + struct IndexedRandomAccess2DIteratorConcept { + typedef I1 subiterator1_type; + typedef I2 subiterator2_type; + + void constraints () { + function_requires< RandomAccessIteratorConcept >(); + function_requires< RandomAccessIteratorConcept >(); + function_requires< Indexed2DIteratorConcept >(); + function_requires< Indexed2DIteratorConcept >(); + } + }; + + template + struct Mutable_IndexedRandomAccess2DIteratorConcept { + typedef I1 subiterator1_type; + typedef I2 subiterator2_type; + + void constraints () { + function_requires< Mutable_RandomAccessIteratorConcept >(); + function_requires< Mutable_RandomAccessIteratorConcept >(); + function_requires< Indexed2DIteratorConcept >(); + function_requires< Indexed2DIteratorConcept >(); + } + }; + + template + struct StorageArrayConcept { + typedef C container_type; + typedef typename C::size_type size_type; + typedef typename C::value_type value_type; + + void constraints () { + function_requires< RandomAccessContainerConcept >(); + size_type n (0); + // Sizing constructor + container_type c = container_type (n); + // Initialised sizing constructor + container_type (n, value_type (5)); + ignore_unused_variable_warning (c); + } + }; + + template + struct Mutable_StorageArrayConcept { + typedef C container_type; + typedef typename C::size_type size_type; + typedef typename C::value_type value_type; + typedef typename C::iterator iterator_type; + + void constraints () { + function_requires< Mutable_RandomAccessContainerConcept > (); + size_type n (0); + // Sizing constructor + container_type c = container_type (n); + // Initialised sizing constructor + c = container_type (n, value_type (3)); + // Resize + c.resize (n, value_type (5)); + // Resize - none preserving + c.resize (n); + } + }; + + template + struct StorageSparseConcept { + typedef C container_type; + typedef typename C::size_type size_type; + + void constraints () { + function_requires< ReversibleContainerConcept > (); + } + }; + + template + struct Mutable_StorageSparseConcept { + typedef C container_type; + typedef typename C::size_type size_type; + typedef typename C::value_type value_type; + typedef typename C::iterator iterator_type; + + void constraints () { + // NOTE - Not Mutable_ReversibleContainerConcept + function_requires< ReversibleContainerConcept >(); + container_type c = container_type (); + value_type t = value_type (); + iterator_type it = iterator_type (), it1 = iterator_type (), it2 = iterator_type (); + // Insert + c.insert (it, t); + // Erase + c.erase (it); + // Range erase + c.erase (it1, it2); + // Clear + c.clear (); + } + }; + + template + struct IndexSetConcept { + typedef G generator_type; + typedef typename G::size_type size_type; + typedef typename G::value_type value_type; + + void constraints () { + function_requires< AssignableConcept >(); + function_requires< ReversibleContainerConcept >(); + generator_type g = generator_type (); + size_type n (0); + value_type t; + // Element access + t = g (n); + ignore_unused_variable_warning (t); + } + }; + + /** \brief Scalar expression concept. + * + * requirements + * \li \c SE::value_type is the type of the scalar expression + * \li \c SE must be convertable to \c SE::value_type + * \li the constant \c SE::complexity must exist + * + * \param SE the type of the scalar expression + */ + template + struct ScalarExpressionConcept { + typedef SE scalar_expression_type; + typedef typename SE::value_type value_type; + + static const unsigned complexity = SE::complexity; + + void constraints () { + scalar_expression_type *sp; + scalar_expression_type s = *sp; + value_type t; + // Conversion + t = s; + ignore_unused_variable_warning (t); + } + }; + + /** \brief Vector expression concept. + * + * requirements + * \li \c VE::value_type is the type of the elements + * \li \c VE::const_reference The return type when accessing an element of a constant vector + * expression. Must be convertable to a \c value_type. + * \li \c VE::size_type is the (unsigned) type of the indices + * \li \c VE::difference_type is the (signed) type of distances between indices + * \li \c VE::category + * + * \li the constant \c SE::complexity must exist + * + * \param SE the type of the scalar expression + */ + template + struct VectorExpressionConcept { + typedef VE vector_expression_type; + typedef typename VE::type_category type_category; + typedef typename VE::size_type size_type; + typedef typename VE::difference_type difference_type; + typedef typename VE::value_type value_type; + typedef typename VE::const_reference const_reference; + typedef typename VE::const_iterator const_iterator_type; + typedef typename VE::const_reverse_iterator const_reverse_iterator_type; + + void constraints () { + vector_expression_type *vp; + const vector_expression_type *cvp; + vector_expression_type v = *vp; + const vector_expression_type cv = *cvp; + size_type n (0), i (0); + value_type t; + // Find (internal?) + const_iterator_type cit (v.find (i)); + // Beginning of range + const_iterator_type cit_begin (v.begin ()); + // End of range + const_iterator_type cit_end (v.end ()); + // Size + n = v.size (); + // Beginning of reverse range + const_reverse_iterator_type crit_begin (cv.rbegin ()); + // End of reverse range + const_reverse_iterator_type crit_end (cv.rend ()); + // Element access + t = v (i); + ignore_unused_variable_warning (n); + ignore_unused_variable_warning (cit); + ignore_unused_variable_warning (cit_begin); + ignore_unused_variable_warning (cit_end); + ignore_unused_variable_warning (crit_begin); + ignore_unused_variable_warning (crit_end); + ignore_unused_variable_warning (t); + } + }; + + template + struct Mutable_VectorExpressionConcept { + typedef VE vector_expression_type; + typedef typename VE::size_type size_type; + typedef typename VE::value_type value_type; + typedef typename VE::iterator iterator_type; + typedef typename VE::reverse_iterator reverse_iterator_type; + + void constraints () { + function_requires< AssignableConcept >(); + function_requires< VectorExpressionConcept >(); + vector_expression_type *vp; + vector_expression_type v = *vp, v1 = *vp, v2 = *vp; + size_type i (0); + value_type t = value_type (); + // Find (internal?) + iterator_type it (v.find (i)); + // Beginning of range + iterator_type it_begin (v.begin ()); + // End of range + iterator_type it_end (v.end ()); + // Swap + v1.swap (v2); + // Beginning of reverse range + reverse_iterator_type rit_begin (v.rbegin ()); + // End of reverse range + reverse_iterator_type rit_end (v.rend ()); + // Assignments + v2 = v1; + v2.assign (v1); + v2 += v1; + v2.plus_assign (v1); + v2 -= v1; + v2.minus_assign (v1); + v *= t; + ignore_unused_variable_warning (it); + ignore_unused_variable_warning (it_begin); + ignore_unused_variable_warning (it_end); + ignore_unused_variable_warning (rit_begin); + ignore_unused_variable_warning (rit_end); + } + }; + + template + struct MatrixExpressionConcept { + typedef ME matrix_expression_type; + typedef typename ME::type_category type_category; + typedef typename ME::size_type size_type; + typedef typename ME::value_type value_type; + typedef typename ME::const_iterator1 const_subiterator1_type; + typedef typename ME::const_iterator2 const_subiterator2_type; + typedef typename ME::const_reverse_iterator1 const_reverse_subiterator1_type; + typedef typename ME::const_reverse_iterator2 const_reverse_subiterator2_type; + + void constraints () { + matrix_expression_type *mp; + const matrix_expression_type *cmp; + matrix_expression_type m = *mp; + const matrix_expression_type cm = *cmp; + size_type n (0), i (0), j (0); + value_type t; + // Find (internal?) + const_subiterator1_type cit1 (m.find1 (0, i, j)); + const_subiterator2_type cit2 (m.find2 (0, i, j)); + // Beginning of range + const_subiterator1_type cit1_begin (m.begin1 ()); + const_subiterator2_type cit2_begin (m.begin2 ()); + // End of range + const_subiterator1_type cit1_end (m.end1 ()); + const_subiterator2_type cit2_end (m.end2 ()); + // Size + n = m.size1 (); + n = m.size2 (); + // Beginning of reverse range + const_reverse_subiterator1_type crit1_begin (cm.rbegin1 ()); + const_reverse_subiterator2_type crit2_begin (cm.rbegin2 ()); + // End of reverse range + const_reverse_subiterator1_type crit1_end (cm.rend1 ()); + const_reverse_subiterator2_type crit2_end (cm.rend2 ()); + // Element access + t = m (i, j); + ignore_unused_variable_warning (n); + ignore_unused_variable_warning (cit1); + ignore_unused_variable_warning (cit2); + ignore_unused_variable_warning (cit1_begin); + ignore_unused_variable_warning (cit2_begin); + ignore_unused_variable_warning (cit1_end); + ignore_unused_variable_warning (cit2_end); + ignore_unused_variable_warning (crit1_begin); + ignore_unused_variable_warning (crit2_begin); + ignore_unused_variable_warning (crit1_end); + ignore_unused_variable_warning (crit2_end); + ignore_unused_variable_warning (t); + } + }; + + template + struct Mutable_MatrixExpressionConcept { + typedef ME matrix_expression_type; + typedef typename ME::size_type size_type; + typedef typename ME::value_type value_type; + typedef typename ME::iterator1 subiterator1_type; + typedef typename ME::iterator2 subiterator2_type; + typedef typename ME::reverse_iterator1 reverse_subiterator1_type; + typedef typename ME::reverse_iterator2 reverse_subiterator2_type; + + void constraints () { + function_requires< AssignableConcept >(); + function_requires< MatrixExpressionConcept >(); + matrix_expression_type *mp; + matrix_expression_type m = *mp, m1 = *mp, m2 = *mp; + size_type i (0), j (0); + value_type t = value_type (); + // Find (internal?) + subiterator1_type it1 (m.find1 (0, i, j)); + subiterator2_type it2 (m.find2 (0, i, j)); + // Beginning of range + subiterator1_type it1_begin (m.begin1 ()); + subiterator2_type it2_begin (m.begin2 ()); + // End of range + subiterator1_type it1_end (m.end1 ()); + subiterator2_type it2_end (m.end2 ()); + // Swap + m1.swap (m2); + // Beginning of reverse range + reverse_subiterator1_type rit1_begin (m.rbegin1 ()); + reverse_subiterator2_type rit2_begin (m.rbegin2 ()); + // End of reverse range + reverse_subiterator1_type rit1_end (m.rend1 ()); + reverse_subiterator2_type rit2_end (m.rend2 ()); + // Assignments + m2 = m1; + m2.assign (m1); + m2 += m1; + m2.plus_assign (m1); + m2 -= m1; + m2.minus_assign (m1); + m *= t; + ignore_unused_variable_warning (it1); + ignore_unused_variable_warning (it2); + ignore_unused_variable_warning (it1_begin); + ignore_unused_variable_warning (it2_begin); + ignore_unused_variable_warning (it1_end); + ignore_unused_variable_warning (it2_end); + ignore_unused_variable_warning (rit1_begin); + ignore_unused_variable_warning (rit2_begin); + ignore_unused_variable_warning (rit1_end); + ignore_unused_variable_warning (rit2_end); + } + }; + + template + struct VectorConcept { + typedef V vector_type; + typedef typename V::size_type size_type; + typedef typename V::value_type value_type; + typedef const value_type *const_pointer; + + void constraints () { + function_requires< VectorExpressionConcept >(); + size_type n (0); + size_type i (0); + // Sizing constructor + vector_type v (n); + // Element support + const_pointer p = v.find_element (i); + + ignore_unused_variable_warning (p); + } + }; + + template + struct Mutable_VectorConcept { + typedef V vector_type; + typedef typename V::size_type size_type; + typedef typename V::value_type value_type; + typedef value_type *pointer; + + void constraints () { + function_requires< VectorConcept >(); + function_requires< DefaultConstructible >(); + function_requires< Mutable_VectorExpressionConcept >(); + size_type n (0); + value_type t = value_type (); + size_type i (0); + vector_type v; + // Element support + pointer p = v.find_element (i); + // Element assignment + value_type r = v.insert_element (i, t); + v.insert_element (i, t) = r; + // Zeroing + v.clear (); + // Resize + v.resize (n); + + ignore_unused_variable_warning (p); + ignore_unused_variable_warning (r); + } + }; + + template + struct SparseVectorConcept { + typedef V vector_type; + typedef typename V::size_type size_type; + + void constraints () { + function_requires< VectorConcept >(); + } + }; + + template + struct Mutable_SparseVectorConcept { + typedef V vector_type; + typedef typename V::size_type size_type; + typedef typename V::value_type value_type; + + void constraints () { + function_requires< SparseVectorConcept >(); + function_requires< Mutable_VectorConcept >(); + size_type i (0); + vector_type v; + // Element erasure + v.erase_element (i); + } + }; + + template + struct MatrixConcept { + typedef M matrix_type; + typedef typename M::size_type size_type; + typedef typename M::value_type value_type; + typedef const value_type *const_pointer; + + void constraints () { + function_requires< MatrixExpressionConcept >(); + size_type n (0); + size_type i (0), j (0); + // Sizing constructor + matrix_type m (n, n); + // Element support +#ifndef SKIP_BAD + const_pointer p = m.find_element (i, j); +#else + const_pointer p; + ignore_unused_variable_warning (i); + ignore_unused_variable_warning (j); +#endif + ignore_unused_variable_warning (p); + } + }; + + template + struct Mutable_MatrixConcept { + typedef M matrix_type; + typedef typename M::size_type size_type; + typedef typename M::value_type value_type; + typedef value_type *pointer; + + void constraints () { + function_requires< MatrixConcept >(); + function_requires< DefaultConstructible >(); + function_requires< Mutable_MatrixExpressionConcept >(); + size_type n (0); + value_type t = value_type (); + size_type i (0), j (0); + matrix_type m; + // Element support +#ifndef SKIP_BAD + pointer p = m.find_element (i, j); + ignore_unused_variable_warning (i); + ignore_unused_variable_warning (j); +#else + pointer p; +#endif + // Element assigment + value_type r = m.insert_element (i, j, t); + m.insert_element (i, j, t) = r; + // Zeroing + m.clear (); + // Resize + m.resize (n, n); + m.resize (n, n, false); + + ignore_unused_variable_warning (p); + ignore_unused_variable_warning (r); + } + }; + + template + struct SparseMatrixConcept { + typedef M matrix_type; + typedef typename M::size_type size_type; + + void constraints () { + function_requires< MatrixConcept >(); + } + }; + + template + struct Mutable_SparseMatrixConcept { + typedef M matrix_type; + typedef typename M::size_type size_type; + typedef typename M::value_type value_type; + + void constraints () { + function_requires< SparseMatrixConcept >(); + function_requires< Mutable_MatrixConcept >(); + size_type i (0), j (0); + matrix_type m; + // Elemnent erasure + m.erase_element (i, j); + } + }; + + /** introduce anonymous namespace to make following functions + * local to the current compilation unit. + */ + namespace { + + template + T + ZeroElement (T); + template<> + float + ZeroElement (float) { + return 0.f; + } + template<> + double + ZeroElement (double) { + return 0.; + } + template<> + vector + ZeroElement (vector) { + return zero_vector (); + } + template<> + vector + ZeroElement (vector) { + return zero_vector (); + } + template<> + matrix + ZeroElement (matrix) { + return zero_matrix (); + } + template<> + matrix + ZeroElement (matrix) { + return zero_matrix (); + } + template<> + std::complex + ZeroElement (std::complex) { + return std::complex (0.f); + } + template<> + std::complex + ZeroElement (std::complex) { + return std::complex (0.); + } + template<> + vector > + ZeroElement (vector >) { + return zero_vector > (); + } + template<> + vector > + ZeroElement (vector >) { + return zero_vector > (); + } + template<> + matrix > + ZeroElement (matrix >) { + return zero_matrix > (); + } + template<> + matrix > + ZeroElement (matrix >) { + return zero_matrix > (); + } + + template + T + OneElement (T); + template<> + float + OneElement (float) { + return 1.f; + } + template<> + double + OneElement (double) { + return 1.; + } + template<> + matrix + OneElement (matrix) { + return identity_matrix (); + } + template<> + matrix + OneElement (matrix) { + return identity_matrix (); + } + template<> + std::complex + OneElement (std::complex) { + return std::complex (1.f); + } + template<> + std::complex + OneElement (std::complex) { + return std::complex (1.); + } + template<> + matrix > + OneElement (matrix >) { + return identity_matrix > (); + } + template<> + matrix > + OneElement (matrix >) { + return identity_matrix > (); + } + + template + bool + operator == (const vector_expression &e1, const vector_expression &e2) { + typedef typename promote_traits::promote_type value_type; + typedef typename type_traits::real_type real_type; + return norm_inf (e1 - e2) == real_type/*zero*/(); + } + template + bool + operator == (const matrix_expression &e1, const matrix_expression &e2) { + typedef typename promote_traits::promote_type value_type; + typedef typename type_traits::real_type real_type; + return norm_inf (e1 - e2) == real_type/*zero*/(); + } + + template + struct AdditiveAbelianGroupConcept { + typedef T value_type; + + void constraints () { + bool r; + value_type a = value_type (), b = value_type (), c = value_type (); + r = (a + b) + c == a + (b + c); + r = ZeroElement (value_type ()) + a == a; + r = a + ZeroElement (value_type ()) == a; + r = a + (- a) == ZeroElement (value_type ()); + r = (- a) + a == ZeroElement (value_type ()); + r = a + b == b + a; + ignore_unused_variable_warning (r); + } + }; + + template + struct MultiplicativeAbelianGroupConcept { + typedef T value_type; + + void constraints () { + bool r; + value_type a = value_type (), b = value_type (), c = value_type (); + r = (a * b) * c == a * (b * c); + r = OneElement (value_type ()) * a == a; + r = a * OneElement (value_type ()) == a; + r = a * (OneElement (value_type ()) / a) == a; + r = (OneElement (value_type ()) / a) * a == a; + r = a * b == b * a; + ignore_unused_variable_warning (r); + } + }; + + template + struct RingWithIdentityConcept { + typedef T value_type; + + void constraints () { + function_requires< AdditiveAbelianGroupConcept >(); + bool r; + value_type a = value_type (), b = value_type (), c = value_type (); + r = (a * b) * c == a * (b * c); + r = (a + b) * c == a * c + b * c; + r = OneElement (value_type ()) * a == a; + r = a * OneElement (value_type ()) == a; + ignore_unused_variable_warning (r); + } + }; + + template + struct Prod_RingWithIdentityConcept { + typedef T value_type; + + void constraints () { + function_requires< AdditiveAbelianGroupConcept >(); + bool r; + value_type a = value_type (), b = value_type (), c = value_type (); + r = prod (T (prod (a, b)), c) == prod (a, T (prod (b, c))); + r = prod (a + b, c) == prod (a, c) + prod (b, c); + r = prod (OneElement (value_type ()), a) == a; + r = prod (a, OneElement (value_type ())) == a; + ignore_unused_variable_warning (r); + } + }; + + template + struct CommutativeRingWithIdentityConcept { + typedef T value_type; + + void constraints () { + function_requires< RingWithIdentityConcept >(); + bool r; + value_type a = value_type (), b = value_type (); + r = a * b == b * a; + ignore_unused_variable_warning (r); + } + }; + + template + struct FieldConcept { + typedef T value_type; + + void constraints () { + function_requires< CommutativeRingWithIdentityConcept >(); + bool r; + value_type a = value_type (); + r = a == ZeroElement (value_type ()) || a * (OneElement (value_type ()) / a) == a; + r = a == ZeroElement (value_type ()) || (OneElement (value_type ()) / a) * a == a; + ignore_unused_variable_warning (r); + } + }; + + template + struct VectorSpaceConcept { + typedef T value_type; + typedef V vector_type; + + void constraints () { + function_requires< FieldConcept >(); + function_requires< AdditiveAbelianGroupConcept >(); + bool r; + value_type alpha = value_type (), beta = value_type (); + vector_type a = vector_type (), b = vector_type (); + r = alpha * (a + b) == alpha * a + alpha * b; + r = (alpha + beta) * a == alpha * a + beta * a; + r = (alpha * beta) * a == alpha * (beta * a); + r = OneElement (value_type ()) * a == a; + ignore_unused_variable_warning (r); + } + }; + + template + struct LinearOperatorConcept { + typedef T value_type; + typedef V vector_type; + typedef M matrix_type; + + void constraints () { + function_requires< VectorSpaceConcept >(); + bool r; + value_type alpha = value_type (), beta = value_type (); + vector_type a = vector_type (), b = vector_type (); + matrix_type A = matrix_type (); + r = prod (A, alpha * a + beta * b) == alpha * prod (A, a) + beta * prod (A, b); + ignore_unused_variable_warning (r); + } + }; + + void concept_checks () { + + // Allow tests to be group to keep down compiler storage requirement +#ifdef INTERAL +#define INTERNAL_STORAGE +#define INTERNAL_VECTOR +#define INTERNAL_MATRIX +#define INTERNAL_SPECIAL +#define INTERNAL_SPARSE +#define INTERNAL_EXPRESSION +#endif + + // TODO enable this for development + // #define VIEW_CONCEPTS + + // Element value type for tests + typedef float T; + + // Storage Array +#if defined (INTERNAL_STORAGE) || defined (INTERNAL_STORAGE_DENSE) + { + typedef std::vector container_model; + function_requires< Mutable_StorageArrayConcept >(); + function_requires< RandomAccessIteratorConcept >(); + function_requires< Mutable_RandomAccessIteratorConcept >(); + } + + { + typedef bounded_array container_model; + function_requires< Mutable_StorageArrayConcept >(); + function_requires< RandomAccessIteratorConcept >(); + function_requires< Mutable_RandomAccessIteratorConcept >(); + } + + { + typedef unbounded_array container_model; + function_requires< Mutable_StorageArrayConcept >(); + function_requires< RandomAccessIteratorConcept >(); + function_requires< Mutable_RandomAccessIteratorConcept >(); + } + +/* FIXME array_adaptors are in progress + { + typedef array_adaptor container_model; + function_requires< Mutable_StorageArrayConcept >(); + function_requires< RandomAccessIteratorConcept >(); + function_requires< Mutable_RandomAccessIteratorConcept >(); + } +*/ + + { + typedef range container_model; + function_requires< IndexSetConcept >(); + function_requires< RandomAccessIteratorConcept >(); + } + + { + typedef slice container_model; + function_requires< IndexSetConcept >(); + function_requires< RandomAccessIteratorConcept >(); + } + + { + typedef indirect_array<> container_model; + function_requires< IndexSetConcept >(); + function_requires< RandomAccessIteratorConcept >(); + } +#endif + + // Storage Sparse +#if defined (INTERNAL_STORAGE) || defined (INTERNAL_STORAGE_SPARSE) + { + typedef map_array container_model; + function_requires< Mutable_StorageSparseConcept >(); + function_requires< RandomAccessIteratorConcept >(); + function_requires< RandomAccessIteratorConcept >(); + } + + { + typedef std::map container_model; + function_requires< Mutable_StorageSparseConcept >(); + function_requires< BidirectionalIteratorConcept >(); + function_requires< BidirectionalIteratorConcept >(); + } +#endif + +#ifdef VIEW_CONCEPTS + // read only vectors + { + typedef vector_view container_model; + function_requires< RandomAccessContainerConcept >(); + function_requires< VectorConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + } +#endif + + // Vector +#if defined (INTERNAL_VECTOR) || defined (INTERNAL_VECTOR_DENSE) + { + typedef vector container_model; + function_requires< RandomAccessContainerConcept >(); + function_requires< Mutable_VectorConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess1DIteratorConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess1DIteratorConcept >(); + } + + { + typedef zero_vector container_model; + function_requires< VectorConcept >(); + function_requires< IndexedBidirectional1DIteratorConcept >(); + function_requires< IndexedBidirectional1DIteratorConcept >(); + } + + { + typedef unit_vector container_model; + function_requires< VectorConcept >(); + function_requires< IndexedBidirectional1DIteratorConcept >(); + function_requires< IndexedBidirectional1DIteratorConcept >(); + } + + { + typedef scalar_vector container_model; + function_requires< VectorConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + } + + { + typedef c_vector container_model; + function_requires< Mutable_VectorConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess1DIteratorConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess1DIteratorConcept >(); + } +#endif + + // Vector Proxies +#if defined (INTERNAL_VECTOR) || defined (INTERNAL_VECTOR_PROXY) + { + typedef vector_range > container_model; + function_requires< Mutable_VectorExpressionConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess1DIteratorConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess1DIteratorConcept >(); + } + + { + typedef vector_slice > container_model; + function_requires< Mutable_VectorExpressionConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess1DIteratorConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess1DIteratorConcept >(); + } + + { + typedef vector_indirect > container_model; + function_requires< Mutable_VectorExpressionConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess1DIteratorConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess1DIteratorConcept >(); + } +#endif + + // Sparse Vector +#if defined (INTERNAL_SPARSE) || defined (INTERNAL_VECTOR_SPARSE) + { + typedef mapped_vector container_model; + function_requires< Mutable_SparseVectorConcept >(); + function_requires< IndexedBidirectional1DIteratorConcept >(); + function_requires< Mutable_IndexedBidirectional1DIteratorConcept >(); + function_requires< IndexedBidirectional1DIteratorConcept >(); + function_requires< Mutable_IndexedBidirectional1DIteratorConcept >(); + } + + { + typedef compressed_vector container_model; + function_requires< Mutable_SparseVectorConcept >(); + function_requires< IndexedBidirectional1DIteratorConcept >(); + function_requires< Mutable_IndexedBidirectional1DIteratorConcept >(); + function_requires< IndexedBidirectional1DIteratorConcept >(); + function_requires< Mutable_IndexedBidirectional1DIteratorConcept >(); + } + + { + typedef coordinate_vector container_model; + function_requires< Mutable_SparseVectorConcept >(); + function_requires< IndexedBidirectional1DIteratorConcept >(); + function_requires< Mutable_IndexedBidirectional1DIteratorConcept >(); + function_requires< IndexedBidirectional1DIteratorConcept >(); + function_requires< Mutable_IndexedBidirectional1DIteratorConcept >(); + } +#endif + + // Matrix +#if defined (INTERNAL_MATRIX) || defined (INTERNAL_MATRIX_DENSE) + { + typedef matrix container_model; + function_requires< Mutable_MatrixConcept > >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess2DIteratorConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess2DIteratorConcept >(); + } + + { + typedef vector_of_vector container_model; + function_requires< Mutable_MatrixConcept > >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess2DIteratorConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess2DIteratorConcept >(); + } + + { + typedef zero_matrix container_model; + function_requires< Mutable_MatrixConcept > >(); + function_requires< IndexedBidirectional2DIteratorConcept >(); + function_requires< IndexedBidirectional2DIteratorConcept >(); + } + + { + typedef identity_matrix container_model; + function_requires< Mutable_MatrixConcept > >(); + function_requires< IndexedBidirectional2DIteratorConcept >(); + function_requires< IndexedBidirectional2DIteratorConcept >(); + } + + { + typedef scalar_matrix container_model; + function_requires< Mutable_MatrixConcept > >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + } + + { + typedef c_matrix container_model; + function_requires< Mutable_MatrixConcept > >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess2DIteratorConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess2DIteratorConcept >(); + } +#endif + + // Matrix Proxies +#if defined (INTERNAL_MATRIX) || defined (INTERNAL_MATRIX_PROXY) + { + typedef matrix_row > container_model; + function_requires< Mutable_VectorExpressionConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess1DIteratorConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess1DIteratorConcept >(); + } + + { + typedef matrix_column > container_model; + function_requires< Mutable_VectorExpressionConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess1DIteratorConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess1DIteratorConcept >(); + } + + { + typedef matrix_vector_range > container_model; + function_requires< Mutable_VectorExpressionConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess1DIteratorConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess1DIteratorConcept >(); + } + + { + typedef matrix_vector_slice > container_model; + function_requires< Mutable_VectorExpressionConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess1DIteratorConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess1DIteratorConcept >(); + } + + { + typedef matrix_vector_indirect > container_model; + function_requires< Mutable_VectorExpressionConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess1DIteratorConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess1DIteratorConcept >(); + } + + { + typedef matrix_range > container_model; + function_requires< Mutable_MatrixExpressionConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess2DIteratorConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess2DIteratorConcept >(); + } + + { + typedef matrix_slice > container_model; + function_requires< Mutable_MatrixExpressionConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess2DIteratorConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess2DIteratorConcept >(); + } + + { + typedef matrix_indirect > container_model; + function_requires< Mutable_MatrixExpressionConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess2DIteratorConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess2DIteratorConcept >(); + } +#endif + + // Banded Matrix +#if defined (INTERNAL_SPECIAL) || defined (INTERNAL_BANDED) + { + typedef banded_matrix container_model; + function_requires< Mutable_MatrixConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess2DIteratorConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess2DIteratorConcept >(); + } + + { + typedef banded_adaptor > container_model; + function_requires< Mutable_MatrixExpressionConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess2DIteratorConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess2DIteratorConcept >(); + } +#endif + + // Triangular Matrix +#if defined (INTERNAL_SPECIAL) || defined (INTERNAL_TRIANGULAR) + { + typedef triangular_matrix container_model; + function_requires< Mutable_MatrixConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess2DIteratorConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess2DIteratorConcept >(); + } + + { + typedef triangular_adaptor > container_model; + function_requires< Mutable_MatrixExpressionConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess2DIteratorConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess2DIteratorConcept >(); + } +#endif + + // Symmetric Matrix +#if defined (INTERNA_SPECIAL) || defined (INTERNAL_SYMMETRIC) + { + typedef symmetric_matrix container_model; + function_requires< Mutable_MatrixConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess2DIteratorConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess2DIteratorConcept >(); + } + + { + typedef banded_adaptor > container_model; +#ifndef SKIP_BAD + // const_iterator (iterator) constructor is bad + function_requires< Mutable_MatrixExpressionConcept >(); +#endif + function_requires< IndexedRandomAccess2DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess2DIteratorConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess2DIteratorConcept >(); + } +#endif + + // Hermitian Matrix +#if defined (INTERNAL_SPECIAL) || defined (INTERNAL_HERMITIAN) + { + typedef hermitian_matrix container_model; + function_requires< Mutable_MatrixConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess2DIteratorConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess2DIteratorConcept >(); + } + + { + typedef hermitian_adaptor > container_model; +#ifndef SKIP_BAD + // const_iterator (iterator) constructor is bad + function_requires< Mutable_MatrixExpressionConcept >(); +#endif + function_requires< IndexedRandomAccess2DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess2DIteratorConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess2DIteratorConcept >(); + } +#endif + + // Sparse Matrix +#if defined (INTERNAL_SPARSE) || defined (INTERNAL_MATRIX_SPARSE) + { + typedef mapped_matrix container_model; + function_requires< Mutable_SparseMatrixConcept >(); + function_requires< IndexedBidirectional2DIteratorConcept >(); + function_requires< Mutable_IndexedBidirectional2DIteratorConcept >(); + function_requires< IndexedBidirectional2DIteratorConcept >(); + function_requires< Mutable_IndexedBidirectional2DIteratorConcept >(); + } + { + typedef mapped_vector_of_mapped_vector container_model; + function_requires< Mutable_SparseMatrixConcept >(); + function_requires< IndexedBidirectional2DIteratorConcept >(); + function_requires< Mutable_IndexedBidirectional2DIteratorConcept >(); + function_requires< IndexedBidirectional2DIteratorConcept >(); + function_requires< Mutable_IndexedBidirectional2DIteratorConcept >(); + } + { + typedef compressed_matrix container_model; + function_requires< Mutable_SparseMatrixConcept >(); + function_requires< IndexedBidirectional2DIteratorConcept >(); + function_requires< Mutable_IndexedBidirectional2DIteratorConcept >(); + function_requires< IndexedBidirectional2DIteratorConcept >(); + function_requires< Mutable_IndexedBidirectional2DIteratorConcept >(); + } + { + typedef coordinate_matrix container_model; + function_requires< Mutable_SparseMatrixConcept >(); + function_requires< IndexedBidirectional2DIteratorConcept >(); + function_requires< Mutable_IndexedBidirectional2DIteratorConcept >(); + function_requires< IndexedBidirectional2DIteratorConcept >(); + function_requires< Mutable_IndexedBidirectional2DIteratorConcept >(); + } + { + typedef generalized_vector_of_vector > > container_model; + function_requires< Mutable_SparseMatrixConcept >(); + function_requires< IndexedBidirectional2DIteratorConcept >(); + function_requires< Mutable_IndexedBidirectional2DIteratorConcept >(); + function_requires< IndexedBidirectional2DIteratorConcept >(); + function_requires< Mutable_IndexedBidirectional2DIteratorConcept >(); + } + +#endif + + // Scalar Expressions +#if defined (INTERNAL_EXPRESSION) || defined (INTERNAL_VECTOR_EXPRESSION) + function_requires< ScalarExpressionConcept > >(); + function_requires< ScalarExpressionConcept > >(); + + // Vector Expressions + { + typedef vector_reference > expression_model; + function_requires< VectorExpressionConcept >(); + function_requires< Mutable_VectorExpressionConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess1DIteratorConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess1DIteratorConcept >(); + } + + { + typedef vector_unary, scalar_identity > expression_model; + function_requires< VectorExpressionConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + } + + { + typedef vector_binary, vector, scalar_plus > expression_model; + function_requires< VectorExpressionConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + } + + { + typedef vector_binary_scalar1, scalar_multiplies > expression_model; + function_requires< VectorExpressionConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + } + + { + typedef vector_binary_scalar2, scalar_value, scalar_multiplies > expression_model; + function_requires< VectorExpressionConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + } + + { + typedef vector_binary_scalar1, vector, scalar_multiplies > expression_model; + function_requires< VectorExpressionConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + } + + { + typedef vector_binary_scalar2, scalar_value, scalar_multiplies > expression_model; + function_requires< VectorExpressionConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + } + + function_requires< ScalarExpressionConcept, vector_sum > > > >(); + function_requires< ScalarExpressionConcept, vector_norm_1 > > > >(); + function_requires< ScalarExpressionConcept, vector_norm_2 > > > >(); + function_requires< ScalarExpressionConcept, vector_norm_inf > > > >(); + + function_requires< ScalarExpressionConcept, vector, vector_inner_prod, vector, T> > > >(); +#endif + + // Matrix Expressions +#if defined (INTERNAL_EXPRESSION) || defined (INTERNAL_MATRIX_EXPRESSION) + { + typedef matrix_reference > expression_model; + function_requires< MatrixExpressionConcept >(); + function_requires< Mutable_MatrixExpressionConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess2DIteratorConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + function_requires< Mutable_IndexedRandomAccess2DIteratorConcept >(); + } + + { + typedef vector_matrix_binary, vector, scalar_multiplies > expression_model; + function_requires< MatrixExpressionConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + } + + { + typedef matrix_unary1, scalar_identity > expression_model; + function_requires< MatrixExpressionConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + } + + { + typedef matrix_unary2, scalar_identity > expression_model; + function_requires< MatrixExpressionConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + } + + { + typedef matrix_binary, matrix, scalar_plus > expression_model; + function_requires< MatrixExpressionConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + } + + { + typedef matrix_binary_scalar1, scalar_multiplies > expression_model; + function_requires< MatrixExpressionConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + } + + { + typedef matrix_binary_scalar2, T, scalar_multiplies > expression_model; + function_requires< MatrixExpressionConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + } + + { + typedef matrix_binary_scalar1, matrix, scalar_multiplies > expression_model; + function_requires< MatrixExpressionConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + } + + { + typedef matrix_binary_scalar2, scalar_value, scalar_multiplies > expression_model; + function_requires< MatrixExpressionConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + } + + { + typedef matrix_vector_binary1, vector, matrix_vector_prod1, vector, T> > expression_model; + function_requires< VectorExpressionConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + } + + { + typedef matrix_vector_binary2, matrix, matrix_vector_prod2, vector, T > > expression_model; + function_requires< VectorExpressionConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + } + + { + typedef matrix_matrix_binary, matrix, matrix_matrix_prod, matrix, T > > expression_model; + function_requires< MatrixExpressionConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + function_requires< IndexedRandomAccess2DIteratorConcept >(); + } + + function_requires< ScalarExpressionConcept, matrix_norm_1 > > > >(); + function_requires< ScalarExpressionConcept, matrix_norm_frobenius > > > >(); + function_requires< ScalarExpressionConcept, matrix_norm_inf > > > >(); +#endif + +#ifdef EXTERNAL + function_requires< AdditiveAbelianGroupConcept >(); + function_requires< CommutativeRingWithIdentityConcept >(); + function_requires< FieldConcept >(); + function_requires< VectorSpaceConcept > >(); + function_requires< Prod_RingWithIdentityConcept > >(); + function_requires< VectorSpaceConcept > >(); + function_requires< LinearOperatorConcept, matrix > >(); + + function_requires< AdditiveAbelianGroupConcept > >(); + function_requires< CommutativeRingWithIdentityConcept > >(); + function_requires< FieldConcept > >(); + function_requires< VectorSpaceConcept, vector > > >(); + function_requires< Prod_RingWithIdentityConcept > > >(); + function_requires< VectorSpaceConcept, matrix > > >(); + function_requires< LinearOperatorConcept, vector >, matrix > > >(); +#endif + } + + } // end of anonymous namespace + +}}} + +#endif diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/ublas/detail/config.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/ublas/detail/config.hpp new file mode 100644 index 0000000000..6d25bcc223 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/ublas/detail/config.hpp @@ -0,0 +1,290 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// 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) +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + +#ifndef _BOOST_UBLAS_CONFIG_ +#define _BOOST_UBLAS_CONFIG_ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +// Microsoft Visual C++ +#if defined (BOOST_MSVC) && ! defined (BOOST_STRICT_CONFIG) + +// Version 6.0 and 7.0 +#if BOOST_MSVC <= 1300 +#define BOOST_UBLAS_UNSUPPORTED_COMPILER 1 +#endif + +// Version 7.1 +#if BOOST_MSVC == 1310 +// One of these workarounds is needed for MSVC 7.1 AFAIK +// (thanks to John Maddock and Martin Lauer). +#if !(defined(BOOST_UBLAS_NO_NESTED_CLASS_RELATION) || defined(BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION)) +#define BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#endif + +#endif + +#endif + + +// GNU Compiler Collection +#if defined (__GNUC__) && ! defined (BOOST_STRICT_CONFIG) + +#if __GNUC__ >= 4 || (__GNUC__ >= 3 && __GNUC_MINOR__ >= 4) +// Specified by ABI definition see GCC bug id 9982 +#define BOOST_UBLAS_USEFUL_ARRAY_PLACEMENT_NEW +#endif + +#if __GNUC__ < 3 +#define BOOST_UBLAS_UNSUPPORTED_COMPILER 1 +#endif + +#endif + + +// Intel Compiler +#if defined (BOOST_INTEL) && ! defined (BOOST_STRICT_CONFIG) + +#if defined (BOOST_INTEL_LINUX) && (BOOST_INTEL_LINUX >= 800) +// By inspection of compiler results +#define BOOST_UBLAS_USEFUL_ARRAY_PLACEMENT_NEW +#endif + +#if (BOOST_INTEL < 700) +#define BOOST_UBLAS_UNSUPPORTED_COMPILER 1 +#endif + +// Define swap for index_pair and triple. +#if (BOOST_INTEL <= 800) +namespace boost { namespace numeric { namespace ublas { + template + class indexed_iterator; + + template + class index_pair; + template + class index_triple; +}}} + +namespace std { + template + inline + void swap (boost::numeric::ublas::index_pair i1, boost::numeric::ublas::index_pair i2) { + i1.swap (i2); + } + template + inline + void swap (boost::numeric::ublas::index_triple i1, boost::numeric::ublas::index_triple i2) { + i1.swap (i2); + } + // iter_swap also needed for ICC on Itanium? + template + inline + void iter_swap (boost::numeric::ublas::indexed_iterator it1, + boost::numeric::ublas::indexed_iterator it2) { + swap (*it1, *it2); + } +} +#endif + +#endif + + +// Comeau compiler - thanks to Kresimir Fresl +#if defined (__COMO__) && ! defined (BOOST_STRICT_CONFIG) + +// Missing std::abs overloads for float types in are in +#if defined(__LIBCOMO__) && (__LIBCOMO_VERSION__ <= 31) +#include +#endif + +#endif + + +// HP aCC C++ compiler +#if defined (__HP_aCC) && ! defined (BOOST_STRICT_CONFIG) +# if (__HP_aCC >= 60000 ) +# define BOOST_UBLAS_USEFUL_ARRAY_PLACEMENT_NEW +#endif +#endif + + +// SGI MIPSpro C++ compiler +#if defined (__sgi) && ! defined (BOOST_STRICT_CONFIG) + +// Missing std::abs overloads for float types in are in +// This test should be library version specific. +#include + +#if __COMPILER_VERSION >=650 +// By inspection of compiler results - thanks to Peter Schmitteckert +#define BOOST_UBLAS_USEFUL_ARRAY_PLACEMENT_NEW +#endif + +#endif + + +// Metrowerks Codewarrior +#if defined (__MWERKS__) && ! defined (BOOST_STRICT_CONFIG) + +// 8.x +#if __MWERKS__ <= 0x3003 +#define BOOST_UBLAS_UNSUPPORTED_COMPILER 1 +#endif + +#endif + + +// Detect other compilers with serious defects - override by defineing BOOST_UBLAS_UNSUPPORTED_COMPILER=0 +#ifndef BOOST_UBLAS_UNSUPPORTED_COMPILER +#if defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) || defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) || defined(BOOST_NO_SFINAE) || defined(BOOST_NO_STDC_NAMESPACE) +#define BOOST_UBLAS_UNSUPPORTED_COMPILER 1 +#endif +#endif + +// Cannot continue with an unsupported compiler +#if defined(BOOST_UBLAS_UNSUPPORTED_COMPILER) && (BOOST_UBLAS_UNSUPPORTED_COMPILER != 0) +#error Your compiler and/or configuration is unsupported by this verions of uBLAS. Define BOOST_UBLAS_UNSUPPORTED_COMPILER=0 to override this message. Boost 1.32.0 includes uBLAS with support for many older compilers. +#endif + + + +// Enable performance options in RELEASE mode +#if defined (NDEBUG) || defined (BOOST_UBLAS_NDEBUG) + +#ifndef BOOST_UBLAS_INLINE +#define BOOST_UBLAS_INLINE inline +#endif + +// Do not check sizes! +#define BOOST_UBLAS_USE_FAST_SAME + +// NO runtime error checks with BOOST_UBLAS_CHECK macro +#ifndef BOOST_UBLAS_CHECK_ENABLE +#define BOOST_UBLAS_CHECK_ENABLE 0 +#endif + +// NO type compatibility numeric checks +#ifndef BOOST_UBLAS_TYPE_CHECK +#define BOOST_UBLAS_TYPE_CHECK 0 +#endif + + +// Disable performance options in DEBUG mode +#else + +#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 compatibiltity numeric checks +#ifndef BOOST_UBLAS_TYPE_CHECK +#define BOOST_UBLAS_TYPE_CHECK 1 +#endif + +#endif + + +/* + * Type compatibility checks + * 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 +{ + static bool value; +}; +template +bool disable_type_check::value = false; +#endif +#ifndef BOOST_UBLAS_TYPE_CHECK_EPSILON +#define BOOST_UBLAS_TYPE_CHECK_EPSILON (type_traits::type_sqrt (std::numeric_limits::epsilon ())) +#endif +#ifndef BOOST_UBLAS_TYPE_CHECK_MIN +#define BOOST_UBLAS_TYPE_CHECK_MIN (type_traits::type_sqrt ( (std::numeric_limits::min) ())) +#endif + + +/* + * General Configuration + */ + +// Proxy shortcuts overload the alreadly heavily over used operator () +//#define BOOST_UBLAS_ENABLE_PROXY_SHORTCUTS + +// 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 + +// Use invariant hoisting. +// #define BOOST_UBLAS_USE_INVARIANT_HOISTING + +// Use Duff's device in element access loops +// #define BOOST_UBLAS_USE_DUFF_DEVICE + +// Choose evaluation method for dense vectors and matrices +#if !(defined(BOOST_UBLAS_USE_INDEXING) || defined(BOOST_UBLAS_USE_ITERATING)) +#define BOOST_UBLAS_USE_INDEXING +#endif +// #define BOOST_UBLAS_ITERATOR_THRESHOLD 0 + +// Use indexed iterators - unsupported implementation experiment +// #define BOOST_UBLAS_USE_INDEXED_ITERATOR + +// Alignment of bounded_array type +#ifndef BOOST_UBLAS_BOUNDED_ARRAY_ALIGN +#define BOOST_UBLAS_BOUNDED_ARRAY_ALIGN +#endif + +// Enable different sparse element proxies +#ifndef BOOST_UBLAS_NO_ELEMENT_PROXIES +// Sparse proxies prevent reference invalidation problems in expressions such as: +// a [1] = a [0] = 1 Thanks to Marc Duflot for spotting this. +// #define BOOST_UBLAS_STRICT_MAP_ARRAY +#define BOOST_UBLAS_STRICT_VECTOR_SPARSE +#define BOOST_UBLAS_STRICT_MATRIX_SPARSE +// Hermitian matrices use element proxies to allow assignment to conjugate triangle +#define BOOST_UBLAS_STRICT_HERMITIAN +#endif + +// Define to configure special settings for reference returning members +// #define BOOST_UBLAS_REFERENCE_CONST_MEMBER +// #define BOOST_UBLAS_PROXY_CONST_MEMBER + + +// Include type declerations and functions +#include +#include + + +#endif diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/ublas/detail/definitions.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/ublas/detail/definitions.hpp new file mode 100644 index 0000000000..c5e1cfca03 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/ublas/detail/definitions.hpp @@ -0,0 +1,212 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// 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) +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + +#ifndef _BOOST_UBLAS_DEFINITIONS_ +#define _BOOST_UBLAS_DEFINITIONS_ + + +namespace boost { namespace numeric { namespace ublas { + + namespace detail { + /* Borrowed from boost/concept_checks.hpp + "inline" is used for ignore_unused_variable_warning() + to make sure there is no overhead with g++. + */ + template inline + void ignore_unused_variable_warning(const T&) {} + } // namespace detail + + // Borrowed from Dave Abraham's noncopyable. + // I believe this should be part of utility.hpp one day... + namespace nonassignable_ // protection from unintended ADL + { + class nonassignable { + protected: + nonassignable () {} + ~nonassignable () {} + private: // emphasize the following members are private + const nonassignable& operator= (const nonassignable &); + }; // nonassignable + } + typedef nonassignable_::nonassignable nonassignable; + + + // Assignment proxy. + // Provides temporary free assigment when LHS has no alias on RHS + template + class noalias_proxy: + private nonassignable { + public: + typedef typename C::closure_type closure_type; + + BOOST_UBLAS_INLINE + noalias_proxy (C& lval): + nonassignable (), lval_ (lval) {} + BOOST_UBLAS_INLINE + noalias_proxy (const noalias_proxy& p): + nonassignable (), lval_ (p.lval_) {} + + template + BOOST_UBLAS_INLINE + closure_type &operator= (const E& e) { + lval_.assign (e); + return lval_; + } + + template + BOOST_UBLAS_INLINE + closure_type &operator+= (const E& e) { + lval_.plus_assign (e); + return lval_; + } + + template + BOOST_UBLAS_INLINE + closure_type &operator-= (const E& e) { + lval_.minus_assign (e); + return lval_; + } + + private: + closure_type lval_; + }; + + // Improve syntax of efficient assignment where no aliases of LHS appear on the RHS + // noalias(lhs) = rhs_expression + template + BOOST_UBLAS_INLINE + noalias_proxy noalias (C& lvalue) { + return noalias_proxy (lvalue); + } + template + BOOST_UBLAS_INLINE + noalias_proxy noalias (const C& lvalue) { + return noalias_proxy (lvalue); + } + + // Possible future compatible syntax where lvalue possible has an unsafe alias on the RHS + // safe(lhs) = rhs_expression + template + BOOST_UBLAS_INLINE + C& safe (C& lvalue) { + return lvalue; + } + template + BOOST_UBLAS_INLINE + const C& safe (const C& lvalue) { + return lvalue; + } + + + // Dimension accessors + namespace dimension { + + // Generic accessors + template + struct dimension_properties {}; + + template<> + struct dimension_properties<1> { + template + BOOST_UBLAS_INLINE static + typename E::size_type size (const vector_expression &e) { + return e ().size (); + } + template + BOOST_UBLAS_INLINE static + typename E::size_type size (const matrix_expression &e) { + return e ().size1 (); + } + // Note: Index functions cannot deduce dependant template parameter V or M from i + template + BOOST_UBLAS_INLINE static + typename V::size_type index (const typename V::iterator &i) { + return i.index (); + } + template + BOOST_UBLAS_INLINE static + typename M::size_type index (const typename M::iterator1 &i) { + return i.index1 (); + } + template + BOOST_UBLAS_INLINE static + typename M::size_type index (const typename M::iterator2 &i) { + return i.index1 (); + } + }; + template<> + struct dimension_properties<2> { + template + BOOST_UBLAS_INLINE static + typename E::size_type size (const vector_expression &) { + return 1; + } + template + BOOST_UBLAS_INLINE static + typename E::size_type size (const matrix_expression &e) { + return e ().size2 (); + } + template + BOOST_UBLAS_INLINE static + typename V::size_type index (const typename V::iterator &) { + return 1; + } + template + BOOST_UBLAS_INLINE static + typename M::size_type index (const typename M::iterator1 &i) { + return i.index2 (); + } + template + BOOST_UBLAS_INLINE static + typename M::size_type index (const typename M::iterator2 &i) { + return i.index2 (); + } + }; + + template + BOOST_UBLAS_INLINE + typename E::size_type size (const E& e) { + return dimension_properties::size (e); + } + + template + BOOST_UBLAS_INLINE + typename I::container_type::size_type + index (const I& i) { + typedef typename I::container_type container_type; + return dimension_properties::template index (i); + } + + + // Named accessors - just syntactic sugar + template + typename V::size_type num_elements (const V &v) { + return v.size (); + } + template + typename M::size_type num_rows (const M &m) { + return m.size1 (); + } + template + typename M::size_type num_columns (const M &m) { + return m.size2 (); + } + template + typename MV::size_type num_non_zeros (const MV &mv) { + return mv.non_zeros (); + } + } + + +}}} + +#endif diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/ublas/detail/documentation.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/ublas/detail/documentation.hpp new file mode 100644 index 0000000000..4b2bcf0bef --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/ublas/detail/documentation.hpp @@ -0,0 +1,33 @@ +// +// Copyright (c) 2000-2004 +// Joerg Walter, Mathias Koch +// +// 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) +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + +// this file should not contain any code, but the documentation +// global to all files + +/** \namespace boost::numeric::ublas + \brief contains all important classes and functions of uBLAS + + all ublas definitions ... + \todo expand this section + */ + +/** \defgroup blas1 Level 1 BLAS + \brief level 1 basic linear algebra subroutines +*/ + +/** \defgroup blas2 Level 2 BLAS + \brief level 2 basic linear algebra subroutines +*/ + +/** \defgroup blas3 Level 3 BLAS + \brief level 3 basic linear algebra subroutines +*/ diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/ublas/detail/duff.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/ublas/detail/duff.hpp new file mode 100644 index 0000000000..b0ec08c903 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/ublas/detail/duff.hpp @@ -0,0 +1,56 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// 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) +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + +#ifndef _BOOST_UBLAS_DUFF_ +#define _BOOST_UBLAS_DUFF_ + +#define DD_SWITCH(n, d, r, expr) \ + { \ + unsigned r = ((n) + (d) - 1) / (d); \ + switch ((n) % (d)) { \ + case 0: do { expr; +#define DD_CASE_I(i, expr) \ + case (i): expr; +#define DD_WHILE(r) \ + } while (-- (r) > 0); \ + } \ + } + +#define DD_1T(n, d, r, expr) \ + DD_WHILE(r) +#define DD_2T(n, d, r, expr) \ + DD_CASE_I(1, expr) \ + DD_1T(n, d, r, expr) +#define DD_3T(n, d, r, expr) \ + DD_CASE_I(2, expr) \ + DD_2T(n, d, r, expr) +#define DD_4T(n, d, r, expr) \ + DD_CASE_I(3, expr) \ + DD_3T(n, d, r, expr) +#define DD_5T(n, d, r, expr) \ + DD_CASE_I(4, expr) \ + DD_4T(n, d, r, expr) +#define DD_6T(n, d, r, expr) \ + DD_CASE_I(5, expr) \ + DD_5T(n, d, r, expr) +#define DD_7T(n, d, r, expr) \ + DD_CASE_I(6, expr) \ + DD_6T(n, d, r, expr) +#define DD_8T(n, d, r, expr) \ + DD_CASE_I(7, expr) \ + DD_7T(n, d, r, expr) + +#define DD(n, d, r, expr) \ + DD_SWITCH(n, d, r, expr) \ + DD_##d##T(n, d, r, expr) + +#endif diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/ublas/detail/iterator.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/ublas/detail/iterator.hpp new file mode 100644 index 0000000000..1723a301cd --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/ublas/detail/iterator.hpp @@ -0,0 +1,1436 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// 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) +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + +#ifndef _BOOST_UBLAS_ITERATOR_ +#define _BOOST_UBLAS_ITERATOR_ + +#include +#include + + +namespace boost { namespace numeric { namespace ublas { + + /** \brief Base class of all proxy classes that contain + * a (redirectable) reference to an immutable object. + * + * \param C the type of the container referred to + */ + template + class container_const_reference: + private nonassignable { + public: + typedef C container_type; + + BOOST_UBLAS_INLINE + container_const_reference (): + c_ (0) {} + BOOST_UBLAS_INLINE + container_const_reference (const container_type &c): + c_ (&c) {} + + BOOST_UBLAS_INLINE + const container_type &operator () () const { + return *c_; + } + + BOOST_UBLAS_INLINE + container_const_reference &assign (const container_type *c) { + c_ = c; + return *this; + } + + // Closure comparison + BOOST_UBLAS_INLINE + bool same_closure (const container_const_reference &cr) const { + return c_ == cr.c_; + } + + private: + const container_type *c_; + }; + + /** \brief Base class of all proxy classes that contain + * a (redirectable) reference to a mutable object. + * + * \param C the type of the container referred to + */ + template + class container_reference: + private nonassignable { + public: + typedef C container_type; + + BOOST_UBLAS_INLINE + container_reference (): + c_ (0) {} + BOOST_UBLAS_INLINE + container_reference (container_type &c): + c_ (&c) {} + + BOOST_UBLAS_INLINE + container_type &operator () () const { + return *c_; + } + + BOOST_UBLAS_INLINE + container_reference &assign (container_type *c) { + c_ = c; + return *this; + } + + // Closure comparison + BOOST_UBLAS_INLINE + bool same_closure (const container_reference &cr) const { + return c_ == cr.c_; + } + + private: + container_type *c_; + }; + + /** \brief Base class of all forward iterators. + * + * \param IC the iterator category + * \param I the derived iterator type + * \param T the value type + * + * The forward iterator can only proceed in one direction + * via the post increment operator. + */ + template + struct forward_iterator_base: + public std::iterator { + typedef I derived_iterator_type; + typedef T derived_value_type; + + // Arithmetic + BOOST_UBLAS_INLINE + derived_iterator_type operator ++ (int) { + derived_iterator_type &d (*static_cast (this)); + derived_iterator_type tmp (d); + ++ d; + return tmp; + } + BOOST_UBLAS_INLINE + friend derived_iterator_type operator ++ (derived_iterator_type &d, int) { + derived_iterator_type tmp (d); + ++ d; + return tmp; + } + + // Comparison + BOOST_UBLAS_INLINE + bool operator != (const derived_iterator_type &it) const { + const derived_iterator_type *d = static_cast (this); + return ! (*d == it); + } + }; + + /** \brief Base class of all bidirectional iterators. + * + * \param IC the iterator category + * \param I the derived iterator type + * \param T the value type + * + * The bidirectional iterator can proceed in both directions + * via the post increment and post decrement operator. + */ + template + struct bidirectional_iterator_base: + public std::iterator { + typedef I derived_iterator_type; + typedef T derived_value_type; + + // Arithmetic + BOOST_UBLAS_INLINE + derived_iterator_type operator ++ (int) { + derived_iterator_type &d (*static_cast (this)); + derived_iterator_type tmp (d); + ++ d; + return tmp; + } + BOOST_UBLAS_INLINE + friend derived_iterator_type operator ++ (derived_iterator_type &d, int) { + derived_iterator_type tmp (d); + ++ d; + return tmp; + } + BOOST_UBLAS_INLINE + derived_iterator_type operator -- (int) { + derived_iterator_type &d (*static_cast (this)); + derived_iterator_type tmp (d); + -- d; + return tmp; + } + BOOST_UBLAS_INLINE + friend derived_iterator_type operator -- (derived_iterator_type &d, int) { + derived_iterator_type tmp (d); + -- d; + return tmp; + } + + // Comparison + BOOST_UBLAS_INLINE + bool operator != (const derived_iterator_type &it) const { + const derived_iterator_type *d = static_cast (this); + return ! (*d == it); + } + }; + + /** \brief Base class of all random access iterators. + * + * \param IC the iterator category + * \param I the derived iterator type + * \param T the value type + * \param D the difference type, default: std::ptrdiff_t + * + * The random access iterator can proceed in both directions + * via the post increment/decrement operator or in larger steps + * via the +, - and +=, -= operators. The random access iterator + * is LessThan Comparable. + */ + template + // ISSUE the default for D seems rather dangerous as it can easily be (silently) incorrect + struct random_access_iterator_base: + public std::iterator { + typedef I derived_iterator_type; + typedef T derived_value_type; + typedef D derived_difference_type; + + /* FIXME Need to explicitly pass derived_reference_type as otherwise I undefined type or forward declared + typedef typename derived_iterator_type::reference derived_reference_type; + // Indexed element + BOOST_UBLAS_INLINE + derived_reference_type operator [] (derived_difference_type n) { + return *(*this + n); + } + */ + + // Arithmetic + BOOST_UBLAS_INLINE + derived_iterator_type operator ++ (int) { + derived_iterator_type &d (*static_cast (this)); + derived_iterator_type tmp (d); + ++ d; + return tmp; + } + BOOST_UBLAS_INLINE + friend derived_iterator_type operator ++ (derived_iterator_type &d, int) { + derived_iterator_type tmp (d); + ++ d; + return tmp; + } + BOOST_UBLAS_INLINE + derived_iterator_type operator -- (int) { + derived_iterator_type &d (*static_cast (this)); + derived_iterator_type tmp (d); + -- d; + return tmp; + } + BOOST_UBLAS_INLINE + friend derived_iterator_type operator -- (derived_iterator_type &d, int) { + derived_iterator_type tmp (d); + -- d; + return tmp; + } + BOOST_UBLAS_INLINE + derived_iterator_type operator + (derived_difference_type n) const { + derived_iterator_type tmp (*static_cast (this)); + return tmp += n; + } + BOOST_UBLAS_INLINE + friend derived_iterator_type operator + (const derived_iterator_type &d, derived_difference_type n) { + derived_iterator_type tmp (d); + return tmp += n; + } + BOOST_UBLAS_INLINE + friend derived_iterator_type operator + (derived_difference_type n, const derived_iterator_type &d) { + derived_iterator_type tmp (d); + return tmp += n; + } + BOOST_UBLAS_INLINE + derived_iterator_type operator - (derived_difference_type n) const { + derived_iterator_type tmp (*static_cast (this)); + return tmp -= n; + } + BOOST_UBLAS_INLINE + friend derived_iterator_type operator - (const derived_iterator_type &d, derived_difference_type n) { + derived_iterator_type tmp (d); + return tmp -= n; + } + + // Comparison + BOOST_UBLAS_INLINE + bool operator != (const derived_iterator_type &it) const { + const derived_iterator_type *d = static_cast (this); + return ! (*d == it); + } + BOOST_UBLAS_INLINE + bool operator <= (const derived_iterator_type &it) const { + const derived_iterator_type *d = static_cast (this); + return ! (it < *d); + } + BOOST_UBLAS_INLINE + bool operator >= (const derived_iterator_type &it) const { + const derived_iterator_type *d = static_cast (this); + return ! (*d < it); + } + BOOST_UBLAS_INLINE + bool operator > (const derived_iterator_type &it) const { + const derived_iterator_type *d = static_cast (this); + return it < *d; + } + }; + + /** \brief Base class of all reverse iterators. (non-MSVC version) + * + * \param I the derived iterator type + * \param T the value type + * \param R the reference type + * + * The reverse iterator implements a bidirectional iterator + * reversing the elements of the underlying iterator. It + * implements most operators of a random access iterator. + * + * uBLAS extension: it.index() + */ + + // Renamed this class from reverse_iterator to get + // typedef reverse_iterator<...> reverse_iterator + // working. Thanks to Gabriel Dos Reis for explaining this. + template + class reverse_iterator_base: + public std::reverse_iterator { + public: + typedef typename I::container_type container_type; + typedef typename container_type::size_type size_type; + typedef typename I::difference_type difference_type; + typedef I iterator_type; + + // Construction and destruction + BOOST_UBLAS_INLINE + reverse_iterator_base (): + std::reverse_iterator () {} + BOOST_UBLAS_INLINE + reverse_iterator_base (const iterator_type &it): + std::reverse_iterator (it) {} + + // Arithmetic + BOOST_UBLAS_INLINE + reverse_iterator_base &operator ++ () { + return *this = -- this->base (); + } + BOOST_UBLAS_INLINE + reverse_iterator_base operator ++ (int) { + reverse_iterator_base tmp (*this); + *this = -- this->base (); + return tmp; + } + BOOST_UBLAS_INLINE + reverse_iterator_base &operator -- () { + return *this = ++ this->base (); + } + BOOST_UBLAS_INLINE + reverse_iterator_base operator -- (int) { + reverse_iterator_base tmp (*this); + *this = ++ this->base (); + return tmp; + } + BOOST_UBLAS_INLINE + reverse_iterator_base &operator += (difference_type n) { + return *this = this->base () - n; + } + BOOST_UBLAS_INLINE + reverse_iterator_base &operator -= (difference_type n) { + return *this = this->base () + n; + } + + BOOST_UBLAS_INLINE + friend reverse_iterator_base operator + (const reverse_iterator_base &it, difference_type n) { + reverse_iterator_base tmp (it); + return tmp += n; + } + BOOST_UBLAS_INLINE + friend reverse_iterator_base operator + (difference_type n, const reverse_iterator_base &it) { + reverse_iterator_base tmp (it); + return tmp += n; + } + BOOST_UBLAS_INLINE + friend reverse_iterator_base operator - (const reverse_iterator_base &it, difference_type n) { + reverse_iterator_base tmp (it); + return tmp -= n; + } + BOOST_UBLAS_INLINE + friend difference_type operator - (const reverse_iterator_base &it1, const reverse_iterator_base &it2) { + return it2.base () - it1.base (); + } + + BOOST_UBLAS_INLINE + const container_type &operator () () const { + return this->base () (); + } + + BOOST_UBLAS_INLINE + size_type index () const { + iterator_type tmp (this->base ()); + return (-- tmp).index (); + } + }; + + /** \brief 1st base class of all matrix reverse iterators. (non-MSVC version) + * + * \param I the derived iterator type + * + * The reverse iterator implements a bidirectional iterator + * reversing the elements of the underlying iterator. It + * implements most operators of a random access iterator. + * + * uBLAS extension: it.index1(), it.index2() and access to + * the dual iterator via begin(), end(), rbegin(), rend() + */ + + // Renamed this class from reverse_iterator1 to get + // typedef reverse_iterator1<...> reverse_iterator1 + // working. Thanks to Gabriel Dos Reis for explaining this. + template + class reverse_iterator_base1: + public std::reverse_iterator { + public: + typedef typename I::container_type container_type; + typedef typename container_type::size_type size_type; + typedef typename I::difference_type difference_type; + typedef I iterator_type; + typedef typename I::dual_iterator_type dual_iterator_type; + typedef typename I::dual_reverse_iterator_type dual_reverse_iterator_type; + + // Construction and destruction + BOOST_UBLAS_INLINE + reverse_iterator_base1 (): + std::reverse_iterator () {} + BOOST_UBLAS_INLINE + reverse_iterator_base1 (const iterator_type &it): + std::reverse_iterator (it) {} + + // Arithmetic + BOOST_UBLAS_INLINE + reverse_iterator_base1 &operator ++ () { + return *this = -- this->base (); + } + BOOST_UBLAS_INLINE + reverse_iterator_base1 operator ++ (int) { + reverse_iterator_base1 tmp (*this); + *this = -- this->base (); + return tmp; + } + BOOST_UBLAS_INLINE + reverse_iterator_base1 &operator -- () { + return *this = ++ this->base (); + } + BOOST_UBLAS_INLINE + reverse_iterator_base1 operator -- (int) { + reverse_iterator_base1 tmp (*this); + *this = ++ this->base (); + return tmp; + } + BOOST_UBLAS_INLINE + reverse_iterator_base1 &operator += (difference_type n) { + return *this = this->base () - n; + } + BOOST_UBLAS_INLINE + reverse_iterator_base1 &operator -= (difference_type n) { + return *this = this->base () + n; + } + + BOOST_UBLAS_INLINE + friend reverse_iterator_base1 operator + (const reverse_iterator_base1 &it, difference_type n) { + reverse_iterator_base1 tmp (it); + return tmp += n; + } + BOOST_UBLAS_INLINE + friend reverse_iterator_base1 operator + (difference_type n, const reverse_iterator_base1 &it) { + reverse_iterator_base1 tmp (it); + return tmp += n; + } + BOOST_UBLAS_INLINE + friend reverse_iterator_base1 operator - (const reverse_iterator_base1 &it, difference_type n) { + reverse_iterator_base1 tmp (it); + return tmp -= n; + } + BOOST_UBLAS_INLINE + friend difference_type operator - (const reverse_iterator_base1 &it1, const reverse_iterator_base1 &it2) { + return it2.base () - it1.base (); + } + + BOOST_UBLAS_INLINE + const container_type &operator () () const { + return this->base () (); + } + + BOOST_UBLAS_INLINE + size_type index1 () const { + iterator_type tmp (this->base ()); + return (-- tmp).index1 (); + } + BOOST_UBLAS_INLINE + size_type index2 () const { + iterator_type tmp (this->base ()); + return (-- tmp).index2 (); + } + + BOOST_UBLAS_INLINE + dual_iterator_type begin () const { + iterator_type tmp (this->base ()); + return (-- tmp).begin (); + } + BOOST_UBLAS_INLINE + dual_iterator_type end () const { + iterator_type tmp (this->base ()); + return (-- tmp).end (); + } + BOOST_UBLAS_INLINE + dual_reverse_iterator_type rbegin () const { + return dual_reverse_iterator_type (end ()); + } + BOOST_UBLAS_INLINE + dual_reverse_iterator_type rend () const { + return dual_reverse_iterator_type (begin ()); + } + }; + + /** \brief 2nd base class of all matrix reverse iterators. (non-MSVC version) + * + * \param I the derived iterator type + * + * The reverse iterator implements a bidirectional iterator + * reversing the elements of the underlying iterator. It + * implements most operators of a random access iterator. + * + * uBLAS extension: it.index1(), it.index2() and access to + * the dual iterator via begin(), end(), rbegin(), rend() + * + * Note: this type is _identical_ to reverse_iterator_base1 + */ + + // Renamed this class from reverse_iterator2 to get + // typedef reverse_iterator2<...> reverse_iterator2 + // working. Thanks to Gabriel Dos Reis for explaining this. + template + class reverse_iterator_base2: + public std::reverse_iterator { + public: + typedef typename I::container_type container_type; + typedef typename container_type::size_type size_type; + typedef typename I::difference_type difference_type; + typedef I iterator_type; + typedef typename I::dual_iterator_type dual_iterator_type; + typedef typename I::dual_reverse_iterator_type dual_reverse_iterator_type; + + // Construction and destruction + BOOST_UBLAS_INLINE + reverse_iterator_base2 (): + std::reverse_iterator () {} + BOOST_UBLAS_INLINE + reverse_iterator_base2 (const iterator_type &it): + std::reverse_iterator (it) {} + + // Arithmetic + BOOST_UBLAS_INLINE + reverse_iterator_base2 &operator ++ () { + return *this = -- this->base (); + } + BOOST_UBLAS_INLINE + reverse_iterator_base2 operator ++ (int) { + reverse_iterator_base2 tmp (*this); + *this = -- this->base (); + return tmp; + } + BOOST_UBLAS_INLINE + reverse_iterator_base2 &operator -- () { + return *this = ++ this->base (); + } + BOOST_UBLAS_INLINE + reverse_iterator_base2 operator -- (int) { + reverse_iterator_base2 tmp (*this); + *this = ++ this->base (); + return tmp; + } + BOOST_UBLAS_INLINE + reverse_iterator_base2 &operator += (difference_type n) { + return *this = this->base () - n; + } + BOOST_UBLAS_INLINE + reverse_iterator_base2 &operator -= (difference_type n) { + return *this = this->base () + n; + } + + BOOST_UBLAS_INLINE + friend reverse_iterator_base2 operator + (const reverse_iterator_base2 &it, difference_type n) { + reverse_iterator_base2 tmp (it); + return tmp += n; + } + BOOST_UBLAS_INLINE + friend reverse_iterator_base2 operator + (difference_type n, const reverse_iterator_base2 &it) { + reverse_iterator_base2 tmp (it); + return tmp += n; + } + BOOST_UBLAS_INLINE + friend reverse_iterator_base2 operator - (const reverse_iterator_base2 &it, difference_type n) { + reverse_iterator_base2 tmp (it); + return tmp -= n; + } + BOOST_UBLAS_INLINE + friend difference_type operator - (const reverse_iterator_base2 &it1, const reverse_iterator_base2 &it2) { + return it2.base () - it1.base (); + } + + BOOST_UBLAS_INLINE + const container_type &operator () () const { + return this->base () (); + } + + BOOST_UBLAS_INLINE + size_type index1 () const { + iterator_type tmp (this->base ()); + return (-- tmp).index1 (); + } + BOOST_UBLAS_INLINE + size_type index2 () const { + iterator_type tmp (this->base ()); + return (-- tmp).index2 (); + } + + BOOST_UBLAS_INLINE + dual_iterator_type begin () const { + iterator_type tmp (this->base ()); + return (-- tmp).begin (); + } + BOOST_UBLAS_INLINE + dual_iterator_type end () const { + iterator_type tmp (this->base ()); + return (-- tmp).end (); + } + BOOST_UBLAS_INLINE + dual_reverse_iterator_type rbegin () const { + return dual_reverse_iterator_type (end ()); + } + BOOST_UBLAS_INLINE + dual_reverse_iterator_type rend () const { + return dual_reverse_iterator_type (begin ()); + } + }; + + /** \brief A class implementing an indexed random access iterator. + * + * \param C the (mutable) container type + * \param IC the iterator category + * + * This class implements a random access iterator. The current + * position is stored as the unsigned integer it_ and the + * values are accessed via operator()(it_) of the container. + * + * uBLAS extension: index() + */ + + template + class indexed_iterator: + public container_reference, + public random_access_iterator_base, + typename C::value_type, + typename C::difference_type> { + public: + typedef C container_type; + typedef IC iterator_category; + typedef typename container_type::size_type size_type; + typedef typename container_type::difference_type difference_type; + typedef typename container_type::value_type value_type; + typedef typename container_type::reference reference; + + // Construction and destruction + BOOST_UBLAS_INLINE + indexed_iterator (): + container_reference (), it_ () {} + BOOST_UBLAS_INLINE + indexed_iterator (container_type &c, size_type it): + container_reference (c), it_ (it) {} + + // Arithmetic + BOOST_UBLAS_INLINE + indexed_iterator &operator ++ () { + ++ it_; + return *this; + } + BOOST_UBLAS_INLINE + indexed_iterator &operator -- () { + -- it_; + return *this; + } + BOOST_UBLAS_INLINE + indexed_iterator &operator += (difference_type n) { + it_ += n; + return *this; + } + BOOST_UBLAS_INLINE + indexed_iterator &operator -= (difference_type n) { + it_ -= n; + return *this; + } + BOOST_UBLAS_INLINE + difference_type operator - (const indexed_iterator &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + return it_ - it.it_; + } + + // Dereference + BOOST_UBLAS_INLINE + reference operator * () const { + BOOST_UBLAS_CHECK (index () < (*this) ().size (), bad_index ()); + return (*this) () (it_); + } + BOOST_UBLAS_INLINE + reference operator [] (difference_type n) const { + return *((*this) + n); + } + + // Index + BOOST_UBLAS_INLINE + size_type index () const { + return it_; + } + + // Assignment + BOOST_UBLAS_INLINE + indexed_iterator &operator = (const indexed_iterator &it) { + // FIX: ICC needs full qualification?! + // assign (&it ()); + container_reference::assign (&it ()); + it_ = it.it_; + return *this; + } + + // Comparison + BOOST_UBLAS_INLINE + bool operator == (const indexed_iterator &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + return it_ == it.it_; + } + BOOST_UBLAS_INLINE + bool operator < (const indexed_iterator &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + return it_ < it.it_; + } + + private: + size_type it_; + }; + + /** \brief A class implementing an indexed random access iterator. + * + * \param C the (immutable) container type + * \param IC the iterator category + * + * This class implements a random access iterator. The current + * position is stored as the unsigned integer \c it_ and the + * values are accessed via \c operator()(it_) of the container. + * + * uBLAS extension: \c index() + * + * Note: there is an automatic conversion from + * \c indexed_iterator to \c indexed_const_iterator + */ + + template + class indexed_const_iterator: + public container_const_reference, + public random_access_iterator_base, + typename C::value_type, + typename C::difference_type> { + public: + typedef C container_type; + typedef IC iterator_category; + typedef typename container_type::size_type size_type; + typedef typename container_type::difference_type difference_type; + typedef typename container_type::value_type value_type; + typedef typename container_type::const_reference reference; + typedef indexed_iterator iterator_type; + + // Construction and destruction + BOOST_UBLAS_INLINE + indexed_const_iterator (): + container_const_reference (), it_ () {} + BOOST_UBLAS_INLINE + indexed_const_iterator (const container_type &c, size_type it): + container_const_reference (c), it_ (it) {} + BOOST_UBLAS_INLINE + indexed_const_iterator (const iterator_type &it): + container_const_reference (it ()), it_ (it.index ()) {} + + // Arithmetic + BOOST_UBLAS_INLINE + indexed_const_iterator &operator ++ () { + ++ it_; + return *this; + } + BOOST_UBLAS_INLINE + indexed_const_iterator &operator -- () { + -- it_; + return *this; + } + BOOST_UBLAS_INLINE + indexed_const_iterator &operator += (difference_type n) { + it_ += n; + return *this; + } + BOOST_UBLAS_INLINE + indexed_const_iterator &operator -= (difference_type n) { + it_ -= n; + return *this; + } + BOOST_UBLAS_INLINE + difference_type operator - (const indexed_const_iterator &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + return it_ - it.it_; + } + + // Dereference + BOOST_UBLAS_INLINE + reference operator * () const { + BOOST_UBLAS_CHECK (index () < (*this) ().size (), bad_index ()); + return (*this) () (it_); + } + BOOST_UBLAS_INLINE + reference operator [] (difference_type n) const { + return *((*this) + n); + } + + // Index + BOOST_UBLAS_INLINE + size_type index () const { + return it_; + } + + // Assignment + BOOST_UBLAS_INLINE + indexed_const_iterator &operator = (const indexed_const_iterator &it) { + // FIX: ICC needs full qualification?! + // assign (&it ()); + container_const_reference::assign (&it ()); + it_ = it.it_; + return *this; + } + + // Comparison + BOOST_UBLAS_INLINE + bool operator == (const indexed_const_iterator &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + return it_ == it.it_; + } + BOOST_UBLAS_INLINE + bool operator < (const indexed_const_iterator &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + return it_ < it.it_; + } + + private: + size_type it_; + + friend class indexed_iterator; + }; + + template + class indexed_iterator2; + + /** \brief A class implementing an indexed random access iterator + * of a matrix. + * + * \param C the (mutable) container type + * \param IC the iterator category + * + * This class implements a random access iterator. The current + * position is stored as two unsigned integers \c it1_ and \c it2_ + * and the values are accessed via \c operator()(it1_, it2_) of the + * container. The iterator changes the first index. + * + * uBLAS extension: \c index1(), \c index2() and access to the + * dual iterator via \c begin(), \c end(), \c rbegin() and \c rend() + * + * Note: The container has to support the \code find2(rank, i, j) \endcode + * method + */ + + template + class indexed_iterator1: + public container_reference, + public random_access_iterator_base, + typename C::value_type, + typename C::difference_type> { + public: + typedef C container_type; + typedef IC iterator_category; + typedef typename container_type::size_type size_type; + typedef typename container_type::difference_type difference_type; + typedef typename container_type::value_type value_type; + typedef typename container_type::reference reference; + + typedef indexed_iterator2 dual_iterator_type; + typedef reverse_iterator_base2 dual_reverse_iterator_type; + + // Construction and destruction + BOOST_UBLAS_INLINE + indexed_iterator1 (): + container_reference (), it1_ (), it2_ () {} + BOOST_UBLAS_INLINE + indexed_iterator1 (container_type &c, size_type it1, size_type it2): + container_reference (c), it1_ (it1), it2_ (it2) {} + + // Arithmetic + BOOST_UBLAS_INLINE + indexed_iterator1 &operator ++ () { + ++ it1_; + return *this; + } + BOOST_UBLAS_INLINE + indexed_iterator1 &operator -- () { + -- it1_; + return *this; + } + BOOST_UBLAS_INLINE + indexed_iterator1 &operator += (difference_type n) { + it1_ += n; + return *this; + } + BOOST_UBLAS_INLINE + indexed_iterator1 &operator -= (difference_type n) { + it1_ -= n; + return *this; + } + BOOST_UBLAS_INLINE + difference_type operator - (const indexed_iterator1 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK (it2_ == it.it2_, external_logic ()); + return it1_ - it.it1_; + } + + // Dereference + BOOST_UBLAS_INLINE + reference operator * () const { + BOOST_UBLAS_CHECK (index1 () < (*this) ().size1 (), bad_index ()); + BOOST_UBLAS_CHECK (index2 () < (*this) ().size2 (), bad_index ()); + return (*this) () (it1_, it2_); + } + BOOST_UBLAS_INLINE + reference operator [] (difference_type n) const { + return *((*this) + n); + } + + // Index + BOOST_UBLAS_INLINE + size_type index1 () const { + return it1_; + } + BOOST_UBLAS_INLINE + size_type index2 () const { + return it2_; + } + + BOOST_UBLAS_INLINE + dual_iterator_type begin () const { + return (*this) ().find2 (1, index1 (), 0); + } + BOOST_UBLAS_INLINE + dual_iterator_type end () const { + return (*this) ().find2 (1, index1 (), (*this) ().size2 ()); + } + BOOST_UBLAS_INLINE + dual_reverse_iterator_type rbegin () const { + return dual_reverse_iterator_type (end ()); + } + BOOST_UBLAS_INLINE + dual_reverse_iterator_type rend () const { + return dual_reverse_iterator_type (begin ()); + } + + // Assignment + BOOST_UBLAS_INLINE + indexed_iterator1 &operator = (const indexed_iterator1 &it) { + // FIX: ICC needs full qualification?! + // assign (&it ()); + container_reference::assign (&it ()); + it1_ = it.it1_; + it2_ = it.it2_; + return *this; + } + + // Comparison + BOOST_UBLAS_INLINE + bool operator == (const indexed_iterator1 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK (it2_ == it.it2_, external_logic ()); + return it1_ == it.it1_; + } + BOOST_UBLAS_INLINE + bool operator < (const indexed_iterator1 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK (it2_ == it.it2_, external_logic ()); + return it1_ < it.it1_; + } + + private: + size_type it1_; + size_type it2_; + }; + + template + class indexed_const_iterator2; + + /** \brief A class implementing an indexed random access iterator + * of a matrix. + * + * \param C the (immutable) container type + * \param IC the iterator category + * + * This class implements a random access iterator. The current + * position is stored as two unsigned integers \c it1_ and \c it2_ + * and the values are accessed via \c operator()(it1_, it2_) of the + * container. The iterator changes the first index. + * + * uBLAS extension: \c index1(), \c index2() and access to the + * dual iterator via \c begin(), \c end(), \c rbegin() and \c rend() + * + * Note 1: The container has to support the find2(rank, i, j) method + * + * Note 2: there is an automatic conversion from + * \c indexed_iterator1 to \c indexed_const_iterator1 + */ + + template + class indexed_const_iterator1: + public container_const_reference, + public random_access_iterator_base, + typename C::value_type, + typename C::difference_type> { + public: + typedef C container_type; + typedef IC iterator_category; + typedef typename container_type::size_type size_type; + typedef typename container_type::difference_type difference_type; + typedef typename container_type::value_type value_type; + typedef typename container_type::const_reference reference; + + typedef indexed_iterator1 iterator_type; + typedef indexed_const_iterator2 dual_iterator_type; + typedef reverse_iterator_base2 dual_reverse_iterator_type; + + // Construction and destruction + BOOST_UBLAS_INLINE + indexed_const_iterator1 (): + container_const_reference (), it1_ (), it2_ () {} + BOOST_UBLAS_INLINE + indexed_const_iterator1 (const container_type &c, size_type it1, size_type it2): + container_const_reference (c), it1_ (it1), it2_ (it2) {} + BOOST_UBLAS_INLINE + indexed_const_iterator1 (const iterator_type &it): + container_const_reference (it ()), it1_ (it.index1 ()), it2_ (it.index2 ()) {} + + // Arithmetic + BOOST_UBLAS_INLINE + indexed_const_iterator1 &operator ++ () { + ++ it1_; + return *this; + } + BOOST_UBLAS_INLINE + indexed_const_iterator1 &operator -- () { + -- it1_; + return *this; + } + BOOST_UBLAS_INLINE + indexed_const_iterator1 &operator += (difference_type n) { + it1_ += n; + return *this; + } + BOOST_UBLAS_INLINE + indexed_const_iterator1 &operator -= (difference_type n) { + it1_ -= n; + return *this; + } + BOOST_UBLAS_INLINE + difference_type operator - (const indexed_const_iterator1 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK (it2_ == it.it2_, external_logic ()); + return it1_ - it.it1_; + } + + // Dereference + BOOST_UBLAS_INLINE + reference operator * () const { + BOOST_UBLAS_CHECK (index1 () < (*this) ().size1 (), bad_index ()); + BOOST_UBLAS_CHECK (index2 () < (*this) ().size2 (), bad_index ()); + return (*this) () (it1_, it2_); + } + BOOST_UBLAS_INLINE + reference operator [] (difference_type n) const { + return *((*this) + n); + } + + // Index + BOOST_UBLAS_INLINE + size_type index1 () const { + return it1_; + } + BOOST_UBLAS_INLINE + size_type index2 () const { + return it2_; + } + + BOOST_UBLAS_INLINE + dual_iterator_type begin () const { + return (*this) ().find2 (1, index1 (), 0); + } + BOOST_UBLAS_INLINE + dual_iterator_type end () const { + return (*this) ().find2 (1, index1 (), (*this) ().size2 ()); + } + BOOST_UBLAS_INLINE + dual_reverse_iterator_type rbegin () const { + return dual_reverse_iterator_type (end ()); + } + BOOST_UBLAS_INLINE + dual_reverse_iterator_type rend () const { + return dual_reverse_iterator_type (begin ()); + } + + // Assignment + BOOST_UBLAS_INLINE + indexed_const_iterator1 &operator = (const indexed_const_iterator1 &it) { + // FIX: ICC needs full qualification?! + // assign (&it ()); + container_const_reference::assign (&it ()); + it1_ = it.it1_; + it2_ = it.it2_; + return *this; + } + + // Comparison + BOOST_UBLAS_INLINE + bool operator == (const indexed_const_iterator1 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK (it2_ == it.it2_, external_logic ()); + return it1_ == it.it1_; + } + BOOST_UBLAS_INLINE + bool operator < (const indexed_const_iterator1 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK (it2_ == it.it2_, external_logic ()); + return it1_ < it.it1_; + } + + private: + size_type it1_; + size_type it2_; + + friend class indexed_iterator1; + }; + + /** \brief A class implementing an indexed random access iterator + * of a matrix. + * + * \param C the (mutable) container type + * \param IC the iterator category + * + * This class implements a random access iterator. The current + * position is stored as two unsigned integers \c it1_ and \c it2_ + * and the values are accessed via \c operator()(it1_, it2_) of the + * container. The iterator changes the second index. + * + * uBLAS extension: \c index1(), \c index2() and access to the + * dual iterator via \c begin(), \c end(), \c rbegin() and \c rend() + * + * Note: The container has to support the find1(rank, i, j) method + */ + template + class indexed_iterator2: + public container_reference, + public random_access_iterator_base, + typename C::value_type, + typename C::difference_type> { + public: + typedef C container_type; + typedef IC iterator_category; + typedef typename container_type::size_type size_type; + typedef typename container_type::difference_type difference_type; + typedef typename container_type::value_type value_type; + typedef typename container_type::reference reference; + + typedef indexed_iterator1 dual_iterator_type; + typedef reverse_iterator_base1 dual_reverse_iterator_type; + + // Construction and destruction + BOOST_UBLAS_INLINE + indexed_iterator2 (): + container_reference (), it1_ (), it2_ () {} + BOOST_UBLAS_INLINE + indexed_iterator2 (container_type &c, size_type it1, size_type it2): + container_reference (c), it1_ (it1), it2_ (it2) {} + + // Arithmetic + BOOST_UBLAS_INLINE + indexed_iterator2 &operator ++ () { + ++ it2_; + return *this; + } + BOOST_UBLAS_INLINE + indexed_iterator2 &operator -- () { + -- it2_; + return *this; + } + BOOST_UBLAS_INLINE + indexed_iterator2 &operator += (difference_type n) { + it2_ += n; + return *this; + } + BOOST_UBLAS_INLINE + indexed_iterator2 &operator -= (difference_type n) { + it2_ -= n; + return *this; + } + BOOST_UBLAS_INLINE + difference_type operator - (const indexed_iterator2 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ()); + return it2_ - it.it2_; + } + + // Dereference + BOOST_UBLAS_INLINE + reference operator * () const { + BOOST_UBLAS_CHECK (index1 () < (*this) ().size1 (), bad_index ()); + BOOST_UBLAS_CHECK (index2 () < (*this) ().size2 (), bad_index ()); + return (*this) () (it1_, it2_); + } + BOOST_UBLAS_INLINE + reference operator [] (difference_type n) const { + return *((*this) + n); + } + + // Index + BOOST_UBLAS_INLINE + size_type index1 () const { + return it1_; + } + BOOST_UBLAS_INLINE + size_type index2 () const { + return it2_; + } + + BOOST_UBLAS_INLINE + dual_iterator_type begin () const { + return (*this) ().find1 (1, 0, index2 ()); + } + BOOST_UBLAS_INLINE + dual_iterator_type end () const { + return (*this) ().find1 (1, (*this) ().size1 (), index2 ()); + } + BOOST_UBLAS_INLINE + dual_reverse_iterator_type rbegin () const { + return dual_reverse_iterator_type (end ()); + } + BOOST_UBLAS_INLINE + dual_reverse_iterator_type rend () const { + return dual_reverse_iterator_type (begin ()); + } + + // Assignment + BOOST_UBLAS_INLINE + indexed_iterator2 &operator = (const indexed_iterator2 &it) { + // FIX: ICC needs full qualification?! + // assign (&it ()); + container_reference::assign (&it ()); + it1_ = it.it1_; + it2_ = it.it2_; + return *this; + } + + // Comparison + BOOST_UBLAS_INLINE + bool operator == (const indexed_iterator2 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ()); + return it2_ == it.it2_; + } + BOOST_UBLAS_INLINE + bool operator < (const indexed_iterator2 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ()); + return it2_ < it.it2_; + } + + private: + size_type it1_; + size_type it2_; + }; + + /** \brief A class implementing an indexed random access iterator + * of a matrix. + * + * \param C the (immutable) container type + * \param IC the iterator category + * + * This class implements a random access iterator. The current + * position is stored as two unsigned integers \c it1_ and \c it2_ + * and the values are accessed via \c operator()(it1_, it2_) of the + * container. The iterator changes the second index. + * + * uBLAS extension: \c index1(), \c index2() and access to the + * dual iterator via \c begin(), \c end(), \c rbegin() and \c rend() + * + * Note 1: The container has to support the \c find2(rank, i, j) method + * + * Note 2: there is an automatic conversion from + * \c indexed_iterator2 to \c indexed_const_iterator2 + */ + + template + class indexed_const_iterator2: + public container_const_reference, + public random_access_iterator_base, + typename C::value_type, + typename C::difference_type> { + public: + typedef C container_type; + typedef IC iterator_category; + typedef typename container_type::size_type size_type; + typedef typename container_type::difference_type difference_type; + typedef typename container_type::value_type value_type; + typedef typename container_type::const_reference reference; + + typedef indexed_iterator2 iterator_type; + typedef indexed_const_iterator1 dual_iterator_type; + typedef reverse_iterator_base1 dual_reverse_iterator_type; + + // Construction and destruction + BOOST_UBLAS_INLINE + indexed_const_iterator2 (): + container_const_reference (), it1_ (), it2_ () {} + BOOST_UBLAS_INLINE + indexed_const_iterator2 (const container_type &c, size_type it1, size_type it2): + container_const_reference (c), it1_ (it1), it2_ (it2) {} + BOOST_UBLAS_INLINE + indexed_const_iterator2 (const iterator_type &it): + container_const_reference (it ()), it1_ (it.index1 ()), it2_ (it.index2 ()) {} + + // Arithmetic + BOOST_UBLAS_INLINE + indexed_const_iterator2 &operator ++ () { + ++ it2_; + return *this; + } + BOOST_UBLAS_INLINE + indexed_const_iterator2 &operator -- () { + -- it2_; + return *this; + } + BOOST_UBLAS_INLINE + indexed_const_iterator2 &operator += (difference_type n) { + it2_ += n; + return *this; + } + BOOST_UBLAS_INLINE + indexed_const_iterator2 &operator -= (difference_type n) { + it2_ -= n; + return *this; + } + BOOST_UBLAS_INLINE + difference_type operator - (const indexed_const_iterator2 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ()); + return it2_ - it.it2_; + } + + // Dereference + BOOST_UBLAS_INLINE + reference operator * () const { + BOOST_UBLAS_CHECK (index1 () < (*this) ().size1 (), bad_index ()); + BOOST_UBLAS_CHECK (index2 () < (*this) ().size2 (), bad_index ()); + return (*this) () (it1_, it2_); + } + BOOST_UBLAS_INLINE + reference operator [] (difference_type n) const { + return *((*this) + n); + } + + // Index + BOOST_UBLAS_INLINE + size_type index1 () const { + return it1_; + } + BOOST_UBLAS_INLINE + size_type index2 () const { + return it2_; + } + + BOOST_UBLAS_INLINE + dual_iterator_type begin () const { + return (*this) ().find1 (1, 0, index2 ()); + } + BOOST_UBLAS_INLINE + dual_iterator_type end () const { + return (*this) ().find1 (1, (*this) ().size1 (), index2 ()); + } + BOOST_UBLAS_INLINE + dual_reverse_iterator_type rbegin () const { + return dual_reverse_iterator_type (end ()); + } + BOOST_UBLAS_INLINE + dual_reverse_iterator_type rend () const { + return dual_reverse_iterator_type (begin ()); + } + + // Assignment + BOOST_UBLAS_INLINE + indexed_const_iterator2 &operator = (const indexed_const_iterator2 &it) { + // FIX: ICC needs full qualification?! + // assign (&it ()); + container_const_reference::assign (&it ()); + it1_ = it.it1_; + it2_ = it.it2_; + return *this; + } + + // Comparison + BOOST_UBLAS_INLINE + bool operator == (const indexed_const_iterator2 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ()); + return it2_ == it.it2_; + } + BOOST_UBLAS_INLINE + bool operator < (const indexed_const_iterator2 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ()); + return it2_ < it.it2_; + } + + private: + size_type it1_; + size_type it2_; + + friend class indexed_iterator2; + }; + +}}} + +#endif diff --git a/deal.II/contrib/boost-1.49.0/include/boost/numeric/ublas/detail/matrix_assign.hpp b/deal.II/contrib/boost-1.49.0/include/boost/numeric/ublas/detail/matrix_assign.hpp new file mode 100644 index 0000000000..3bc48ee072 --- /dev/null +++ b/deal.II/contrib/boost-1.49.0/include/boost/numeric/ublas/detail/matrix_assign.hpp @@ -0,0 +1,1633 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// 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) +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + +#ifndef _BOOST_UBLAS_MATRIX_ASSIGN_ +#define _BOOST_UBLAS_MATRIX_ASSIGN_ + +#include +// Required for make_conformant storage +#include + +// Iterators based on ideas of Jeremy Siek + +namespace boost { namespace numeric { namespace ublas { +namespace detail { + + // Weak equality check - useful to compare equality two arbitary matrix expression results. + // Since the actual expressions are unknown, we check for and arbitary error bound + // on the relative error. + // For a linear expression the infinity norm makes sense as we do not know how the elements will be + // combined in the expression. False positive results are inevitable for arbirary expressions! + template + BOOST_UBLAS_INLINE + bool equals (const matrix_expression &e1, const matrix_expression &e2, S epsilon, S min_norm) { + return norm_inf (e1 - e2) < epsilon * + std::max (std::max (norm_inf (e1), norm_inf (e2)), min_norm); + } + + template + BOOST_UBLAS_INLINE + bool expression_type_check (const matrix_expression &e1, const matrix_expression &e2) { + typedef typename type_traits::promote_type>::real_type real_type; + return equals (e1, e2, BOOST_UBLAS_TYPE_CHECK_EPSILON, BOOST_UBLAS_TYPE_CHECK_MIN); + } + + + template + // BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it. + void make_conformant (M &m, const matrix_expression &e, row_major_tag, R) { + BOOST_UBLAS_CHECK (m.size1 () == e ().size1 (), bad_size ()); + BOOST_UBLAS_CHECK (m.size2 () == e ().size2 (), bad_size ()); + typedef R conformant_restrict_type; + typedef typename M::size_type size_type; + typedef typename M::difference_type difference_type; + typedef typename M::value_type value_type; + // FIXME unbounded_array with push_back maybe better + std::vector > index; + typename M::iterator1 it1 (m.begin1 ()); + typename M::iterator1 it1_end (m.end1 ()); + typename E::const_iterator1 it1e (e ().begin1 ()); + typename E::const_iterator1 it1e_end (e ().end1 ()); + while (it1 != it1_end && it1e != it1e_end) { + difference_type compare = it1.index1 () - it1e.index1 (); + if (compare == 0) { +#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION + typename M::iterator2 it2 (it1.begin ()); + typename M::iterator2 it2_end (it1.end ()); + typename E::const_iterator2 it2e (it1e.begin ()); + typename E::const_iterator2 it2e_end (it1e.end ()); +#else + typename M::iterator2 it2 (begin (it1, iterator1_tag ())); + typename M::iterator2 it2_end (end (it1, iterator1_tag ())); + typename E::const_iterator2 it2e (begin (it1e, iterator1_tag ())); + typename E::const_iterator2 it2e_end (end (it1e, iterator1_tag ())); +#endif + if (it2 != it2_end && it2e != it2e_end) { + size_type it2_index = it2.index2 (), it2e_index = it2e.index2 (); + while (true) { + difference_type compare = it2_index - it2e_index; + if (compare == 0) { + ++ it2, ++ it2e; + if (it2 != it2_end && it2e != it2e_end) { + it2_index = it2.index2 (); + it2e_index = it2e.index2 (); + } else + break; + } else if (compare < 0) { + increment (it2, it2_end, - compare); + if (it2 != it2_end) + it2_index = it2.index2 (); + else + break; + } else if (compare > 0) { + if (conformant_restrict_type::other (it2e.index1 (), it2e.index2 ())) + if (static_cast(*it2e) != value_type/*zero*/()) + index.push_back (std::pair (it2e.index1 (), it2e.index2 ())); + ++ it2e; + if (it2e != it2e_end) + it2e_index = it2e.index2 (); + else + break; + } + } + } + while (it2e != it2e_end) { + if (conformant_restrict_type::other (it2e.index1 (), it2e.index2 ())) + if (static_cast(*it2e) != value_type/*zero*/()) + index.push_back (std::pair (it2e.index1 (), it2e.index2 ())); + ++ it2e; + } + ++ it1, ++ it1e; + } else if (compare < 0) { + increment (it1, it1_end, - compare); + } else if (compare > 0) { +#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION + typename E::const_iterator2 it2e (it1e.begin ()); + typename E::const_iterator2 it2e_end (it1e.end ()); +#else + typename E::const_iterator2 it2e (begin (it1e, iterator1_tag ())); + typename E::const_iterator2 it2e_end (end (it1e, iterator1_tag ())); +#endif + while (it2e != it2e_end) { + if (conformant_restrict_type::other (it2e.index1 (), it2e.index2 ())) + if (static_cast(*it2e) != value_type/*zero*/()) + index.push_back (std::pair (it2e.index1 (), it2e.index2 ())); + ++ it2e; + } + ++ it1e; + } + } + while (it1e != it1e_end) { +#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION + typename E::const_iterator2 it2e (it1e.begin ()); + typename E::const_iterator2 it2e_end (it1e.end ()); +#else + typename E::const_iterator2 it2e (begin (it1e, iterator1_tag ())); + typename E::const_iterator2 it2e_end (end (it1e, iterator1_tag ())); +#endif + while (it2e != it2e_end) { + if (conformant_restrict_type::other (it2e.index1 (), it2e.index2 ())) + if (static_cast(*it2e) != value_type/*zero*/()) + index.push_back (std::pair (it2e.index1 (), it2e.index2 ())); + ++ it2e; + } + ++ it1e; + } + // ISSUE proxies require insert_element + for (size_type k = 0; k < index.size (); ++ k) + m (index [k].first, index [k].second) = value_type/*zero*/(); + } + template + // BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it. + void make_conformant (M &m, const matrix_expression &e, column_major_tag, R) { + BOOST_UBLAS_CHECK (m.size1 () == e ().size1 (), bad_size ()); + BOOST_UBLAS_CHECK (m.size2 () == e ().size2 (), bad_size ()); + typedef R conformant_restrict_type; + typedef typename M::size_type size_type; + typedef typename M::difference_type difference_type; + typedef typename M::value_type value_type; + std::vector > index; + typename M::iterator2 it2 (m.begin2 ()); + typename M::iterator2 it2_end (m.end2 ()); + typename E::const_iterator2 it2e (e ().begin2 ()); + typename E::const_iterator2 it2e_end (e ().end2 ()); + while (it2 != it2_end && it2e != it2e_end) { + difference_type compare = it2.index2 () - it2e.index2 (); + if (compare == 0) { +#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION + typename M::iterator1 it1 (it2.begin ()); + typename M::iterator1 it1_end (it2.end ()); + typename E::const_iterator1 it1e (it2e.begin ()); + typename E::const_iterator1 it1e_end (it2e.end ()); +#else + typename M::iterator1 it1 (begin (it2, iterator2_tag ())); + typename M::iterator1 it1_end (end (it2, iterator2_tag ())); + typename E::const_iterator1 it1e (begin (it2e, iterator2_tag ())); + typename E::const_iterator1 it1e_end (end (it2e, iterator2_tag ())); +#endif + if (it1 != it1_end && it1e != it1e_end) { + size_type it1_index = it1.index1 (), it1e_index = it1e.index1 (); + while (true) { + difference_type compare = it1_index - it1e_index; + if (compare == 0) { + ++ it1, ++ it1e; + if (it1 != it1_end && it1e != it1e_end) { + it1_index = it1.index1 (); + it1e_index = it1e.index1 (); + } else + break; + } else if (compare < 0) { + increment (it1, it1_end, - compare); + if (it1 != it1_end) + it1_index = it1.index1 (); + else + break; + } else if (compare > 0) { + if (conformant_restrict_type::other (it1e.index1 (), it1e.index2 ())) + if (static_cast(*it1e) != value_type/*zero*/()) + index.push_back (std::pair (it1e.index1 (), it1e.index2 ())); + ++ it1e; + if (it1e != it1e_end) + it1e_index = it1e.index1 (); + else + break; + } + } + } + while (it1e != it1e_end) { + if (conformant_restrict_type::other (it1e.index1 (), it1e.index2 ())) + if (static_cast(*it1e) != value_type/*zero*/()) + index.push_back (std::pair (it1e.index1 (), it1e.index2 ())); + ++ it1e; + } + ++ it2, ++ it2e; + } else if (compare < 0) { + increment (it2, it2_end, - compare); + } else if (compare > 0) { +#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION + typename E::const_iterator1 it1e (it2e.begin ()); + typename E::const_iterator1 it1e_end (it2e.end ()); +#else + typename E::const_iterator1 it1e (begin (it2e, iterator2_tag ())); + typename E::const_iterator1 it1e_end (end (it2e, iterator2_tag ())); +#endif + while (it1e != it1e_end) { + if (conformant_restrict_type::other (it1e.index1 (), it1e.index2 ())) + if (static_cast(*it1e) != value_type/*zero*/()) + index.push_back (std::pair (it1e.index1 (), it1e.index2 ())); + ++ it1e; + } + ++ it2e; + } + } + while (it2e != it2e_end) { +#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION + typename E::const_iterator1 it1e (it2e.begin ()); + typename E::const_iterator1 it1e_end (it2e.end ()); +#else + typename E::const_iterator1 it1e (begin (it2e, iterator2_tag ())); + typename E::const_iterator1 it1e_end (end (it2e, iterator2_tag ())); +#endif + while (it1e != it1e_end) { + if (conformant_restrict_type::other (it1e.index1 (), it1e.index2 ())) + if (static_cast(*it1e) != value_type/*zero*/()) + index.push_back (std::pair (it1e.index1 (), it1e.index2 ())); + ++ it1e; + } + ++ it2e; + } + // ISSUE proxies require insert_element + for (size_type k = 0; k < index.size (); ++ k) + m (index [k].first, index [k].second) = value_type/*zero*/(); + } + +}//namespace detail + + + // Explicitly iterating row major + template