Added precompiled boost libraries - NOT TESTED YET!
This commit is contained in:
@@ -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<class N>
|
||||
struct bounds : boundsdetail::get_impl<N>::type
|
||||
{} ;
|
||||
|
||||
} } // namespace boost::numeric
|
||||
|
||||
#endif
|
||||
51
project/jni/boost/include/boost/numeric/conversion/cast.hpp
Normal file
51
project/jni/boost/include/boost/numeric/conversion/cast.hpp
Normal file
@@ -0,0 +1,51 @@
|
||||
// (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
|
||||
//
|
||||
#ifndef BOOST_NUMERIC_CONVERSION_CAST_25OCT2001_HPP
|
||||
#define BOOST_NUMERIC_CONVERSION_CAST_25OCT2001_HPP
|
||||
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
|
||||
|
||||
# include<boost/numeric/conversion/detail/old_numeric_cast.hpp>
|
||||
|
||||
#else
|
||||
|
||||
#include <boost/type.hpp>
|
||||
#include <boost/numeric/conversion/converter.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
template<typename Target, typename Source>
|
||||
inline
|
||||
Target numeric_cast ( Source arg )
|
||||
{
|
||||
typedef boost::numeric::converter<Target,Source> Converter ;
|
||||
return Converter::convert(arg);
|
||||
}
|
||||
|
||||
using numeric::bad_numeric_cast;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
@@ -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<class T, class S>
|
||||
struct conversion_traits
|
||||
: convdetail::get_conversion_traits<T,S>::type
|
||||
{
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
typedef typename convdetail::get_conversion_traits<T,S>::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
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@@ -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 T,
|
||||
class S,
|
||||
class Traits = conversion_traits<T,S>,
|
||||
class OverflowHandler = def_overflow_handler,
|
||||
class Float2IntRounder = Trunc< BOOST_DEDUCED_TYPENAME Traits::source_type> ,
|
||||
class RawConverter = raw_converter<Traits>,
|
||||
class UserRangeChecker = UseInternalRangeChecker
|
||||
>
|
||||
struct converter : convdetail::get_converter_impl<Traits,
|
||||
OverflowHandler,
|
||||
Float2IntRounder,
|
||||
RawConverter,
|
||||
UserRangeChecker
|
||||
>::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 S,
|
||||
class OverflowHandler = def_overflow_handler,
|
||||
class Float2IntRounder = Trunc<S> ,
|
||||
class UserRangeChecker = UseInternalRangeChecker
|
||||
>
|
||||
struct make_converter_from
|
||||
{
|
||||
template<class T,
|
||||
class Traits = conversion_traits<T,S>,
|
||||
class RawConverter = raw_converter<Traits>
|
||||
>
|
||||
struct to
|
||||
{
|
||||
typedef converter<T,S,Traits,OverflowHandler,Float2IntRounder,RawConverter,UserRangeChecker> type ;
|
||||
} ;
|
||||
|
||||
} ;
|
||||
|
||||
} } // namespace boost::numeric
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -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 <typeinfo> // for std::bad_cast
|
||||
|
||||
#include <boost/config/no_tr1/cmath.hpp> // for std::floor and std::ceil
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include "boost/type_traits/is_arithmetic.hpp"
|
||||
|
||||
#include "boost/mpl/if.hpp"
|
||||
#include "boost/mpl/integral_c.hpp"
|
||||
|
||||
namespace boost { namespace numeric
|
||||
{
|
||||
|
||||
template<class S>
|
||||
struct Trunc
|
||||
{
|
||||
typedef S source_type ;
|
||||
|
||||
typedef typename mpl::if_< is_arithmetic<S>,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<S>(0) ? ceil(s) : floor(s) ;
|
||||
}
|
||||
|
||||
typedef mpl::integral_c< std::float_round_style, std::round_toward_zero> round_style ;
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
template<class S>
|
||||
struct Floor
|
||||
{
|
||||
typedef S source_type ;
|
||||
|
||||
typedef typename mpl::if_< is_arithmetic<S>,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<class S>
|
||||
struct Ceil
|
||||
{
|
||||
typedef S source_type ;
|
||||
|
||||
typedef typename mpl::if_< is_arithmetic<S>,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<class S>
|
||||
struct RoundEven
|
||||
{
|
||||
typedef S source_type ;
|
||||
|
||||
typedef typename mpl::if_< is_arithmetic<S>,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<class Traits>
|
||||
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<result_type>(s) ; }
|
||||
} ;
|
||||
|
||||
struct UseInternalRangeChecker {} ;
|
||||
|
||||
} } // namespace boost::numeric
|
||||
|
||||
#endif
|
||||
@@ -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 N>
|
||||
class Integral
|
||||
{
|
||||
typedef std::numeric_limits<N> 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<N>(1); }
|
||||
} ;
|
||||
|
||||
template<class N>
|
||||
class Float
|
||||
{
|
||||
typedef std::numeric_limits<N> limits ;
|
||||
|
||||
public :
|
||||
|
||||
static N lowest () { return static_cast<N>(-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<class N>
|
||||
struct get_impl
|
||||
{
|
||||
typedef mpl::bool_< ::std::numeric_limits<N>::is_integer > is_int ;
|
||||
|
||||
typedef Integral<N> impl_int ;
|
||||
typedef Float <N> impl_float ;
|
||||
|
||||
typedef typename mpl::if_<is_int,impl_int,impl_float>::type type ;
|
||||
} ;
|
||||
|
||||
} } } // namespace boost::numeric::boundsdetail.
|
||||
|
||||
#endif
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -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<class T,class S>
|
||||
struct non_trivial_traits_impl
|
||||
{
|
||||
typedef typename get_int_float_mixture <T,S>::type int_float_mixture ;
|
||||
typedef typename get_sign_mixture <T,S>::type sign_mixture ;
|
||||
typedef typename get_udt_builtin_mixture <T,S>::type udt_builtin_mixture ;
|
||||
|
||||
typedef typename get_is_subranged<T,S>::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, S const&>::type argument_type ;
|
||||
|
||||
typedef typename mpl::if_<subranged,S,T>::type supertype ;
|
||||
typedef typename mpl::if_<subranged,T,S>::type subtype ;
|
||||
} ;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Implementation of the Conversion Traits for T == S
|
||||
//
|
||||
// This is a VISIBLE base class of the user-level conversion_traits<> class.
|
||||
//-------------------------------------------------------------------
|
||||
template<class N>
|
||||
struct trivial_traits_impl
|
||||
{
|
||||
typedef typename get_int_float_mixture <N,N>::type int_float_mixture ;
|
||||
typedef typename get_sign_mixture <N,N>::type sign_mixture ;
|
||||
typedef typename get_udt_builtin_mixture<N,N>::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<class T, class S>
|
||||
struct get_conversion_traits
|
||||
{
|
||||
typedef typename remove_cv<T>::type target_type ;
|
||||
typedef typename remove_cv<S>::type source_type ;
|
||||
|
||||
typedef typename is_same<target_type,source_type>::type is_trivial ;
|
||||
|
||||
typedef trivial_traits_impl <target_type> trivial_imp ;
|
||||
typedef non_trivial_traits_impl<target_type,source_type> non_trivial_imp ;
|
||||
|
||||
typedef typename mpl::if_<is_trivial,trivial_imp,non_trivial_imp>::type type ;
|
||||
} ;
|
||||
|
||||
} } } // namespace boost::numeric::convdetail
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -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 <functional>
|
||||
|
||||
#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<std::float_round_style, std::round_toward_zero> round2zero_c ;
|
||||
typedef mpl::integral_c<std::float_round_style, std::round_to_nearest> round2nearest_c ;
|
||||
typedef mpl::integral_c<std::float_round_style, std::round_toward_infinity> round2inf_c ;
|
||||
typedef mpl::integral_c<std::float_round_style, std::round_toward_neg_infinity> round2neg_inf_c ;
|
||||
|
||||
// Metafunction:
|
||||
//
|
||||
// for_round_style<RoundStyle,RoundToZero,RoundToNearest,RoundToInf,RoundToNegInf>::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<class RoundStyle,class RoundToZero,class RoundToNearest,class RoundToInf,class RoundToNegInf>
|
||||
struct for_round_style
|
||||
{
|
||||
typedef ct_switch4<RoundStyle
|
||||
, round2zero_c, round2nearest_c, round2inf_c // round2neg_inf_c
|
||||
, RoundToZero , RoundToNearest , RoundToInf , RoundToNegInf
|
||||
> 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<class Traits>
|
||||
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<S>(bounds<T>::lowest()) ? cNegOverflow : cInRange ;
|
||||
}
|
||||
} ;
|
||||
|
||||
// s < 0 ? cNegOverflow : cInRange
|
||||
//
|
||||
template<class Traits>
|
||||
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<S>(0) ? cNegOverflow : cInRange ;
|
||||
}
|
||||
} ;
|
||||
|
||||
// s <= Lowest(T)-1 ? cNegOverflow : cInRange
|
||||
//
|
||||
template<class Traits>
|
||||
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<S>(bounds<T>::lowest()) - static_cast<S>(1.0)
|
||||
? cNegOverflow : cInRange ;
|
||||
}
|
||||
} ;
|
||||
|
||||
// s < Lowest(T)-0.5 ? cNegOverflow : cInRange
|
||||
//
|
||||
template<class Traits>
|
||||
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<S>(bounds<T>::lowest()) - static_cast<S>(0.5)
|
||||
? cNegOverflow : cInRange ;
|
||||
}
|
||||
} ;
|
||||
|
||||
// s > Highest(T) ? cPosOverflow : cInRange
|
||||
//
|
||||
template<class Traits>
|
||||
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<S>(bounds<T>::highest())
|
||||
? cPosOverflow : cInRange ;
|
||||
}
|
||||
} ;
|
||||
|
||||
// s >= Lowest(T) + 1 ? cPosOverflow : cInRange
|
||||
//
|
||||
template<class Traits>
|
||||
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<S>(bounds<T>::highest()) + static_cast<S>(1.0)
|
||||
? cPosOverflow : cInRange ;
|
||||
}
|
||||
} ;
|
||||
|
||||
// s >= Lowest(T) + 0.5 ? cPosgOverflow : cInRange
|
||||
//
|
||||
template<class Traits>
|
||||
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<S>(bounds<T>::highest()) + static_cast<S>(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<class PredA, class PredB>
|
||||
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<class PredA, class PredB>
|
||||
struct combine
|
||||
{
|
||||
typedef applyBoth<PredA,PredB> 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<do_applyA, do_applyB, Both, PredA, PredB, NNone>::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<class Traits>
|
||||
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<class Traits, class IsNegOverflow, class IsPosOverflow, class OverflowHandler>
|
||||
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<IsNegOverflow,IsPosOverflow>::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<class Traits,class OverflowHandler>
|
||||
struct GetRC_Sig2Sig_or_Unsig2Unsig
|
||||
{
|
||||
typedef dummy_range_checker<Traits> Dummy ;
|
||||
|
||||
typedef LT_LoT<Traits> Pred1 ;
|
||||
typedef GT_HiT<Traits> Pred2 ;
|
||||
|
||||
typedef generic_range_checker<Traits,Pred1,Pred2,OverflowHandler> Normal ;
|
||||
|
||||
typedef typename Traits::subranged subranged ;
|
||||
|
||||
typedef typename mpl::if_<subranged,Normal,Dummy>::type type ;
|
||||
} ;
|
||||
|
||||
template<class Traits, class OverflowHandler>
|
||||
struct GetRC_Sig2Unsig
|
||||
{
|
||||
typedef LT_Zero<Traits> Pred1 ;
|
||||
typedef GT_HiT <Traits> Pred2 ;
|
||||
|
||||
typedef generic_range_checker<Traits,Pred1,Pred2,OverflowHandler> ChoiceA ;
|
||||
|
||||
typedef generic_range_checker<Traits,Pred1,non_applicable,OverflowHandler> ChoiceB ;
|
||||
|
||||
typedef typename Traits::target_type T ;
|
||||
typedef typename Traits::source_type S ;
|
||||
|
||||
typedef typename subranged_Unsig2Sig<S,T>::type oposite_subranged ;
|
||||
|
||||
typedef typename mpl::not_<oposite_subranged>::type positively_subranged ;
|
||||
|
||||
typedef typename mpl::if_<positively_subranged,ChoiceA,ChoiceB>::type type ;
|
||||
} ;
|
||||
|
||||
template<class Traits, class OverflowHandler>
|
||||
struct GetRC_Unsig2Sig
|
||||
{
|
||||
typedef GT_HiT<Traits> Pred1 ;
|
||||
|
||||
typedef generic_range_checker<Traits,non_applicable,Pred1,OverflowHandler> type ;
|
||||
} ;
|
||||
|
||||
template<class Traits,class OverflowHandler>
|
||||
struct GetRC_Int2Int
|
||||
{
|
||||
typedef GetRC_Sig2Sig_or_Unsig2Unsig<Traits,OverflowHandler> Sig2SigQ ;
|
||||
typedef GetRC_Sig2Unsig <Traits,OverflowHandler> Sig2UnsigQ ;
|
||||
typedef GetRC_Unsig2Sig <Traits,OverflowHandler> Unsig2SigQ ;
|
||||
typedef Sig2SigQ Unsig2UnsigQ ;
|
||||
|
||||
typedef typename Traits::sign_mixture sign_mixture ;
|
||||
|
||||
typedef typename
|
||||
for_sign_mixture<sign_mixture,Sig2SigQ,Sig2UnsigQ,Unsig2SigQ,Unsig2UnsigQ>::type
|
||||
selector ;
|
||||
|
||||
typedef typename selector::type type ;
|
||||
} ;
|
||||
|
||||
template<class Traits>
|
||||
struct GetRC_Int2Float
|
||||
{
|
||||
typedef dummy_range_checker<Traits> type ;
|
||||
} ;
|
||||
|
||||
template<class Traits, class OverflowHandler, class Float2IntRounder>
|
||||
struct GetRC_Float2Int
|
||||
{
|
||||
typedef LE_PrevLoT <Traits> Pred1 ;
|
||||
typedef GE_SuccHiT <Traits> Pred2 ;
|
||||
typedef LT_HalfPrevLoT<Traits> Pred3 ;
|
||||
typedef GT_HalfSuccHiT<Traits> Pred4 ;
|
||||
typedef GT_HiT <Traits> Pred5 ;
|
||||
typedef LT_LoT <Traits> Pred6 ;
|
||||
|
||||
typedef generic_range_checker<Traits,Pred1,Pred2,OverflowHandler> ToZero ;
|
||||
typedef generic_range_checker<Traits,Pred3,Pred4,OverflowHandler> ToNearest ;
|
||||
typedef generic_range_checker<Traits,Pred1,Pred5,OverflowHandler> ToInf ;
|
||||
typedef generic_range_checker<Traits,Pred6,Pred2,OverflowHandler> ToNegInf ;
|
||||
|
||||
typedef typename Float2IntRounder::round_style round_style ;
|
||||
|
||||
typedef typename for_round_style<round_style,ToZero,ToNearest,ToInf,ToNegInf>::type type ;
|
||||
} ;
|
||||
|
||||
template<class Traits, class OverflowHandler>
|
||||
struct GetRC_Float2Float
|
||||
{
|
||||
typedef dummy_range_checker<Traits> Dummy ;
|
||||
|
||||
typedef LT_LoT<Traits> Pred1 ;
|
||||
typedef GT_HiT<Traits> Pred2 ;
|
||||
|
||||
typedef generic_range_checker<Traits,Pred1,Pred2,OverflowHandler> Normal ;
|
||||
|
||||
typedef typename Traits::subranged subranged ;
|
||||
|
||||
typedef typename mpl::if_<subranged,Normal,Dummy>::type type ;
|
||||
} ;
|
||||
|
||||
template<class Traits, class OverflowHandler, class Float2IntRounder>
|
||||
struct GetRC_BuiltIn2BuiltIn
|
||||
{
|
||||
typedef GetRC_Int2Int<Traits,OverflowHandler> Int2IntQ ;
|
||||
typedef GetRC_Int2Float<Traits> Int2FloatQ ;
|
||||
typedef GetRC_Float2Int<Traits,OverflowHandler,Float2IntRounder> Float2IntQ ;
|
||||
typedef GetRC_Float2Float<Traits,OverflowHandler> Float2FloatQ ;
|
||||
|
||||
typedef typename Traits::int_float_mixture int_float_mixture ;
|
||||
|
||||
typedef typename for_int_float_mixture<int_float_mixture, Int2IntQ, Int2FloatQ, Float2IntQ, Float2FloatQ>::type selector ;
|
||||
|
||||
typedef typename selector::type type ;
|
||||
} ;
|
||||
|
||||
template<class Traits, class OverflowHandler, class Float2IntRounder>
|
||||
struct GetRC
|
||||
{
|
||||
typedef GetRC_BuiltIn2BuiltIn<Traits,OverflowHandler,Float2IntRounder> BuiltIn2BuiltInQ ;
|
||||
|
||||
typedef dummy_range_checker<Traits> Dummy ;
|
||||
|
||||
typedef mpl::identity<Dummy> DummyQ ;
|
||||
|
||||
typedef typename Traits::udt_builtin_mixture udt_builtin_mixture ;
|
||||
|
||||
typedef typename for_udt_builtin_mixture<udt_builtin_mixture,BuiltIn2BuiltInQ,DummyQ,DummyQ,DummyQ>::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<class Traits>
|
||||
struct trivial_converter_impl : public std::unary_function< BOOST_DEDUCED_TYPENAME Traits::argument_type
|
||||
,BOOST_DEDUCED_TYPENAME Traits::result_type
|
||||
>
|
||||
,public dummy_range_checker<Traits>
|
||||
{
|
||||
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<class Traits,class RangeChecker,class RawConverter,class Float2IntRounder>
|
||||
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<class Traits,class RangeChecker,class RawConverter>
|
||||
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<class Traits,class OverflowHandler,class Float2IntRounder,class RawConverter, class UserRangeChecker>
|
||||
struct get_non_trivial_converter
|
||||
{
|
||||
typedef GetRC<Traits,OverflowHandler,Float2IntRounder> InternalRangeCheckerQ ;
|
||||
|
||||
typedef is_same<UserRangeChecker,UseInternalRangeChecker> use_internal_RC ;
|
||||
|
||||
typedef mpl::identity<UserRangeChecker> UserRangeCheckerQ ;
|
||||
|
||||
typedef typename
|
||||
mpl::eval_if<use_internal_RC,InternalRangeCheckerQ,UserRangeCheckerQ>::type
|
||||
RangeChecker ;
|
||||
|
||||
typedef non_rounding_converter<Traits,RangeChecker,RawConverter> NonRounding ;
|
||||
typedef rounding_converter<Traits,RangeChecker,RawConverter,Float2IntRounder> Rounding ;
|
||||
|
||||
typedef mpl::identity<NonRounding> NonRoundingQ ;
|
||||
typedef mpl::identity<Rounding> RoundingQ ;
|
||||
|
||||
typedef typename Traits::int_float_mixture int_float_mixture ;
|
||||
|
||||
typedef typename
|
||||
for_int_float_mixture<int_float_mixture, NonRoundingQ, NonRoundingQ, RoundingQ, NonRoundingQ>::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<Traits> Trivial ;
|
||||
typedef mpl::identity <Trivial> TrivialQ ;
|
||||
|
||||
typedef get_non_trivial_converter< Traits
|
||||
,OverflowHandler
|
||||
,Float2IntRounder
|
||||
,RawConverter
|
||||
,UserRangeChecker
|
||||
> NonTrivialQ ;
|
||||
|
||||
typedef typename Traits::trivial trivial ;
|
||||
|
||||
typedef typename mpl::eval_if<trivial,TrivialQ,NonTrivialQ>::type type ;
|
||||
} ;
|
||||
|
||||
} } } // namespace boost::numeric::convdetail
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -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<int_float_mixture_enum, integral_to_integral> int2int_c ;
|
||||
typedef mpl::integral_c<int_float_mixture_enum, integral_to_float> int2float_c ;
|
||||
typedef mpl::integral_c<int_float_mixture_enum, float_to_integral> float2int_c ;
|
||||
typedef mpl::integral_c<int_float_mixture_enum, float_to_float> float2float_c ;
|
||||
|
||||
// Metafunction:
|
||||
//
|
||||
// get_int_float_mixture<T,S>::type
|
||||
//
|
||||
// Selects the appropriate Int-Float Mixture Integral Constant for the combination T,S.
|
||||
//
|
||||
template<class T,class S>
|
||||
struct get_int_float_mixture
|
||||
{
|
||||
typedef mpl::bool_< ::std::numeric_limits<S>::is_integer > S_int ;
|
||||
typedef mpl::bool_< ::std::numeric_limits<T>::is_integer > T_int ;
|
||||
|
||||
typedef typename
|
||||
for_both<S_int, T_int, int2int_c, int2float_c, float2int_c, float2float_c>::type
|
||||
type ;
|
||||
} ;
|
||||
|
||||
// Metafunction:
|
||||
//
|
||||
// for_int_float_mixture<Mixture,int_int,int_float,float_int,float_float>::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<class IntFloatMixture, class Int2Int, class Int2Float, class Float2Int, class Float2Float>
|
||||
struct for_int_float_mixture
|
||||
{
|
||||
typedef typename
|
||||
ct_switch4<IntFloatMixture
|
||||
,int2int_c, int2float_c, float2int_c // default
|
||||
,Int2Int , Int2Float , Float2Int , Float2Float
|
||||
>::type
|
||||
type ;
|
||||
} ;
|
||||
|
||||
} } } // namespace boost::numeric::convdetail
|
||||
|
||||
#endif
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@@ -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<class T,class S>
|
||||
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<class T,class S>
|
||||
struct subranged_Unsig2Sig
|
||||
{
|
||||
// IMPORTANT NOTE:
|
||||
//
|
||||
// This code assumes that signed/unsigned integral values are represented
|
||||
// such that:
|
||||
//
|
||||
// numeric_limits<signed T>::digits + 1 == numeric_limits<unsigned T>::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<T>::digits+1) < (2*numeric_limits<S>::digits) )
|
||||
// then the conversion is subranged.
|
||||
//
|
||||
|
||||
typedef mpl::int_< ::std::numeric_limits<S>::digits > S_digits ;
|
||||
typedef mpl::int_< ::std::numeric_limits<T>::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<S_digits,Two>::type S_digits_times_2 ;
|
||||
|
||||
typedef typename mpl::less<u_T_digits,S_digits_times_2>::type type ;
|
||||
} ;
|
||||
|
||||
// for integral to integral conversions of the same sign.
|
||||
template<class T,class S>
|
||||
struct subranged_SameSign
|
||||
{
|
||||
// An integral conversion of the same sign is subranged if digits(T) < digits(S).
|
||||
|
||||
typedef mpl::int_< ::std::numeric_limits<S>::digits > S_digits ;
|
||||
typedef mpl::int_< ::std::numeric_limits<T>::digits > T_digits ;
|
||||
|
||||
typedef typename mpl::less<T_digits,S_digits>::type type ;
|
||||
} ;
|
||||
|
||||
// for integral to float conversions
|
||||
template<class T,class S>
|
||||
struct subranged_Int2Float
|
||||
{
|
||||
typedef mpl::false_ type ;
|
||||
} ;
|
||||
|
||||
// for float to integral conversions
|
||||
template<class T,class S>
|
||||
struct subranged_Float2Int
|
||||
{
|
||||
typedef mpl::true_ type ;
|
||||
} ;
|
||||
|
||||
// for float to float conversions
|
||||
template<class T,class S>
|
||||
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<S>::digits > S_mantisa ;
|
||||
typedef mpl::int_< ::std::numeric_limits<T>::digits > T_mantisa ;
|
||||
|
||||
typedef mpl::int_< ::std::numeric_limits<S>::max_exponent > S_exponent ;
|
||||
typedef mpl::int_< ::std::numeric_limits<T>::max_exponent > T_exponent ;
|
||||
|
||||
typedef typename mpl::less<T_exponent,S_exponent>::type T_smaller_exponent ;
|
||||
|
||||
typedef typename mpl::equal_to<T_exponent,S_exponent>::type equal_exponents ;
|
||||
|
||||
typedef mpl::less<T_mantisa,S_mantisa> T_smaller_mantisa ;
|
||||
|
||||
typedef mpl::eval_if<equal_exponents,T_smaller_mantisa,mpl::false_> not_bigger_exponent_case ;
|
||||
|
||||
typedef typename
|
||||
mpl::eval_if<T_smaller_exponent,mpl::true_,not_bigger_exponent_case>::type
|
||||
type ;
|
||||
} ;
|
||||
|
||||
// for Udt to built-in conversions
|
||||
template<class T,class S>
|
||||
struct subranged_Udt2BuiltIn
|
||||
{
|
||||
typedef mpl::true_ type ;
|
||||
} ;
|
||||
|
||||
// for built-in to Udt conversions
|
||||
template<class T,class S>
|
||||
struct subranged_BuiltIn2Udt
|
||||
{
|
||||
typedef mpl::false_ type ;
|
||||
} ;
|
||||
|
||||
// for Udt to Udt conversions
|
||||
template<class T,class S>
|
||||
struct subranged_Udt2Udt
|
||||
{
|
||||
typedef mpl::false_ type ;
|
||||
} ;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Selectors for the implementations of the subranged predicate
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
template<class T,class S>
|
||||
struct get_subranged_Int2Int
|
||||
{
|
||||
typedef subranged_SameSign<T,S> Sig2Sig ;
|
||||
typedef subranged_Sig2Unsig<T,S> Sig2Unsig ;
|
||||
typedef subranged_Unsig2Sig<T,S> Unsig2Sig ;
|
||||
typedef Sig2Sig Unsig2Unsig ;
|
||||
|
||||
typedef typename get_sign_mixture<T,S>::type sign_mixture ;
|
||||
|
||||
typedef typename
|
||||
for_sign_mixture<sign_mixture, Sig2Sig, Sig2Unsig, Unsig2Sig, Unsig2Unsig>::type
|
||||
type ;
|
||||
} ;
|
||||
|
||||
template<class T,class S>
|
||||
struct get_subranged_BuiltIn2BuiltIn
|
||||
{
|
||||
typedef get_subranged_Int2Int<T,S> Int2IntQ ;
|
||||
|
||||
typedef subranged_Int2Float <T,S> Int2Float ;
|
||||
typedef subranged_Float2Int <T,S> Float2Int ;
|
||||
typedef subranged_Float2Float<T,S> Float2Float ;
|
||||
|
||||
typedef mpl::identity<Int2Float > Int2FloatQ ;
|
||||
typedef mpl::identity<Float2Int > Float2IntQ ;
|
||||
typedef mpl::identity<Float2Float> Float2FloatQ ;
|
||||
|
||||
typedef typename get_int_float_mixture<T,S>::type int_float_mixture ;
|
||||
|
||||
typedef for_int_float_mixture<int_float_mixture, Int2IntQ, Int2FloatQ, Float2IntQ, Float2FloatQ> for_ ;
|
||||
|
||||
typedef typename for_::type selected ;
|
||||
|
||||
typedef typename selected::type type ;
|
||||
} ;
|
||||
|
||||
template<class T,class S>
|
||||
struct get_subranged
|
||||
{
|
||||
typedef get_subranged_BuiltIn2BuiltIn<T,S> BuiltIn2BuiltInQ ;
|
||||
|
||||
typedef subranged_BuiltIn2Udt<T,S> BuiltIn2Udt ;
|
||||
typedef subranged_Udt2BuiltIn<T,S> Udt2BuiltIn ;
|
||||
typedef subranged_Udt2Udt<T,S> Udt2Udt ;
|
||||
|
||||
typedef mpl::identity<BuiltIn2Udt> BuiltIn2UdtQ ;
|
||||
typedef mpl::identity<Udt2BuiltIn> Udt2BuiltInQ ;
|
||||
typedef mpl::identity<Udt2Udt > Udt2UdtQ ;
|
||||
|
||||
typedef typename get_udt_builtin_mixture<T,S>::type udt_builtin_mixture ;
|
||||
|
||||
typedef typename
|
||||
for_udt_builtin_mixture<udt_builtin_mixture, BuiltIn2BuiltInQ, BuiltIn2UdtQ, Udt2BuiltInQ, Udt2UdtQ>::type
|
||||
selected ;
|
||||
|
||||
typedef typename selected::type selected2 ;
|
||||
|
||||
typedef typename selected2::type type ;
|
||||
} ;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Top level implementation selector.
|
||||
//-------------------------------------------------------------------
|
||||
template<class T, class S>
|
||||
struct get_is_subranged
|
||||
{
|
||||
typedef get_subranged<T,S> non_trivial_case ;
|
||||
typedef mpl::identity<mpl::false_> trivial_case ;
|
||||
|
||||
typedef is_same<T,S> is_trivial ;
|
||||
|
||||
typedef typename mpl::if_<is_trivial,trivial_case,non_trivial_case>::type selected ;
|
||||
|
||||
typedef typename selected::type type ;
|
||||
} ;
|
||||
|
||||
} } } // namespace boost::numeric::convdetail
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -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_<value> 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<Value,Case0Val,Case1Val,Case2Val,Case0Type,Case1Type,Case2Type,DefaultType>::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<class Value,
|
||||
class Case0Val,
|
||||
class Case1Val,
|
||||
class Case2Val,
|
||||
class Case0Type,
|
||||
class Case1Type,
|
||||
class Case2Type,
|
||||
class DefaultType
|
||||
>
|
||||
struct ct_switch4
|
||||
{
|
||||
typedef mpl::identity<Case0Type> Case0TypeQ ;
|
||||
typedef mpl::identity<Case1Type> Case1TypeQ ;
|
||||
|
||||
typedef equal_to<Value,Case0Val> is_case0 ;
|
||||
typedef equal_to<Value,Case1Val> is_case1 ;
|
||||
typedef equal_to<Value,Case2Val> is_case2 ;
|
||||
|
||||
typedef mpl::if_<is_case2,Case2Type,DefaultType> choose_2_3Q ;
|
||||
typedef mpl::eval_if<is_case1,Case1TypeQ,choose_2_3Q> choose_1_2_3Q ;
|
||||
|
||||
typedef typename
|
||||
mpl::eval_if<is_case0,Case0TypeQ,choose_1_2_3Q>::type
|
||||
type ;
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
|
||||
// Metafunction:
|
||||
//
|
||||
// for_both<expr0,expr1,TT,TF,FT,FF>::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<class expr0, class expr1, class TT, class TF, class FT, class FF>
|
||||
struct for_both
|
||||
{
|
||||
typedef mpl::identity<TF> TF_Q ;
|
||||
typedef mpl::identity<TT> TT_Q ;
|
||||
|
||||
typedef typename mpl::not_<expr0>::type not_expr0 ;
|
||||
typedef typename mpl::not_<expr1>::type not_expr1 ;
|
||||
|
||||
typedef typename mpl::and_<expr0,expr1>::type caseTT ;
|
||||
typedef typename mpl::and_<expr0,not_expr1>::type caseTF ;
|
||||
typedef typename mpl::and_<not_expr0,expr1>::type caseFT ;
|
||||
|
||||
typedef mpl::if_<caseFT,FT,FF> choose_FT_FF_Q ;
|
||||
typedef mpl::eval_if<caseTF,TF_Q,choose_FT_FF_Q> choose_TF_FT_FF_Q ;
|
||||
|
||||
typedef typename mpl::eval_if<caseTT,TT_Q,choose_TF_FT_FF_Q>::type type ;
|
||||
} ;
|
||||
|
||||
} } } // namespace boost::numeric::convdetail
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -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
|
||||
// <boost/limits.hpp> 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 <boost/config.hpp>
|
||||
# include <cassert>
|
||||
# include <typeinfo>
|
||||
# include <boost/type.hpp>
|
||||
# include <boost/limits.hpp>
|
||||
# include <boost/numeric/conversion/converter_policies.hpp>
|
||||
|
||||
// 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<Target>* = 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 <class T>
|
||||
struct signed_numeric_limits : std::numeric_limits<T>
|
||||
{
|
||||
static inline T min BOOST_PREVENT_MACRO_SUBSTITUTION ()
|
||||
{
|
||||
return (std::numeric_limits<T>::min)() >= 0
|
||||
// unary minus causes integral promotion, thus the static_cast<>
|
||||
? static_cast<T>(-(std::numeric_limits<T>::max)())
|
||||
: (std::numeric_limits<T>::min)();
|
||||
};
|
||||
};
|
||||
|
||||
// Move to namespace boost in utility.hpp?
|
||||
template <class T, bool specialized>
|
||||
struct fixed_numeric_limits_base
|
||||
: public if_true< std::numeric_limits<T>::is_signed >
|
||||
::BOOST_NESTED_TEMPLATE then< signed_numeric_limits<T>,
|
||||
std::numeric_limits<T>
|
||||
>::type
|
||||
{};
|
||||
|
||||
template <class T>
|
||||
struct fixed_numeric_limits
|
||||
: fixed_numeric_limits_base<T,(std::numeric_limits<T>::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<X>::is_signed
|
||||
// y_is_signed should be numeric_limits<Y>::is_signed
|
||||
// y_min should be numeric_limits<Y>::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 <bool x_is_signed, bool y_is_signed>
|
||||
struct less_than_type_min
|
||||
{
|
||||
template <class X, class Y>
|
||||
static bool check(X x, Y y_min)
|
||||
{ return x < y_min; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct less_than_type_min<false, true>
|
||||
{
|
||||
template <class X, class Y>
|
||||
static bool check(X, Y)
|
||||
{ return false; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct less_than_type_min<true, false>
|
||||
{
|
||||
template <class X, class Y>
|
||||
static bool check(X x, Y)
|
||||
{ return x < 0; }
|
||||
};
|
||||
|
||||
// greater_than_type_max -
|
||||
// same_sign should be:
|
||||
// numeric_limits<X>::is_signed == numeric_limits<Y>::is_signed
|
||||
// y_max should be numeric_limits<Y>::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 <bool same_sign, bool x_is_signed>
|
||||
struct greater_than_type_max;
|
||||
|
||||
template<>
|
||||
struct greater_than_type_max<true, true>
|
||||
{
|
||||
template <class X, class Y>
|
||||
static inline bool check(X x, Y y_max)
|
||||
{ return x > y_max; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct greater_than_type_max<false, true>
|
||||
{
|
||||
// What does the standard say about this? I think it's right, and it
|
||||
// will work with every compiler I know of.
|
||||
template <class X, class Y>
|
||||
static inline bool check(X x, Y)
|
||||
{ return x >= 0 && static_cast<X>(static_cast<Y>(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<unsigned __int64>(x); \
|
||||
bool odd = y & 0x1; \
|
||||
__int64 div2 = static_cast<__int64>(y >> 1); \
|
||||
return ((static_cast<src_type>(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<true, false>
|
||||
{
|
||||
template <class X, class Y>
|
||||
static inline bool check(X x, Y y_max)
|
||||
{ return x > y_max; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct greater_than_type_max<false, false>
|
||||
{
|
||||
// What does the standard say about this? I think it's right, and it
|
||||
// will work with every compiler I know of.
|
||||
template <class X, class Y>
|
||||
static inline bool check(X x, Y)
|
||||
{ return static_cast<X>(static_cast<Y>(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 <class T>
|
||||
struct fixed_numeric_limits : public std::numeric_limits<T>
|
||||
{
|
||||
static inline T min BOOST_PREVENT_MACRO_SUBSTITUTION ()
|
||||
{
|
||||
return std::numeric_limits<T>::is_signed && (std::numeric_limits<T>::min)() >= 0
|
||||
? T(-(std::numeric_limits<T>::max)()) : (std::numeric_limits<T>::min)();
|
||||
}
|
||||
};
|
||||
|
||||
# if BOOST_MSVC
|
||||
# pragma warning(pop)
|
||||
#elif defined(__BORLANDC__)
|
||||
# pragma option pop
|
||||
# endif
|
||||
} // namespace detail
|
||||
|
||||
#endif
|
||||
|
||||
template<typename Target, typename Source>
|
||||
inline Target numeric_cast(Source arg BOOST_EXPLICIT_DEFAULT_TARGET)
|
||||
{
|
||||
// typedefs abbreviating respective trait classes
|
||||
typedef detail::fixed_numeric_limits<Source> arg_traits;
|
||||
typedef detail::fixed_numeric_limits<Target> 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<arg_is_signed, result_is_signed>::check(arg, (result_traits::min)())
|
||||
|| greater_than_type_max<same_sign, arg_is_signed>::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<Target>(arg);
|
||||
} // numeric_cast
|
||||
|
||||
# undef BOOST_EXPLICIT_DEFAULT_TARGET
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_OLD_NUMERIC_CAST_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<sign_mixture_enum, unsigned_to_unsigned> unsig2unsig_c ;
|
||||
typedef mpl::integral_c<sign_mixture_enum, signed_to_signed> sig2sig_c ;
|
||||
typedef mpl::integral_c<sign_mixture_enum, signed_to_unsigned> sig2unsig_c ;
|
||||
typedef mpl::integral_c<sign_mixture_enum, unsigned_to_signed> unsig2sig_c ;
|
||||
|
||||
// Metafunction:
|
||||
//
|
||||
// get_sign_mixture<T,S>::type
|
||||
//
|
||||
// Selects the appropriate SignMixture Integral Constant for the combination T,S.
|
||||
//
|
||||
template<class T,class S>
|
||||
struct get_sign_mixture
|
||||
{
|
||||
typedef mpl::bool_< ::std::numeric_limits<S>::is_signed > S_signed ;
|
||||
typedef mpl::bool_< ::std::numeric_limits<T>::is_signed > T_signed ;
|
||||
|
||||
typedef typename
|
||||
for_both<S_signed, T_signed, sig2sig_c, sig2unsig_c, unsig2sig_c, unsig2unsig_c>::type
|
||||
type ;
|
||||
} ;
|
||||
|
||||
// Metafunction:
|
||||
//
|
||||
// for_sign_mixture<SignMixture,Sig2Sig,Sig2Unsig,Unsig2Sig,Unsig2Unsig>::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<class SignMixture, class Sig2Sig, class Sig2Unsig, class Unsig2Sig, class Unsig2Unsig>
|
||||
struct for_sign_mixture
|
||||
{
|
||||
typedef typename
|
||||
ct_switch4<SignMixture
|
||||
, sig2sig_c, sig2unsig_c, unsig2sig_c // default
|
||||
, Sig2Sig , Sig2Unsig , Unsig2Sig , Unsig2Unsig
|
||||
>::type
|
||||
type ;
|
||||
} ;
|
||||
|
||||
} } } // namespace boost::numeric::convdetail
|
||||
|
||||
#endif
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@@ -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<udt_builtin_mixture_enum, builtin_to_builtin> builtin2builtin_c ;
|
||||
typedef mpl::integral_c<udt_builtin_mixture_enum, builtin_to_udt> builtin2udt_c ;
|
||||
typedef mpl::integral_c<udt_builtin_mixture_enum, udt_to_builtin> udt2builtin_c ;
|
||||
typedef mpl::integral_c<udt_builtin_mixture_enum, udt_to_udt> udt2udt_c ;
|
||||
|
||||
// Metafunction:
|
||||
//
|
||||
// for_udt_mixture<UdtMixture,BuiltIn2BuiltIn,BuiltIn2Udt,Udt2BuiltIn,Udt2Udt>::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<class UdtMixture, class BuiltIn2BuiltIn, class BuiltIn2Udt, class Udt2BuiltIn, class Udt2Udt>
|
||||
struct for_udt_builtin_mixture
|
||||
{
|
||||
typedef typename
|
||||
ct_switch4<UdtMixture
|
||||
, builtin2builtin_c, builtin2udt_c, udt2builtin_c // default
|
||||
, BuiltIn2BuiltIn , BuiltIn2Udt , Udt2BuiltIn , Udt2Udt
|
||||
>::type
|
||||
type ;
|
||||
} ;
|
||||
|
||||
// Metafunction:
|
||||
//
|
||||
// get_udt_mixture<T,S>::type
|
||||
//
|
||||
// Selects the appropriate UdtMixture Integral Constant for the combination T,S.
|
||||
//
|
||||
template<class T,class S>
|
||||
struct get_udt_builtin_mixture
|
||||
{
|
||||
typedef is_arithmetic<S> S_builtin ;
|
||||
typedef is_arithmetic<T> T_builtin ;
|
||||
|
||||
typedef typename
|
||||
for_both<S_builtin, T_builtin, builtin2builtin_c, builtin2udt_c, udt2builtin_c, udt2udt_c>::type
|
||||
type ;
|
||||
} ;
|
||||
|
||||
} } } // namespace boost::numeric::convdetail
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -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<class T, class S>
|
||||
struct int_float_mixture
|
||||
: convdetail::get_int_float_mixture< BOOST_DEDUCED_TYPENAME remove_cv<T>::type
|
||||
,BOOST_DEDUCED_TYPENAME remove_cv<S>::type
|
||||
>::type {} ;
|
||||
|
||||
} } // namespace boost::numeric
|
||||
|
||||
#endif
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@@ -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
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@@ -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<class T, class S>
|
||||
struct is_subranged
|
||||
: convdetail::get_is_subranged< BOOST_DEDUCED_TYPENAME remove_cv<T>::type
|
||||
,BOOST_DEDUCED_TYPENAME remove_cv<S>::type
|
||||
>::type {} ;
|
||||
|
||||
} } // namespace boost::numeric
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -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<class T, class S>
|
||||
struct sign_mixture
|
||||
: convdetail::get_sign_mixture< BOOST_DEDUCED_TYPENAME remove_cv<T>::type
|
||||
,BOOST_DEDUCED_TYPENAME remove_cv<S>::type
|
||||
>::type {} ;
|
||||
|
||||
} } // namespace boost::numeric
|
||||
|
||||
#endif
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@@ -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
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@@ -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<class T, class S>
|
||||
struct udt_builtin_mixture
|
||||
: convdetail::get_udt_builtin_mixture< BOOST_DEDUCED_TYPENAME remove_cv<T>::type
|
||||
,BOOST_DEDUCED_TYPENAME remove_cv<S>::type
|
||||
>::type {} ;
|
||||
|
||||
} } // namespace boost::numeric
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
32
project/jni/boost/include/boost/numeric/interval.hpp
Normal file
32
project/jni/boost/include/boost/numeric/interval.hpp
Normal file
@@ -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 <boost/limits.hpp>
|
||||
#include <boost/numeric/interval/interval.hpp>
|
||||
#include <boost/numeric/interval/policies.hpp>
|
||||
|
||||
#include <boost/numeric/interval/hw_rounding.hpp>
|
||||
#include <boost/numeric/interval/rounded_arith.hpp>
|
||||
#include <boost/numeric/interval/rounded_transc.hpp>
|
||||
#include <boost/numeric/interval/constants.hpp>
|
||||
|
||||
#include <boost/numeric/interval/checking.hpp>
|
||||
#include <boost/numeric/interval/compare.hpp>
|
||||
#include <boost/numeric/interval/utility.hpp>
|
||||
|
||||
#include <boost/numeric/interval/arith.hpp>
|
||||
#include <boost/numeric/interval/arith2.hpp>
|
||||
#include <boost/numeric/interval/arith3.hpp>
|
||||
#include <boost/numeric/interval/transc.hpp>
|
||||
|
||||
#endif // BOOST_NUMERIC_INTERVAL_HPP
|
||||
305
project/jni/boost/include/boost/numeric/interval/arith.hpp
Normal file
305
project/jni/boost/include/boost/numeric/interval/arith.hpp
Normal file
@@ -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 <boost/config.hpp>
|
||||
#include <boost/numeric/interval/interval.hpp>
|
||||
#include <boost/numeric/interval/detail/bugs.hpp>
|
||||
#include <boost/numeric/interval/detail/test_input.hpp>
|
||||
#include <boost/numeric/interval/detail/division.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
namespace boost {
|
||||
namespace numeric {
|
||||
|
||||
/*
|
||||
* Basic arithmetic operators
|
||||
*/
|
||||
|
||||
template<class T, class Policies> inline
|
||||
const interval<T, Policies>& operator+(const interval<T, Policies>& x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> operator-(const interval<T, Policies>& x)
|
||||
{
|
||||
if (interval_lib::detail::test_input(x))
|
||||
return interval<T, Policies>::empty();
|
||||
return interval<T, Policies>(-x.upper(), -x.lower(), true);
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies>& interval<T, Policies>::operator+=(const interval<T, Policies>& 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<class T, class Policies> inline
|
||||
interval<T, Policies>& interval<T, Policies>::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<class T, class Policies> inline
|
||||
interval<T, Policies>& interval<T, Policies>::operator-=(const interval<T, Policies>& 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<class T, class Policies> inline
|
||||
interval<T, Policies>& interval<T, Policies>::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<class T, class Policies> inline
|
||||
interval<T, Policies>& interval<T, Policies>::operator*=(const interval<T, Policies>& r)
|
||||
{
|
||||
return *this = *this * r;
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies>& interval<T, Policies>::operator*=(const T& r)
|
||||
{
|
||||
return *this = r * *this;
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies>& interval<T, Policies>::operator/=(const interval<T, Policies>& r)
|
||||
{
|
||||
return *this = *this / r;
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies>& interval<T, Policies>::operator/=(const T& r)
|
||||
{
|
||||
return *this = *this / r;
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> operator+(const interval<T, Policies>& x,
|
||||
const interval<T, Policies>& y)
|
||||
{
|
||||
if (interval_lib::detail::test_input(x, y))
|
||||
return interval<T, Policies>::empty();
|
||||
typename Policies::rounding rnd;
|
||||
return interval<T,Policies>(rnd.add_down(x.lower(), y.lower()),
|
||||
rnd.add_up (x.upper(), y.upper()), true);
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> operator+(const T& x, const interval<T, Policies>& y)
|
||||
{
|
||||
if (interval_lib::detail::test_input(x, y))
|
||||
return interval<T, Policies>::empty();
|
||||
typename Policies::rounding rnd;
|
||||
return interval<T,Policies>(rnd.add_down(x, y.lower()),
|
||||
rnd.add_up (x, y.upper()), true);
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> operator+(const interval<T, Policies>& x, const T& y)
|
||||
{ return y + x; }
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> operator-(const interval<T, Policies>& x,
|
||||
const interval<T, Policies>& y)
|
||||
{
|
||||
if (interval_lib::detail::test_input(x, y))
|
||||
return interval<T, Policies>::empty();
|
||||
typename Policies::rounding rnd;
|
||||
return interval<T,Policies>(rnd.sub_down(x.lower(), y.upper()),
|
||||
rnd.sub_up (x.upper(), y.lower()), true);
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> operator-(const T& x, const interval<T, Policies>& y)
|
||||
{
|
||||
if (interval_lib::detail::test_input(x, y))
|
||||
return interval<T, Policies>::empty();
|
||||
typename Policies::rounding rnd;
|
||||
return interval<T,Policies>(rnd.sub_down(x, y.upper()),
|
||||
rnd.sub_up (x, y.lower()), true);
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> operator-(const interval<T, Policies>& x, const T& y)
|
||||
{
|
||||
if (interval_lib::detail::test_input(x, y))
|
||||
return interval<T, Policies>::empty();
|
||||
typename Policies::rounding rnd;
|
||||
return interval<T,Policies>(rnd.sub_down(x.lower(), y),
|
||||
rnd.sub_up (x.upper(), y), true);
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> operator*(const interval<T, Policies>& x,
|
||||
const interval<T, Policies>& y)
|
||||
{
|
||||
BOOST_USING_STD_MIN();
|
||||
BOOST_USING_STD_MAX();
|
||||
typedef interval<T, Policies> 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<T>(0), static_cast<T>(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<T>(0), static_cast<T>(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<T>(0), static_cast<T>(0), true);
|
||||
else // Z * ?
|
||||
return I(static_cast<T>(0), static_cast<T>(0), true);
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> operator*(const T& x, const interval<T, Policies>& y)
|
||||
{
|
||||
typedef interval<T, Policies> 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<T>(0), static_cast<T>(0), true);
|
||||
else
|
||||
return I(rnd.mul_down(x, yl), rnd.mul_up(x, yu), true);
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> operator*(const interval<T, Policies>& x, const T& y)
|
||||
{ return y * x; }
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> operator/(const interval<T, Policies>& x,
|
||||
const interval<T, Policies>& y)
|
||||
{
|
||||
if (interval_lib::detail::test_input(x, y))
|
||||
return interval<T, Policies>::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<T, Policies>::empty();
|
||||
else
|
||||
return interval_lib::detail::div_non_zero(x, y);
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> operator/(const T& x, const interval<T, Policies>& y)
|
||||
{
|
||||
if (interval_lib::detail::test_input(x, y))
|
||||
return interval<T, Policies>::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<T, Policies>(x);
|
||||
else
|
||||
return interval_lib::detail::div_negative<T, Policies>(x, y.lower());
|
||||
else
|
||||
if (!interval_lib::user::is_zero(y.upper()))
|
||||
return interval_lib::detail::div_positive<T, Policies>(x, y.upper());
|
||||
else
|
||||
return interval<T, Policies>::empty();
|
||||
else
|
||||
return interval_lib::detail::div_non_zero(x, y);
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> operator/(const interval<T, Policies>& x, const T& y)
|
||||
{
|
||||
if (interval_lib::detail::test_input(x, y) || interval_lib::user::is_zero(y))
|
||||
return interval<T, Policies>::empty();
|
||||
typename Policies::rounding rnd;
|
||||
const T& xl = x.lower();
|
||||
const T& xu = x.upper();
|
||||
if (interval_lib::user::is_neg(y))
|
||||
return interval<T, Policies>(rnd.div_down(xu, y), rnd.div_up(xl, y), true);
|
||||
else
|
||||
return interval<T, Policies>(rnd.div_down(xl, y), rnd.div_up(xu, y), true);
|
||||
}
|
||||
|
||||
} // namespace numeric
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_NUMERIC_INTERVAL_ARITH_HPP
|
||||
305
project/jni/boost/include/boost/numeric/interval/arith2.hpp
Normal file
305
project/jni/boost/include/boost/numeric/interval/arith2.hpp
Normal file
@@ -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 <boost/config.hpp>
|
||||
#include <boost/numeric/interval/detail/interval_prototype.hpp>
|
||||
#include <boost/numeric/interval/detail/test_input.hpp>
|
||||
#include <boost/numeric/interval/detail/bugs.hpp>
|
||||
#include <boost/numeric/interval/detail/division.hpp>
|
||||
#include <boost/numeric/interval/arith.hpp>
|
||||
#include <boost/numeric/interval/policies.hpp>
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <boost/config/no_tr1/cmath.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace numeric {
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> fmod(const interval<T, Policies>& x,
|
||||
const interval<T, Policies>& y)
|
||||
{
|
||||
if (interval_lib::detail::test_input(x, y))
|
||||
return interval<T, Policies>::empty();
|
||||
typename Policies::rounding rnd;
|
||||
typedef typename interval_lib::unprotect<interval<T, Policies> >::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<class T, class Policies> inline
|
||||
interval<T, Policies> fmod(const interval<T, Policies>& x, const T& y)
|
||||
{
|
||||
if (interval_lib::detail::test_input(x, y))
|
||||
return interval<T, Policies>::empty();
|
||||
typename Policies::rounding rnd;
|
||||
typedef typename interval_lib::unprotect<interval<T, Policies> >::type I;
|
||||
T n = rnd.int_down(rnd.div_down(x.lower(), y));
|
||||
return (const I&)x - n * I(y);
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> fmod(const T& x, const interval<T, Policies>& y)
|
||||
{
|
||||
if (interval_lib::detail::test_input(x, y))
|
||||
return interval<T, Policies>::empty();
|
||||
typename Policies::rounding rnd;
|
||||
typedef typename interval_lib::unprotect<interval<T, Policies> >::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<class T, class Policies> inline
|
||||
interval<T, Policies> division_part1(const interval<T, Policies>& x,
|
||||
const interval<T, Policies>& y, bool& b)
|
||||
{
|
||||
typedef interval<T, Policies> 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<class T, class Policies> inline
|
||||
interval<T, Policies> division_part2(const interval<T, Policies>& x,
|
||||
const interval<T, Policies>& y, bool b = true)
|
||||
{
|
||||
if (!b) return interval<T, Policies>::empty();
|
||||
return detail::div_zero_part2(x, y);
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> multiplicative_inverse(const interval<T, Policies>& x)
|
||||
{
|
||||
typedef interval<T, Policies> I;
|
||||
if (detail::test_input(x))
|
||||
return I::empty();
|
||||
T one = static_cast<T>(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<class T, class Rounding> 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<T>(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<class T, class Rounding> 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<T>(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<class T, class Policies> inline
|
||||
interval<T, Policies> pow(const interval<T, Policies>& x, int pwr)
|
||||
{
|
||||
BOOST_USING_STD_MAX();
|
||||
using interval_lib::detail::pow_dn;
|
||||
using interval_lib::detail::pow_up;
|
||||
typedef interval<T, Policies> 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<T>(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<T>(-x.upper()), pwr, rnd);
|
||||
T yu = pow_up(static_cast<T>(-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(-x.lower(), pwr, rnd), pow_up(x.upper(), pwr, rnd), true);
|
||||
} else { // [-1,1]^2
|
||||
return I(static_cast<T>(0), pow_up(max BOOST_PREVENT_MACRO_SUBSTITUTION(static_cast<T>(-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<class T, class Policies> inline
|
||||
interval<T, Policies> sqrt(const interval<T, Policies>& x)
|
||||
{
|
||||
typedef interval<T, Policies> 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<T>(0) : rnd.sqrt_down(x.lower());
|
||||
return I(l, rnd.sqrt_up(x.upper()), true);
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> square(const interval<T, Policies>& x)
|
||||
{
|
||||
typedef interval<T, Policies> 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<T>(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<T>(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<I>(x, k).lower();
|
||||
if (x == one) return one;
|
||||
return rnd.div_down(one, root_aux<I>(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<I>(x, k).upper();
|
||||
if (x == one) return one;
|
||||
return rnd.div_up(one, root_aux<I>(rnd.div_down(one, x), k).lower());
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace interval_lib
|
||||
|
||||
template< class T, class Policies > inline
|
||||
interval<T, Policies> nth_root(interval<T, Policies> const &x, int k)
|
||||
{
|
||||
typedef interval<T, Policies> 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<I>::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<R>(-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<R>(-x.lower(), k),
|
||||
-interval_lib::detail::root_aux_dn<R>(-x.upper(), k), true);
|
||||
}
|
||||
}
|
||||
T u = interval_lib::detail::root_aux_up<R>(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<T>(0), u, true);
|
||||
else // [-1,1]^/3
|
||||
return I(-interval_lib::detail::root_aux_up<R>(-x.lower(), k), u, true);
|
||||
else // [1,2]
|
||||
return I(interval_lib::detail::root_aux_dn<R>(x.lower(), k), u, true);
|
||||
}
|
||||
|
||||
} // namespace numeric
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_NUMERIC_INTERVAL_ARITH2_HPP
|
||||
69
project/jni/boost/include/boost/numeric/interval/arith3.hpp
Normal file
69
project/jni/boost/include/boost/numeric/interval/arith3.hpp
Normal file
@@ -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 <boost/numeric/interval/detail/interval_prototype.hpp>
|
||||
#include <boost/numeric/interval/detail/test_input.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace numeric {
|
||||
namespace interval_lib {
|
||||
|
||||
template<class I> 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<typename I::base_type, Policies>(x, y))
|
||||
return I::empty();
|
||||
typename Policies::rounding rnd;
|
||||
return I(rnd.add_down(x, y), rnd.add_up(x, y), true);
|
||||
}
|
||||
|
||||
template<class I> 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<typename I::base_type, Policies>(x, y))
|
||||
return I::empty();
|
||||
typename Policies::rounding rnd;
|
||||
return I(rnd.sub_down(x, y), rnd.sub_up(x, y), true);
|
||||
}
|
||||
|
||||
template<class I> 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<typename I::base_type, Policies>(x, y))
|
||||
return I::empty();
|
||||
typename Policies::rounding rnd;
|
||||
return I(rnd.mul_down(x, y), rnd.mul_up(x, y), true);
|
||||
}
|
||||
|
||||
template<class I> 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<typename I::base_type, Policies>(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
|
||||
130
project/jni/boost/include/boost/numeric/interval/checking.hpp
Normal file
130
project/jni/boost/include/boost/numeric/interval/checking.hpp
Normal file
@@ -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 <stdexcept>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
#include <boost/limits.hpp>
|
||||
|
||||
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<class T>
|
||||
struct checking_base
|
||||
{
|
||||
static T pos_inf()
|
||||
{
|
||||
assert(std::numeric_limits<T>::has_infinity);
|
||||
return std::numeric_limits<T>::infinity();
|
||||
}
|
||||
static T neg_inf()
|
||||
{
|
||||
assert(std::numeric_limits<T>::has_infinity);
|
||||
return -std::numeric_limits<T>::infinity();
|
||||
}
|
||||
static T nan()
|
||||
{
|
||||
assert(std::numeric_limits<T>::has_quiet_NaN);
|
||||
return std::numeric_limits<T>::quiet_NaN();
|
||||
}
|
||||
static bool is_nan(const T& x)
|
||||
{
|
||||
return std::numeric_limits<T>::has_quiet_NaN && (x != x);
|
||||
}
|
||||
static T empty_lower()
|
||||
{
|
||||
return (std::numeric_limits<T>::has_quiet_NaN ?
|
||||
std::numeric_limits<T>::quiet_NaN() : static_cast<T>(1));
|
||||
}
|
||||
static T empty_upper()
|
||||
{
|
||||
return (std::numeric_limits<T>::has_quiet_NaN ?
|
||||
std::numeric_limits<T>::quiet_NaN() : static_cast<T>(0));
|
||||
}
|
||||
static bool is_empty(const T& l, const T& u)
|
||||
{
|
||||
return !(l <= u); // safety for partial orders
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, class Checking = checking_base<T>,
|
||||
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<class T, class Checking = checking_base<T> >
|
||||
struct checking_no_nan: Checking
|
||||
{
|
||||
static bool is_nan(const T&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, class Checking = checking_base<T>,
|
||||
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<class T>
|
||||
struct checking_strict:
|
||||
checking_no_nan<T, checking_no_empty<T> >
|
||||
{};
|
||||
|
||||
} // namespace interval_lib
|
||||
} // namespace numeric
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_NUMERIC_INTERVAL_CHECKING_HPP
|
||||
19
project/jni/boost/include/boost/numeric/interval/compare.hpp
Normal file
19
project/jni/boost/include/boost/numeric/interval/compare.hpp
Normal file
@@ -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 <boost/numeric/interval/compare/certain.hpp>
|
||||
#include <boost/numeric/interval/compare/possible.hpp>
|
||||
#include <boost/numeric/interval/compare/explicit.hpp>
|
||||
#include <boost/numeric/interval/compare/lexicographic.hpp>
|
||||
#include <boost/numeric/interval/compare/set.hpp>
|
||||
|
||||
#endif // BOOST_NUMERIC_INTERVAL_COMPARE_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 <boost/numeric/interval/detail/interval_prototype.hpp>
|
||||
#include <boost/numeric/interval/detail/test_input.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace numeric {
|
||||
namespace interval_lib {
|
||||
namespace compare {
|
||||
namespace certain {
|
||||
|
||||
template<class T, class Policies1, class Policies2> inline
|
||||
bool operator<(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
|
||||
{
|
||||
if (detail::test_input(x, y)) throw comparison_error();
|
||||
return x.upper() < y.lower();
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool operator<(const interval<T, Policies>& x, const T& y)
|
||||
{
|
||||
if (detail::test_input(x, y)) throw comparison_error();
|
||||
return x.upper() < y;
|
||||
}
|
||||
|
||||
template<class T, class Policies1, class Policies2> inline
|
||||
bool operator<=(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
|
||||
{
|
||||
if (detail::test_input(x, y)) throw comparison_error();
|
||||
return x.upper() <= y.lower();
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool operator<=(const interval<T, Policies>& x, const T& y)
|
||||
{
|
||||
if (detail::test_input(x, y)) throw comparison_error();
|
||||
return x.upper() <= y;
|
||||
}
|
||||
|
||||
template<class T, class Policies1, class Policies2> inline
|
||||
bool operator>(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
|
||||
{
|
||||
if (detail::test_input(x, y)) throw comparison_error();
|
||||
return x.lower() > y.upper();
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool operator>(const interval<T, Policies>& x, const T& y)
|
||||
{
|
||||
if (detail::test_input(x, y)) throw comparison_error();
|
||||
return x.lower() > y;
|
||||
}
|
||||
|
||||
template<class T, class Policies1, class Policies2> inline
|
||||
bool operator>=(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
|
||||
{
|
||||
if (detail::test_input(x, y)) throw comparison_error();
|
||||
return x.lower() >= y.upper();
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool operator>=(const interval<T, Policies>& x, const T& y)
|
||||
{
|
||||
if (detail::test_input(x, y)) throw comparison_error();
|
||||
return x.lower() >= y;
|
||||
}
|
||||
|
||||
template<class T, class Policies1, class Policies2> inline
|
||||
bool operator==(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
|
||||
{
|
||||
if (detail::test_input(x, y)) throw comparison_error();
|
||||
return x.upper() == y.lower() && x.lower() == y.upper();
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool operator==(const interval<T, Policies>& x, const T& y)
|
||||
{
|
||||
if (detail::test_input(x, y)) throw comparison_error();
|
||||
return x.upper() == y && x.lower() == y;
|
||||
}
|
||||
|
||||
template<class T, class Policies1, class Policies2> inline
|
||||
bool operator!=(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
|
||||
{
|
||||
if (detail::test_input(x, y)) throw comparison_error();
|
||||
return x.upper() < y.lower() || x.lower() > y.upper();
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool operator!=(const interval<T, Policies>& 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
|
||||
@@ -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 <boost/numeric/interval/detail/interval_prototype.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace numeric {
|
||||
namespace interval_lib {
|
||||
|
||||
/*
|
||||
* Certainly... operations
|
||||
*/
|
||||
|
||||
template<class T, class Policies1, class Policies2> inline
|
||||
bool cerlt(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
|
||||
{
|
||||
return x.upper() < y.lower();
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool cerlt(const interval<T, Policies>& x, const T& y)
|
||||
{
|
||||
return x.upper() < y;
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool cerlt(const T& x, const interval<T, Policies>& y)
|
||||
{
|
||||
return x < y.lower();
|
||||
}
|
||||
|
||||
template<class T, class Policies1, class Policies2> inline
|
||||
bool cerle(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
|
||||
{
|
||||
return x.upper() <= y.lower();
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool cerle(const interval<T, Policies>& x, const T& y)
|
||||
{
|
||||
return x.upper() <= y;
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool cerle(const T& x, const interval<T, Policies>& y)
|
||||
{
|
||||
return x <= y.lower();
|
||||
}
|
||||
|
||||
template<class T, class Policies1, class Policies2> inline
|
||||
bool cergt(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
|
||||
{
|
||||
return x.lower() > y.upper();
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool cergt(const interval<T, Policies>& x, const T& y)
|
||||
{
|
||||
return x.lower() > y;
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool cergt(const T& x, const interval<T, Policies>& y)
|
||||
{
|
||||
return x > y.upper();
|
||||
}
|
||||
|
||||
template<class T, class Policies1, class Policies2> inline
|
||||
bool cerge(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
|
||||
{
|
||||
return x.lower() >= y.upper();
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool cerge(const interval<T, Policies>& x, const T& y)
|
||||
{
|
||||
return x.lower() >= y;
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool cerge(const T& x, const interval<T, Policies>& y)
|
||||
{
|
||||
return x >= y.upper();
|
||||
}
|
||||
|
||||
template<class T, class Policies1, class Policies2> inline
|
||||
bool cereq(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
|
||||
{
|
||||
return x.lower() == y.upper() && y.lower() == x.upper();
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool cereq(const interval<T, Policies>& x, const T& y)
|
||||
{
|
||||
return x.lower() == y && x.upper() == y;
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool cereq(const T& x, const interval<T, Policies>& y)
|
||||
{
|
||||
return x == y.lower() && x == y.upper();
|
||||
}
|
||||
|
||||
template<class T, class Policies1, class Policies2> inline
|
||||
bool cerne(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
|
||||
{
|
||||
return x.upper() < y.lower() || y.upper() < x.lower();
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool cerne(const interval<T, Policies>& x, const T& y)
|
||||
{
|
||||
return x.upper() < y || y < x.lower();
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool cerne(const T& x, const interval<T, Policies>& y)
|
||||
{
|
||||
return x < y.lower() || y.upper() < x;
|
||||
}
|
||||
|
||||
/*
|
||||
* Possibly... comparisons
|
||||
*/
|
||||
|
||||
template<class T, class Policies1, class Policies2> inline
|
||||
bool poslt(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
|
||||
{
|
||||
return x.lower() < y.upper();
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool poslt(const interval<T, Policies>& x, const T& y)
|
||||
{
|
||||
return x.lower() < y;
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool poslt(const T& x, const interval<T, Policies>& y)
|
||||
{
|
||||
return x < y.upper();
|
||||
}
|
||||
|
||||
template<class T, class Policies1, class Policies2> inline
|
||||
bool posle(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
|
||||
{
|
||||
return x.lower() <= y.upper();
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool posle(const interval<T, Policies>& x, const T& y)
|
||||
{
|
||||
return x.lower() <= y;
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool posle(const T& x, const interval<T, Policies>& y)
|
||||
{
|
||||
return x <= y.upper();
|
||||
}
|
||||
|
||||
template<class T, class Policies1, class Policies2> inline
|
||||
bool posgt(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
|
||||
{
|
||||
return x.upper() > y.lower();
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool posgt(const interval<T, Policies>& x, const T& y)
|
||||
{
|
||||
return x.upper() > y;
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool posgt(const T& x, const interval<T, Policies> & y)
|
||||
{
|
||||
return x > y.lower();
|
||||
}
|
||||
|
||||
template<class T, class Policies1, class Policies2> inline
|
||||
bool posge(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
|
||||
{
|
||||
return x.upper() >= y.lower();
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool posge(const interval<T, Policies>& x, const T& y)
|
||||
{
|
||||
return x.upper() >= y;
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool posge(const T& x, const interval<T, Policies>& y)
|
||||
{
|
||||
return x >= y.lower();
|
||||
}
|
||||
|
||||
template<class T, class Policies1, class Policies2> inline
|
||||
bool poseq(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
|
||||
{
|
||||
return x.upper() >= y.lower() && y.upper() >= x.lower();
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool poseq(const interval<T, Policies>& x, const T& y)
|
||||
{
|
||||
return x.upper() >= y && y >= x.lower();
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool poseq(const T& x, const interval<T, Policies>& y)
|
||||
{
|
||||
return x >= y.lower() && y.upper() >= x;
|
||||
}
|
||||
|
||||
template<class T, class Policies1, class Policies2> inline
|
||||
bool posne(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
|
||||
{
|
||||
return x.upper() != y.lower() || y.upper() != x.lower();
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool posne(const interval<T, Policies>& x, const T& y)
|
||||
{
|
||||
return x.upper() != y || y != x.lower();
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool posne(const T& x, const interval<T, Policies>& y)
|
||||
{
|
||||
return x != y.lower() || y.upper() != x;
|
||||
}
|
||||
|
||||
} // namespace interval_lib
|
||||
} // namespace numeric
|
||||
} //namespace boost
|
||||
|
||||
#endif // BOOST_NUMERIC_INTERVAL_COMPARE_EXPLICIT_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 <boost/numeric/interval/detail/interval_prototype.hpp>
|
||||
#include <boost/numeric/interval/detail/test_input.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace numeric {
|
||||
namespace interval_lib {
|
||||
namespace compare {
|
||||
namespace lexicographic {
|
||||
|
||||
template<class T, class Policies1, class Policies2> inline
|
||||
bool operator<(const interval<T, Policies1>& x, const interval<T, Policies2>& 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<class T, class Policies> inline
|
||||
bool operator<(const interval<T, Policies>& x, const T& y)
|
||||
{
|
||||
if (detail::test_input(x, y)) throw comparison_error();
|
||||
return x.lower() < y;
|
||||
}
|
||||
|
||||
template<class T, class Policies1, class Policies2> inline
|
||||
bool operator<=(const interval<T, Policies1>& x, const interval<T, Policies2>& 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<class T, class Policies> inline
|
||||
bool operator<=(const interval<T, Policies>& 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<class T, class Policies1, class Policies2> inline
|
||||
bool operator>(const interval<T, Policies1>& x, const interval<T, Policies2>& 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<class T, class Policies> inline
|
||||
bool operator>(const interval<T, Policies>& 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<class T, class Policies1, class Policies2> inline
|
||||
bool operator>=(const interval<T, Policies1>& x, const interval<T, Policies2>& 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<class T, class Policies> inline
|
||||
bool operator>=(const interval<T, Policies>& x, const T& y)
|
||||
{
|
||||
if (detail::test_input(x, y)) throw comparison_error();
|
||||
return x.lower() >= y;
|
||||
}
|
||||
|
||||
template<class T, class Policies1, class Policies2> inline
|
||||
bool operator==(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
|
||||
{
|
||||
if (detail::test_input(x, y)) throw comparison_error();
|
||||
return x.lower() == y.lower() && x.upper() == y.upper();
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool operator==(const interval<T, Policies>& x, const T& y)
|
||||
{
|
||||
if (detail::test_input(x, y)) throw comparison_error();
|
||||
return x.lower() == y && x.upper() == y;
|
||||
}
|
||||
|
||||
template<class T, class Policies1, class Policies2> inline
|
||||
bool operator!=(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
|
||||
{
|
||||
if (detail::test_input(x, y)) throw comparison_error();
|
||||
return x.lower() != y.lower() || x.upper() != y.upper();
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool operator!=(const interval<T, Policies>& 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
|
||||
@@ -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 <boost/numeric/interval/detail/interval_prototype.hpp>
|
||||
#include <boost/numeric/interval/detail/test_input.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace numeric {
|
||||
namespace interval_lib {
|
||||
namespace compare {
|
||||
namespace possible {
|
||||
|
||||
template<class T, class Policies1, class Policies2> inline
|
||||
bool operator<(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
|
||||
{
|
||||
if (detail::test_input(x, y)) throw comparison_error();
|
||||
return x.lower() < y.upper();
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool operator<(const interval<T, Policies>& x, const T& y)
|
||||
{
|
||||
if (detail::test_input(x, y)) throw comparison_error();
|
||||
return x.lower() < y;
|
||||
}
|
||||
|
||||
template<class T, class Policies1, class Policies2> inline
|
||||
bool operator<=(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
|
||||
{
|
||||
if (detail::test_input(x, y)) throw comparison_error();
|
||||
return x.lower() <= y.upper();
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool operator<=(const interval<T, Policies>& x, const T& y)
|
||||
{
|
||||
if (detail::test_input(x, y)) throw comparison_error();
|
||||
return x.lower() <= y;
|
||||
}
|
||||
|
||||
template<class T, class Policies1, class Policies2> inline
|
||||
bool operator>(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
|
||||
{
|
||||
if (detail::test_input(x, y)) throw comparison_error();
|
||||
return x.upper() > y.lower();
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool operator>(const interval<T, Policies>& x, const T& y)
|
||||
{
|
||||
if (detail::test_input(x, y)) throw comparison_error();
|
||||
return x.upper() > y;
|
||||
}
|
||||
|
||||
template<class T, class Policies1, class Policies2> inline
|
||||
bool operator>=(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
|
||||
{
|
||||
if (detail::test_input(x, y)) throw comparison_error();
|
||||
return x.upper() >= y.lower();
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool operator>=(const interval<T, Policies>& x, const T& y)
|
||||
{
|
||||
if (detail::test_input(x, y)) throw comparison_error();
|
||||
return x.upper() >= y;
|
||||
}
|
||||
|
||||
template<class T, class Policies1, class Policies2> inline
|
||||
bool operator==(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
|
||||
{
|
||||
if (detail::test_input(x, y)) throw comparison_error();
|
||||
return x.lower() <= y.upper() && x.upper() >= y.lower();
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool operator==(const interval<T, Policies>& x, const T& y)
|
||||
{
|
||||
if (detail::test_input(x, y)) throw comparison_error();
|
||||
return x.lower() <= y && x.upper() >= y;
|
||||
}
|
||||
|
||||
template<class T, class Policies1, class Policies2> inline
|
||||
bool operator!=(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
|
||||
{
|
||||
if (detail::test_input(x, y)) throw comparison_error();
|
||||
return x.lower() != y.upper() || x.upper() != y.lower();
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool operator!=(const interval<T, Policies>& 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
|
||||
101
project/jni/boost/include/boost/numeric/interval/compare/set.hpp
Normal file
101
project/jni/boost/include/boost/numeric/interval/compare/set.hpp
Normal file
@@ -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 <boost/numeric/interval/detail/interval_prototype.hpp>
|
||||
#include <boost/numeric/interval/detail/test_input.hpp>
|
||||
#include <boost/numeric/interval/utility.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace numeric {
|
||||
namespace interval_lib {
|
||||
namespace compare {
|
||||
namespace set {
|
||||
|
||||
template<class T, class Policies1, class Policies2> inline
|
||||
bool operator<(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
|
||||
{
|
||||
return proper_subset(x, y);
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool operator<(const interval<T, Policies>& x, const T& y)
|
||||
{
|
||||
throw comparison_error();
|
||||
}
|
||||
|
||||
template<class T, class Policies1, class Policies2> inline
|
||||
bool operator<=(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
|
||||
{
|
||||
return subset(x, y);
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool operator<=(const interval<T, Policies>& x, const T& y)
|
||||
{
|
||||
throw comparison_error();
|
||||
}
|
||||
|
||||
template<class T, class Policies1, class Policies2> inline
|
||||
bool operator>(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
|
||||
{
|
||||
return proper_subset(y, x);
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool operator>(const interval<T, Policies>& x, const T& y)
|
||||
{
|
||||
throw comparison_error();
|
||||
}
|
||||
|
||||
template<class T, class Policies1, class Policies2> inline
|
||||
bool operator>=(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
|
||||
{
|
||||
return subset(y, x);
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool operator>=(const interval<T, Policies>& x, const T& y)
|
||||
{
|
||||
throw comparison_error();
|
||||
}
|
||||
|
||||
template<class T, class Policies1, class Policies2> inline
|
||||
bool operator==(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
|
||||
{
|
||||
return equal(y, x);
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool operator==(const interval<T, Policies>& x, const T& y)
|
||||
{
|
||||
throw comparison_error();
|
||||
}
|
||||
|
||||
template<class T, class Policies1, class Policies2> inline
|
||||
bool operator!=(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
|
||||
{
|
||||
return !equal(y, x);
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool operator!=(const interval<T, Policies>& 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
|
||||
@@ -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 <boost/numeric/interval/detail/interval_prototype.hpp>
|
||||
#include <boost/numeric/interval/detail/test_input.hpp>
|
||||
#include <boost/logic/tribool.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace numeric {
|
||||
namespace interval_lib {
|
||||
namespace compare {
|
||||
namespace tribool {
|
||||
|
||||
template<class T, class Policies1, class Policies2> inline
|
||||
logic::tribool operator<(const interval<T, Policies1>& x, const interval<T, Policies2>& 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<class T, class Policies> inline
|
||||
logic::tribool operator<(const interval<T, Policies>& 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<class T, class Policies1, class Policies2> inline
|
||||
logic::tribool operator<=(const interval<T, Policies1>& x, const interval<T, Policies2>& 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<class T, class Policies> inline
|
||||
logic::tribool operator<=(const interval<T, Policies>& 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<class T, class Policies1, class Policies2> inline
|
||||
logic::tribool operator>(const interval<T, Policies1>& x, const interval<T, Policies2>& 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<class T, class Policies> inline
|
||||
logic::tribool operator>(const interval<T, Policies>& 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<class T, class Policies1, class Policies2> inline
|
||||
logic::tribool operator>=(const interval<T, Policies1>& x, const interval<T, Policies2>& 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<class T, class Policies> inline
|
||||
logic::tribool operator>=(const interval<T, Policies>& 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<class T, class Policies1, class Policies2> inline
|
||||
logic::tribool operator==(const interval<T, Policies1>& x, const interval<T, Policies2>& 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<class T, class Policies> inline
|
||||
logic::tribool operator==(const interval<T, Policies>& 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<class T, class Policies1, class Policies2> inline
|
||||
logic::tribool operator!=(const interval<T, Policies1>& x, const interval<T, Policies2>& 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<class T, class Policies> inline
|
||||
logic::tribool operator!=(const interval<T, Policies>& 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
|
||||
@@ -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<class T> inline T pi_lower() { return 3; }
|
||||
template<class T> inline T pi_upper() { return 4; }
|
||||
template<class T> inline T pi_half_lower() { return 1; }
|
||||
template<class T> inline T pi_half_upper() { return 2; }
|
||||
template<class T> inline T pi_twice_lower() { return 6; }
|
||||
template<class T> inline T pi_twice_upper() { return 7; }
|
||||
|
||||
template<> inline float pi_lower<float>() { return pi_f_l; }
|
||||
template<> inline float pi_upper<float>() { return pi_f_u; }
|
||||
template<> inline float pi_half_lower<float>() { return pi_f_l / 2; }
|
||||
template<> inline float pi_half_upper<float>() { return pi_f_u / 2; }
|
||||
template<> inline float pi_twice_lower<float>() { return pi_f_l * 2; }
|
||||
template<> inline float pi_twice_upper<float>() { return pi_f_u * 2; }
|
||||
|
||||
template<> inline double pi_lower<double>() { return pi_d_l; }
|
||||
template<> inline double pi_upper<double>() { return pi_d_u; }
|
||||
template<> inline double pi_half_lower<double>() { return pi_d_l / 2; }
|
||||
template<> inline double pi_half_upper<double>() { return pi_d_u / 2; }
|
||||
template<> inline double pi_twice_lower<double>() { return pi_d_l * 2; }
|
||||
template<> inline double pi_twice_upper<double>() { return pi_d_u * 2; }
|
||||
|
||||
template<> inline long double pi_lower<long double>() { return pi_d_l; }
|
||||
template<> inline long double pi_upper<long double>() { return pi_d_u; }
|
||||
template<> inline long double pi_half_lower<long double>() { return pi_d_l / 2; }
|
||||
template<> inline long double pi_half_upper<long double>() { return pi_d_u / 2; }
|
||||
template<> inline long double pi_twice_lower<long double>() { return pi_d_l * 2; }
|
||||
template<> inline long double pi_twice_upper<long double>() { return pi_d_u * 2; }
|
||||
|
||||
} // namespace constants
|
||||
|
||||
template<class I> inline
|
||||
I pi()
|
||||
{
|
||||
typedef typename I::base_type T;
|
||||
return I(constants::pi_lower<T>(),
|
||||
constants::pi_upper<T>(), true);
|
||||
}
|
||||
|
||||
template<class I> inline
|
||||
I pi_half()
|
||||
{
|
||||
typedef typename I::base_type T;
|
||||
return I(constants::pi_half_lower<T>(),
|
||||
constants::pi_half_upper<T>(), true);
|
||||
}
|
||||
|
||||
template<class I> inline
|
||||
I pi_twice()
|
||||
{
|
||||
typedef typename I::base_type T;
|
||||
return I(constants::pi_twice_lower<T>(),
|
||||
constants::pi_twice_upper<T>(), true);
|
||||
}
|
||||
|
||||
} // namespace interval_lib
|
||||
} // namespace numeric
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_NUMERIC_INTERVAL_CONSTANTS_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 <float.h> // 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<float>:
|
||||
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<double>:
|
||||
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<long double>:
|
||||
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 */
|
||||
@@ -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 <float.h> // 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 */
|
||||
@@ -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 <boost/config.hpp>
|
||||
|
||||
#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 <algorithm>
|
||||
#include <boost/config/no_tr1/cmath.hpp>
|
||||
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
|
||||
@@ -0,0 +1,47 @@
|
||||
/* 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 <boost/numeric/interval/detail/c99sub_rounding_control.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace numeric {
|
||||
namespace interval_lib {
|
||||
namespace detail {
|
||||
|
||||
struct c99_rounding_control: c99_rounding
|
||||
{
|
||||
template<class T>
|
||||
static T force_rounding(const T& r) { volatile T r_ = r; return r_; }
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<>
|
||||
struct rounding_control<float>:
|
||||
detail::c99_rounding_control { };
|
||||
|
||||
template<>
|
||||
struct rounding_control<double>:
|
||||
detail::c99_rounding_control { };
|
||||
|
||||
template<>
|
||||
struct rounding_control<long double>:
|
||||
detail::c99_rounding_control { };
|
||||
|
||||
} // namespace interval_lib
|
||||
} // namespace numeric
|
||||
} // namespace boost
|
||||
|
||||
#undef BOOST_NUMERIC_INTERVAL_NO_HARDWARE
|
||||
|
||||
#endif // BOOST_NUMERIC_INTERVAL_DETAIL_C99_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 <fenv.h> // ISO C 99 rounding mode control
|
||||
|
||||
namespace boost {
|
||||
namespace numeric {
|
||||
namespace interval_lib {
|
||||
namespace detail {
|
||||
|
||||
extern "C" { double rint(double); }
|
||||
|
||||
struct c99_rounding
|
||||
{
|
||||
typedef 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); }
|
||||
|
||||
template<class T>
|
||||
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
|
||||
@@ -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 <boost/numeric/interval/detail/interval_prototype.hpp>
|
||||
#include <boost/numeric/interval/detail/bugs.hpp>
|
||||
#include <boost/numeric/interval/detail/test_input.hpp>
|
||||
#include <boost/numeric/interval/rounded_arith.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
namespace boost {
|
||||
namespace numeric {
|
||||
namespace interval_lib {
|
||||
namespace detail {
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> div_non_zero(const interval<T, Policies>& x,
|
||||
const interval<T, Policies>& y)
|
||||
{
|
||||
// assert(!in_zero(y));
|
||||
typename Policies::rounding rnd;
|
||||
typedef interval<T, Policies> 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<class T, class Policies> inline
|
||||
interval<T, Policies> div_non_zero(const T& x, const interval<T, Policies>& y)
|
||||
{
|
||||
// assert(!in_zero(y));
|
||||
typename Policies::rounding rnd;
|
||||
typedef interval<T, Policies> 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<class T, class Policies> inline
|
||||
interval<T, Policies> div_positive(const interval<T, Policies>& 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<T, Policies> 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<class T, class Policies> inline
|
||||
interval<T, Policies> div_positive(const T& x, const T& yu)
|
||||
{
|
||||
// assert(::boost::numeric::interval_lib::user::is_pos(yu));
|
||||
typedef interval<T, Policies> I;
|
||||
if (::boost::numeric::interval_lib::user::is_zero(x))
|
||||
return I(static_cast<T>(0), static_cast<T>(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<class T, class Policies> inline
|
||||
interval<T, Policies> div_negative(const interval<T, Policies>& 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<T, Policies> 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<class T, class Policies> inline
|
||||
interval<T, Policies> div_negative(const T& x, const T& yl)
|
||||
{
|
||||
// assert(::boost::numeric::interval_lib::user::is_neg(yl));
|
||||
typedef interval<T, Policies> I;
|
||||
if (::boost::numeric::interval_lib::user::is_zero(x))
|
||||
return I(static_cast<T>(0), static_cast<T>(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<class T, class Policies> inline
|
||||
interval<T, Policies> div_zero(const interval<T, Policies>& 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<T, Policies>::whole();
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> div_zero(const T& x)
|
||||
{
|
||||
if (::boost::numeric::interval_lib::user::is_zero(x))
|
||||
return interval<T, Policies>(static_cast<T>(0), static_cast<T>(0), true);
|
||||
else return interval<T, Policies>::whole();
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> div_zero_part1(const interval<T, Policies>& x,
|
||||
const interval<T, Policies>& 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<T, Policies> 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<class T, class Policies> inline
|
||||
interval<T, Policies> div_zero_part2(const interval<T, Policies>& x,
|
||||
const interval<T, Policies>& 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<T, Policies> 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
|
||||
@@ -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 <fenv.h>
|
||||
|
||||
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<float>:
|
||||
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<double>:
|
||||
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<long double>:
|
||||
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 */
|
||||
|
||||
@@ -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<class T> struct rounded_math;
|
||||
template<class T> struct checking_strict;
|
||||
class comparison_error;
|
||||
template<class Rounding, class Checking> struct policies;
|
||||
|
||||
/*
|
||||
* default policies class
|
||||
*/
|
||||
|
||||
template<class T>
|
||||
struct default_policies
|
||||
{
|
||||
typedef policies<rounded_math<T>, checking_strict<T> > type;
|
||||
};
|
||||
|
||||
} // namespace interval_lib
|
||||
|
||||
template<class T, class Policies = typename interval_lib::default_policies<T>::type >
|
||||
class interval;
|
||||
|
||||
} // namespace numeric
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_NUMERIC_INTERVAL_DETAIL_INTERVAL_PROTOTYPE_HPP
|
||||
@@ -0,0 +1,91 @@
|
||||
/* 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 <float.h> // 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 {
|
||||
|
||||
extern "C" { double rint(double); }
|
||||
|
||||
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 */
|
||||
@@ -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 <math.h> 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<float>:
|
||||
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<double>:
|
||||
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<long double>:
|
||||
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 */
|
||||
@@ -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 <ieeefp.h>
|
||||
#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<float>:
|
||||
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<double>:
|
||||
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<long double>:
|
||||
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 */
|
||||
@@ -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 <boost/numeric/interval/detail/interval_prototype.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace numeric {
|
||||
namespace interval_lib {
|
||||
namespace user {
|
||||
|
||||
template<class T> inline
|
||||
bool is_zero(T const &v) { return v == static_cast<T>(0); }
|
||||
|
||||
template<class T> inline
|
||||
bool is_neg (T const &v) { return v < static_cast<T>(0); }
|
||||
|
||||
template<class T> inline
|
||||
bool is_pos (T const &v) { return v > static_cast<T>(0); }
|
||||
|
||||
} // namespace user
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool test_input(const interval<T, Policies>& x) {
|
||||
typedef typename Policies::checking checking;
|
||||
return checking::is_empty(x.lower(), x.upper());
|
||||
}
|
||||
|
||||
template<class T, class Policies1, class Policies2> inline
|
||||
bool test_input(const interval<T, Policies1>& x, const interval<T, Policies2>& 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<class T, class Policies> inline
|
||||
bool test_input(const T& x, const interval<T, Policies>& y) {
|
||||
typedef typename Policies::checking checking;
|
||||
return checking::is_nan(x) || checking::is_empty(y.lower(), y.upper());
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool test_input(const interval<T, Policies>& x, const T& y) {
|
||||
typedef typename Policies::checking checking;
|
||||
return checking::is_empty(x.lower(), x.upper()) || checking::is_nan(y);
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool test_input(const T& x) {
|
||||
typedef typename Policies::checking checking;
|
||||
return checking::is_nan(x);
|
||||
}
|
||||
|
||||
template<class T, class Policies> 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
|
||||
@@ -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 <boost/numeric/interval/detail/x86gcc_rounding_control.hpp>
|
||||
#elif defined(__BORLANDC__)
|
||||
# include <boost/numeric/interval/detail/bcc_rounding_control.hpp>
|
||||
#elif defined(_MSC_VER)
|
||||
# include <boost/numeric/interval/detail/msvc_rounding_control.hpp>
|
||||
#elif defined(__MWERKS__) || defined(__ICC)
|
||||
# define BOOST_NUMERIC_INTERVAL_USE_C99_SUBSYSTEM
|
||||
# include <boost/numeric/interval/detail/c99sub_rounding_control.hpp>
|
||||
#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 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<float>: detail::x86_rounding_control
|
||||
{
|
||||
static float force_rounding(const float& r)
|
||||
{ volatile float r_ = r; return r_; }
|
||||
};
|
||||
|
||||
template<>
|
||||
struct rounding_control<double>: 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<bool>
|
||||
struct x86_rounding_control_long_double;
|
||||
|
||||
template<>
|
||||
struct x86_rounding_control_long_double<false>: 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<true>: x86_rounding_control
|
||||
{
|
||||
static long double const &force_rounding(long double const &r)
|
||||
{ return r; }
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<>
|
||||
struct rounding_control<long double>:
|
||||
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 */
|
||||
@@ -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<class T>
|
||||
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 */
|
||||
@@ -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 <boost/numeric/interval/detail/interval_prototype.hpp>
|
||||
#include <boost/numeric/interval/detail/test_input.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace numeric {
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> operator+ (const interval<T, Policies>& x, int y)
|
||||
{
|
||||
return x + static_cast<T>(y);
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> operator+ (int x, const interval<T, Policies>& y)
|
||||
{
|
||||
return static_cast<T>(x) + y;
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> operator- (const interval<T, Policies>& x, int y)
|
||||
{
|
||||
return x - static_cast<T>(y);
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> operator- (int x, const interval<T, Policies>& y)
|
||||
{
|
||||
return static_cast<T>(x) - y;
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> operator* (const interval<T, Policies>& x, int y)
|
||||
{
|
||||
return x * static_cast<T>(y);
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> operator* (int x, const interval<T, Policies>& y)
|
||||
{
|
||||
return static_cast<T>(x) * y;
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> operator/ (const interval<T, Policies>& x, int y)
|
||||
{
|
||||
return x / static_cast<T>(y);
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> operator/ (int x, const interval<T, Policies>& y)
|
||||
{
|
||||
return static_cast<T>(x) / y;
|
||||
}
|
||||
|
||||
} // namespace numeric
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_NUMERIC_INTERVAL_EXT_INTEGER_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<class T>
|
||||
struct x86_fast_rounding_control;
|
||||
|
||||
template<>
|
||||
struct x86_fast_rounding_control<float>: 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<double>: 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<long double>: 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
|
||||
@@ -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 <boost/numeric/interval/rounding.hpp>
|
||||
#include <boost/numeric/interval/rounded_arith.hpp>
|
||||
|
||||
#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 <boost/numeric/interval/detail/c99_rounding_control.hpp>
|
||||
#elif defined(__i386__) || defined(_M_IX86) || defined(__BORLANDC__) || defined(_M_X64)
|
||||
# include <boost/numeric/interval/detail/x86_rounding_control.hpp>
|
||||
#elif defined(powerpc) || defined(__powerpc__) || defined(__ppc__)
|
||||
# include <boost/numeric/interval/detail/ppc_rounding_control.hpp>
|
||||
#elif defined(sparc) || defined(__sparc__)
|
||||
# include <boost/numeric/interval/detail/sparc_rounding_control.hpp>
|
||||
#elif defined(alpha) || defined(__alpha__)
|
||||
# include <boost/numeric/interval/detail/alpha_rounding_control.hpp>
|
||||
#elif defined(ia64) || defined(__ia64) || defined(__ia64__)
|
||||
# include <boost/numeric/interval/detail/ia64_rounding_control.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NUMERIC_INTERVAL_NO_HARDWARE) && (defined(__USE_ISOC99) || defined(__MSL__))
|
||||
# include <boost/numeric/interval/detail/c99_rounding_control.hpp>
|
||||
#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<T>
|
||||
*/
|
||||
|
||||
template<>
|
||||
struct rounded_math<float>
|
||||
: save_state<rounded_arith_opp<float> >
|
||||
{};
|
||||
|
||||
template<>
|
||||
struct rounded_math<double>
|
||||
: save_state<rounded_arith_opp<double> >
|
||||
{};
|
||||
|
||||
template<>
|
||||
struct rounded_math<long double>
|
||||
: save_state<rounded_arith_opp<long double> >
|
||||
{};
|
||||
|
||||
} // namespace interval_lib
|
||||
} // namespace numeric
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_NUMERIC_INTERVAL_HW_ROUNDING_HPP
|
||||
450
project/jni/boost/include/boost/numeric/interval/interval.hpp
Normal file
450
project/jni/boost/include/boost/numeric/interval/interval.hpp
Normal file
@@ -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 <stdexcept>
|
||||
#include <string>
|
||||
#include <boost/numeric/interval/detail/interval_prototype.hpp>
|
||||
|
||||
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 T, class Policies>
|
||||
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<class T1> interval(T1 const &v);
|
||||
interval(T const &l, T const &u);
|
||||
template<class T1, class T2> interval(T1 const &l, T2 const &u);
|
||||
interval(interval<T, Policies> const &r);
|
||||
template<class Policies1> interval(interval<T, Policies1> const &r);
|
||||
template<class T1, class Policies1> interval(interval<T1, Policies1> const &r);
|
||||
|
||||
interval &operator=(T const &v);
|
||||
template<class T1> interval &operator=(T1 const &v);
|
||||
interval &operator=(interval<T, Policies> const &r);
|
||||
template<class Policies1> interval &operator=(interval<T, Policies1> const &r);
|
||||
template<class T1, class Policies1> interval &operator=(interval<T1, Policies1> 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<class Policies2>
|
||||
interval_holder(const interval<T, Policies2>& 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<class T, class Policies> inline
|
||||
interval<T, Policies>::interval():
|
||||
low(static_cast<T>(0)), up(static_cast<T>(0))
|
||||
{}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies>::interval(T const &v): low(v), up(v)
|
||||
{
|
||||
if (checking::is_nan(v)) set_empty();
|
||||
}
|
||||
|
||||
template<class T, class Policies> template<class T1> inline
|
||||
interval<T, Policies>::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<class T, class Policies> template<class T1, class T2> inline
|
||||
interval<T, Policies>::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<class T, class Policies> inline
|
||||
interval<T, Policies>::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<class T, class Policies> inline
|
||||
interval<T, Policies>::interval(interval<T, Policies> const &r): low(r.lower()), up(r.upper())
|
||||
{}
|
||||
|
||||
template<class T, class Policies> template<class Policies1> inline
|
||||
interval<T, Policies>::interval(interval<T, Policies1> const &r): low(r.lower()), up(r.upper())
|
||||
{
|
||||
typedef typename Policies1::checking checking1;
|
||||
if (checking1::is_empty(r.lower(), r.upper())) set_empty();
|
||||
}
|
||||
|
||||
template<class T, class Policies> template<class T1, class Policies1> inline
|
||||
interval<T, Policies>::interval(interval<T1, Policies1> 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<class T, class Policies> inline
|
||||
interval<T, Policies> &interval<T, Policies>::operator=(T const &v)
|
||||
{
|
||||
if (checking::is_nan(v)) set_empty();
|
||||
else low = up = v;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class T, class Policies> template<class T1> inline
|
||||
interval<T, Policies> &interval<T, Policies>::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<class T, class Policies> inline
|
||||
interval<T, Policies> &interval<T, Policies>::operator=(interval<T, Policies> const &r)
|
||||
{
|
||||
low = r.lower();
|
||||
up = r.upper();
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class T, class Policies> template<class Policies1> inline
|
||||
interval<T, Policies> &interval<T, Policies>::operator=(interval<T, Policies1> 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<class T, class Policies> template<class T1, class Policies1> inline
|
||||
interval<T, Policies> &interval<T, Policies>::operator=(interval<T1, Policies1> 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<class T, class Policies> inline
|
||||
void interval<T, Policies>::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<class T, class Policies> inline
|
||||
void interval<T, Policies>::set(const T& l, const T& u)
|
||||
{
|
||||
low = l;
|
||||
up = u;
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
void interval<T, Policies>::set_empty()
|
||||
{
|
||||
low = checking::empty_lower();
|
||||
up = checking::empty_upper();
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
void interval<T, Policies>::set_whole()
|
||||
{
|
||||
low = checking::neg_inf();
|
||||
up = checking::pos_inf();
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> interval<T, Policies>::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<class T, class Policies> inline
|
||||
interval<T, Policies> interval<T, Policies>::empty()
|
||||
{
|
||||
return interval<T, Policies>(checking::empty_lower(),
|
||||
checking::empty_upper(), true);
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> interval<T, Policies>::whole()
|
||||
{
|
||||
return interval<T, Policies>(checking::neg_inf(), checking::pos_inf(), true);
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
const T& interval<T, Policies>::lower() const
|
||||
{
|
||||
return low;
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
const T& interval<T, Policies>::upper() const
|
||||
{
|
||||
return up;
|
||||
}
|
||||
|
||||
/*
|
||||
* interval/interval comparisons
|
||||
*/
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool interval<T, Policies>::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<class T, class Policies> inline
|
||||
bool interval<T, Policies>::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<class T, class Policies> inline
|
||||
bool interval<T, Policies>::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<class T, class Policies> inline
|
||||
bool interval<T, Policies>::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<class T, class Policies> inline
|
||||
bool interval<T, Policies>::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<class T, class Policies> inline
|
||||
bool interval<T, Policies>::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<class T, class Policies> inline
|
||||
bool interval<T, Policies>::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<class T, class Policies> inline
|
||||
bool interval<T, Policies>::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<class T, class Policies> inline
|
||||
bool interval<T, Policies>::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<class T, class Policies> inline
|
||||
bool interval<T, Policies>::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<class T, class Policies> inline
|
||||
bool interval<T, Policies>::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<class T, class Policies> inline
|
||||
bool interval<T, Policies>::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
|
||||
41
project/jni/boost/include/boost/numeric/interval/io.hpp
Normal file
41
project/jni/boost/include/boost/numeric/interval/io.hpp
Normal file
@@ -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 <boost/numeric/interval/interval.hpp>
|
||||
#include <boost/numeric/interval/utility.hpp>
|
||||
#include <ostream>
|
||||
|
||||
namespace boost {
|
||||
namespace numeric {
|
||||
|
||||
template<class CharType, class CharTraits, class T, class Policies>
|
||||
std::basic_ostream<CharType, CharTraits> &operator<<
|
||||
(std::basic_ostream<CharType, CharTraits> &stream,
|
||||
interval<T, Policies> const &value)
|
||||
{
|
||||
if (empty(value))
|
||||
return stream << "[]";
|
||||
else
|
||||
return stream << '[' << lower(value) << ',' << upper(value) << ']';
|
||||
}
|
||||
|
||||
} // namespace numeric
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_NUMERIC_INTERVAL_IO_HPP
|
||||
51
project/jni/boost/include/boost/numeric/interval/limits.hpp
Normal file
51
project/jni/boost/include/boost/numeric/interval/limits.hpp
Normal file
@@ -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 <boost/config.hpp>
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/numeric/interval/detail/interval_prototype.hpp>
|
||||
|
||||
namespace std {
|
||||
|
||||
template<class T, class Policies>
|
||||
class numeric_limits<boost::numeric::interval<T, Policies> >
|
||||
: public numeric_limits<T>
|
||||
{
|
||||
private:
|
||||
typedef boost::numeric::interval<T, Policies> I;
|
||||
typedef numeric_limits<T> 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
|
||||
@@ -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 <boost/numeric/interval/interval.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace numeric {
|
||||
namespace interval_lib {
|
||||
|
||||
/*
|
||||
* policies class
|
||||
*/
|
||||
|
||||
template<class Rounding, class Checking>
|
||||
struct policies
|
||||
{
|
||||
typedef Rounding rounding;
|
||||
typedef Checking checking;
|
||||
};
|
||||
|
||||
/*
|
||||
* policies switching classes
|
||||
*/
|
||||
|
||||
template<class OldInterval, class NewRounding>
|
||||
class change_rounding
|
||||
{
|
||||
typedef typename OldInterval::base_type T;
|
||||
typedef typename OldInterval::traits_type p;
|
||||
typedef typename p::checking checking;
|
||||
public:
|
||||
typedef interval<T, policies<NewRounding, checking> > type;
|
||||
};
|
||||
|
||||
template<class OldInterval, class NewChecking>
|
||||
class change_checking
|
||||
{
|
||||
typedef typename OldInterval::base_type T;
|
||||
typedef typename OldInterval::traits_type p;
|
||||
typedef typename p::rounding rounding;
|
||||
public:
|
||||
typedef interval<T, policies<rounding, NewChecking> > type;
|
||||
};
|
||||
|
||||
/*
|
||||
* Protect / unprotect: control whether the rounding mode is set/reset
|
||||
* at each operation, rather than once and for all.
|
||||
*/
|
||||
|
||||
template<class OldInterval>
|
||||
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<OldInterval, newRounding>::type type;
|
||||
};
|
||||
|
||||
} // namespace interval_lib
|
||||
} // namespace numeric
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_NUMERIC_INTERVAL_POLICIES_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 <boost/numeric/interval/rounding.hpp>
|
||||
#include <boost/numeric/interval/detail/bugs.hpp>
|
||||
#include <boost/config/no_tr1/cmath.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace numeric {
|
||||
namespace interval_lib {
|
||||
|
||||
/*
|
||||
* Three classes of rounding: exact, std, opp
|
||||
* See documentation for details.
|
||||
*/
|
||||
|
||||
template<class T, class Rounding>
|
||||
struct rounded_arith_exact: Rounding {
|
||||
void init() { }
|
||||
template<class U> T conv_down(U const &v) { return v; }
|
||||
template<class U> 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<class T, class Rounding>
|
||||
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<class U> T conv_down(U const &v) { BOOST_DN(v); }
|
||||
template<class U> 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<class T, class Rounding>
|
||||
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<class U> T conv_down(U const &v) { BOOST_UP_NEG(-v); }
|
||||
template<class U> 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
|
||||
@@ -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 <boost/numeric/interval/rounding.hpp>
|
||||
#include <boost/numeric/interval/detail/bugs.hpp>
|
||||
#include <boost/config/no_tr1/cmath.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace numeric {
|
||||
namespace interval_lib {
|
||||
|
||||
template<class T, class Rounding>
|
||||
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<class T, class Rounding>
|
||||
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<class T, class Rounding>
|
||||
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
|
||||
101
project/jni/boost/include/boost/numeric/interval/rounding.hpp
Normal file
101
project/jni/boost/include/boost/numeric/interval/rounding.hpp
Normal file
@@ -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<class T>
|
||||
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<class T, class Rounding = rounding_control<T> >
|
||||
struct rounded_arith_exact;
|
||||
|
||||
template<class T, class Rounding = rounding_control<T> >
|
||||
struct rounded_arith_std;
|
||||
|
||||
template<class T, class Rounding = rounding_control<T> >
|
||||
struct rounded_arith_opp;
|
||||
|
||||
template<class T, class Rounding>
|
||||
struct rounded_transc_dummy;
|
||||
|
||||
template<class T, class Rounding = rounded_arith_exact<T> >
|
||||
struct rounded_transc_exact;
|
||||
|
||||
template<class T, class Rounding = rounded_arith_std<T> >
|
||||
struct rounded_transc_std;
|
||||
|
||||
template<class T, class Rounding = rounded_arith_opp<T> >
|
||||
struct rounded_transc_opp;
|
||||
|
||||
/*
|
||||
* State-saving classes: allow to set and reset rounding control
|
||||
*/
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class Rounding>
|
||||
struct save_state_unprotected: Rounding
|
||||
{
|
||||
typedef save_state_unprotected<Rounding> unprotected_rounding;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<class Rounding>
|
||||
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<Rounding> unprotected_rounding;
|
||||
};
|
||||
|
||||
template<class Rounding>
|
||||
struct save_state_nothing: Rounding
|
||||
{
|
||||
typedef save_state_nothing<Rounding> unprotected_rounding;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct rounded_math: save_state_nothing<rounded_arith_exact<T> >
|
||||
{};
|
||||
|
||||
} // namespace interval_lib
|
||||
} // namespace numeric
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_NUMERIC_INTERVAL_ROUNDING_HPP
|
||||
232
project/jni/boost/include/boost/numeric/interval/transc.hpp
Normal file
232
project/jni/boost/include/boost/numeric/interval/transc.hpp
Normal file
@@ -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 <boost/config.hpp>
|
||||
#include <boost/numeric/interval/detail/interval_prototype.hpp>
|
||||
#include <boost/numeric/interval/detail/bugs.hpp>
|
||||
#include <boost/numeric/interval/detail/test_input.hpp>
|
||||
#include <boost/numeric/interval/rounding.hpp>
|
||||
#include <boost/numeric/interval/constants.hpp>
|
||||
#include <boost/numeric/interval/arith.hpp>
|
||||
#include <boost/numeric/interval/arith2.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
namespace boost {
|
||||
namespace numeric {
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> exp(const interval<T, Policies>& x)
|
||||
{
|
||||
typedef interval<T, Policies> 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<class T, class Policies> inline
|
||||
interval<T, Policies> log(const interval<T, Policies>& x)
|
||||
{
|
||||
typedef interval<T, Policies> 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<class T, class Policies> inline
|
||||
interval<T, Policies> cos(const interval<T, Policies>& x)
|
||||
{
|
||||
if (interval_lib::detail::test_input(x))
|
||||
return interval<T, Policies>::empty();
|
||||
typename Policies::rounding rnd;
|
||||
typedef interval<T, Policies> I;
|
||||
typedef typename interval_lib::unprotect<I>::type R;
|
||||
|
||||
// get lower bound within [0, pi]
|
||||
const R pi2 = interval_lib::pi_twice<R>();
|
||||
R tmp = fmod((const R&)x, pi2);
|
||||
if (width(tmp) >= pi2.lower())
|
||||
return I(static_cast<T>(-1), static_cast<T>(1), true); // we are covering a full period
|
||||
if (tmp.lower() >= interval_lib::constants::pi_upper<T>())
|
||||
return -cos(tmp - interval_lib::pi<R>());
|
||||
T l = tmp.lower();
|
||||
T u = tmp.upper();
|
||||
|
||||
BOOST_USING_STD_MIN();
|
||||
// separate into monotone subintervals
|
||||
if (u <= interval_lib::constants::pi_lower<T>())
|
||||
return I(rnd.cos_down(u), rnd.cos_up(l), true);
|
||||
else if (u <= pi2.lower())
|
||||
return I(static_cast<T>(-1), rnd.cos_up(min BOOST_PREVENT_MACRO_SUBSTITUTION(rnd.sub_down(pi2.lower(), u), l)), true);
|
||||
else
|
||||
return I(static_cast<T>(-1), static_cast<T>(1), true);
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> sin(const interval<T, Policies>& x)
|
||||
{
|
||||
typedef interval<T, Policies> I;
|
||||
if (interval_lib::detail::test_input(x))
|
||||
return I::empty();
|
||||
typename Policies::rounding rnd;
|
||||
typedef typename interval_lib::unprotect<I>::type R;
|
||||
I r = cos((const R&)x - interval_lib::pi_half<R>());
|
||||
(void)&rnd;
|
||||
return r;
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> tan(const interval<T, Policies>& x)
|
||||
{
|
||||
typedef interval<T, Policies> I;
|
||||
if (interval_lib::detail::test_input(x))
|
||||
return I::empty();
|
||||
typename Policies::rounding rnd;
|
||||
typedef typename interval_lib::unprotect<I>::type R;
|
||||
|
||||
// get lower bound within [-pi/2, pi/2]
|
||||
const R pi = interval_lib::pi<R>();
|
||||
R tmp = fmod((const R&)x, pi);
|
||||
const T pi_half_d = interval_lib::constants::pi_half_lower<T>();
|
||||
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<class T, class Policies> inline
|
||||
interval<T, Policies> asin(const interval<T, Policies>& x)
|
||||
{
|
||||
typedef interval<T, Policies> I;
|
||||
if (interval_lib::detail::test_input(x)
|
||||
|| x.upper() < static_cast<T>(-1) || x.lower() > static_cast<T>(1))
|
||||
return I::empty();
|
||||
typename Policies::rounding rnd;
|
||||
T l = (x.lower() <= static_cast<T>(-1))
|
||||
? -interval_lib::constants::pi_half_upper<T>()
|
||||
: rnd.asin_down(x.lower());
|
||||
T u = (x.upper() >= static_cast<T>(1) )
|
||||
? interval_lib::constants::pi_half_upper<T>()
|
||||
: rnd.asin_up (x.upper());
|
||||
return I(l, u, true);
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> acos(const interval<T, Policies>& x)
|
||||
{
|
||||
typedef interval<T, Policies> I;
|
||||
if (interval_lib::detail::test_input(x)
|
||||
|| x.upper() < static_cast<T>(-1) || x.lower() > static_cast<T>(1))
|
||||
return I::empty();
|
||||
typename Policies::rounding rnd;
|
||||
T l = (x.upper() >= static_cast<T>(1) )
|
||||
? static_cast<T>(0)
|
||||
: rnd.acos_down(x.upper());
|
||||
T u = (x.lower() <= static_cast<T>(-1))
|
||||
? interval_lib::constants::pi_upper<T>()
|
||||
: rnd.acos_up (x.lower());
|
||||
return I(l, u, true);
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> atan(const interval<T, Policies>& x)
|
||||
{
|
||||
typedef interval<T, Policies> 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<class T, class Policies> inline
|
||||
interval<T, Policies> sinh(const interval<T, Policies>& x)
|
||||
{
|
||||
typedef interval<T, Policies> 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<class T, class Policies> inline
|
||||
interval<T, Policies> cosh(const interval<T, Policies>& x)
|
||||
{
|
||||
typedef interval<T, Policies> 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<T>(0), rnd.cosh_up(-x.lower() > x.upper() ? x.lower() : x.upper()), true);
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> tanh(const interval<T, Policies>& x)
|
||||
{
|
||||
typedef interval<T, Policies> 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<class T, class Policies> inline
|
||||
interval<T, Policies> asinh(const interval<T, Policies>& x)
|
||||
{
|
||||
typedef interval<T, Policies> 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<class T, class Policies> inline
|
||||
interval<T, Policies> acosh(const interval<T, Policies>& x)
|
||||
{
|
||||
typedef interval<T, Policies> I;
|
||||
if (interval_lib::detail::test_input(x) || x.upper() < static_cast<T>(1))
|
||||
return I::empty();
|
||||
typename Policies::rounding rnd;
|
||||
T l = x.lower() <= static_cast<T>(1) ? static_cast<T>(0) : rnd.acosh_down(x.lower());
|
||||
return I(l, rnd.acosh_up(x.upper()), true);
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> atanh(const interval<T, Policies>& x)
|
||||
{
|
||||
typedef interval<T, Policies> I;
|
||||
if (interval_lib::detail::test_input(x)
|
||||
|| x.upper() < static_cast<T>(-1) || x.lower() > static_cast<T>(1))
|
||||
return I::empty();
|
||||
typename Policies::rounding rnd;
|
||||
typedef typename Policies::checking checking;
|
||||
T l = (x.lower() <= static_cast<T>(-1))
|
||||
? checking::neg_inf() : rnd.atanh_down(x.lower());
|
||||
T u = (x.upper() >= static_cast<T>(1) )
|
||||
? checking::pos_inf() : rnd.atanh_up (x.upper());
|
||||
return I(l, u, true);
|
||||
}
|
||||
|
||||
} // namespace numeric
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_NUMERIC_INTERVAL_TRANSC_HPP
|
||||
337
project/jni/boost/include/boost/numeric/interval/utility.hpp
Normal file
337
project/jni/boost/include/boost/numeric/interval/utility.hpp
Normal file
@@ -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 <boost/config.hpp>
|
||||
#include <boost/numeric/interval/detail/interval_prototype.hpp>
|
||||
#include <boost/numeric/interval/detail/test_input.hpp>
|
||||
#include <boost/numeric/interval/detail/bugs.hpp>
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
|
||||
/*
|
||||
* Implementation of simple functions
|
||||
*/
|
||||
|
||||
namespace boost {
|
||||
namespace numeric {
|
||||
|
||||
/*
|
||||
* Utility Functions
|
||||
*/
|
||||
|
||||
template<class T, class Policies> inline
|
||||
const T& lower(const interval<T, Policies>& x)
|
||||
{
|
||||
return x.lower();
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
const T& upper(const interval<T, Policies>& x)
|
||||
{
|
||||
return x.upper();
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
T checked_lower(const interval<T, Policies>& x)
|
||||
{
|
||||
if (empty(x)) {
|
||||
typedef typename Policies::checking checking;
|
||||
return checking::nan();
|
||||
}
|
||||
return x.lower();
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
T checked_upper(const interval<T, Policies>& x)
|
||||
{
|
||||
if (empty(x)) {
|
||||
typedef typename Policies::checking checking;
|
||||
return checking::nan();
|
||||
}
|
||||
return x.upper();
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
T width(const interval<T, Policies>& x)
|
||||
{
|
||||
if (interval_lib::detail::test_input(x)) return static_cast<T>(0);
|
||||
typename Policies::rounding rnd;
|
||||
return rnd.sub_up(x.upper(), x.lower());
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
T median(const interval<T, Policies>& 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<class T, class Policies> inline
|
||||
interval<T, Policies> widen(const interval<T, Policies>& x, const T& v)
|
||||
{
|
||||
if (interval_lib::detail::test_input(x))
|
||||
return interval<T, Policies>::empty();
|
||||
typename Policies::rounding rnd;
|
||||
return interval<T, Policies>(rnd.sub_down(x.lower(), v),
|
||||
rnd.add_up (x.upper(), v), true);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set-like operations
|
||||
*/
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool empty(const interval<T, Policies>& x)
|
||||
{
|
||||
return interval_lib::detail::test_input(x);
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool zero_in(const interval<T, Policies>& 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<class T, class Policies> inline
|
||||
bool in_zero(const interval<T, Policies>& x) // DEPRECATED
|
||||
{
|
||||
return zero_in<T, Policies>(x);
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool in(const T& x, const interval<T, Policies>& y)
|
||||
{
|
||||
if (interval_lib::detail::test_input(x, y)) return false;
|
||||
return y.lower() <= x && x <= y.upper();
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
bool subset(const interval<T, Policies>& x,
|
||||
const interval<T, Policies>& y)
|
||||
{
|
||||
if (empty(x)) return true;
|
||||
return !empty(y) && y.lower() <= x.lower() && x.upper() <= y.upper();
|
||||
}
|
||||
|
||||
template<class T, class Policies1, class Policies2> inline
|
||||
bool proper_subset(const interval<T, Policies1>& x,
|
||||
const interval<T, Policies2>& 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<class T, class Policies1, class Policies2> inline
|
||||
bool overlap(const interval<T, Policies1>& x,
|
||||
const interval<T, Policies2>& 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<class T, class Policies> inline
|
||||
bool singleton(const interval<T, Policies>& x)
|
||||
{
|
||||
return !empty(x) && x.lower() == x.upper();
|
||||
}
|
||||
|
||||
template<class T, class Policies1, class Policies2> inline
|
||||
bool equal(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
|
||||
{
|
||||
if (empty(x)) return empty(y);
|
||||
return !empty(y) && x.lower() == y.lower() && x.upper() == y.upper();
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> intersect(const interval<T, Policies>& x,
|
||||
const interval<T, Policies>& y)
|
||||
{
|
||||
BOOST_USING_STD_MIN();
|
||||
BOOST_USING_STD_MAX();
|
||||
if (interval_lib::detail::test_input(x, y))
|
||||
return interval<T, Policies>::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<T, Policies>(l, u, true);
|
||||
else return interval<T, Policies>::empty();
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> hull(const interval<T, Policies>& x,
|
||||
const interval<T, Policies>& 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<T, Policies>::empty();
|
||||
else return y;
|
||||
else
|
||||
if (bad_y) return x;
|
||||
return interval<T, Policies>(min BOOST_PREVENT_MACRO_SUBSTITUTION(x.lower(), y.lower()),
|
||||
max BOOST_PREVENT_MACRO_SUBSTITUTION(x.upper(), y.upper()), true);
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> hull(const interval<T, Policies>& 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<T, Policies>(y);
|
||||
if (bad_y)
|
||||
if (bad_x) return interval<T, Policies>::empty();
|
||||
else return x;
|
||||
else
|
||||
if (bad_x) return interval<T, Policies>(y, y, true);
|
||||
return interval<T, Policies>(min BOOST_PREVENT_MACRO_SUBSTITUTION(x.lower(), y),
|
||||
max BOOST_PREVENT_MACRO_SUBSTITUTION(x.upper(), y), true);
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> hull(const T& x, const interval<T, Policies>& y)
|
||||
{
|
||||
BOOST_USING_STD_MIN();
|
||||
BOOST_USING_STD_MAX();
|
||||
bool bad_x = interval_lib::detail::test_input<T, Policies>(x);
|
||||
bool bad_y = interval_lib::detail::test_input(y);
|
||||
if (bad_x)
|
||||
if (bad_y) return interval<T, Policies>::empty();
|
||||
else return y;
|
||||
else
|
||||
if (bad_y) return interval<T, Policies>(x, x, true);
|
||||
return interval<T, Policies>(min BOOST_PREVENT_MACRO_SUBSTITUTION(x, y.lower()),
|
||||
max BOOST_PREVENT_MACRO_SUBSTITUTION(x, y.upper()), true);
|
||||
}
|
||||
|
||||
template<class T> inline
|
||||
interval<T> hull(const T& x, const T& y)
|
||||
{
|
||||
return interval<T>::hull(x, y);
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
std::pair<interval<T, Policies>, interval<T, Policies> >
|
||||
bisect(const interval<T, Policies>& x)
|
||||
{
|
||||
typedef interval<T, Policies> I;
|
||||
if (interval_lib::detail::test_input(x))
|
||||
return std::pair<I,I>(I::empty(), I::empty());
|
||||
const T m = median(x);
|
||||
return std::pair<I,I>(I(x.lower(), m, true), I(m, x.upper(), true));
|
||||
}
|
||||
|
||||
/*
|
||||
* Elementary functions
|
||||
*/
|
||||
|
||||
template<class T, class Policies> inline
|
||||
T norm(const interval<T, Policies>& x)
|
||||
{
|
||||
typedef interval<T, Policies> 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<T>(-x.lower()), x.upper());
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> abs(const interval<T, Policies>& x)
|
||||
{
|
||||
typedef interval<T, Policies> 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<T>(0), max BOOST_PREVENT_MACRO_SUBSTITUTION(static_cast<T>(-x.lower()), x.upper()), true);
|
||||
}
|
||||
|
||||
template<class T, class Policies> inline
|
||||
interval<T, Policies> max BOOST_PREVENT_MACRO_SUBSTITUTION (const interval<T, Policies>& x,
|
||||
const interval<T, Policies>& y)
|
||||
{
|
||||
typedef interval<T, Policies> 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<class T, class Policies> inline
|
||||
interval<T, Policies> max BOOST_PREVENT_MACRO_SUBSTITUTION (const interval<T, Policies>& x, const T& y)
|
||||
{
|
||||
typedef interval<T, Policies> 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<class T, class Policies> inline
|
||||
interval<T, Policies> max BOOST_PREVENT_MACRO_SUBSTITUTION (const T& x, const interval<T, Policies>& y)
|
||||
{
|
||||
typedef interval<T, Policies> 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<class T, class Policies> inline
|
||||
interval<T, Policies> min BOOST_PREVENT_MACRO_SUBSTITUTION (const interval<T, Policies>& x,
|
||||
const interval<T, Policies>& y)
|
||||
{
|
||||
typedef interval<T, Policies> 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<class T, class Policies> inline
|
||||
interval<T, Policies> min BOOST_PREVENT_MACRO_SUBSTITUTION (const interval<T, Policies>& x, const T& y)
|
||||
{
|
||||
typedef interval<T, Policies> 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<class T, class Policies> inline
|
||||
interval<T, Policies> min BOOST_PREVENT_MACRO_SUBSTITUTION (const T& x, const interval<T, Policies>& y)
|
||||
{
|
||||
typedef interval<T, Policies> 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
|
||||
1281
project/jni/boost/include/boost/numeric/ublas/assignment.hpp
Normal file
1281
project/jni/boost/include/boost/numeric/ublas/assignment.hpp
Normal file
File diff suppressed because it is too large
Load Diff
2071
project/jni/boost/include/boost/numeric/ublas/banded.hpp
Normal file
2071
project/jni/boost/include/boost/numeric/ublas/banded.hpp
Normal file
File diff suppressed because it is too large
Load Diff
502
project/jni/boost/include/boost/numeric/ublas/blas.hpp
Normal file
502
project/jni/boost/include/boost/numeric/ublas/blas.hpp
Normal file
@@ -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 <boost/numeric/ublas/traits.hpp>
|
||||
|
||||
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
|
||||
* <a href="http://en.wikipedia.org/wiki/BLAS">http://en.wikipedia.org/wiki/BLAS</a>
|
||||
*/
|
||||
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<class V>
|
||||
typename type_traits<typename V::value_type>::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<class V>
|
||||
typename type_traits<typename V::value_type>::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<class V>
|
||||
typename type_traits<typename V::value_type>::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<class V1, class V2>
|
||||
typename promote_traits<typename V1::value_type, typename V2::value_type>::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<class V1, class V2>
|
||||
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<class V1, class V2>
|
||||
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<class V, class T>
|
||||
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<class V1, class T, class V2>
|
||||
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<class T1, class V1, class T2, class V2>
|
||||
void rot (const T1 &t1, V1 &v1, const T2 &t2, V2 &v2)
|
||||
{
|
||||
typedef typename promote_traits<typename V1::value_type, typename V2::value_type>::promote_type promote_type;
|
||||
vector<promote_type> 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
|
||||
* <a href="http://en.wikipedia.org/wiki/BLAS">http://en.wikipedia.org/wiki/BLAS</a>
|
||||
*/
|
||||
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<class V, class M>
|
||||
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<class V, class M, class C>
|
||||
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<class V1, class T1, class T2, class M, class V2>
|
||||
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<class M, class T, class V1, class V2>
|
||||
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<class M, class T, class V>
|
||||
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<class M, class T, class V>
|
||||
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<class M, class T, class V1, class V2>
|
||||
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<class M, class T, class V1, class V2>
|
||||
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<T>::conj (t) * outer_prod (v2, conj (v1));
|
||||
#else
|
||||
return m = m + t * outer_prod (v1, conj (v2)) + type_traits<T>::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
|
||||
* <a href="http://en.wikipedia.org/wiki/BLAS">http://en.wikipedia.org/wiki/BLAS</a>
|
||||
*/
|
||||
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<class M1, class T, class M2, class M3>
|
||||
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<class M1, class T, class M2, class C>
|
||||
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<class M1, class T1, class T2, class M2, class M3>
|
||||
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<class M1, class T1, class T2, class M2>
|
||||
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<class M1, class T1, class T2, class M2>
|
||||
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<class M1, class T1, class T2, class M2, class M3>
|
||||
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<class M1, class T1, class T2, class M2, class M3>
|
||||
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<T2>::conj (t2) * prod (m3, herm (m2));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}}}
|
||||
|
||||
#endif
|
||||
1540
project/jni/boost/include/boost/numeric/ublas/detail/concepts.hpp
Normal file
1540
project/jni/boost/include/boost/numeric/ublas/detail/concepts.hpp
Normal file
File diff suppressed because it is too large
Load Diff
290
project/jni/boost/include/boost/numeric/ublas/detail/config.hpp
Normal file
290
project/jni/boost/include/boost/numeric/ublas/detail/config.hpp
Normal file
@@ -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 <cassert>
|
||||
#include <cstddef>
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/and.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
|
||||
|
||||
// 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 C, class IC>
|
||||
class indexed_iterator;
|
||||
|
||||
template<class V>
|
||||
class index_pair;
|
||||
template<class M>
|
||||
class index_triple;
|
||||
}}}
|
||||
|
||||
namespace std {
|
||||
template<class V>
|
||||
inline
|
||||
void swap (boost::numeric::ublas::index_pair<V> i1, boost::numeric::ublas::index_pair<V> i2) {
|
||||
i1.swap (i2);
|
||||
}
|
||||
template<class M>
|
||||
inline
|
||||
void swap (boost::numeric::ublas::index_triple<M> i1, boost::numeric::ublas::index_triple<M> i2) {
|
||||
i1.swap (i2);
|
||||
}
|
||||
// iter_swap also needed for ICC on Itanium?
|
||||
template<class C, class IC>
|
||||
inline
|
||||
void iter_swap (boost::numeric::ublas::indexed_iterator<C, IC> it1,
|
||||
boost::numeric::ublas::indexed_iterator<C, IC> 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 <cmath> are in <cstdlib>
|
||||
#if defined(__LIBCOMO__) && (__LIBCOMO_VERSION__ <= 31)
|
||||
#include <cstdlib>
|
||||
#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 <cmath> are in <cstdlib>
|
||||
// This test should be library version specific.
|
||||
#include <cstdlib>
|
||||
|
||||
#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 <class Dummy>
|
||||
struct disable_type_check
|
||||
{
|
||||
static bool value;
|
||||
};
|
||||
template <class Dummy>
|
||||
bool disable_type_check<Dummy>::value = false;
|
||||
#endif
|
||||
#ifndef BOOST_UBLAS_TYPE_CHECK_EPSILON
|
||||
#define BOOST_UBLAS_TYPE_CHECK_EPSILON (type_traits<real_type>::type_sqrt (std::numeric_limits<real_type>::epsilon ()))
|
||||
#endif
|
||||
#ifndef BOOST_UBLAS_TYPE_CHECK_MIN
|
||||
#define BOOST_UBLAS_TYPE_CHECK_MIN (type_traits<real_type>::type_sqrt ( (std::numeric_limits<real_type>::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 <boost/numeric/ublas/fwd.hpp>
|
||||
#include <boost/numeric/ublas/detail/definitions.hpp>
|
||||
|
||||
|
||||
#endif
|
||||
@@ -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 <class T> 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 C>
|
||||
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 <class E>
|
||||
BOOST_UBLAS_INLINE
|
||||
closure_type &operator= (const E& e) {
|
||||
lval_.assign (e);
|
||||
return lval_;
|
||||
}
|
||||
|
||||
template <class E>
|
||||
BOOST_UBLAS_INLINE
|
||||
closure_type &operator+= (const E& e) {
|
||||
lval_.plus_assign (e);
|
||||
return lval_;
|
||||
}
|
||||
|
||||
template <class E>
|
||||
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 <class C>
|
||||
BOOST_UBLAS_INLINE
|
||||
noalias_proxy<C> noalias (C& lvalue) {
|
||||
return noalias_proxy<C> (lvalue);
|
||||
}
|
||||
template <class C>
|
||||
BOOST_UBLAS_INLINE
|
||||
noalias_proxy<const C> noalias (const C& lvalue) {
|
||||
return noalias_proxy<const C> (lvalue);
|
||||
}
|
||||
|
||||
// Possible future compatible syntax where lvalue possible has an unsafe alias on the RHS
|
||||
// safe(lhs) = rhs_expression
|
||||
template <class C>
|
||||
BOOST_UBLAS_INLINE
|
||||
C& safe (C& lvalue) {
|
||||
return lvalue;
|
||||
}
|
||||
template <class C>
|
||||
BOOST_UBLAS_INLINE
|
||||
const C& safe (const C& lvalue) {
|
||||
return lvalue;
|
||||
}
|
||||
|
||||
|
||||
// Dimension accessors
|
||||
namespace dimension {
|
||||
|
||||
// Generic accessors
|
||||
template<unsigned dimension>
|
||||
struct dimension_properties {};
|
||||
|
||||
template<>
|
||||
struct dimension_properties<1> {
|
||||
template <class E>
|
||||
BOOST_UBLAS_INLINE static
|
||||
typename E::size_type size (const vector_expression<E> &e) {
|
||||
return e ().size ();
|
||||
}
|
||||
template <class E>
|
||||
BOOST_UBLAS_INLINE static
|
||||
typename E::size_type size (const matrix_expression<E> &e) {
|
||||
return e ().size1 ();
|
||||
}
|
||||
// Note: Index functions cannot deduce dependant template parameter V or M from i
|
||||
template <class V>
|
||||
BOOST_UBLAS_INLINE static
|
||||
typename V::size_type index (const typename V::iterator &i) {
|
||||
return i.index ();
|
||||
}
|
||||
template <class M>
|
||||
BOOST_UBLAS_INLINE static
|
||||
typename M::size_type index (const typename M::iterator1 &i) {
|
||||
return i.index1 ();
|
||||
}
|
||||
template <class M>
|
||||
BOOST_UBLAS_INLINE static
|
||||
typename M::size_type index (const typename M::iterator2 &i) {
|
||||
return i.index1 ();
|
||||
}
|
||||
};
|
||||
template<>
|
||||
struct dimension_properties<2> {
|
||||
template <class E>
|
||||
BOOST_UBLAS_INLINE static
|
||||
typename E::size_type size (const vector_expression<E> &) {
|
||||
return 1;
|
||||
}
|
||||
template <class E>
|
||||
BOOST_UBLAS_INLINE static
|
||||
typename E::size_type size (const matrix_expression<E> &e) {
|
||||
return e ().size2 ();
|
||||
}
|
||||
template <class V>
|
||||
BOOST_UBLAS_INLINE static
|
||||
typename V::size_type index (const typename V::iterator &) {
|
||||
return 1;
|
||||
}
|
||||
template <class M>
|
||||
BOOST_UBLAS_INLINE static
|
||||
typename M::size_type index (const typename M::iterator1 &i) {
|
||||
return i.index2 ();
|
||||
}
|
||||
template <class M>
|
||||
BOOST_UBLAS_INLINE static
|
||||
typename M::size_type index (const typename M::iterator2 &i) {
|
||||
return i.index2 ();
|
||||
}
|
||||
};
|
||||
|
||||
template<unsigned dimension, class E>
|
||||
BOOST_UBLAS_INLINE
|
||||
typename E::size_type size (const E& e) {
|
||||
return dimension_properties<dimension>::size (e);
|
||||
}
|
||||
|
||||
template<unsigned dimension, class I>
|
||||
BOOST_UBLAS_INLINE
|
||||
typename I::container_type::size_type
|
||||
index (const I& i) {
|
||||
typedef typename I::container_type container_type;
|
||||
return dimension_properties<dimension>::template index<container_type> (i);
|
||||
}
|
||||
|
||||
|
||||
// Named accessors - just syntactic sugar
|
||||
template<class V>
|
||||
typename V::size_type num_elements (const V &v) {
|
||||
return v.size ();
|
||||
}
|
||||
template<class M>
|
||||
typename M::size_type num_rows (const M &m) {
|
||||
return m.size1 ();
|
||||
}
|
||||
template<class M>
|
||||
typename M::size_type num_columns (const M &m) {
|
||||
return m.size2 ();
|
||||
}
|
||||
template<class MV>
|
||||
typename MV::size_type num_non_zeros (const MV &mv) {
|
||||
return mv.non_zeros ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}}}
|
||||
|
||||
#endif
|
||||
@@ -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
|
||||
*/
|
||||
@@ -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
|
||||
1436
project/jni/boost/include/boost/numeric/ublas/detail/iterator.hpp
Normal file
1436
project/jni/boost/include/boost/numeric/ublas/detail/iterator.hpp
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
878
project/jni/boost/include/boost/numeric/ublas/detail/raw.hpp
Normal file
878
project/jni/boost/include/boost/numeric/ublas/detail/raw.hpp
Normal file
@@ -0,0 +1,878 @@
|
||||
//
|
||||
// Copyright (c) 2002-2003
|
||||
// Toon Knapen, Kresimir Fresl, Joerg Walter
|
||||
//
|
||||
// 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_UBLAS_RAW_
|
||||
#define _BOOST_UBLAS_RAW_
|
||||
|
||||
namespace boost { namespace numeric { namespace ublas { namespace raw {
|
||||
|
||||
// We need data_const() mostly due to MSVC 6.0.
|
||||
// But how shall we write portable code otherwise?
|
||||
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
int size( const V &v ) ;
|
||||
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
int size( const vector_reference<V> &v ) ;
|
||||
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
int size1( const M &m ) ;
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
int size2( const M &m ) ;
|
||||
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
int size1( const matrix_reference<M> &m ) ;
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
int size2( const matrix_reference<M> &m ) ;
|
||||
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
int leading_dimension( const M &m, row_major_tag ) ;
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
int leading_dimension( const M &m, column_major_tag ) ;
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
int leading_dimension( const M &m ) ;
|
||||
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
int leading_dimension( const matrix_reference<M> &m ) ;
|
||||
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
int stride( const V &v ) ;
|
||||
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
int stride( const vector_range<V> &v ) ;
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
int stride( const vector_slice<V> &v ) ;
|
||||
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
int stride( const matrix_row<M> &v ) ;
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
int stride( const matrix_column<M> &v ) ;
|
||||
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
int stride1( const M &m ) ;
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
int stride2( const M &m ) ;
|
||||
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
int stride1( const matrix_reference<M> &m ) ;
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
int stride2( const matrix_reference<M> &m ) ;
|
||||
|
||||
template < typename T, std::size_t M, std::size_t N >
|
||||
BOOST_UBLAS_INLINE
|
||||
int stride1( const c_matrix<T, M, N> &m ) ;
|
||||
template < typename T, std::size_t M, std::size_t N >
|
||||
BOOST_UBLAS_INLINE
|
||||
int stride2( const c_matrix<T, M, N> &m ) ;
|
||||
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
int stride1( const matrix_range<M> &m ) ;
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
int stride1( const matrix_slice<M> &m ) ;
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
int stride2( const matrix_range<M> &m ) ;
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
int stride2( const matrix_slice<M> &m ) ;
|
||||
|
||||
template < typename MV >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename MV::array_type::array_type::const_pointer data( const MV &mv ) ;
|
||||
template < typename MV >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename MV::array_type::array_type::const_pointer data_const( const MV &mv ) ;
|
||||
template < typename MV >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename MV::array_type::pointer data( MV &mv ) ;
|
||||
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename V::array_type::array_type::const_pointer data( const vector_reference<V> &v ) ;
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename V::array_type::array_type::const_pointer data_const( const vector_reference<V> &v ) ;
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename V::array_type::pointer data( vector_reference<V> &v ) ;
|
||||
|
||||
template < typename T, std::size_t N >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename c_vector<T, N>::array_type::array_type::const_pointer data( const c_vector<T, N> &v ) ;
|
||||
template < typename T, std::size_t N >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename c_vector<T, N>::array_type::array_type::const_pointer data_const( const c_vector<T, N> &v ) ;
|
||||
template < typename T, std::size_t N >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename c_vector<T, N>::pointer data( c_vector<T, N> &v ) ;
|
||||
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename V::array_type::array_type::const_pointer data( const vector_range<V> &v ) ;
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename V::array_type::array_type::const_pointer data( const vector_slice<V> &v ) ;
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename V::array_type::array_type::const_pointer data_const( const vector_range<V> &v ) ;
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename V::array_type::array_type::const_pointer data_const( const vector_slice<V> &v ) ;
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename V::array_type::pointer data( vector_range<V> &v ) ;
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename V::array_type::pointer data( vector_slice<V> &v ) ;
|
||||
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::array_type::const_pointer data( const matrix_reference<M> &m ) ;
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::array_type::const_pointer data_const( const matrix_reference<M> &m ) ;
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::pointer data( matrix_reference<M> &m ) ;
|
||||
|
||||
template < typename T, std::size_t M, std::size_t N >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename c_matrix<T, M, N>::array_type::array_type::const_pointer data( const c_matrix<T, M, N> &m ) ;
|
||||
template < typename T, std::size_t M, std::size_t N >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename c_matrix<T, M, N>::array_type::array_type::const_pointer data_const( const c_matrix<T, M, N> &m ) ;
|
||||
template < typename T, std::size_t M, std::size_t N >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename c_matrix<T, M, N>::pointer data( c_matrix<T, M, N> &m ) ;
|
||||
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::array_type::const_pointer data( const matrix_row<M> &v ) ;
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::array_type::const_pointer data( const matrix_column<M> &v ) ;
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::array_type::const_pointer data_const( const matrix_row<M> &v ) ;
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::array_type::const_pointer data_const( const matrix_column<M> &v ) ;
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::pointer data( matrix_row<M> &v ) ;
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::pointer data( matrix_column<M> &v ) ;
|
||||
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::array_type::const_pointer data( const matrix_range<M> &m ) ;
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::array_type::const_pointer data( const matrix_slice<M> &m ) ;
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::array_type::const_pointer data_const( const matrix_range<M> &m ) ;
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::array_type::const_pointer data_const( const matrix_slice<M> &m ) ;
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::pointer data( matrix_range<M> &m ) ;
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::pointer data( matrix_slice<M> &m ) ;
|
||||
|
||||
template < typename MV >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename MV::array_type::array_type::const_pointer base( const MV &mv ) ;
|
||||
|
||||
template < typename MV >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename MV::array_type::array_type::const_pointer base_const( const MV &mv ) ;
|
||||
template < typename MV >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename MV::array_type::pointer base( MV &mv ) ;
|
||||
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename V::array_type::array_type::const_pointer base( const vector_reference<V> &v ) ;
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename V::array_type::array_type::const_pointer base_const( const vector_reference<V> &v ) ;
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename V::array_type::pointer base( vector_reference<V> &v ) ;
|
||||
|
||||
template < typename T, std::size_t N >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename c_vector<T, N>::array_type::array_type::const_pointer base( const c_vector<T, N> &v ) ;
|
||||
template < typename T, std::size_t N >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename c_vector<T, N>::array_type::array_type::const_pointer base_const( const c_vector<T, N> &v ) ;
|
||||
template < typename T, std::size_t N >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename c_vector<T, N>::pointer base( c_vector<T, N> &v ) ;
|
||||
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename V::array_type::array_type::const_pointer base( const vector_range<V> &v ) ;
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename V::array_type::array_type::const_pointer base( const vector_slice<V> &v ) ;
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename V::array_type::array_type::const_pointer base_const( const vector_range<V> &v ) ;
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename V::array_type::array_type::const_pointer base_const( const vector_slice<V> &v ) ;
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename V::array_type::pointer base( vector_range<V> &v ) ;
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename V::array_type::pointer base( vector_slice<V> &v ) ;
|
||||
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::array_type::const_pointer base( const matrix_reference<M> &m ) ;
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::array_type::const_pointer base_const( const matrix_reference<M> &m ) ;
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::pointer base( matrix_reference<M> &m ) ;
|
||||
|
||||
template < typename T, std::size_t M, std::size_t N >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename c_matrix<T, M, N>::array_type::array_type::const_pointer base( const c_matrix<T, M, N> &m ) ;
|
||||
template < typename T, std::size_t M, std::size_t N >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename c_matrix<T, M, N>::array_type::array_type::const_pointer base_const( const c_matrix<T, M, N> &m ) ;
|
||||
template < typename T, std::size_t M, std::size_t N >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename c_matrix<T, M, N>::pointer base( c_matrix<T, M, N> &m ) ;
|
||||
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::array_type::const_pointer base( const matrix_row<M> &v ) ;
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::array_type::const_pointer base( const matrix_column<M> &v ) ;
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::array_type::const_pointer base_const( const matrix_row<M> &v ) ;
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::array_type::const_pointer base_const( const matrix_column<M> &v ) ;
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::pointer base( matrix_row<M> &v ) ;
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::pointer base( matrix_column<M> &v ) ;
|
||||
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::array_type::const_pointer base( const matrix_range<M> &m ) ;
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::array_type::const_pointer base( const matrix_slice<M> &m ) ;
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::array_type::const_pointer base_const( const matrix_range<M> &m ) ;
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::array_type::const_pointer base_const( const matrix_slice<M> &m ) ;
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::pointer base( matrix_range<M> &m ) ;
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::pointer base( matrix_slice<M> &m ) ;
|
||||
|
||||
template < typename MV >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename MV::size_type start( const MV &mv ) ;
|
||||
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename V::size_type start( const vector_range<V> &v ) ;
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename V::size_type start( const vector_slice<V> &v ) ;
|
||||
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::size_type start( const matrix_row<M> &v ) ;
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::size_type start( const matrix_column<M> &v ) ;
|
||||
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::size_type start( const matrix_range<M> &m ) ;
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::size_type start( const matrix_slice<M> &m ) ;
|
||||
|
||||
|
||||
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
int size( const V &v ) {
|
||||
return v.size() ;
|
||||
}
|
||||
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
int size( const vector_reference<V> &v ) {
|
||||
return size( v ) ;
|
||||
}
|
||||
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
int size1( const M &m ) {
|
||||
return m.size1() ;
|
||||
}
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
int size2( const M &m ) {
|
||||
return m.size2() ;
|
||||
}
|
||||
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
int size1( const matrix_reference<M> &m ) {
|
||||
return size1( m.expression() ) ;
|
||||
}
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
int size2( const matrix_reference<M> &m ) {
|
||||
return size2( m.expression() ) ;
|
||||
}
|
||||
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
int leading_dimension( const M &m, row_major_tag ) {
|
||||
return m.size2() ;
|
||||
}
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
int leading_dimension( const M &m, column_major_tag ) {
|
||||
return m.size1() ;
|
||||
}
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
int leading_dimension( const M &m ) {
|
||||
return leading_dimension( m, typename M::orientation_category() ) ;
|
||||
}
|
||||
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
int leading_dimension( const matrix_reference<M> &m ) {
|
||||
return leading_dimension( m.expression() ) ;
|
||||
}
|
||||
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
int stride( const V &v ) {
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
int stride( const vector_range<V> &v ) {
|
||||
return stride( v.data() ) ;
|
||||
}
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
int stride( const vector_slice<V> &v ) {
|
||||
return v.stride() * stride( v.data() ) ;
|
||||
}
|
||||
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
int stride( const matrix_row<M> &v ) {
|
||||
return stride2( v.data() ) ;
|
||||
}
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
int stride( const matrix_column<M> &v ) {
|
||||
return stride1( v.data() ) ;
|
||||
}
|
||||
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
int stride1( const M &m ) {
|
||||
typedef typename M::functor_type functor_type;
|
||||
return functor_type::one1( m.size1(), m.size2() ) ;
|
||||
}
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
int stride2( const M &m ) {
|
||||
typedef typename M::functor_type functor_type;
|
||||
return functor_type::one2( m.size1(), m.size2() ) ;
|
||||
}
|
||||
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
int stride1( const matrix_reference<M> &m ) {
|
||||
return stride1( m.expression() ) ;
|
||||
}
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
int stride2( const matrix_reference<M> &m ) {
|
||||
return stride2( m.expression() ) ;
|
||||
}
|
||||
|
||||
template < typename T, std::size_t M, std::size_t N >
|
||||
BOOST_UBLAS_INLINE
|
||||
int stride1( const c_matrix<T, M, N> &m ) {
|
||||
return N ;
|
||||
}
|
||||
template < typename T, std::size_t M, std::size_t N >
|
||||
BOOST_UBLAS_INLINE
|
||||
int stride2( const c_matrix<T, M, N> &m ) {
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
int stride1( const matrix_range<M> &m ) {
|
||||
return stride1( m.data() ) ;
|
||||
}
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
int stride1( const matrix_slice<M> &m ) {
|
||||
return m.stride1() * stride1( m.data() ) ;
|
||||
}
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
int stride2( const matrix_range<M> &m ) {
|
||||
return stride2( m.data() ) ;
|
||||
}
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
int stride2( const matrix_slice<M> &m ) {
|
||||
return m.stride2() * stride2( m.data() ) ;
|
||||
}
|
||||
|
||||
template < typename MV >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename MV::array_type::array_type::array_type::const_pointer data( const MV &mv ) {
|
||||
return &mv.data().begin()[0] ;
|
||||
}
|
||||
template < typename MV >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename MV::array_type::array_type::const_pointer data_const( const MV &mv ) {
|
||||
return &mv.data().begin()[0] ;
|
||||
}
|
||||
template < typename MV >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename MV::array_type::pointer data( MV &mv ) {
|
||||
return &mv.data().begin()[0] ;
|
||||
}
|
||||
|
||||
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename V::array_type::array_type::const_pointer data( const vector_reference<V> &v ) {
|
||||
return data( v.expression () ) ;
|
||||
}
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename V::array_type::array_type::const_pointer data_const( const vector_reference<V> &v ) {
|
||||
return data_const( v.expression () ) ;
|
||||
}
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename V::array_type::pointer data( vector_reference<V> &v ) {
|
||||
return data( v.expression () ) ;
|
||||
}
|
||||
|
||||
template < typename T, std::size_t N >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename c_vector<T, N>::array_type::array_type::const_pointer data( const c_vector<T, N> &v ) {
|
||||
return v.data() ;
|
||||
}
|
||||
template < typename T, std::size_t N >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename c_vector<T, N>::array_type::array_type::const_pointer data_const( const c_vector<T, N> &v ) {
|
||||
return v.data() ;
|
||||
}
|
||||
template < typename T, std::size_t N >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename c_vector<T, N>::pointer data( c_vector<T, N> &v ) {
|
||||
return v.data() ;
|
||||
}
|
||||
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename V::array_type::array_type::const_pointer data( const vector_range<V> &v ) {
|
||||
return data( v.data() ) + v.start() * stride (v.data() ) ;
|
||||
}
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename V::array_type::array_type::const_pointer data( const vector_slice<V> &v ) {
|
||||
return data( v.data() ) + v.start() * stride (v.data() ) ;
|
||||
}
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename V::array_type::array_type::const_pointer data_const( const vector_range<V> &v ) {
|
||||
return data_const( v.data() ) + v.start() * stride (v.data() ) ;
|
||||
}
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename V::array_type::const_pointer data_const( const vector_slice<V> &v ) {
|
||||
return data_const( v.data() ) + v.start() * stride (v.data() ) ;
|
||||
}
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename V::array_type::pointer data( vector_range<V> &v ) {
|
||||
return data( v.data() ) + v.start() * stride (v.data() ) ;
|
||||
}
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename V::array_type::pointer data( vector_slice<V> &v ) {
|
||||
return data( v.data() ) + v.start() * stride (v.data() ) ;
|
||||
}
|
||||
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::const_pointer data( const matrix_reference<M> &m ) {
|
||||
return data( m.expression () ) ;
|
||||
}
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::const_pointer data_const( const matrix_reference<M> &m ) {
|
||||
return data_const( m.expression () ) ;
|
||||
}
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::pointer data( matrix_reference<M> &m ) {
|
||||
return data( m.expression () ) ;
|
||||
}
|
||||
|
||||
template < typename T, std::size_t M, std::size_t N >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename c_matrix<T, M, N>::array_type::const_pointer data( const c_matrix<T, M, N> &m ) {
|
||||
return m.data() ;
|
||||
}
|
||||
template < typename T, std::size_t M, std::size_t N >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename c_matrix<T, M, N>::array_type::const_pointer data_const( const c_matrix<T, M, N> &m ) {
|
||||
return m.data() ;
|
||||
}
|
||||
template < typename T, std::size_t M, std::size_t N >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename c_matrix<T, M, N>::pointer data( c_matrix<T, M, N> &m ) {
|
||||
return m.data() ;
|
||||
}
|
||||
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::const_pointer data( const matrix_row<M> &v ) {
|
||||
return data( v.data() ) + v.index() * stride1( v.data() ) ;
|
||||
}
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::const_pointer data( const matrix_column<M> &v ) {
|
||||
return data( v.data() ) + v.index() * stride2( v.data() ) ;
|
||||
}
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::const_pointer data_const( const matrix_row<M> &v ) {
|
||||
return data_const( v.data() ) + v.index() * stride1( v.data() ) ;
|
||||
}
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::const_pointer data_const( const matrix_column<M> &v ) {
|
||||
return data_const( v.data() ) + v.index() * stride2( v.data() ) ;
|
||||
}
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::pointer data( matrix_row<M> &v ) {
|
||||
return data( v.data() ) + v.index() * stride1( v.data() ) ;
|
||||
}
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::pointer data( matrix_column<M> &v ) {
|
||||
return data( v.data() ) + v.index() * stride2( v.data() ) ;
|
||||
}
|
||||
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::const_pointer data( const matrix_range<M> &m ) {
|
||||
return data( m.data() ) + m.start1() * stride1( m.data () ) + m.start2() * stride2( m.data () ) ;
|
||||
}
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::const_pointer data( const matrix_slice<M> &m ) {
|
||||
return data( m.data() ) + m.start1() * stride1( m.data () ) + m.start2() * stride2( m.data () ) ;
|
||||
}
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::const_pointer data_const( const matrix_range<M> &m ) {
|
||||
return data_const( m.data() ) + m.start1() * stride1( m.data () ) + m.start2() * stride2( m.data () ) ;
|
||||
}
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::const_pointer data_const( const matrix_slice<M> &m ) {
|
||||
return data_const( m.data() ) + m.start1() * stride1( m.data () ) + m.start2() * stride2( m.data () ) ;
|
||||
}
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::pointer data( matrix_range<M> &m ) {
|
||||
return data( m.data() ) + m.start1() * stride1( m.data () ) + m.start2() * stride2( m.data () ) ;
|
||||
}
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::pointer data( matrix_slice<M> &m ) {
|
||||
return data( m.data() ) + m.start1() * stride1( m.data () ) + m.start2() * stride2( m.data () ) ;
|
||||
}
|
||||
|
||||
|
||||
template < typename MV >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename MV::array_type::const_pointer base( const MV &mv ) {
|
||||
return &mv.data().begin()[0] ;
|
||||
}
|
||||
template < typename MV >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename MV::array_type::const_pointer base_const( const MV &mv ) {
|
||||
return &mv.data().begin()[0] ;
|
||||
}
|
||||
template < typename MV >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename MV::array_type::pointer base( MV &mv ) {
|
||||
return &mv.data().begin()[0] ;
|
||||
}
|
||||
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename V::array_type::const_pointer base( const vector_reference<V> &v ) {
|
||||
return base( v.expression () ) ;
|
||||
}
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename V::array_type::const_pointer base_const( const vector_reference<V> &v ) {
|
||||
return base_const( v.expression () ) ;
|
||||
}
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename V::array_type::pointer base( vector_reference<V> &v ) {
|
||||
return base( v.expression () ) ;
|
||||
}
|
||||
|
||||
template < typename T, std::size_t N >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename c_vector<T, N>::array_type::const_pointer base( const c_vector<T, N> &v ) {
|
||||
return v.data() ;
|
||||
}
|
||||
template < typename T, std::size_t N >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename c_vector<T, N>::array_type::const_pointer base_const( const c_vector<T, N> &v ) {
|
||||
return v.data() ;
|
||||
}
|
||||
template < typename T, std::size_t N >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename c_vector<T, N>::pointer base( c_vector<T, N> &v ) {
|
||||
return v.data() ;
|
||||
}
|
||||
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename V::array_type::const_pointer base( const vector_range<V> &v ) {
|
||||
return base( v.data() ) ;
|
||||
}
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename V::array_type::const_pointer base( const vector_slice<V> &v ) {
|
||||
return base( v.data() ) ;
|
||||
}
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename V::array_type::const_pointer base_const( const vector_range<V> &v ) {
|
||||
return base_const( v.data() ) ;
|
||||
}
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename V::array_type::const_pointer base_const( const vector_slice<V> &v ) {
|
||||
return base_const( v.data() ) ;
|
||||
}
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename V::array_type::pointer base( vector_range<V> &v ) {
|
||||
return base( v.data() ) ;
|
||||
}
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename V::array_type::pointer base( vector_slice<V> &v ) {
|
||||
return base( v.data() ) ;
|
||||
}
|
||||
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::const_pointer base( const matrix_reference<M> &m ) {
|
||||
return base( m.expression () ) ;
|
||||
}
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::const_pointer base_const( const matrix_reference<M> &m ) {
|
||||
return base_const( m.expression () ) ;
|
||||
}
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::pointer base( matrix_reference<M> &m ) {
|
||||
return base( m.expression () ) ;
|
||||
}
|
||||
|
||||
template < typename T, std::size_t M, std::size_t N >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename c_matrix<T, M, N>::array_type::const_pointer base( const c_matrix<T, M, N> &m ) {
|
||||
return m.data() ;
|
||||
}
|
||||
template < typename T, std::size_t M, std::size_t N >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename c_matrix<T, M, N>::array_type::const_pointer base_const( const c_matrix<T, M, N> &m ) {
|
||||
return m.data() ;
|
||||
}
|
||||
template < typename T, std::size_t M, std::size_t N >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename c_matrix<T, M, N>::pointer base( c_matrix<T, M, N> &m ) {
|
||||
return m.data() ;
|
||||
}
|
||||
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::const_pointer base( const matrix_row<M> &v ) {
|
||||
return base( v.data() ) ;
|
||||
}
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::const_pointer base( const matrix_column<M> &v ) {
|
||||
return base( v.data() ) ;
|
||||
}
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::const_pointer base_const( const matrix_row<M> &v ) {
|
||||
return base_const( v.data() ) ;
|
||||
}
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::const_pointer base_const( const matrix_column<M> &v ) {
|
||||
return base_const( v.data() ) ;
|
||||
}
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::pointer base( matrix_row<M> &v ) {
|
||||
return base( v.data() ) ;
|
||||
}
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::pointer base( matrix_column<M> &v ) {
|
||||
return base( v.data() ) ;
|
||||
}
|
||||
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::const_pointer base( const matrix_range<M> &m ) {
|
||||
return base( m.data() ) ;
|
||||
}
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::const_pointer base( const matrix_slice<M> &m ) {
|
||||
return base( m.data() ) ;
|
||||
}
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::const_pointer base_const( const matrix_range<M> &m ) {
|
||||
return base_const( m.data() ) ;
|
||||
}
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::const_pointer base_const( const matrix_slice<M> &m ) {
|
||||
return base_const( m.data() ) ;
|
||||
}
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::pointer base( matrix_range<M> &m ) {
|
||||
return base( m.data() ) ;
|
||||
}
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::array_type::pointer base( matrix_slice<M> &m ) {
|
||||
return base( m.data() ) ;
|
||||
}
|
||||
|
||||
template < typename MV >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename MV::size_type start( const MV &mv ) {
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename V::size_type start( const vector_range<V> &v ) {
|
||||
return v.start() * stride (v.data() ) ;
|
||||
}
|
||||
template < typename V >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename V::size_type start( const vector_slice<V> &v ) {
|
||||
return v.start() * stride (v.data() ) ;
|
||||
}
|
||||
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::size_type start( const matrix_row<M> &v ) {
|
||||
return v.index() * stride1( v.data() ) ;
|
||||
}
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::size_type start( const matrix_column<M> &v ) {
|
||||
return v.index() * stride2( v.data() ) ;
|
||||
}
|
||||
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::size_type start( const matrix_range<M> &m ) {
|
||||
return m.start1() * stride1( m.data () ) + m.start2() * stride2( m.data () ) ;
|
||||
}
|
||||
template < typename M >
|
||||
BOOST_UBLAS_INLINE
|
||||
typename M::size_type start( const matrix_slice<M> &m ) {
|
||||
return m.start1() * stride1( m.data () ) + m.start2() * stride2( m.data () ) ;
|
||||
}
|
||||
|
||||
}}}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,174 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Joel de Guzman
|
||||
*
|
||||
* 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)
|
||||
*/
|
||||
#ifndef _BOOST_UBLAS_NUMERICTYPE_DEDUCTION_
|
||||
#define _BOOST_UBLAS_NUMERICTYPE_DEDUCTION_
|
||||
|
||||
// See original in boost-sandbox/boost/utility/type_deduction.hpp for comments
|
||||
|
||||
#include <boost/mpl/vector/vector20.hpp>
|
||||
#include <boost/mpl/at.hpp>
|
||||
#include <boost/mpl/or.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
#include <boost/type_traits/remove_cv.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
|
||||
namespace boost { namespace numeric { namespace ublas {
|
||||
|
||||
struct error_cant_deduce_type {};
|
||||
|
||||
namespace type_deduction_detail
|
||||
{
|
||||
typedef char(&bool_value_type)[1];
|
||||
typedef char(&float_value_type)[2];
|
||||
typedef char(&double_value_type)[3];
|
||||
typedef char(&long_double_value_type)[4];
|
||||
typedef char(&char_value_type)[5];
|
||||
typedef char(&schar_value_type)[6];
|
||||
typedef char(&uchar_value_type)[7];
|
||||
typedef char(&short_value_type)[8];
|
||||
typedef char(&ushort_value_type)[9];
|
||||
typedef char(&int_value_type)[10];
|
||||
typedef char(&uint_value_type)[11];
|
||||
typedef char(&long_value_type)[12];
|
||||
typedef char(&ulong_value_type)[13];
|
||||
|
||||
typedef char(&x_value_type)[14];
|
||||
typedef char(&y_value_type)[15];
|
||||
|
||||
typedef char(&cant_deduce_type)[16];
|
||||
|
||||
template <typename T, typename PlainT = typename remove_cv<T>::type>
|
||||
struct is_basic
|
||||
: mpl::or_<
|
||||
typename mpl::or_<
|
||||
is_same<PlainT, bool>
|
||||
, is_same<PlainT, float>
|
||||
, is_same<PlainT, double>
|
||||
, is_same<PlainT, long double>
|
||||
> ::type,
|
||||
typename mpl::or_<
|
||||
is_same<PlainT, char>
|
||||
, is_same<PlainT, signed char>
|
||||
, is_same<PlainT, unsigned char>
|
||||
, is_same<PlainT, short>
|
||||
, is_same<PlainT, unsigned short>
|
||||
> ::type,
|
||||
typename mpl::or_<
|
||||
is_same<PlainT, int>
|
||||
, is_same<PlainT, unsigned int>
|
||||
, is_same<PlainT, long>
|
||||
, is_same<PlainT, unsigned long>
|
||||
> ::type
|
||||
> {};
|
||||
|
||||
struct asymmetric;
|
||||
|
||||
template <typename X, typename Y>
|
||||
cant_deduce_type
|
||||
test(...); // The black hole !!!
|
||||
|
||||
template <typename X, typename Y>
|
||||
bool_value_type
|
||||
test(bool const&);
|
||||
|
||||
template <typename X, typename Y>
|
||||
float_value_type
|
||||
test(float const&);
|
||||
|
||||
template <typename X, typename Y>
|
||||
double_value_type
|
||||
test(double const&);
|
||||
|
||||
template <typename X, typename Y>
|
||||
long_double_value_type
|
||||
test(long double const&);
|
||||
|
||||
template <typename X, typename Y>
|
||||
char_value_type
|
||||
test(char const&);
|
||||
|
||||
template <typename X, typename Y>
|
||||
schar_value_type
|
||||
test(signed char const&);
|
||||
|
||||
template <typename X, typename Y>
|
||||
uchar_value_type
|
||||
test(unsigned char const&);
|
||||
|
||||
template <typename X, typename Y>
|
||||
short_value_type
|
||||
test(short const&);
|
||||
|
||||
template <typename X, typename Y>
|
||||
ushort_value_type
|
||||
test(unsigned short const&);
|
||||
|
||||
template <typename X, typename Y>
|
||||
int_value_type
|
||||
test(int const&);
|
||||
|
||||
template <typename X, typename Y>
|
||||
uint_value_type
|
||||
test(unsigned int const&);
|
||||
|
||||
template <typename X, typename Y>
|
||||
long_value_type
|
||||
test(long const&);
|
||||
|
||||
template <typename X, typename Y>
|
||||
ulong_value_type
|
||||
test(unsigned long const&);
|
||||
|
||||
template <typename X, typename Y>
|
||||
typename disable_if<
|
||||
is_basic<X>, x_value_type
|
||||
>::type
|
||||
test(X const&);
|
||||
|
||||
template <typename X, typename Y>
|
||||
typename disable_if<
|
||||
mpl::or_<
|
||||
is_basic<Y>
|
||||
, is_same<Y, asymmetric>
|
||||
, is_same<const X, const Y>
|
||||
>
|
||||
, y_value_type
|
||||
>::type
|
||||
test(Y const&);
|
||||
|
||||
template <typename X, typename Y>
|
||||
struct base_result_of
|
||||
{
|
||||
typedef typename remove_cv<X>::type x_type;
|
||||
typedef typename remove_cv<Y>::type y_type;
|
||||
|
||||
typedef mpl::vector16<
|
||||
mpl::identity<bool>
|
||||
, mpl::identity<float>
|
||||
, mpl::identity<double>
|
||||
, mpl::identity<long double>
|
||||
, mpl::identity<char>
|
||||
, mpl::identity<signed char>
|
||||
, mpl::identity<unsigned char>
|
||||
, mpl::identity<short>
|
||||
, mpl::identity<unsigned short>
|
||||
, mpl::identity<int>
|
||||
, mpl::identity<unsigned int>
|
||||
, mpl::identity<long>
|
||||
, mpl::identity<unsigned long>
|
||||
, mpl::identity<x_type>
|
||||
, mpl::identity<y_type>
|
||||
, mpl::identity<error_cant_deduce_type>
|
||||
>
|
||||
types;
|
||||
};
|
||||
|
||||
}}} } // namespace boost::numeric::ublas ::type_deduction_detail
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// 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_TEMPORARY_
|
||||
#define _BOOST_UBLAS_TEMPORARY_
|
||||
|
||||
|
||||
namespace boost { namespace numeric { namespace ublas {
|
||||
|
||||
/// For the creation of temporary vectors in the assignment of proxies
|
||||
template <class M>
|
||||
struct vector_temporary_traits {
|
||||
typedef typename M::vector_temporary_type type ;
|
||||
};
|
||||
|
||||
/// For the creation of temporary vectors in the assignment of proxies
|
||||
template <class M>
|
||||
struct matrix_temporary_traits {
|
||||
typedef typename M::matrix_temporary_type type ;
|
||||
};
|
||||
|
||||
} } }
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,571 @@
|
||||
//
|
||||
// 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_VECTOR_ASSIGN_
|
||||
#define _BOOST_UBLAS_VECTOR_ASSIGN_
|
||||
|
||||
#include <boost/numeric/ublas/functional.hpp> // scalar_assign
|
||||
// Required for make_conformant storage
|
||||
#include <vector>
|
||||
|
||||
// Iterators based on ideas of Jeremy Siek
|
||||
|
||||
namespace boost { namespace numeric { namespace ublas {
|
||||
namespace detail {
|
||||
|
||||
// Weak equality check - useful to compare equality two arbitary vector 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<class E1, class E2, class S>
|
||||
BOOST_UBLAS_INLINE
|
||||
bool equals (const vector_expression<E1> &e1, const vector_expression<E2> &e2, S epsilon, S min_norm) {
|
||||
return norm_inf (e1 - e2) < epsilon *
|
||||
std::max<S> (std::max<S> (norm_inf (e1), norm_inf (e2)), min_norm);
|
||||
}
|
||||
|
||||
template<class E1, class E2>
|
||||
BOOST_UBLAS_INLINE
|
||||
bool expression_type_check (const vector_expression<E1> &e1, const vector_expression<E2> &e2) {
|
||||
typedef typename type_traits<typename promote_traits<typename E1::value_type,
|
||||
typename E2::value_type>::promote_type>::real_type real_type;
|
||||
return equals (e1, e2, BOOST_UBLAS_TYPE_CHECK_EPSILON, BOOST_UBLAS_TYPE_CHECK_MIN);
|
||||
}
|
||||
|
||||
|
||||
// Make sparse proxies conformant
|
||||
template<class V, class E>
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
void make_conformant (V &v, const vector_expression<E> &e) {
|
||||
BOOST_UBLAS_CHECK (v.size () == e ().size (), bad_size ());
|
||||
typedef typename V::size_type size_type;
|
||||
typedef typename V::difference_type difference_type;
|
||||
typedef typename V::value_type value_type;
|
||||
// FIXME unbounded_array with push_back maybe better
|
||||
std::vector<size_type> index;
|
||||
typename V::iterator it (v.begin ());
|
||||
typename V::iterator it_end (v.end ());
|
||||
typename E::const_iterator ite (e ().begin ());
|
||||
typename E::const_iterator ite_end (e ().end ());
|
||||
if (it != it_end && ite != ite_end) {
|
||||
size_type it_index = it.index (), ite_index = ite.index ();
|
||||
while (true) {
|
||||
difference_type compare = it_index - ite_index;
|
||||
if (compare == 0) {
|
||||
++ it, ++ ite;
|
||||
if (it != it_end && ite != ite_end) {
|
||||
it_index = it.index ();
|
||||
ite_index = ite.index ();
|
||||
} else
|
||||
break;
|
||||
} else if (compare < 0) {
|
||||
increment (it, it_end, - compare);
|
||||
if (it != it_end)
|
||||
it_index = it.index ();
|
||||
else
|
||||
break;
|
||||
} else if (compare > 0) {
|
||||
if (*ite != value_type/*zero*/())
|
||||
index.push_back (ite.index ());
|
||||
++ ite;
|
||||
if (ite != ite_end)
|
||||
ite_index = ite.index ();
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (ite != ite_end) {
|
||||
if (*ite != value_type/*zero*/())
|
||||
index.push_back (ite.index ());
|
||||
++ ite;
|
||||
}
|
||||
for (size_type k = 0; k < index.size (); ++ k)
|
||||
v (index [k]) = value_type/*zero*/();
|
||||
}
|
||||
|
||||
}//namespace detail
|
||||
|
||||
|
||||
// Explicitly iterating
|
||||
template<template <class T1, class T2> class F, class V, class T>
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
void iterating_vector_assign_scalar (V &v, const T &t) {
|
||||
typedef F<typename V::iterator::reference, T> functor_type;
|
||||
typedef typename V::difference_type difference_type;
|
||||
difference_type size (v.size ());
|
||||
typename V::iterator it (v.begin ());
|
||||
BOOST_UBLAS_CHECK (v.end () - it == size, bad_size ());
|
||||
#ifndef BOOST_UBLAS_USE_DUFF_DEVICE
|
||||
while (-- size >= 0)
|
||||
functor_type::apply (*it, t), ++ it;
|
||||
#else
|
||||
DD (size, 4, r, (functor_type::apply (*it, t), ++ it));
|
||||
#endif
|
||||
}
|
||||
// Explicitly case
|
||||
template<template <class T1, class T2> class F, class V, class T>
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
void indexing_vector_assign_scalar (V &v, const T &t) {
|
||||
typedef F<typename V::reference, T> functor_type;
|
||||
typedef typename V::size_type size_type;
|
||||
size_type size (v.size ());
|
||||
#ifndef BOOST_UBLAS_USE_DUFF_DEVICE
|
||||
for (size_type i = 0; i < size; ++ i)
|
||||
functor_type::apply (v (i), t);
|
||||
#else
|
||||
size_type i (0);
|
||||
DD (size, 4, r, (functor_type::apply (v (i), t), ++ i));
|
||||
#endif
|
||||
}
|
||||
|
||||
// Dense (proxy) case
|
||||
template<template <class T1, class T2> class F, class V, class T>
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
void vector_assign_scalar (V &v, const T &t, dense_proxy_tag) {
|
||||
#ifdef BOOST_UBLAS_USE_INDEXING
|
||||
indexing_vector_assign_scalar<F> (v, t);
|
||||
#elif BOOST_UBLAS_USE_ITERATING
|
||||
iterating_vector_assign_scalar<F> (v, t);
|
||||
#else
|
||||
typedef typename V::size_type size_type;
|
||||
size_type size (v.size ());
|
||||
if (size >= BOOST_UBLAS_ITERATOR_THRESHOLD)
|
||||
iterating_vector_assign_scalar<F> (v, t);
|
||||
else
|
||||
indexing_vector_assign_scalar<F> (v, t);
|
||||
#endif
|
||||
}
|
||||
// Packed (proxy) case
|
||||
template<template <class T1, class T2> class F, class V, class T>
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
void vector_assign_scalar (V &v, const T &t, packed_proxy_tag) {
|
||||
typedef F<typename V::iterator::reference, T> functor_type;
|
||||
typedef typename V::difference_type difference_type;
|
||||
typename V::iterator it (v.begin ());
|
||||
difference_type size (v.end () - it);
|
||||
while (-- size >= 0)
|
||||
functor_type::apply (*it, t), ++ it;
|
||||
}
|
||||
// Sparse (proxy) case
|
||||
template<template <class T1, class T2> class F, class V, class T>
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
void vector_assign_scalar (V &v, const T &t, sparse_proxy_tag) {
|
||||
typedef F<typename V::iterator::reference, T> functor_type;
|
||||
typename V::iterator it (v.begin ());
|
||||
typename V::iterator it_end (v.end ());
|
||||
while (it != it_end)
|
||||
functor_type::apply (*it, t), ++ it;
|
||||
}
|
||||
|
||||
// Dispatcher
|
||||
template<template <class T1, class T2> class F, class V, class T>
|
||||
BOOST_UBLAS_INLINE
|
||||
void vector_assign_scalar (V &v, const T &t) {
|
||||
typedef typename V::storage_category storage_category;
|
||||
vector_assign_scalar<F> (v, t, storage_category ());
|
||||
}
|
||||
|
||||
template<class SC, bool COMPUTED, class RI>
|
||||
struct vector_assign_traits {
|
||||
typedef SC storage_category;
|
||||
};
|
||||
|
||||
template<bool COMPUTED>
|
||||
struct vector_assign_traits<dense_tag, COMPUTED, packed_random_access_iterator_tag> {
|
||||
typedef packed_tag storage_category;
|
||||
};
|
||||
template<>
|
||||
struct vector_assign_traits<dense_tag, false, sparse_bidirectional_iterator_tag> {
|
||||
typedef sparse_tag storage_category;
|
||||
};
|
||||
template<>
|
||||
struct vector_assign_traits<dense_tag, true, sparse_bidirectional_iterator_tag> {
|
||||
typedef sparse_proxy_tag storage_category;
|
||||
};
|
||||
|
||||
template<bool COMPUTED>
|
||||
struct vector_assign_traits<dense_proxy_tag, COMPUTED, packed_random_access_iterator_tag> {
|
||||
typedef packed_proxy_tag storage_category;
|
||||
};
|
||||
template<>
|
||||
struct vector_assign_traits<dense_proxy_tag, false, sparse_bidirectional_iterator_tag> {
|
||||
typedef sparse_proxy_tag storage_category;
|
||||
};
|
||||
template<>
|
||||
struct vector_assign_traits<dense_proxy_tag, true, sparse_bidirectional_iterator_tag> {
|
||||
typedef sparse_proxy_tag storage_category;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct vector_assign_traits<packed_tag, false, sparse_bidirectional_iterator_tag> {
|
||||
typedef sparse_tag storage_category;
|
||||
};
|
||||
template<>
|
||||
struct vector_assign_traits<packed_tag, true, sparse_bidirectional_iterator_tag> {
|
||||
typedef sparse_proxy_tag storage_category;
|
||||
};
|
||||
|
||||
template<bool COMPUTED>
|
||||
struct vector_assign_traits<packed_proxy_tag, COMPUTED, sparse_bidirectional_iterator_tag> {
|
||||
typedef sparse_proxy_tag storage_category;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct vector_assign_traits<sparse_tag, true, dense_random_access_iterator_tag> {
|
||||
typedef sparse_proxy_tag storage_category;
|
||||
};
|
||||
template<>
|
||||
struct vector_assign_traits<sparse_tag, true, packed_random_access_iterator_tag> {
|
||||
typedef sparse_proxy_tag storage_category;
|
||||
};
|
||||
template<>
|
||||
struct vector_assign_traits<sparse_tag, true, sparse_bidirectional_iterator_tag> {
|
||||
typedef sparse_proxy_tag storage_category;
|
||||
};
|
||||
|
||||
// Explicitly iterating
|
||||
template<template <class T1, class T2> class F, class V, class E>
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
void iterating_vector_assign (V &v, const vector_expression<E> &e) {
|
||||
typedef F<typename V::iterator::reference, typename E::value_type> functor_type;
|
||||
typedef typename V::difference_type difference_type;
|
||||
difference_type size (BOOST_UBLAS_SAME (v.size (), e ().size ()));
|
||||
typename V::iterator it (v.begin ());
|
||||
BOOST_UBLAS_CHECK (v.end () - it == size, bad_size ());
|
||||
typename E::const_iterator ite (e ().begin ());
|
||||
BOOST_UBLAS_CHECK (e ().end () - ite == size, bad_size ());
|
||||
#ifndef BOOST_UBLAS_USE_DUFF_DEVICE
|
||||
while (-- size >= 0)
|
||||
functor_type::apply (*it, *ite), ++ it, ++ ite;
|
||||
#else
|
||||
DD (size, 2, r, (functor_type::apply (*it, *ite), ++ it, ++ ite));
|
||||
#endif
|
||||
}
|
||||
// Explicitly indexing
|
||||
template<template <class T1, class T2> class F, class V, class E>
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
void indexing_vector_assign (V &v, const vector_expression<E> &e) {
|
||||
typedef F<typename V::reference, typename E::value_type> functor_type;
|
||||
typedef typename V::size_type size_type;
|
||||
size_type size (BOOST_UBLAS_SAME (v.size (), e ().size ()));
|
||||
#ifndef BOOST_UBLAS_USE_DUFF_DEVICE
|
||||
for (size_type i = 0; i < size; ++ i)
|
||||
functor_type::apply (v (i), e () (i));
|
||||
#else
|
||||
size_type i (0);
|
||||
DD (size, 2, r, (functor_type::apply (v (i), e () (i)), ++ i));
|
||||
#endif
|
||||
}
|
||||
|
||||
// Dense (proxy) case
|
||||
template<template <class T1, class T2> class F, class V, class E>
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
void vector_assign (V &v, const vector_expression<E> &e, dense_proxy_tag) {
|
||||
#ifdef BOOST_UBLAS_USE_INDEXING
|
||||
indexing_vector_assign<F> (v, e);
|
||||
#elif BOOST_UBLAS_USE_ITERATING
|
||||
iterating_vector_assign<F> (v, e);
|
||||
#else
|
||||
typedef typename V::size_type size_type;
|
||||
size_type size (BOOST_UBLAS_SAME (v.size (), e ().size ()));
|
||||
if (size >= BOOST_UBLAS_ITERATOR_THRESHOLD)
|
||||
iterating_vector_assign<F> (v, e);
|
||||
else
|
||||
indexing_vector_assign<F> (v, e);
|
||||
#endif
|
||||
}
|
||||
// Packed (proxy) case
|
||||
template<template <class T1, class T2> class F, class V, class E>
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
void vector_assign (V &v, const vector_expression<E> &e, packed_proxy_tag) {
|
||||
BOOST_UBLAS_CHECK (v.size () == e ().size (), bad_size ());
|
||||
typedef F<typename V::iterator::reference, typename E::value_type> functor_type;
|
||||
typedef typename V::difference_type difference_type;
|
||||
typedef typename V::value_type value_type;
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
vector<value_type> cv (v.size ());
|
||||
indexing_vector_assign<scalar_assign> (cv, v);
|
||||
indexing_vector_assign<F> (cv, e);
|
||||
#endif
|
||||
typename V::iterator it (v.begin ());
|
||||
typename V::iterator it_end (v.end ());
|
||||
typename E::const_iterator ite (e ().begin ());
|
||||
typename E::const_iterator ite_end (e ().end ());
|
||||
difference_type it_size (it_end - it);
|
||||
difference_type ite_size (ite_end - ite);
|
||||
if (it_size > 0 && ite_size > 0) {
|
||||
difference_type size ((std::min) (difference_type (it.index () - ite.index ()), ite_size));
|
||||
if (size > 0) {
|
||||
ite += size;
|
||||
ite_size -= size;
|
||||
}
|
||||
}
|
||||
if (it_size > 0 && ite_size > 0) {
|
||||
difference_type size ((std::min) (difference_type (ite.index () - it.index ()), it_size));
|
||||
if (size > 0) {
|
||||
it_size -= size;
|
||||
if (!functor_type::computed) {
|
||||
while (-- size >= 0) // zeroing
|
||||
functor_type::apply (*it, value_type/*zero*/()), ++ it;
|
||||
} else {
|
||||
it += size;
|
||||
}
|
||||
}
|
||||
}
|
||||
difference_type size ((std::min) (it_size, ite_size));
|
||||
it_size -= size;
|
||||
ite_size -= size;
|
||||
while (-- size >= 0)
|
||||
functor_type::apply (*it, *ite), ++ it, ++ ite;
|
||||
size = it_size;
|
||||
if (!functor_type::computed) {
|
||||
while (-- size >= 0) // zeroing
|
||||
functor_type::apply (*it, value_type/*zero*/()), ++ it;
|
||||
} else {
|
||||
it += size;
|
||||
}
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
if (! disable_type_check<bool>::value)
|
||||
BOOST_UBLAS_CHECK (detail::expression_type_check (v, cv),
|
||||
external_logic ("external logic or bad condition of inputs"));
|
||||
#endif
|
||||
}
|
||||
// Sparse case
|
||||
template<template <class T1, class T2> class F, class V, class E>
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
void vector_assign (V &v, const vector_expression<E> &e, sparse_tag) {
|
||||
BOOST_UBLAS_CHECK (v.size () == e ().size (), bad_size ());
|
||||
typedef F<typename V::iterator::reference, typename E::value_type> functor_type;
|
||||
BOOST_STATIC_ASSERT ((!functor_type::computed));
|
||||
typedef typename V::value_type value_type;
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
vector<value_type> cv (v.size ());
|
||||
indexing_vector_assign<scalar_assign> (cv, v);
|
||||
indexing_vector_assign<F> (cv, e);
|
||||
#endif
|
||||
v.clear ();
|
||||
typename E::const_iterator ite (e ().begin ());
|
||||
typename E::const_iterator ite_end (e ().end ());
|
||||
while (ite != ite_end) {
|
||||
value_type t (*ite);
|
||||
if (t != value_type/*zero*/())
|
||||
v.insert_element (ite.index (), t);
|
||||
++ ite;
|
||||
}
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
if (! disable_type_check<bool>::value)
|
||||
BOOST_UBLAS_CHECK (detail::expression_type_check (v, cv),
|
||||
external_logic ("external logic or bad condition of inputs"));
|
||||
#endif
|
||||
}
|
||||
// Sparse proxy or functional case
|
||||
template<template <class T1, class T2> class F, class V, class E>
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
void vector_assign (V &v, const vector_expression<E> &e, sparse_proxy_tag) {
|
||||
BOOST_UBLAS_CHECK (v.size () == e ().size (), bad_size ());
|
||||
typedef F<typename V::iterator::reference, typename E::value_type> functor_type;
|
||||
typedef typename V::size_type size_type;
|
||||
typedef typename V::difference_type difference_type;
|
||||
typedef typename V::value_type value_type;
|
||||
typedef typename V::reference reference;
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
vector<value_type> cv (v.size ());
|
||||
indexing_vector_assign<scalar_assign> (cv, v);
|
||||
indexing_vector_assign<F> (cv, e);
|
||||
#endif
|
||||
detail::make_conformant (v, e);
|
||||
|
||||
typename V::iterator it (v.begin ());
|
||||
typename V::iterator it_end (v.end ());
|
||||
typename E::const_iterator ite (e ().begin ());
|
||||
typename E::const_iterator ite_end (e ().end ());
|
||||
if (it != it_end && ite != ite_end) {
|
||||
size_type it_index = it.index (), ite_index = ite.index ();
|
||||
while (true) {
|
||||
difference_type compare = it_index - ite_index;
|
||||
if (compare == 0) {
|
||||
functor_type::apply (*it, *ite);
|
||||
++ it, ++ ite;
|
||||
if (it != it_end && ite != ite_end) {
|
||||
it_index = it.index ();
|
||||
ite_index = ite.index ();
|
||||
} else
|
||||
break;
|
||||
} else if (compare < 0) {
|
||||
if (!functor_type::computed) {
|
||||
functor_type::apply (*it, value_type/*zero*/());
|
||||
++ it;
|
||||
} else
|
||||
increment (it, it_end, - compare);
|
||||
if (it != it_end)
|
||||
it_index = it.index ();
|
||||
else
|
||||
break;
|
||||
} else if (compare > 0) {
|
||||
increment (ite, ite_end, compare);
|
||||
if (ite != ite_end)
|
||||
ite_index = ite.index ();
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!functor_type::computed) {
|
||||
while (it != it_end) { // zeroing
|
||||
functor_type::apply (*it, value_type/*zero*/());
|
||||
++ it;
|
||||
}
|
||||
} else {
|
||||
it = it_end;
|
||||
}
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
if (! disable_type_check<bool>::value)
|
||||
BOOST_UBLAS_CHECK (detail::expression_type_check (v, cv),
|
||||
external_logic ("external logic or bad condition of inputs"));
|
||||
#endif
|
||||
}
|
||||
|
||||
// Dispatcher
|
||||
template<template <class T1, class T2> class F, class V, class E>
|
||||
BOOST_UBLAS_INLINE
|
||||
void vector_assign (V &v, const vector_expression<E> &e) {
|
||||
typedef typename vector_assign_traits<typename V::storage_category,
|
||||
F<typename V::reference, typename E::value_type>::computed,
|
||||
typename E::const_iterator::iterator_category>::storage_category storage_category;
|
||||
vector_assign<F> (v, e, storage_category ());
|
||||
}
|
||||
|
||||
template<class SC, class RI>
|
||||
struct vector_swap_traits {
|
||||
typedef SC storage_category;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct vector_swap_traits<dense_proxy_tag, sparse_bidirectional_iterator_tag> {
|
||||
typedef sparse_proxy_tag storage_category;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct vector_swap_traits<packed_proxy_tag, sparse_bidirectional_iterator_tag> {
|
||||
typedef sparse_proxy_tag storage_category;
|
||||
};
|
||||
|
||||
// Dense (proxy) case
|
||||
template<template <class T1, class T2> class F, class V, class E>
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
void vector_swap (V &v, vector_expression<E> &e, dense_proxy_tag) {
|
||||
typedef F<typename V::iterator::reference, typename E::iterator::reference> functor_type;
|
||||
typedef typename V::difference_type difference_type;
|
||||
difference_type size (BOOST_UBLAS_SAME (v.size (), e ().size ()));
|
||||
typename V::iterator it (v.begin ());
|
||||
typename E::iterator ite (e ().begin ());
|
||||
while (-- size >= 0)
|
||||
functor_type::apply (*it, *ite), ++ it, ++ ite;
|
||||
}
|
||||
// Packed (proxy) case
|
||||
template<template <class T1, class T2> class F, class V, class E>
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
void vector_swap (V &v, vector_expression<E> &e, packed_proxy_tag) {
|
||||
typedef F<typename V::iterator::reference, typename E::iterator::reference> functor_type;
|
||||
typedef typename V::difference_type difference_type;
|
||||
typename V::iterator it (v.begin ());
|
||||
typename V::iterator it_end (v.end ());
|
||||
typename E::iterator ite (e ().begin ());
|
||||
typename E::iterator ite_end (e ().end ());
|
||||
difference_type it_size (it_end - it);
|
||||
difference_type ite_size (ite_end - ite);
|
||||
if (it_size > 0 && ite_size > 0) {
|
||||
difference_type size ((std::min) (difference_type (it.index () - ite.index ()), ite_size));
|
||||
if (size > 0) {
|
||||
ite += size;
|
||||
ite_size -= size;
|
||||
}
|
||||
}
|
||||
if (it_size > 0 && ite_size > 0) {
|
||||
difference_type size ((std::min) (difference_type (ite.index () - it.index ()), it_size));
|
||||
if (size > 0)
|
||||
it_size -= size;
|
||||
}
|
||||
difference_type size ((std::min) (it_size, ite_size));
|
||||
it_size -= size;
|
||||
ite_size -= size;
|
||||
while (-- size >= 0)
|
||||
functor_type::apply (*it, *ite), ++ it, ++ ite;
|
||||
}
|
||||
// Sparse proxy case
|
||||
template<template <class T1, class T2> class F, class V, class E>
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
void vector_swap (V &v, vector_expression<E> &e, sparse_proxy_tag) {
|
||||
BOOST_UBLAS_CHECK (v.size () == e ().size (), bad_size ());
|
||||
typedef F<typename V::iterator::reference, typename E::iterator::reference> functor_type;
|
||||
typedef typename V::size_type size_type;
|
||||
typedef typename V::difference_type difference_type;
|
||||
typedef typename V::value_type value_type;
|
||||
|
||||
detail::make_conformant (v, e);
|
||||
// FIXME should be a seperate restriction for E
|
||||
detail::make_conformant (e (), v);
|
||||
|
||||
typename V::iterator it (v.begin ());
|
||||
typename V::iterator it_end (v.end ());
|
||||
typename E::iterator ite (e ().begin ());
|
||||
typename E::iterator ite_end (e ().end ());
|
||||
if (it != it_end && ite != ite_end) {
|
||||
size_type it_index = it.index (), ite_index = ite.index ();
|
||||
while (true) {
|
||||
difference_type compare = it_index - ite_index;
|
||||
if (compare == 0) {
|
||||
functor_type::apply (*it, *ite);
|
||||
++ it, ++ ite;
|
||||
if (it != it_end && ite != ite_end) {
|
||||
it_index = it.index ();
|
||||
ite_index = ite.index ();
|
||||
} else
|
||||
break;
|
||||
} else if (compare < 0) {
|
||||
increment (it, it_end, - compare);
|
||||
if (it != it_end)
|
||||
it_index = it.index ();
|
||||
else
|
||||
break;
|
||||
} else if (compare > 0) {
|
||||
increment (ite, ite_end, compare);
|
||||
if (ite != ite_end)
|
||||
ite_index = ite.index ();
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
increment (ite, ite_end);
|
||||
increment (it, it_end);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Dispatcher
|
||||
template<template <class T1, class T2> class F, class V, class E>
|
||||
BOOST_UBLAS_INLINE
|
||||
void vector_swap (V &v, vector_expression<E> &e) {
|
||||
typedef typename vector_swap_traits<typename V::storage_category,
|
||||
typename E::const_iterator::iterator_category>::storage_category storage_category;
|
||||
vector_swap<F> (v, e, storage_category ());
|
||||
}
|
||||
|
||||
}}}
|
||||
|
||||
#endif
|
||||
65
project/jni/boost/include/boost/numeric/ublas/doxydoc.hpp
Normal file
65
project/jni/boost/include/boost/numeric/ublas/doxydoc.hpp
Normal file
@@ -0,0 +1,65 @@
|
||||
//
|
||||
// Copyright (c) 2010
|
||||
// David Bellot
|
||||
//
|
||||
// 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)
|
||||
//
|
||||
// And we acknowledge the support from all contributors.
|
||||
|
||||
/** \mainpage BOOST uBLAS: a Linear Algebra Library
|
||||
*
|
||||
* This is the API Reference Documentation.
|
||||
*
|
||||
* For introduction, documentations and tutorial, please refer
|
||||
* to http://www.boost.org/doc/libs/1_44_0/libs/numeric/ublas/doc/index.htm
|
||||
*
|
||||
* \section main_classes Main classes
|
||||
*
|
||||
* \subsection listvector Vectors
|
||||
* - \link #boost::numeric::ublas::vector vector \endlink
|
||||
* - \link #boost::numeric::ublas::bounded_vector bounded_vector \endlink
|
||||
* - \link #boost::numeric::ublas::zero_vector zero_vector \endlink
|
||||
* - \link #boost::numeric::ublas::unit_vector unit_vector \endlink
|
||||
* - \link #boost::numeric::ublas::scalar_vector scalar_vector \endlink
|
||||
* - \link #boost::numeric::ublas::c_vector c_vector \endlink
|
||||
* - \link #boost::numeric::ublas::vector_slice vector_slice \endlink
|
||||
* - \link #boost::numeric::ublas::vector_range vector_range \endlink
|
||||
* - \link #boost::numeric::ublas::vector_indirect vector_indirect \endlink
|
||||
* - \link #boost::numeric::ublas::mapped_vector mapped_vector \endlink
|
||||
* - \link #boost::numeric::ublas::compressed_vector compressed_vector \endlink
|
||||
* - \link #boost::numeric::ublas::coordinate_vector coordinate_vector \endlink
|
||||
* - \link #boost::numeric::ublas::matrix_row matrix_row \endlink
|
||||
* - \link #boost::numeric::ublas::matrix_column matrix_column \endlink
|
||||
*
|
||||
* \subsection listmatrix Matrices
|
||||
* - \link #boost::numeric::ublas::matrix matrix \endlink
|
||||
* - \link #boost::numeric::ublas::banded_matrix banded_matrix \endlink
|
||||
* - \link #boost::numeric::ublas::diagonal_matrix diagonal_matrix \endlink
|
||||
* - \link #boost::numeric::ublas::banded_adaptor banded_adaptor \endlink
|
||||
* - \link #boost::numeric::ublas::diagonal_adaptor diagonal_adaptor \endlink
|
||||
* - \link #boost::numeric::ublas::hermitian_matrix hermitian_matrix \endlink
|
||||
* - \link #boost::numeric::ublas::hermitian_adaptor hermitian_adaptor \endlink
|
||||
* - \link #boost::numeric::ublas::symmetric_matrix symmetric_matrix \endlink
|
||||
* - \link #boost::numeric::ublas::symmetric_adaptor symmetric_adaptor \endlink
|
||||
* - \link #boost::numeric::ublas::triangular_matrix triangular_matrix \endlink
|
||||
* - \link #boost::numeric::ublas::triangular_adaptor triangular_adaptor \endlink
|
||||
* - \link #boost::numeric::ublas::vector_of_vector vector_of_vector \endlink
|
||||
* - \link #boost::numeric::ublas::bounded_matrix bounded_matrix \endlink
|
||||
* - \link #boost::numeric::ublas::zero_matrix zero_matrix \endlink
|
||||
* - \link #boost::numeric::ublas::identity_matrix identity_matrix \endlink
|
||||
* - \link #boost::numeric::ublas::scalar_matrix scalar_matrix \endlink
|
||||
* - \link #boost::numeric::ublas::c_matrix c_matrix \endlink
|
||||
* - \link #boost::numeric::ublas::matrix_vector_range matrix_vector_range \endlink
|
||||
* - \link #boost::numeric::ublas::matrix_vector_slice matrix_vector_slice \endlink
|
||||
* - \link #boost::numeric::ublas::matrix_vector_indirect matrix_vector_indirect \endlink
|
||||
* - \link #boost::numeric::ublas::matrix_range matrix_range \endlink
|
||||
* - \link #boost::numeric::ublas::matrix_slice matrix_slice \endlink
|
||||
* - \link #boost::numeric::ublas::matrix_indirect matrix_indirect \endlink
|
||||
* - \link #boost::numeric::ublas::mapped_matrix mapped_matrix \endlink
|
||||
* - \link #boost::numeric::ublas::mapped_vector_of_mapped_vector mapped_vector_of_mapped_vector \endlink
|
||||
* - \link #boost::numeric::ublas::compressed_matrix compressed_matrix \endlink
|
||||
* - \link #boost::numeric::ublas::coordinate_matrix coordinate_matrix \endlink
|
||||
* - \link #boost::numeric::ublas::generalized_vector_of_vector generalized_vector_of_vector \endlink
|
||||
*/
|
||||
303
project/jni/boost/include/boost/numeric/ublas/exception.hpp
Normal file
303
project/jni/boost/include/boost/numeric/ublas/exception.hpp
Normal file
@@ -0,0 +1,303 @@
|
||||
//
|
||||
// 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_EXCEPTION_
|
||||
#define _BOOST_UBLAS_EXCEPTION_
|
||||
|
||||
#if ! defined (BOOST_NO_EXCEPTIONS) && ! defined (BOOST_UBLAS_NO_EXCEPTIONS)
|
||||
#include <stdexcept>
|
||||
#else
|
||||
#include <cstdlib>
|
||||
#endif
|
||||
#ifndef BOOST_UBLAS_NO_STD_CERR
|
||||
#include <iostream>
|
||||
#endif
|
||||
|
||||
#include <boost/numeric/ublas/detail/config.hpp>
|
||||
|
||||
namespace boost { namespace numeric { namespace ublas {
|
||||
|
||||
/** \brief Exception raised when a division by zero occurs
|
||||
*/
|
||||
struct divide_by_zero
|
||||
#if ! defined (BOOST_NO_EXCEPTIONS) && ! defined (BOOST_UBLAS_NO_EXCEPTIONS)
|
||||
// Inherit from standard exceptions as requested during review.
|
||||
: public std::runtime_error
|
||||
{
|
||||
explicit divide_by_zero (const char *s = "divide by zero") :
|
||||
std::runtime_error (s) {}
|
||||
void raise () {
|
||||
throw *this;
|
||||
}
|
||||
#else
|
||||
{
|
||||
divide_by_zero ()
|
||||
{}
|
||||
explicit divide_by_zero (const char *)
|
||||
{}
|
||||
void raise () {
|
||||
std::abort ();
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
/** \brief Expception raised when some interal errors occurs like computations errors, zeros values where you should not have zeros, etc...
|
||||
*/
|
||||
struct internal_logic
|
||||
#if ! defined (BOOST_NO_EXCEPTIONS) && ! defined (BOOST_UBLAS_NO_EXCEPTIONS)
|
||||
// Inherit from standard exceptions as requested during review.
|
||||
: public std::logic_error {
|
||||
explicit internal_logic (const char *s = "internal logic") :
|
||||
std::logic_error (s) {}
|
||||
void raise () {
|
||||
throw *this;
|
||||
}
|
||||
#else
|
||||
{
|
||||
internal_logic ()
|
||||
{}
|
||||
explicit internal_logic (const char *)
|
||||
{}
|
||||
void raise () {
|
||||
std::abort ();
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
struct external_logic
|
||||
#if ! defined (BOOST_NO_EXCEPTIONS) && ! defined (BOOST_UBLAS_NO_EXCEPTIONS)
|
||||
// Inherit from standard exceptions as requested during review.
|
||||
: public std::logic_error {
|
||||
explicit external_logic (const char *s = "external logic") :
|
||||
std::logic_error (s) {}
|
||||
// virtual const char *what () const throw () {
|
||||
// return "exception: external logic";
|
||||
// }
|
||||
void raise () {
|
||||
throw *this;
|
||||
}
|
||||
#else
|
||||
{
|
||||
external_logic ()
|
||||
{}
|
||||
explicit external_logic (const char *)
|
||||
{}
|
||||
void raise () {
|
||||
std::abort ();
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
struct bad_argument
|
||||
#if ! defined (BOOST_NO_EXCEPTIONS) && ! defined (BOOST_UBLAS_NO_EXCEPTIONS)
|
||||
// Inherit from standard exceptions as requested during review.
|
||||
: public std::invalid_argument {
|
||||
explicit bad_argument (const char *s = "bad argument") :
|
||||
std::invalid_argument (s) {}
|
||||
void raise () {
|
||||
throw *this;
|
||||
}
|
||||
#else
|
||||
{
|
||||
bad_argument ()
|
||||
{}
|
||||
explicit bad_argument (const char *)
|
||||
{}
|
||||
void raise () {
|
||||
std::abort ();
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
*/
|
||||
struct bad_size
|
||||
#if ! defined (BOOST_NO_EXCEPTIONS) && ! defined (BOOST_UBLAS_NO_EXCEPTIONS)
|
||||
// Inherit from standard exceptions as requested during review.
|
||||
: public std::domain_error {
|
||||
explicit bad_size (const char *s = "bad size") :
|
||||
std::domain_error (s) {}
|
||||
void raise () {
|
||||
throw *this;
|
||||
}
|
||||
#else
|
||||
{
|
||||
bad_size ()
|
||||
{}
|
||||
explicit bad_size (const char *)
|
||||
{}
|
||||
void raise () {
|
||||
std::abort ();
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
struct bad_index
|
||||
#if ! defined (BOOST_NO_EXCEPTIONS) && ! defined (BOOST_UBLAS_NO_EXCEPTIONS)
|
||||
// Inherit from standard exceptions as requested during review.
|
||||
: public std::out_of_range {
|
||||
explicit bad_index (const char *s = "bad index") :
|
||||
std::out_of_range (s) {}
|
||||
void raise () {
|
||||
throw *this;
|
||||
}
|
||||
#else
|
||||
{
|
||||
bad_index ()
|
||||
{}
|
||||
explicit bad_index (const char *)
|
||||
{}
|
||||
void raise () {
|
||||
std::abort ();
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
struct singular
|
||||
#if ! defined (BOOST_NO_EXCEPTIONS) && ! defined (BOOST_UBLAS_NO_EXCEPTIONS)
|
||||
// Inherit from standard exceptions as requested during review.
|
||||
: public std::runtime_error {
|
||||
explicit singular (const char *s = "singular") :
|
||||
std::runtime_error (s) {}
|
||||
void raise () {
|
||||
throw *this;
|
||||
}
|
||||
#else
|
||||
{
|
||||
singular ()
|
||||
{}
|
||||
explicit singular (const char *)
|
||||
{}
|
||||
void raise () {
|
||||
std::abort ();
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
struct non_real
|
||||
#if ! defined (BOOST_NO_EXCEPTIONS) && ! defined (BOOST_UBLAS_NO_EXCEPTIONS)
|
||||
// Inherit from standard exceptions as requested during review.
|
||||
: public std::domain_error {
|
||||
explicit non_real (const char *s = "exception: non real") :
|
||||
std::domain_error (s) {}
|
||||
void raise () {
|
||||
throw *this;
|
||||
}
|
||||
#else
|
||||
{
|
||||
non_real ()
|
||||
{}
|
||||
explicit non_real (const char *)
|
||||
{}
|
||||
void raise () {
|
||||
std::abort ();
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
#if BOOST_UBLAS_CHECK_ENABLE
|
||||
// Macros are equivilent to
|
||||
// template<class E>
|
||||
// BOOST_UBLAS_INLINE
|
||||
// void check (bool expression, const E &e) {
|
||||
// if (! expression)
|
||||
// e.raise ();
|
||||
// }
|
||||
// template<class E>
|
||||
// BOOST_UBLAS_INLINE
|
||||
// void check_ex (bool expression, const char *file, int line, const E &e) {
|
||||
// if (! expression)
|
||||
// e.raise ();
|
||||
// }
|
||||
#ifndef BOOST_UBLAS_NO_STD_CERR
|
||||
#define BOOST_UBLAS_CHECK_FALSE(e) \
|
||||
std::cerr << "Check failed in file " << __FILE__ << " at line " << __LINE__ << ":" << std::endl; \
|
||||
e.raise ();
|
||||
#define BOOST_UBLAS_CHECK(expression, e) \
|
||||
if (! (expression)) { \
|
||||
std::cerr << "Check failed in file " << __FILE__ << " at line " << __LINE__ << ":" << std::endl; \
|
||||
std::cerr << #expression << std::endl; \
|
||||
e.raise (); \
|
||||
}
|
||||
#define BOOST_UBLAS_CHECK_EX(expression, file, line, e) \
|
||||
if (! (expression)) { \
|
||||
std::cerr << "Check failed in file " << (file) << " at line " << (line) << ":" << std::endl; \
|
||||
std::cerr << #expression << std::endl; \
|
||||
e.raise (); \
|
||||
}
|
||||
#else
|
||||
#define BOOST_UBLAS_CHECK_FALSE(e) \
|
||||
e.raise ();
|
||||
#define BOOST_UBLAS_CHECK(expression, e) \
|
||||
if (! (expression)) { \
|
||||
e.raise (); \
|
||||
}
|
||||
#define BOOST_UBLAS_CHECK_EX(expression, file, line, e) \
|
||||
if (! (expression)) { \
|
||||
e.raise (); \
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
// Macros are equivilent to
|
||||
// template<class E>
|
||||
// BOOST_UBLAS_INLINE
|
||||
// void check (bool expression, const E &e) {}
|
||||
// template<class E>
|
||||
// BOOST_UBLAS_INLINE
|
||||
// void check_ex (bool expression, const char *file, int line, const E &e) {}
|
||||
#define BOOST_UBLAS_CHECK_FALSE(e)
|
||||
#define BOOST_UBLAS_CHECK(expression, e)
|
||||
#define BOOST_UBLAS_CHECK_EX(expression, file, line, e)
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef BOOST_UBLAS_USE_FAST_SAME
|
||||
// Macro is equivilent to
|
||||
// template<class T>
|
||||
// BOOST_UBLAS_INLINE
|
||||
// const T &same_impl (const T &size1, const T &size2) {
|
||||
// BOOST_UBLAS_CHECK (size1 == size2, bad_argument ());
|
||||
// return (std::min) (size1, size2);
|
||||
// }
|
||||
// #define BOOST_UBLAS_SAME(size1, size2) same_impl ((size1), (size2))
|
||||
// need two types here because different containers can have
|
||||
// different size_types (especially sparse types)
|
||||
template<class T1, class T2>
|
||||
BOOST_UBLAS_INLINE
|
||||
// Kresimir Fresl and Dan Muller reported problems with COMO.
|
||||
// We better change the signature instead of libcomo ;-)
|
||||
// const T &same_impl_ex (const T &size1, const T &size2, const char *file, int line) {
|
||||
T1 same_impl_ex (const T1 &size1, const T2 &size2, const char *file, int line) {
|
||||
BOOST_UBLAS_CHECK_EX (size1 == size2, file, line, bad_argument ());
|
||||
return (size1 < size2)?(size1):(size2);
|
||||
}
|
||||
template<class T>
|
||||
BOOST_UBLAS_INLINE
|
||||
T same_impl_ex (const T &size1, const T &size2, const char *file, int line) {
|
||||
BOOST_UBLAS_CHECK_EX (size1 == size2, file, line, bad_argument ());
|
||||
return (std::min) (size1, size2);
|
||||
}
|
||||
#define BOOST_UBLAS_SAME(size1, size2) same_impl_ex ((size1), (size2), __FILE__, __LINE__)
|
||||
#else
|
||||
// Macros are equivilent to
|
||||
// template<class T>
|
||||
// BOOST_UBLAS_INLINE
|
||||
// const T &same_impl (const T &size1, const T &size2) {
|
||||
// return size1;
|
||||
// }
|
||||
// #define BOOST_UBLAS_SAME(size1, size2) same_impl ((size1), (size2))
|
||||
#define BOOST_UBLAS_SAME(size1, size2) (size1)
|
||||
#endif
|
||||
|
||||
}}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,316 @@
|
||||
//
|
||||
// Copyright (c) 2009
|
||||
// Gunter Winkler
|
||||
//
|
||||
// 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_UBLAS_SPARSE_VIEW_
|
||||
#define _BOOST_UBLAS_SPARSE_VIEW_
|
||||
|
||||
#include <boost/numeric/ublas/matrix_expression.hpp>
|
||||
#include <boost/numeric/ublas/detail/matrix_assign.hpp>
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
#include <boost/numeric/ublas/matrix.hpp>
|
||||
#endif
|
||||
|
||||
#include <boost/next_prior.hpp>
|
||||
#include <boost/type_traits/remove_cv.hpp>
|
||||
|
||||
namespace boost { namespace numeric { namespace ublas {
|
||||
|
||||
// view a chunk of memory as ublas array
|
||||
|
||||
template < class T >
|
||||
class c_array_view
|
||||
: public storage_array< c_array_view<T> > {
|
||||
private:
|
||||
typedef c_array_view<T> self_type;
|
||||
typedef T * pointer;
|
||||
|
||||
public:
|
||||
// TODO: think about a const pointer
|
||||
typedef const pointer array_type;
|
||||
|
||||
typedef std::size_t size_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
|
||||
typedef T value_type;
|
||||
typedef const T &const_reference;
|
||||
typedef const T *const_pointer;
|
||||
|
||||
typedef const_pointer const_iterator;
|
||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
|
||||
//
|
||||
// typedefs required by vector concept
|
||||
//
|
||||
|
||||
typedef dense_tag storage_category;
|
||||
typedef const vector_reference<const self_type> const_closure_type;
|
||||
|
||||
c_array_view(size_type size, array_type data) :
|
||||
size_(size), data_(data)
|
||||
{}
|
||||
|
||||
~c_array_view()
|
||||
{}
|
||||
|
||||
//
|
||||
// immutable methods of container concept
|
||||
//
|
||||
|
||||
BOOST_UBLAS_INLINE
|
||||
size_type size () const {
|
||||
return size_;
|
||||
}
|
||||
|
||||
BOOST_UBLAS_INLINE
|
||||
const_reference operator [] (size_type i) const {
|
||||
BOOST_UBLAS_CHECK (i < size_, bad_index ());
|
||||
return data_ [i];
|
||||
}
|
||||
|
||||
BOOST_UBLAS_INLINE
|
||||
const_iterator begin () const {
|
||||
return data_;
|
||||
}
|
||||
BOOST_UBLAS_INLINE
|
||||
const_iterator end () const {
|
||||
return data_ + size_;
|
||||
}
|
||||
|
||||
BOOST_UBLAS_INLINE
|
||||
const_reverse_iterator rbegin () const {
|
||||
return const_reverse_iterator (end ());
|
||||
}
|
||||
BOOST_UBLAS_INLINE
|
||||
const_reverse_iterator rend () const {
|
||||
return const_reverse_iterator (begin ());
|
||||
}
|
||||
|
||||
private:
|
||||
size_type size_;
|
||||
array_type data_;
|
||||
};
|
||||
|
||||
|
||||
/** \brief Present existing arrays as compressed array based
|
||||
* sparse matrix.
|
||||
* This class provides CRS / CCS storage layout.
|
||||
*
|
||||
* see also http://www.netlib.org/utk/papers/templates/node90.html
|
||||
*
|
||||
* \param L layout type, either row_major or column_major
|
||||
* \param IB index base, use 0 for C indexing and 1 for
|
||||
* FORTRAN indexing of the internal index arrays. This
|
||||
* does not affect the operator()(int,int) where the first
|
||||
* row/column has always index 0.
|
||||
* \param IA index array type, e.g., int[]
|
||||
* \param TA value array type, e.g., double[]
|
||||
*/
|
||||
template<class L, std::size_t IB, class IA, class JA, class TA>
|
||||
class compressed_matrix_view:
|
||||
public matrix_expression<compressed_matrix_view<L, IB, IA, JA, TA> > {
|
||||
|
||||
public:
|
||||
typedef typename vector_view_traits<TA>::value_type value_type;
|
||||
|
||||
private:
|
||||
typedef value_type &true_reference;
|
||||
typedef value_type *pointer;
|
||||
typedef const value_type *const_pointer;
|
||||
typedef L layout_type;
|
||||
typedef compressed_matrix_view<L, IB, IA, JA, TA> self_type;
|
||||
|
||||
public:
|
||||
#ifdef BOOST_UBLAS_ENABLE_PROXY_SHORTCUTS
|
||||
using matrix_expression<self_type>::operator ();
|
||||
#endif
|
||||
// ISSUE require type consistency check
|
||||
// is_convertable (IA::size_type, TA::size_type)
|
||||
typedef typename boost::remove_cv<typename vector_view_traits<JA>::value_type>::type index_type;
|
||||
// for compatibility, should be removed some day ...
|
||||
typedef index_type size_type;
|
||||
// size_type for the data arrays.
|
||||
typedef typename vector_view_traits<JA>::size_type array_size_type;
|
||||
typedef typename vector_view_traits<JA>::difference_type difference_type;
|
||||
typedef const value_type & const_reference;
|
||||
|
||||
// do NOT define reference type, because class is read only
|
||||
// typedef value_type & reference;
|
||||
|
||||
typedef IA rowptr_array_type;
|
||||
typedef JA index_array_type;
|
||||
typedef TA value_array_type;
|
||||
typedef const matrix_reference<const self_type> const_closure_type;
|
||||
typedef matrix_reference<self_type> closure_type;
|
||||
|
||||
// FIXME: define a corresponding temporary type
|
||||
// typedef compressed_vector<T, IB, IA, TA> vector_temporary_type;
|
||||
|
||||
// FIXME: define a corresponding temporary type
|
||||
// typedef self_type matrix_temporary_type;
|
||||
|
||||
typedef sparse_tag storage_category;
|
||||
typedef typename L::orientation_category orientation_category;
|
||||
|
||||
//
|
||||
// private types for internal use
|
||||
//
|
||||
|
||||
private:
|
||||
typedef typename vector_view_traits<index_array_type>::const_iterator const_subiterator_type;
|
||||
|
||||
//
|
||||
// Construction and destruction
|
||||
//
|
||||
private:
|
||||
/// private default constructor because data must be filled by caller
|
||||
BOOST_UBLAS_INLINE
|
||||
compressed_matrix_view () { }
|
||||
|
||||
public:
|
||||
BOOST_UBLAS_INLINE
|
||||
compressed_matrix_view (index_type n_rows, index_type n_cols, array_size_type nnz
|
||||
, const rowptr_array_type & iptr
|
||||
, const index_array_type & jptr
|
||||
, const value_array_type & values):
|
||||
matrix_expression<self_type> (),
|
||||
size1_ (n_rows), size2_ (n_cols),
|
||||
nnz_ (nnz),
|
||||
index1_data_ (iptr),
|
||||
index2_data_ (jptr),
|
||||
value_data_ (values) {
|
||||
storage_invariants ();
|
||||
}
|
||||
|
||||
BOOST_UBLAS_INLINE
|
||||
compressed_matrix_view(const compressed_matrix_view& o) :
|
||||
size1_(size1_), size2_(size2_),
|
||||
nnz_(nnz_),
|
||||
index1_data_(index1_data_),
|
||||
index2_data_(index2_data_),
|
||||
value_data_(value_data_)
|
||||
{}
|
||||
|
||||
//
|
||||
// implement immutable iterator types
|
||||
//
|
||||
|
||||
class const_iterator1 {};
|
||||
class const_iterator2 {};
|
||||
|
||||
typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;
|
||||
typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;
|
||||
|
||||
//
|
||||
// implement all read only methods for the matrix expression concept
|
||||
//
|
||||
|
||||
//! return the number of rows
|
||||
index_type size1() const {
|
||||
return size1_;
|
||||
}
|
||||
|
||||
//! return the number of columns
|
||||
index_type size2() const {
|
||||
return size2_;
|
||||
}
|
||||
|
||||
//! return value at position (i,j)
|
||||
value_type operator()(index_type i, index_type j) const {
|
||||
const_pointer p = find_element(i,j);
|
||||
if (!p) {
|
||||
return zero_;
|
||||
} else {
|
||||
return *p;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
//
|
||||
// private helper functions
|
||||
//
|
||||
|
||||
const_pointer find_element (index_type i, index_type j) const {
|
||||
index_type element1 (layout_type::index_M (i, j));
|
||||
index_type element2 (layout_type::index_m (i, j));
|
||||
|
||||
const array_size_type itv = zero_based( index1_data_[element1] );
|
||||
const array_size_type itv_next = zero_based( index1_data_[element1+1] );
|
||||
|
||||
const_subiterator_type it_start = boost::next(vector_view_traits<index_array_type>::begin(index2_data_),itv);
|
||||
const_subiterator_type it_end = boost::next(vector_view_traits<index_array_type>::begin(index2_data_),itv_next);
|
||||
const_subiterator_type it = find_index_in_row(it_start, it_end, element2) ;
|
||||
|
||||
if (it == it_end || *it != k_based (element2))
|
||||
return 0;
|
||||
return &value_data_ [it - vector_view_traits<index_array_type>::begin(index2_data_)];
|
||||
}
|
||||
|
||||
const_subiterator_type find_index_in_row(const_subiterator_type it_start
|
||||
, const_subiterator_type it_end
|
||||
, index_type index) const {
|
||||
return std::lower_bound( it_start
|
||||
, it_end
|
||||
, k_based (index) );
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
void storage_invariants () const {
|
||||
BOOST_UBLAS_CHECK (index1_data_ [layout_type::size_M (size1_, size2_)] == k_based (nnz_), external_logic ());
|
||||
}
|
||||
|
||||
index_type size1_;
|
||||
index_type size2_;
|
||||
|
||||
array_size_type nnz_;
|
||||
|
||||
const rowptr_array_type & index1_data_;
|
||||
const index_array_type & index2_data_;
|
||||
const value_array_type & value_data_;
|
||||
|
||||
static const value_type zero_;
|
||||
|
||||
BOOST_UBLAS_INLINE
|
||||
static index_type zero_based (index_type k_based_index) {
|
||||
return k_based_index - IB;
|
||||
}
|
||||
BOOST_UBLAS_INLINE
|
||||
static index_type k_based (index_type zero_based_index) {
|
||||
return zero_based_index + IB;
|
||||
}
|
||||
|
||||
friend class iterator1;
|
||||
friend class iterator2;
|
||||
friend class const_iterator1;
|
||||
friend class const_iterator2;
|
||||
};
|
||||
|
||||
template<class L, std::size_t IB, class IA, class JA, class TA >
|
||||
const typename compressed_matrix_view<L,IB,IA,JA,TA>::value_type
|
||||
compressed_matrix_view<L,IB,IA,JA,TA>::zero_ = value_type/*zero*/();
|
||||
|
||||
|
||||
template<class L, std::size_t IB, class IA, class JA, class TA >
|
||||
compressed_matrix_view<L,IB,IA,JA,TA>
|
||||
make_compressed_matrix_view(typename vector_view_traits<JA>::value_type n_rows
|
||||
, typename vector_view_traits<JA>::value_type n_cols
|
||||
, typename vector_view_traits<JA>::size_type nnz
|
||||
, const IA & ia
|
||||
, const JA & ja
|
||||
, const TA & ta) {
|
||||
|
||||
return compressed_matrix_view<L,IB,IA,JA,TA>(n_rows, n_cols, nnz, ia, ja, ta);
|
||||
|
||||
}
|
||||
|
||||
}}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,507 @@
|
||||
//
|
||||
// Copyright (c) 2000-2010
|
||||
// Joerg Walter, Mathias Koch. David Bellot
|
||||
//
|
||||
// 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_EXPRESSION_TYPE_
|
||||
#define _BOOST_UBLAS_EXPRESSION_TYPE_
|
||||
|
||||
#include <boost/numeric/ublas/exception.hpp>
|
||||
#include <boost/numeric/ublas/traits.hpp>
|
||||
#include <boost/numeric/ublas/functional.hpp>
|
||||
|
||||
|
||||
// Expression templates based on ideas of Todd Veldhuizen and Geoffrey Furnish
|
||||
// Iterators based on ideas of Jeremy Siek
|
||||
|
||||
namespace boost { namespace numeric { namespace ublas {
|
||||
|
||||
/** \brief Base class for uBLAS statically derived expressions using the the Barton Nackman trick
|
||||
*
|
||||
* This is a NonAssignable class
|
||||
* Directly implement nonassignable - simplifes debugging call trace!
|
||||
*
|
||||
* \tparam E an expression type
|
||||
*/
|
||||
template<class E>
|
||||
class ublas_expression {
|
||||
public:
|
||||
typedef E expression_type;
|
||||
/* E can be an incomplete type - to define the following we would need more template arguments
|
||||
typedef typename E::type_category type_category;
|
||||
typedef typename E::value_type value_type;
|
||||
*/
|
||||
|
||||
protected:
|
||||
ublas_expression () {}
|
||||
~ublas_expression () {}
|
||||
private:
|
||||
const ublas_expression& operator= (const ublas_expression &);
|
||||
};
|
||||
|
||||
|
||||
/** \brief Base class for Scalar Expression models
|
||||
*
|
||||
* It does not model the Scalar Expression concept but all derived types should.
|
||||
* The class defines a common base type and some common interface for all statically
|
||||
* derived Scalar Expression classes.
|
||||
*
|
||||
* We implement the casts to the statically derived type.
|
||||
*
|
||||
* \tparam E an expression type
|
||||
*/
|
||||
template<class E>
|
||||
class scalar_expression:
|
||||
public ublas_expression<E> {
|
||||
public:
|
||||
typedef E expression_type;
|
||||
typedef scalar_tag type_category;
|
||||
|
||||
BOOST_UBLAS_INLINE
|
||||
const expression_type &operator () () const {
|
||||
return *static_cast<const expression_type *> (this);
|
||||
}
|
||||
BOOST_UBLAS_INLINE
|
||||
expression_type &operator () () {
|
||||
return *static_cast<expression_type *> (this);
|
||||
}
|
||||
};
|
||||
|
||||
template<class T>
|
||||
class scalar_reference:
|
||||
public scalar_expression<scalar_reference<T> > {
|
||||
|
||||
typedef scalar_reference<T> self_type;
|
||||
public:
|
||||
typedef T value_type;
|
||||
typedef const value_type &const_reference;
|
||||
typedef typename boost::mpl::if_<boost::is_const<T>,
|
||||
const_reference,
|
||||
value_type &>::type reference;
|
||||
typedef const self_type const_closure_type;
|
||||
typedef const_closure_type closure_type;
|
||||
|
||||
// Construction and destruction
|
||||
BOOST_UBLAS_INLINE
|
||||
explicit scalar_reference (reference t):
|
||||
t_ (t) {}
|
||||
|
||||
// Conversion
|
||||
BOOST_UBLAS_INLINE
|
||||
operator value_type () const {
|
||||
return t_;
|
||||
}
|
||||
|
||||
// Assignment
|
||||
BOOST_UBLAS_INLINE
|
||||
scalar_reference &operator = (const scalar_reference &s) {
|
||||
t_ = s.t_;
|
||||
return *this;
|
||||
}
|
||||
template<class AE>
|
||||
BOOST_UBLAS_INLINE
|
||||
scalar_reference &operator = (const scalar_expression<AE> &ae) {
|
||||
t_ = ae;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Closure comparison
|
||||
BOOST_UBLAS_INLINE
|
||||
bool same_closure (const scalar_reference &sr) const {
|
||||
return &t_ == &sr.t_;
|
||||
}
|
||||
|
||||
private:
|
||||
reference t_;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
class scalar_value:
|
||||
public scalar_expression<scalar_value<T> > {
|
||||
|
||||
typedef scalar_value<T> self_type;
|
||||
public:
|
||||
typedef T value_type;
|
||||
typedef const value_type &const_reference;
|
||||
typedef typename boost::mpl::if_<boost::is_const<T>,
|
||||
const_reference,
|
||||
value_type &>::type reference;
|
||||
typedef const scalar_reference<const self_type> const_closure_type;
|
||||
typedef scalar_reference<self_type> closure_type;
|
||||
|
||||
// Construction and destruction
|
||||
BOOST_UBLAS_INLINE
|
||||
scalar_value ():
|
||||
t_ () {}
|
||||
BOOST_UBLAS_INLINE
|
||||
scalar_value (const value_type &t):
|
||||
t_ (t) {}
|
||||
|
||||
BOOST_UBLAS_INLINE
|
||||
operator value_type () const {
|
||||
return t_;
|
||||
}
|
||||
|
||||
// Assignment
|
||||
BOOST_UBLAS_INLINE
|
||||
scalar_value &operator = (const scalar_value &s) {
|
||||
t_ = s.t_;
|
||||
return *this;
|
||||
}
|
||||
template<class AE>
|
||||
BOOST_UBLAS_INLINE
|
||||
scalar_value &operator = (const scalar_expression<AE> &ae) {
|
||||
t_ = ae;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Closure comparison
|
||||
BOOST_UBLAS_INLINE
|
||||
bool same_closure (const scalar_value &sv) const {
|
||||
return this == &sv; // self closing on instances value
|
||||
}
|
||||
|
||||
private:
|
||||
value_type t_;
|
||||
};
|
||||
|
||||
|
||||
/** \brief Base class for Vector Expression models
|
||||
*
|
||||
* it does not model the Vector Expression concept but all derived types should.
|
||||
* The class defines a common base type and some common interface for all
|
||||
* statically derived Vector Expression classes.
|
||||
* We implement the casts to the statically derived type.
|
||||
*/
|
||||
template<class E>
|
||||
class vector_expression:
|
||||
public ublas_expression<E> {
|
||||
public:
|
||||
static const unsigned complexity = 0;
|
||||
typedef E expression_type;
|
||||
typedef vector_tag type_category;
|
||||
/* E can be an incomplete type - to define the following we would need more template arguments
|
||||
typedef typename E::size_type size_type;
|
||||
*/
|
||||
|
||||
BOOST_UBLAS_INLINE
|
||||
const expression_type &operator () () const {
|
||||
return *static_cast<const expression_type *> (this);
|
||||
}
|
||||
BOOST_UBLAS_INLINE
|
||||
expression_type &operator () () {
|
||||
return *static_cast<expression_type *> (this);
|
||||
}
|
||||
|
||||
#ifdef BOOST_UBLAS_ENABLE_PROXY_SHORTCUTS
|
||||
private:
|
||||
// projection types
|
||||
typedef vector_range<E> vector_range_type;
|
||||
typedef vector_range<const E> const_vector_range_type;
|
||||
typedef vector_slice<E> vector_slice_type;
|
||||
typedef vector_slice<const E> const_vector_slice_type;
|
||||
// vector_indirect_type will depend on the A template parameter
|
||||
typedef basic_range<> default_range; // required to avoid range/slice name confusion
|
||||
typedef basic_slice<> default_slice;
|
||||
public:
|
||||
BOOST_UBLAS_INLINE
|
||||
const_vector_range_type operator () (const default_range &r) const {
|
||||
return const_vector_range_type (operator () (), r);
|
||||
}
|
||||
BOOST_UBLAS_INLINE
|
||||
vector_range_type operator () (const default_range &r) {
|
||||
return vector_range_type (operator () (), r);
|
||||
}
|
||||
BOOST_UBLAS_INLINE
|
||||
const_vector_slice_type operator () (const default_slice &s) const {
|
||||
return const_vector_slice_type (operator () (), s);
|
||||
}
|
||||
BOOST_UBLAS_INLINE
|
||||
vector_slice_type operator () (const default_slice &s) {
|
||||
return vector_slice_type (operator () (), s);
|
||||
}
|
||||
template<class A>
|
||||
BOOST_UBLAS_INLINE
|
||||
const vector_indirect<const E, indirect_array<A> > operator () (const indirect_array<A> &ia) const {
|
||||
return vector_indirect<const E, indirect_array<A> > (operator () (), ia);
|
||||
}
|
||||
template<class A>
|
||||
BOOST_UBLAS_INLINE
|
||||
vector_indirect<E, indirect_array<A> > operator () (const indirect_array<A> &ia) {
|
||||
return vector_indirect<E, indirect_array<A> > (operator () (), ia);
|
||||
}
|
||||
|
||||
BOOST_UBLAS_INLINE
|
||||
const_vector_range_type project (const default_range &r) const {
|
||||
return const_vector_range_type (operator () (), r);
|
||||
}
|
||||
BOOST_UBLAS_INLINE
|
||||
vector_range_type project (const default_range &r) {
|
||||
return vector_range_type (operator () (), r);
|
||||
}
|
||||
BOOST_UBLAS_INLINE
|
||||
const_vector_slice_type project (const default_slice &s) const {
|
||||
return const_vector_slice_type (operator () (), s);
|
||||
}
|
||||
BOOST_UBLAS_INLINE
|
||||
vector_slice_type project (const default_slice &s) {
|
||||
return vector_slice_type (operator () (), s);
|
||||
}
|
||||
template<class A>
|
||||
BOOST_UBLAS_INLINE
|
||||
const vector_indirect<const E, indirect_array<A> > project (const indirect_array<A> &ia) const {
|
||||
return vector_indirect<const E, indirect_array<A> > (operator () (), ia);
|
||||
}
|
||||
template<class A>
|
||||
BOOST_UBLAS_INLINE
|
||||
vector_indirect<E, indirect_array<A> > project (const indirect_array<A> &ia) {
|
||||
return vector_indirect<E, indirect_array<A> > (operator () (), ia);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
/** \brief Base class for Vector container models
|
||||
*
|
||||
* it does not model the Vector concept but all derived types should.
|
||||
* The class defines a common base type and some common interface for all
|
||||
* statically derived Vector classes
|
||||
* We implement the casts to the statically derived type.
|
||||
*/
|
||||
template<class C>
|
||||
class vector_container:
|
||||
public vector_expression<C> {
|
||||
public:
|
||||
static const unsigned complexity = 0;
|
||||
typedef C container_type;
|
||||
typedef vector_tag type_category;
|
||||
|
||||
BOOST_UBLAS_INLINE
|
||||
const container_type &operator () () const {
|
||||
return *static_cast<const container_type *> (this);
|
||||
}
|
||||
BOOST_UBLAS_INLINE
|
||||
container_type &operator () () {
|
||||
return *static_cast<container_type *> (this);
|
||||
}
|
||||
|
||||
#ifdef BOOST_UBLAS_ENABLE_PROXY_SHORTCUTS
|
||||
using vector_expression<C>::operator ();
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
/** \brief Base class for Matrix Expression models
|
||||
*
|
||||
* it does not model the Matrix Expression concept but all derived types should.
|
||||
* The class defines a common base type and some common interface for all
|
||||
* statically derived Matrix Expression classes
|
||||
* We implement the casts to the statically derived type.
|
||||
*/
|
||||
template<class E>
|
||||
class matrix_expression:
|
||||
public ublas_expression<E> {
|
||||
private:
|
||||
typedef matrix_expression<E> self_type;
|
||||
public:
|
||||
static const unsigned complexity = 0;
|
||||
typedef E expression_type;
|
||||
typedef matrix_tag type_category;
|
||||
/* E can be an incomplete type - to define the following we would need more template arguments
|
||||
typedef typename E::size_type size_type;
|
||||
*/
|
||||
|
||||
BOOST_UBLAS_INLINE
|
||||
const expression_type &operator () () const {
|
||||
return *static_cast<const expression_type *> (this);
|
||||
}
|
||||
BOOST_UBLAS_INLINE
|
||||
expression_type &operator () () {
|
||||
return *static_cast<expression_type *> (this);
|
||||
}
|
||||
|
||||
#ifdef BOOST_UBLAS_ENABLE_PROXY_SHORTCUTS
|
||||
private:
|
||||
// projection types
|
||||
typedef vector_range<E> vector_range_type;
|
||||
typedef const vector_range<const E> const_vector_range_type;
|
||||
typedef vector_slice<E> vector_slice_type;
|
||||
typedef const vector_slice<const E> const_vector_slice_type;
|
||||
typedef matrix_row<E> matrix_row_type;
|
||||
typedef const matrix_row<const E> const_matrix_row_type;
|
||||
typedef matrix_column<E> matrix_column_type;
|
||||
typedef const matrix_column<const E> const_matrix_column_type;
|
||||
typedef matrix_range<E> matrix_range_type;
|
||||
typedef const matrix_range<const E> const_matrix_range_type;
|
||||
typedef matrix_slice<E> matrix_slice_type;
|
||||
typedef const matrix_slice<const E> const_matrix_slice_type;
|
||||
// matrix_indirect_type will depend on the A template parameter
|
||||
typedef basic_range<> default_range; // required to avoid range/slice name confusion
|
||||
typedef basic_slice<> default_slice;
|
||||
|
||||
public:
|
||||
BOOST_UBLAS_INLINE
|
||||
const_matrix_row_type operator [] (std::size_t i) const {
|
||||
return const_matrix_row_type (operator () (), i);
|
||||
}
|
||||
BOOST_UBLAS_INLINE
|
||||
matrix_row_type operator [] (std::size_t i) {
|
||||
return matrix_row_type (operator () (), i);
|
||||
}
|
||||
BOOST_UBLAS_INLINE
|
||||
const_matrix_row_type row (std::size_t i) const {
|
||||
return const_matrix_row_type (operator () (), i);
|
||||
}
|
||||
BOOST_UBLAS_INLINE
|
||||
matrix_row_type row (std::size_t i) {
|
||||
return matrix_row_type (operator () (), i);
|
||||
}
|
||||
BOOST_UBLAS_INLINE
|
||||
const_matrix_column_type column (std::size_t j) const {
|
||||
return const_matrix_column_type (operator () (), j);
|
||||
}
|
||||
BOOST_UBLAS_INLINE
|
||||
matrix_column_type column (std::size_t j) {
|
||||
return matrix_column_type (operator () (), j);
|
||||
}
|
||||
|
||||
BOOST_UBLAS_INLINE
|
||||
const_matrix_range_type operator () (const default_range &r1, const default_range &r2) const {
|
||||
return const_matrix_range_type (operator () (), r1, r2);
|
||||
}
|
||||
BOOST_UBLAS_INLINE
|
||||
matrix_range_type operator () (const default_range &r1, const default_range &r2) {
|
||||
return matrix_range_type (operator () (), r1, r2);
|
||||
}
|
||||
BOOST_UBLAS_INLINE
|
||||
const_matrix_slice_type operator () (const default_slice &s1, const default_slice &s2) const {
|
||||
return const_matrix_slice_type (operator () (), s1, s2);
|
||||
}
|
||||
BOOST_UBLAS_INLINE
|
||||
matrix_slice_type operator () (const default_slice &s1, const default_slice &s2) {
|
||||
return matrix_slice_type (operator () (), s1, s2);
|
||||
}
|
||||
template<class A>
|
||||
BOOST_UBLAS_INLINE
|
||||
const matrix_indirect<const E, indirect_array<A> > operator () (const indirect_array<A> &ia1, const indirect_array<A> &ia2) const {
|
||||
return matrix_indirect<const E, indirect_array<A> > (operator () (), ia1, ia2);
|
||||
}
|
||||
template<class A>
|
||||
BOOST_UBLAS_INLINE
|
||||
matrix_indirect<E, indirect_array<A> > operator () (const indirect_array<A> &ia1, const indirect_array<A> &ia2) {
|
||||
return matrix_indirect<E, indirect_array<A> > (operator () (), ia1, ia2);
|
||||
}
|
||||
|
||||
BOOST_UBLAS_INLINE
|
||||
const_matrix_range_type project (const default_range &r1, const default_range &r2) const {
|
||||
return const_matrix_range_type (operator () (), r1, r2);
|
||||
}
|
||||
BOOST_UBLAS_INLINE
|
||||
matrix_range_type project (const default_range &r1, const default_range &r2) {
|
||||
return matrix_range_type (operator () (), r1, r2);
|
||||
}
|
||||
BOOST_UBLAS_INLINE
|
||||
const_matrix_slice_type project (const default_slice &s1, const default_slice &s2) const {
|
||||
return const_matrix_slice_type (operator () (), s1, s2);
|
||||
}
|
||||
BOOST_UBLAS_INLINE
|
||||
matrix_slice_type project (const default_slice &s1, const default_slice &s2) {
|
||||
return matrix_slice_type (operator () (), s1, s2);
|
||||
}
|
||||
template<class A>
|
||||
BOOST_UBLAS_INLINE
|
||||
const matrix_indirect<const E, indirect_array<A> > project (const indirect_array<A> &ia1, const indirect_array<A> &ia2) const {
|
||||
return matrix_indirect<const E, indirect_array<A> > (operator () (), ia1, ia2);
|
||||
}
|
||||
template<class A>
|
||||
BOOST_UBLAS_INLINE
|
||||
matrix_indirect<E, indirect_array<A> > project (const indirect_array<A> &ia1, const indirect_array<A> &ia2) {
|
||||
return matrix_indirect<E, indirect_array<A> > (operator () (), ia1, ia2);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
|
||||
struct iterator1_tag {};
|
||||
struct iterator2_tag {};
|
||||
|
||||
template<class I>
|
||||
BOOST_UBLAS_INLINE
|
||||
typename I::dual_iterator_type begin (const I &it, iterator1_tag) {
|
||||
return it ().find2 (1, it.index1 (), 0);
|
||||
}
|
||||
template<class I>
|
||||
BOOST_UBLAS_INLINE
|
||||
typename I::dual_iterator_type end (const I &it, iterator1_tag) {
|
||||
return it ().find2 (1, it.index1 (), it ().size2 ());
|
||||
}
|
||||
template<class I>
|
||||
BOOST_UBLAS_INLINE
|
||||
typename I::dual_reverse_iterator_type rbegin (const I &it, iterator1_tag) {
|
||||
return typename I::dual_reverse_iterator_type (end (it, iterator1_tag ()));
|
||||
}
|
||||
template<class I>
|
||||
BOOST_UBLAS_INLINE
|
||||
typename I::dual_reverse_iterator_type rend (const I &it, iterator1_tag) {
|
||||
return typename I::dual_reverse_iterator_type (begin (it, iterator1_tag ()));
|
||||
}
|
||||
|
||||
template<class I>
|
||||
BOOST_UBLAS_INLINE
|
||||
typename I::dual_iterator_type begin (const I &it, iterator2_tag) {
|
||||
return it ().find1 (1, 0, it.index2 ());
|
||||
}
|
||||
template<class I>
|
||||
BOOST_UBLAS_INLINE
|
||||
typename I::dual_iterator_type end (const I &it, iterator2_tag) {
|
||||
return it ().find1 (1, it ().size1 (), it.index2 ());
|
||||
}
|
||||
template<class I>
|
||||
BOOST_UBLAS_INLINE
|
||||
typename I::dual_reverse_iterator_type rbegin (const I &it, iterator2_tag) {
|
||||
return typename I::dual_reverse_iterator_type (end (it, iterator2_tag ()));
|
||||
}
|
||||
template<class I>
|
||||
BOOST_UBLAS_INLINE
|
||||
typename I::dual_reverse_iterator_type rend (const I &it, iterator2_tag) {
|
||||
return typename I::dual_reverse_iterator_type (begin (it, iterator2_tag ()));
|
||||
}
|
||||
#endif
|
||||
|
||||
/** \brief Base class for Matrix container models
|
||||
*
|
||||
* it does not model the Matrix concept but all derived types should.
|
||||
* The class defines a common base type and some common interface for all
|
||||
* statically derived Matrix classes
|
||||
* We implement the casts to the statically derived type.
|
||||
*/
|
||||
template<class C>
|
||||
class matrix_container:
|
||||
public matrix_expression<C> {
|
||||
public:
|
||||
static const unsigned complexity = 0;
|
||||
typedef C container_type;
|
||||
typedef matrix_tag type_category;
|
||||
|
||||
BOOST_UBLAS_INLINE
|
||||
const container_type &operator () () const {
|
||||
return *static_cast<const container_type *> (this);
|
||||
}
|
||||
BOOST_UBLAS_INLINE
|
||||
container_type &operator () () {
|
||||
return *static_cast<container_type *> (this);
|
||||
}
|
||||
|
||||
#ifdef BOOST_UBLAS_ENABLE_PROXY_SHORTCUTS
|
||||
using matrix_expression<C>::operator ();
|
||||
#endif
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
#endif
|
||||
2063
project/jni/boost/include/boost/numeric/ublas/functional.hpp
Normal file
2063
project/jni/boost/include/boost/numeric/ublas/functional.hpp
Normal file
File diff suppressed because it is too large
Load Diff
217
project/jni/boost/include/boost/numeric/ublas/fwd.hpp
Normal file
217
project/jni/boost/include/boost/numeric/ublas/fwd.hpp
Normal file
@@ -0,0 +1,217 @@
|
||||
//
|
||||
// Copyright (c) 2000-2010
|
||||
// Joerg Walter, Mathias Koch, David Bellot
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
|
||||
/// \file fwd.hpp is essentially used to forward declare the main types
|
||||
|
||||
#ifndef BOOST_UBLAS_FWD_H
|
||||
#define BOOST_UBLAS_FWD_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace boost { namespace numeric { namespace ublas {
|
||||
|
||||
// Storage types
|
||||
template<class T, class ALLOC = std::allocator<T> >
|
||||
class unbounded_array;
|
||||
|
||||
template<class T, std::size_t N, class ALLOC = std::allocator<T> >
|
||||
class bounded_array;
|
||||
|
||||
template <class Z = std::size_t, class D = std::ptrdiff_t>
|
||||
class basic_range;
|
||||
template <class Z = std::size_t, class D = std::ptrdiff_t>
|
||||
class basic_slice;
|
||||
typedef basic_range<> range;
|
||||
typedef basic_slice<> slice;
|
||||
template<class A = unbounded_array<std::size_t> >
|
||||
class indirect_array;
|
||||
|
||||
template<class I, class T, class ALLOC = std::allocator<std::pair<const I, T> > >
|
||||
class map_std;
|
||||
template<class I, class T, class ALLOC = std::allocator<std::pair<I, T> > >
|
||||
class map_array;
|
||||
|
||||
// Expression types
|
||||
struct scalar_tag {};
|
||||
|
||||
struct vector_tag {};
|
||||
template<class E>
|
||||
class vector_expression;
|
||||
template<class C>
|
||||
class vector_container;
|
||||
|
||||
template<class E>
|
||||
class vector_reference;
|
||||
|
||||
struct matrix_tag {};
|
||||
|
||||
template<class E>
|
||||
class matrix_expression;
|
||||
template<class C>
|
||||
class matrix_container;
|
||||
|
||||
template<class E>
|
||||
class matrix_reference;
|
||||
|
||||
template<class V>
|
||||
class vector_range;
|
||||
template<class V>
|
||||
class vector_slice;
|
||||
template<class V, class IA = indirect_array<> >
|
||||
class vector_indirect;
|
||||
|
||||
template<class M>
|
||||
class matrix_row;
|
||||
template<class M>
|
||||
class matrix_column;
|
||||
template<class M>
|
||||
class matrix_vector_range;
|
||||
template<class M>
|
||||
class matrix_vector_slice;
|
||||
template<class M, class IA = indirect_array<> >
|
||||
class matrix_vector_indirect;
|
||||
template<class M>
|
||||
class matrix_range;
|
||||
template<class M>
|
||||
class matrix_slice;
|
||||
template<class M, class IA = indirect_array<> >
|
||||
class matrix_indirect;
|
||||
|
||||
template<class T, class A = unbounded_array<T> >
|
||||
class vector;
|
||||
template<class T, std::size_t N>
|
||||
class bounded_vector;
|
||||
|
||||
template<class T = int, class ALLOC = std::allocator<T> >
|
||||
class unit_vector;
|
||||
template<class T = int, class ALLOC = std::allocator<T> >
|
||||
class zero_vector;
|
||||
template<class T = int, class ALLOC = std::allocator<T> >
|
||||
class scalar_vector;
|
||||
|
||||
template<class T, std::size_t N>
|
||||
class c_vector;
|
||||
|
||||
// Sparse vectors
|
||||
template<class T, class A = map_std<std::size_t, T> >
|
||||
class mapped_vector;
|
||||
template<class T, std::size_t IB = 0, class IA = unbounded_array<std::size_t>, class TA = unbounded_array<T> >
|
||||
class compressed_vector;
|
||||
template<class T, std::size_t IB = 0, class IA = unbounded_array<std::size_t>, class TA = unbounded_array<T> >
|
||||
class coordinate_vector;
|
||||
|
||||
// Matrix orientation type
|
||||
struct unknown_orientation_tag {};
|
||||
struct row_major_tag {};
|
||||
struct column_major_tag {};
|
||||
|
||||
// Matrix storage layout parameterisation
|
||||
template <class Z = std::size_t, class D = std::ptrdiff_t>
|
||||
struct basic_row_major;
|
||||
typedef basic_row_major<> row_major;
|
||||
|
||||
template <class Z = std::size_t, class D = std::ptrdiff_t>
|
||||
struct basic_column_major;
|
||||
typedef basic_column_major<> column_major;
|
||||
|
||||
template<class T, class L = row_major, class A = unbounded_array<T> >
|
||||
class matrix;
|
||||
template<class T, std::size_t M, std::size_t N, class L = row_major>
|
||||
class bounded_matrix;
|
||||
|
||||
template<class T = int, class ALLOC = std::allocator<T> >
|
||||
class identity_matrix;
|
||||
template<class T = int, class ALLOC = std::allocator<T> >
|
||||
class zero_matrix;
|
||||
template<class T = int, class ALLOC = std::allocator<T> >
|
||||
class scalar_matrix;
|
||||
|
||||
template<class T, std::size_t M, std::size_t N>
|
||||
class c_matrix;
|
||||
|
||||
template<class T, class L = row_major, class A = unbounded_array<unbounded_array<T> > >
|
||||
class vector_of_vector;
|
||||
|
||||
template<class T, class L = row_major, class A = vector<compressed_vector<T> > >
|
||||
class generalized_vector_of_vector;
|
||||
|
||||
// Triangular matrix type
|
||||
struct lower_tag {};
|
||||
struct upper_tag {};
|
||||
struct unit_lower_tag : public lower_tag {};
|
||||
struct unit_upper_tag : public upper_tag {};
|
||||
struct strict_lower_tag : public lower_tag {};
|
||||
struct strict_upper_tag : public upper_tag {};
|
||||
|
||||
// Triangular matrix parameterisation
|
||||
template <class Z = std::size_t>
|
||||
struct basic_full;
|
||||
typedef basic_full<> full;
|
||||
|
||||
template <class Z = std::size_t>
|
||||
struct basic_lower;
|
||||
typedef basic_lower<> lower;
|
||||
|
||||
template <class Z = std::size_t>
|
||||
struct basic_upper;
|
||||
typedef basic_upper<> upper;
|
||||
|
||||
template <class Z = std::size_t>
|
||||
struct basic_unit_lower;
|
||||
typedef basic_unit_lower<> unit_lower;
|
||||
|
||||
template <class Z = std::size_t>
|
||||
struct basic_unit_upper;
|
||||
typedef basic_unit_upper<> unit_upper;
|
||||
|
||||
template <class Z = std::size_t>
|
||||
struct basic_strict_lower;
|
||||
typedef basic_strict_lower<> strict_lower;
|
||||
|
||||
template <class Z = std::size_t>
|
||||
struct basic_strict_upper;
|
||||
typedef basic_strict_upper<> strict_upper;
|
||||
|
||||
// Special matrices
|
||||
template<class T, class L = row_major, class A = unbounded_array<T> >
|
||||
class banded_matrix;
|
||||
template<class T, class L = row_major, class A = unbounded_array<T> >
|
||||
class diagonal_matrix;
|
||||
|
||||
template<class T, class TRI = lower, class L = row_major, class A = unbounded_array<T> >
|
||||
class triangular_matrix;
|
||||
template<class M, class TRI = lower>
|
||||
class triangular_adaptor;
|
||||
|
||||
template<class T, class TRI = lower, class L = row_major, class A = unbounded_array<T> >
|
||||
class symmetric_matrix;
|
||||
template<class M, class TRI = lower>
|
||||
class symmetric_adaptor;
|
||||
|
||||
template<class T, class TRI = lower, class L = row_major, class A = unbounded_array<T> >
|
||||
class hermitian_matrix;
|
||||
template<class M, class TRI = lower>
|
||||
class hermitian_adaptor;
|
||||
|
||||
// Sparse matrices
|
||||
template<class T, class L = row_major, class A = map_std<std::size_t, T> >
|
||||
class mapped_matrix;
|
||||
template<class T, class L = row_major, class A = map_std<std::size_t, map_std<std::size_t, T> > >
|
||||
class mapped_vector_of_mapped_vector;
|
||||
template<class T, class L = row_major, std::size_t IB = 0, class IA = unbounded_array<std::size_t>, class TA = unbounded_array<T> >
|
||||
class compressed_matrix;
|
||||
template<class T, class L = row_major, std::size_t IB = 0, class IA = unbounded_array<std::size_t>, class TA = unbounded_array<T> >
|
||||
class coordinate_matrix;
|
||||
|
||||
}}}
|
||||
|
||||
#endif
|
||||
2457
project/jni/boost/include/boost/numeric/ublas/hermitian.hpp
Normal file
2457
project/jni/boost/include/boost/numeric/ublas/hermitian.hpp
Normal file
File diff suppressed because it is too large
Load Diff
355
project/jni/boost/include/boost/numeric/ublas/io.hpp
Normal file
355
project/jni/boost/include/boost/numeric/ublas/io.hpp
Normal file
@@ -0,0 +1,355 @@
|
||||
//
|
||||
// Copyright (c) 2000-2010
|
||||
// Joerg Walter, Mathias Koch, David Bellot
|
||||
//
|
||||
// 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_IO_
|
||||
#define _BOOST_UBLAS_IO_
|
||||
|
||||
// Only forward definition required to define stream operations
|
||||
#include <iosfwd>
|
||||
#include <sstream>
|
||||
#include <boost/numeric/ublas/matrix_expression.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace numeric { namespace ublas {
|
||||
|
||||
/** \brief output stream operator for vector expressions
|
||||
*
|
||||
* Any vector expressions can be written to a standard output stream
|
||||
* as defined in the C++ standard library. For example:
|
||||
* \code
|
||||
* vector<float> v1(3),v2(3);
|
||||
* for(size_t i=0; i<3; i++)
|
||||
* {
|
||||
* v1(i) = i+0.2;
|
||||
* v2(i) = i+0.3;
|
||||
* }
|
||||
* cout << v1+v2 << endl;
|
||||
* \endcode
|
||||
* will display the some of the 2 vectors like this:
|
||||
* \code
|
||||
* [3](0.5,2.5,4.5)
|
||||
* \endcode
|
||||
*
|
||||
* \param os is a standard basic output stream
|
||||
* \param v is a vector expression
|
||||
* \return a reference to the resulting output stream
|
||||
*/
|
||||
template<class E, class T, class VE>
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
std::basic_ostream<E, T> &operator << (std::basic_ostream<E, T> &os,
|
||||
const vector_expression<VE> &v) {
|
||||
typedef typename VE::size_type size_type;
|
||||
size_type size = v ().size ();
|
||||
std::basic_ostringstream<E, T, std::allocator<E> > s;
|
||||
s.flags (os.flags ());
|
||||
s.imbue (os.getloc ());
|
||||
s.precision (os.precision ());
|
||||
s << '[' << size << "](";
|
||||
if (size > 0)
|
||||
s << v () (0);
|
||||
for (size_type i = 1; i < size; ++ i)
|
||||
s << ',' << v () (i);
|
||||
s << ')';
|
||||
return os << s.str ().c_str ();
|
||||
}
|
||||
|
||||
/** \brief input stream operator for vectors
|
||||
*
|
||||
* This is used to feed in vectors with data stored as an ASCII representation
|
||||
* from a standard input stream.
|
||||
*
|
||||
* From a file or any valid stream, the format is:
|
||||
* \c [<vector size>](<data1>,<data2>,...<dataN>) like for example:
|
||||
* \code
|
||||
* [5](1,2.1,3.2,3.14,0.2)
|
||||
* \endcode
|
||||
*
|
||||
* You can use it like this
|
||||
* \code
|
||||
* my_input_stream >> my_vector;
|
||||
* \endcode
|
||||
*
|
||||
* You can only put data into a valid \c vector<> not a \c vector_expression
|
||||
*
|
||||
* \param is is a standard basic input stream
|
||||
* \param v is a vector
|
||||
* \return a reference to the resulting input stream
|
||||
*/
|
||||
template<class E, class T, class VT, class VA>
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
std::basic_istream<E, T> &operator >> (std::basic_istream<E, T> &is,
|
||||
vector<VT, VA> &v) {
|
||||
typedef typename vector<VT, VA>::size_type size_type;
|
||||
E ch;
|
||||
size_type size;
|
||||
if (is >> ch && ch != '[') {
|
||||
is.putback (ch);
|
||||
is.setstate (std::ios_base::failbit);
|
||||
} else if (is >> size >> ch && ch != ']') {
|
||||
is.putback (ch);
|
||||
is.setstate (std::ios_base::failbit);
|
||||
} else if (! is.fail ()) {
|
||||
vector<VT, VA> s (size);
|
||||
if (is >> ch && ch != '(') {
|
||||
is.putback (ch);
|
||||
is.setstate (std::ios_base::failbit);
|
||||
} else if (! is.fail ()) {
|
||||
for (size_type i = 0; i < size; i ++) {
|
||||
if (is >> s (i) >> ch && ch != ',') {
|
||||
is.putback (ch);
|
||||
if (i < size - 1)
|
||||
is.setstate (std::ios_base::failbit);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (is >> ch && ch != ')') {
|
||||
is.putback (ch);
|
||||
is.setstate (std::ios_base::failbit);
|
||||
}
|
||||
}
|
||||
if (! is.fail ())
|
||||
v.swap (s);
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
/** \brief output stream operator for matrix expressions
|
||||
*
|
||||
* it outpus the content of a \f$(M \times N)\f$ matrix to a standard output
|
||||
* stream using the following format:
|
||||
* \c[<rows>,<columns>]((<m00>,<m01>,...,<m0N>),...,(<mM0>,<mM1>,...,<mMN>))
|
||||
*
|
||||
* For example:
|
||||
* \code
|
||||
* matrix<float> m(3,3) = scalar_matrix<float>(3,3,1.0) - diagonal_matrix<float>(3,3,1.0);
|
||||
* cout << m << endl;
|
||||
* \encode
|
||||
* will display
|
||||
* \code
|
||||
* [3,3]((0,1,1),(1,0,1),(1,1,0))
|
||||
* \endcode
|
||||
* This output is made for storing and retrieving matrices in a simple way but you can
|
||||
* easily recognize the following:
|
||||
* \f[ \left( \begin{array}{ccc} 1 & 1 & 1\\ 1 & 1 & 1\\ 1 & 1 & 1 \end{array} \right) - \left( \begin{array}{ccc} 1 & 0 & 0\\ 0 & 1 & 0\\ 0 & 0 & 1 \end{array} \right) = \left( \begin{array}{ccc} 0 & 1 & 1\\ 1 & 0 & 1\\ 1 & 1 & 0 \end{array} \right) \f]
|
||||
*
|
||||
* \param os is a standard basic output stream
|
||||
* \param m is a matrix expression
|
||||
* \return a reference to the resulting output stream
|
||||
*/
|
||||
template<class E, class T, class ME>
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
std::basic_ostream<E, T> &operator << (std::basic_ostream<E, T> &os,
|
||||
const matrix_expression<ME> &m) {
|
||||
typedef typename ME::size_type size_type;
|
||||
size_type size1 = m ().size1 ();
|
||||
size_type size2 = m ().size2 ();
|
||||
std::basic_ostringstream<E, T, std::allocator<E> > s;
|
||||
s.flags (os.flags ());
|
||||
s.imbue (os.getloc ());
|
||||
s.precision (os.precision ());
|
||||
s << '[' << size1 << ',' << size2 << "](";
|
||||
if (size1 > 0) {
|
||||
s << '(' ;
|
||||
if (size2 > 0)
|
||||
s << m () (0, 0);
|
||||
for (size_type j = 1; j < size2; ++ j)
|
||||
s << ',' << m () (0, j);
|
||||
s << ')';
|
||||
}
|
||||
for (size_type i = 1; i < size1; ++ i) {
|
||||
s << ",(" ;
|
||||
if (size2 > 0)
|
||||
s << m () (i, 0);
|
||||
for (size_type j = 1; j < size2; ++ j)
|
||||
s << ',' << m () (i, j);
|
||||
s << ')';
|
||||
}
|
||||
s << ')';
|
||||
return os << s.str ().c_str ();
|
||||
}
|
||||
|
||||
/** \brief input stream operator for matrices
|
||||
*
|
||||
* This is used to feed in matrices with data stored as an ASCII representation
|
||||
* from a standard input stream.
|
||||
*
|
||||
* From a file or any valid standard stream, the format is:
|
||||
* \c[<rows>,<columns>]((<m00>,<m01>,...,<m0N>),...,(<mM0>,<mM1>,...,<mMN>))
|
||||
*
|
||||
* You can use it like this
|
||||
* \code
|
||||
* my_input_stream >> my_matrix;
|
||||
* \endcode
|
||||
*
|
||||
* You can only put data into a valid \c matrix<> not a \c matrix_expression
|
||||
*
|
||||
* \param is is a standard basic input stream
|
||||
* \param m is a matrix
|
||||
* \return a reference to the resulting input stream
|
||||
*/
|
||||
template<class E, class T, class MT, class MF, class MA>
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
std::basic_istream<E, T> &operator >> (std::basic_istream<E, T> &is,
|
||||
matrix<MT, MF, MA> &m) {
|
||||
typedef typename matrix<MT, MF, MA>::size_type size_type;
|
||||
E ch;
|
||||
size_type size1, size2;
|
||||
if (is >> ch && ch != '[') {
|
||||
is.putback (ch);
|
||||
is.setstate (std::ios_base::failbit);
|
||||
} else if (is >> size1 >> ch && ch != ',') {
|
||||
is.putback (ch);
|
||||
is.setstate (std::ios_base::failbit);
|
||||
} else if (is >> size2 >> ch && ch != ']') {
|
||||
is.putback (ch);
|
||||
is.setstate (std::ios_base::failbit);
|
||||
} else if (! is.fail ()) {
|
||||
matrix<MT, MF, MA> s (size1, size2);
|
||||
if (is >> ch && ch != '(') {
|
||||
is.putback (ch);
|
||||
is.setstate (std::ios_base::failbit);
|
||||
} else if (! is.fail ()) {
|
||||
for (size_type i = 0; i < size1; i ++) {
|
||||
if (is >> ch && ch != '(') {
|
||||
is.putback (ch);
|
||||
is.setstate (std::ios_base::failbit);
|
||||
break;
|
||||
}
|
||||
for (size_type j = 0; j < size2; j ++) {
|
||||
if (is >> s (i, j) >> ch && ch != ',') {
|
||||
is.putback (ch);
|
||||
if (j < size2 - 1) {
|
||||
is.setstate (std::ios_base::failbit);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (is >> ch && ch != ')') {
|
||||
is.putback (ch);
|
||||
is.setstate (std::ios_base::failbit);
|
||||
break;
|
||||
}
|
||||
if (is >> ch && ch != ',') {
|
||||
is.putback (ch);
|
||||
if (i < size1 - 1) {
|
||||
is.setstate (std::ios_base::failbit);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (is >> ch && ch != ')') {
|
||||
is.putback (ch);
|
||||
is.setstate (std::ios_base::failbit);
|
||||
}
|
||||
}
|
||||
if (! is.fail ())
|
||||
m.swap (s);
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
/** \brief special input stream operator for symmetric matrices
|
||||
*
|
||||
* This is used to feed in symmetric matrices with data stored as an ASCII
|
||||
* representation from a standard input stream.
|
||||
*
|
||||
* You can simply write your matrices in a file or any valid stream and read them again
|
||||
* at a later time with this function. The format is the following:
|
||||
* \code [<rows>,<columns>]((<m00>,<m01>,...,<m0N>),...,(<mM0>,<mM1>,...,<mMN>)) \endcode
|
||||
*
|
||||
* You can use it like this
|
||||
* \code
|
||||
* my_input_stream >> my_symmetric_matrix;
|
||||
* \endcode
|
||||
*
|
||||
* You can only put data into a valid \c symmetric_matrix<>, not in a \c matrix_expression
|
||||
* This function also checks that input data form a valid symmetric matrix
|
||||
*
|
||||
* \param is is a standard basic input stream
|
||||
* \param m is a \c symmetric_matrix
|
||||
* \return a reference to the resulting input stream
|
||||
*/
|
||||
template<class E, class T, class MT, class MF1, class MF2, class MA>
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
std::basic_istream<E, T> &operator >> (std::basic_istream<E, T> &is,
|
||||
symmetric_matrix<MT, MF1, MF2, MA> &m) {
|
||||
typedef typename symmetric_matrix<MT, MF1, MF2, MA>::size_type size_type;
|
||||
E ch;
|
||||
size_type size1, size2;
|
||||
MT value;
|
||||
if (is >> ch && ch != '[') {
|
||||
is.putback (ch);
|
||||
is.setstate (std::ios_base::failbit);
|
||||
} else if (is >> size1 >> ch && ch != ',') {
|
||||
is.putback (ch);
|
||||
is.setstate (std::ios_base::failbit);
|
||||
} else if (is >> size2 >> ch && (size2 != size1 || ch != ']')) { // symmetric matrix must be square
|
||||
is.putback (ch);
|
||||
is.setstate (std::ios_base::failbit);
|
||||
} else if (! is.fail ()) {
|
||||
symmetric_matrix<MT, MF1, MF2, MA> s (size1, size2);
|
||||
if (is >> ch && ch != '(') {
|
||||
is.putback (ch);
|
||||
is.setstate (std::ios_base::failbit);
|
||||
} else if (! is.fail ()) {
|
||||
for (size_type i = 0; i < size1; i ++) {
|
||||
if (is >> ch && ch != '(') {
|
||||
is.putback (ch);
|
||||
is.setstate (std::ios_base::failbit);
|
||||
break;
|
||||
}
|
||||
for (size_type j = 0; j < size2; j ++) {
|
||||
if (is >> value >> ch && ch != ',') {
|
||||
is.putback (ch);
|
||||
if (j < size2 - 1) {
|
||||
is.setstate (std::ios_base::failbit);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i <= j) {
|
||||
// this is the first time we read this element - set the value
|
||||
s(i,j) = value;
|
||||
}
|
||||
else if ( s(i,j) != value ) {
|
||||
// matrix is not symmetric
|
||||
is.setstate (std::ios_base::failbit);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (is >> ch && ch != ')') {
|
||||
is.putback (ch);
|
||||
is.setstate (std::ios_base::failbit);
|
||||
break;
|
||||
}
|
||||
if (is >> ch && ch != ',') {
|
||||
is.putback (ch);
|
||||
if (i < size1 - 1) {
|
||||
is.setstate (std::ios_base::failbit);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (is >> ch && ch != ')') {
|
||||
is.putback (ch);
|
||||
is.setstate (std::ios_base::failbit);
|
||||
}
|
||||
}
|
||||
if (! is.fail ())
|
||||
m.swap (s);
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
|
||||
}}}
|
||||
|
||||
#endif
|
||||
351
project/jni/boost/include/boost/numeric/ublas/lu.hpp
Normal file
351
project/jni/boost/include/boost/numeric/ublas/lu.hpp
Normal file
@@ -0,0 +1,351 @@
|
||||
//
|
||||
// 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_LU_
|
||||
#define _BOOST_UBLAS_LU_
|
||||
|
||||
#include <boost/numeric/ublas/operation.hpp>
|
||||
#include <boost/numeric/ublas/vector_proxy.hpp>
|
||||
#include <boost/numeric/ublas/matrix_proxy.hpp>
|
||||
#include <boost/numeric/ublas/vector.hpp>
|
||||
#include <boost/numeric/ublas/triangular.hpp>
|
||||
|
||||
// LU factorizations in the spirit of LAPACK and Golub & van Loan
|
||||
|
||||
namespace boost { namespace numeric { namespace ublas {
|
||||
|
||||
/** \brief
|
||||
*
|
||||
* \tparam T
|
||||
* \tparam A
|
||||
*/
|
||||
template<class T = std::size_t, class A = unbounded_array<T> >
|
||||
class permutation_matrix:
|
||||
public vector<T, A> {
|
||||
public:
|
||||
typedef vector<T, A> vector_type;
|
||||
typedef typename vector_type::size_type size_type;
|
||||
|
||||
// Construction and destruction
|
||||
BOOST_UBLAS_INLINE
|
||||
explicit
|
||||
permutation_matrix (size_type size):
|
||||
vector<T, A> (size) {
|
||||
for (size_type i = 0; i < size; ++ i)
|
||||
(*this) (i) = i;
|
||||
}
|
||||
BOOST_UBLAS_INLINE
|
||||
explicit
|
||||
permutation_matrix (const vector_type & init)
|
||||
: vector_type(init)
|
||||
{ }
|
||||
BOOST_UBLAS_INLINE
|
||||
~permutation_matrix () {}
|
||||
|
||||
// Assignment
|
||||
BOOST_UBLAS_INLINE
|
||||
permutation_matrix &operator = (const permutation_matrix &m) {
|
||||
vector_type::operator = (m);
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
template<class PM, class MV>
|
||||
BOOST_UBLAS_INLINE
|
||||
void swap_rows (const PM &pm, MV &mv, vector_tag) {
|
||||
typedef typename PM::size_type size_type;
|
||||
typedef typename MV::value_type value_type;
|
||||
|
||||
size_type size = pm.size ();
|
||||
for (size_type i = 0; i < size; ++ i) {
|
||||
if (i != pm (i))
|
||||
std::swap (mv (i), mv (pm (i)));
|
||||
}
|
||||
}
|
||||
template<class PM, class MV>
|
||||
BOOST_UBLAS_INLINE
|
||||
void swap_rows (const PM &pm, MV &mv, matrix_tag) {
|
||||
typedef typename PM::size_type size_type;
|
||||
typedef typename MV::value_type value_type;
|
||||
|
||||
size_type size = pm.size ();
|
||||
for (size_type i = 0; i < size; ++ i) {
|
||||
if (i != pm (i))
|
||||
row (mv, i).swap (row (mv, pm (i)));
|
||||
}
|
||||
}
|
||||
// Dispatcher
|
||||
template<class PM, class MV>
|
||||
BOOST_UBLAS_INLINE
|
||||
void swap_rows (const PM &pm, MV &mv) {
|
||||
swap_rows (pm, mv, typename MV::type_category ());
|
||||
}
|
||||
|
||||
// LU factorization without pivoting
|
||||
template<class M>
|
||||
typename M::size_type lu_factorize (M &m) {
|
||||
typedef M matrix_type;
|
||||
typedef typename M::size_type size_type;
|
||||
typedef typename M::value_type value_type;
|
||||
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
matrix_type cm (m);
|
||||
#endif
|
||||
size_type singular = 0;
|
||||
size_type size1 = m.size1 ();
|
||||
size_type size2 = m.size2 ();
|
||||
size_type size = (std::min) (size1, size2);
|
||||
for (size_type i = 0; i < size; ++ i) {
|
||||
matrix_column<M> mci (column (m, i));
|
||||
matrix_row<M> mri (row (m, i));
|
||||
if (m (i, i) != value_type/*zero*/()) {
|
||||
value_type m_inv = value_type (1) / m (i, i);
|
||||
project (mci, range (i + 1, size1)) *= m_inv;
|
||||
} else if (singular == 0) {
|
||||
singular = i + 1;
|
||||
}
|
||||
project (m, range (i + 1, size1), range (i + 1, size2)).minus_assign (
|
||||
outer_prod (project (mci, range (i + 1, size1)),
|
||||
project (mri, range (i + 1, size2))));
|
||||
}
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
BOOST_UBLAS_CHECK (singular != 0 ||
|
||||
detail::expression_type_check (prod (triangular_adaptor<matrix_type, unit_lower> (m),
|
||||
triangular_adaptor<matrix_type, upper> (m)),
|
||||
cm), internal_logic ());
|
||||
#endif
|
||||
return singular;
|
||||
}
|
||||
|
||||
// LU factorization with partial pivoting
|
||||
template<class M, class PM>
|
||||
typename M::size_type lu_factorize (M &m, PM &pm) {
|
||||
typedef M matrix_type;
|
||||
typedef typename M::size_type size_type;
|
||||
typedef typename M::value_type value_type;
|
||||
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
matrix_type cm (m);
|
||||
#endif
|
||||
size_type singular = 0;
|
||||
size_type size1 = m.size1 ();
|
||||
size_type size2 = m.size2 ();
|
||||
size_type size = (std::min) (size1, size2);
|
||||
for (size_type i = 0; i < size; ++ i) {
|
||||
matrix_column<M> mci (column (m, i));
|
||||
matrix_row<M> mri (row (m, i));
|
||||
size_type i_norm_inf = i + index_norm_inf (project (mci, range (i, size1)));
|
||||
BOOST_UBLAS_CHECK (i_norm_inf < size1, external_logic ());
|
||||
if (m (i_norm_inf, i) != value_type/*zero*/()) {
|
||||
if (i_norm_inf != i) {
|
||||
pm (i) = i_norm_inf;
|
||||
row (m, i_norm_inf).swap (mri);
|
||||
} else {
|
||||
BOOST_UBLAS_CHECK (pm (i) == i_norm_inf, external_logic ());
|
||||
}
|
||||
value_type m_inv = value_type (1) / m (i, i);
|
||||
project (mci, range (i + 1, size1)) *= m_inv;
|
||||
} else if (singular == 0) {
|
||||
singular = i + 1;
|
||||
}
|
||||
project (m, range (i + 1, size1), range (i + 1, size2)).minus_assign (
|
||||
outer_prod (project (mci, range (i + 1, size1)),
|
||||
project (mri, range (i + 1, size2))));
|
||||
}
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
swap_rows (pm, cm);
|
||||
BOOST_UBLAS_CHECK (singular != 0 ||
|
||||
detail::expression_type_check (prod (triangular_adaptor<matrix_type, unit_lower> (m),
|
||||
triangular_adaptor<matrix_type, upper> (m)), cm), internal_logic ());
|
||||
#endif
|
||||
return singular;
|
||||
}
|
||||
|
||||
template<class M, class PM>
|
||||
typename M::size_type axpy_lu_factorize (M &m, PM &pm) {
|
||||
typedef M matrix_type;
|
||||
typedef typename M::size_type size_type;
|
||||
typedef typename M::value_type value_type;
|
||||
typedef vector<value_type> vector_type;
|
||||
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
matrix_type cm (m);
|
||||
#endif
|
||||
size_type singular = 0;
|
||||
size_type size1 = m.size1 ();
|
||||
size_type size2 = m.size2 ();
|
||||
size_type size = (std::min) (size1, size2);
|
||||
#ifndef BOOST_UBLAS_LU_WITH_INPLACE_SOLVE
|
||||
matrix_type mr (m);
|
||||
mr.assign (zero_matrix<value_type> (size1, size2));
|
||||
vector_type v (size1);
|
||||
for (size_type i = 0; i < size; ++ i) {
|
||||
matrix_range<matrix_type> lrr (project (mr, range (0, i), range (0, i)));
|
||||
vector_range<matrix_column<matrix_type> > urr (project (column (mr, i), range (0, i)));
|
||||
urr.assign (solve (lrr, project (column (m, i), range (0, i)), unit_lower_tag ()));
|
||||
project (v, range (i, size1)).assign (
|
||||
project (column (m, i), range (i, size1)) -
|
||||
axpy_prod<vector_type> (project (mr, range (i, size1), range (0, i)), urr));
|
||||
size_type i_norm_inf = i + index_norm_inf (project (v, range (i, size1)));
|
||||
BOOST_UBLAS_CHECK (i_norm_inf < size1, external_logic ());
|
||||
if (v (i_norm_inf) != value_type/*zero*/()) {
|
||||
if (i_norm_inf != i) {
|
||||
pm (i) = i_norm_inf;
|
||||
std::swap (v (i_norm_inf), v (i));
|
||||
project (row (m, i_norm_inf), range (i + 1, size2)).swap (project (row (m, i), range (i + 1, size2)));
|
||||
} else {
|
||||
BOOST_UBLAS_CHECK (pm (i) == i_norm_inf, external_logic ());
|
||||
}
|
||||
project (column (mr, i), range (i + 1, size1)).assign (
|
||||
project (v, range (i + 1, size1)) / v (i));
|
||||
if (i_norm_inf != i) {
|
||||
project (row (mr, i_norm_inf), range (0, i)).swap (project (row (mr, i), range (0, i)));
|
||||
}
|
||||
} else if (singular == 0) {
|
||||
singular = i + 1;
|
||||
}
|
||||
mr (i, i) = v (i);
|
||||
}
|
||||
m.assign (mr);
|
||||
#else
|
||||
matrix_type lr (m);
|
||||
matrix_type ur (m);
|
||||
lr.assign (identity_matrix<value_type> (size1, size2));
|
||||
ur.assign (zero_matrix<value_type> (size1, size2));
|
||||
vector_type v (size1);
|
||||
for (size_type i = 0; i < size; ++ i) {
|
||||
matrix_range<matrix_type> lrr (project (lr, range (0, i), range (0, i)));
|
||||
vector_range<matrix_column<matrix_type> > urr (project (column (ur, i), range (0, i)));
|
||||
urr.assign (project (column (m, i), range (0, i)));
|
||||
inplace_solve (lrr, urr, unit_lower_tag ());
|
||||
project (v, range (i, size1)).assign (
|
||||
project (column (m, i), range (i, size1)) -
|
||||
axpy_prod<vector_type> (project (lr, range (i, size1), range (0, i)), urr));
|
||||
size_type i_norm_inf = i + index_norm_inf (project (v, range (i, size1)));
|
||||
BOOST_UBLAS_CHECK (i_norm_inf < size1, external_logic ());
|
||||
if (v (i_norm_inf) != value_type/*zero*/()) {
|
||||
if (i_norm_inf != i) {
|
||||
pm (i) = i_norm_inf;
|
||||
std::swap (v (i_norm_inf), v (i));
|
||||
project (row (m, i_norm_inf), range (i + 1, size2)).swap (project (row (m, i), range (i + 1, size2)));
|
||||
} else {
|
||||
BOOST_UBLAS_CHECK (pm (i) == i_norm_inf, external_logic ());
|
||||
}
|
||||
project (column (lr, i), range (i + 1, size1)).assign (
|
||||
project (v, range (i + 1, size1)) / v (i));
|
||||
if (i_norm_inf != i) {
|
||||
project (row (lr, i_norm_inf), range (0, i)).swap (project (row (lr, i), range (0, i)));
|
||||
}
|
||||
} else if (singular == 0) {
|
||||
singular = i + 1;
|
||||
}
|
||||
ur (i, i) = v (i);
|
||||
}
|
||||
m.assign (triangular_adaptor<matrix_type, strict_lower> (lr) +
|
||||
triangular_adaptor<matrix_type, upper> (ur));
|
||||
#endif
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
swap_rows (pm, cm);
|
||||
BOOST_UBLAS_CHECK (singular != 0 ||
|
||||
detail::expression_type_check (prod (triangular_adaptor<matrix_type, unit_lower> (m),
|
||||
triangular_adaptor<matrix_type, upper> (m)), cm), internal_logic ());
|
||||
#endif
|
||||
return singular;
|
||||
}
|
||||
|
||||
// LU substitution
|
||||
template<class M, class E>
|
||||
void lu_substitute (const M &m, vector_expression<E> &e) {
|
||||
typedef const M const_matrix_type;
|
||||
typedef vector<typename E::value_type> vector_type;
|
||||
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
vector_type cv1 (e);
|
||||
#endif
|
||||
inplace_solve (m, e, unit_lower_tag ());
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
BOOST_UBLAS_CHECK (detail::expression_type_check (prod (triangular_adaptor<const_matrix_type, unit_lower> (m), e), cv1), internal_logic ());
|
||||
vector_type cv2 (e);
|
||||
#endif
|
||||
inplace_solve (m, e, upper_tag ());
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
BOOST_UBLAS_CHECK (detail::expression_type_check (prod (triangular_adaptor<const_matrix_type, upper> (m), e), cv2), internal_logic ());
|
||||
#endif
|
||||
}
|
||||
template<class M, class E>
|
||||
void lu_substitute (const M &m, matrix_expression<E> &e) {
|
||||
typedef const M const_matrix_type;
|
||||
typedef matrix<typename E::value_type> matrix_type;
|
||||
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
matrix_type cm1 (e);
|
||||
#endif
|
||||
inplace_solve (m, e, unit_lower_tag ());
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
BOOST_UBLAS_CHECK (detail::expression_type_check (prod (triangular_adaptor<const_matrix_type, unit_lower> (m), e), cm1), internal_logic ());
|
||||
matrix_type cm2 (e);
|
||||
#endif
|
||||
inplace_solve (m, e, upper_tag ());
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
BOOST_UBLAS_CHECK (detail::expression_type_check (prod (triangular_adaptor<const_matrix_type, upper> (m), e), cm2), internal_logic ());
|
||||
#endif
|
||||
}
|
||||
template<class M, class PMT, class PMA, class MV>
|
||||
void lu_substitute (const M &m, const permutation_matrix<PMT, PMA> &pm, MV &mv) {
|
||||
swap_rows (pm, mv);
|
||||
lu_substitute (m, mv);
|
||||
}
|
||||
template<class E, class M>
|
||||
void lu_substitute (vector_expression<E> &e, const M &m) {
|
||||
typedef const M const_matrix_type;
|
||||
typedef vector<typename E::value_type> vector_type;
|
||||
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
vector_type cv1 (e);
|
||||
#endif
|
||||
inplace_solve (e, m, upper_tag ());
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
BOOST_UBLAS_CHECK (detail::expression_type_check (prod (e, triangular_adaptor<const_matrix_type, upper> (m)), cv1), internal_logic ());
|
||||
vector_type cv2 (e);
|
||||
#endif
|
||||
inplace_solve (e, m, unit_lower_tag ());
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
BOOST_UBLAS_CHECK (detail::expression_type_check (prod (e, triangular_adaptor<const_matrix_type, unit_lower> (m)), cv2), internal_logic ());
|
||||
#endif
|
||||
}
|
||||
template<class E, class M>
|
||||
void lu_substitute (matrix_expression<E> &e, const M &m) {
|
||||
typedef const M const_matrix_type;
|
||||
typedef matrix<typename E::value_type> matrix_type;
|
||||
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
matrix_type cm1 (e);
|
||||
#endif
|
||||
inplace_solve (e, m, upper_tag ());
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
BOOST_UBLAS_CHECK (detail::expression_type_check (prod (e, triangular_adaptor<const_matrix_type, upper> (m)), cm1), internal_logic ());
|
||||
matrix_type cm2 (e);
|
||||
#endif
|
||||
inplace_solve (e, m, unit_lower_tag ());
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
BOOST_UBLAS_CHECK (detail::expression_type_check (prod (e, triangular_adaptor<const_matrix_type, unit_lower> (m)), cm2), internal_logic ());
|
||||
#endif
|
||||
}
|
||||
template<class MV, class M, class PMT, class PMA>
|
||||
void lu_substitute (MV &mv, const M &m, const permutation_matrix<PMT, PMA> &pm) {
|
||||
swap_rows (pm, mv);
|
||||
lu_substitute (mv, m);
|
||||
}
|
||||
|
||||
}}}
|
||||
|
||||
#endif
|
||||
4352
project/jni/boost/include/boost/numeric/ublas/matrix.hpp
Normal file
4352
project/jni/boost/include/boost/numeric/ublas/matrix.hpp
Normal file
File diff suppressed because it is too large
Load Diff
4952
project/jni/boost/include/boost/numeric/ublas/matrix_expression.hpp
Normal file
4952
project/jni/boost/include/boost/numeric/ublas/matrix_expression.hpp
Normal file
File diff suppressed because it is too large
Load Diff
5113
project/jni/boost/include/boost/numeric/ublas/matrix_proxy.hpp
Normal file
5113
project/jni/boost/include/boost/numeric/ublas/matrix_proxy.hpp
Normal file
File diff suppressed because it is too large
Load Diff
5369
project/jni/boost/include/boost/numeric/ublas/matrix_sparse.hpp
Normal file
5369
project/jni/boost/include/boost/numeric/ublas/matrix_sparse.hpp
Normal file
File diff suppressed because it is too large
Load Diff
851
project/jni/boost/include/boost/numeric/ublas/operation.hpp
Normal file
851
project/jni/boost/include/boost/numeric/ublas/operation.hpp
Normal file
@@ -0,0 +1,851 @@
|
||||
//
|
||||
// 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_OPERATION_
|
||||
#define _BOOST_UBLAS_OPERATION_
|
||||
|
||||
#include <boost/numeric/ublas/matrix_proxy.hpp>
|
||||
|
||||
/** \file operation.hpp
|
||||
* \brief This file contains some specialized products.
|
||||
*/
|
||||
|
||||
// axpy-based products
|
||||
// Alexei Novakov had a lot of ideas to improve these. Thanks.
|
||||
// Hendrik Kueck proposed some new kernel. Thanks again.
|
||||
|
||||
namespace boost { namespace numeric { namespace ublas {
|
||||
|
||||
template<class V, class T1, class L1, class IA1, class TA1, class E2>
|
||||
BOOST_UBLAS_INLINE
|
||||
V &
|
||||
axpy_prod (const compressed_matrix<T1, L1, 0, IA1, TA1> &e1,
|
||||
const vector_expression<E2> &e2,
|
||||
V &v, row_major_tag) {
|
||||
typedef typename V::size_type size_type;
|
||||
typedef typename V::value_type value_type;
|
||||
|
||||
for (size_type i = 0; i < e1.filled1 () -1; ++ i) {
|
||||
size_type begin = e1.index1_data () [i];
|
||||
size_type end = e1.index1_data () [i + 1];
|
||||
value_type t (v (i));
|
||||
for (size_type j = begin; j < end; ++ j)
|
||||
t += e1.value_data () [j] * e2 () (e1.index2_data () [j]);
|
||||
v (i) = t;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
template<class V, class T1, class L1, class IA1, class TA1, class E2>
|
||||
BOOST_UBLAS_INLINE
|
||||
V &
|
||||
axpy_prod (const compressed_matrix<T1, L1, 0, IA1, TA1> &e1,
|
||||
const vector_expression<E2> &e2,
|
||||
V &v, column_major_tag) {
|
||||
typedef typename V::size_type size_type;
|
||||
|
||||
for (size_type j = 0; j < e1.filled1 () -1; ++ j) {
|
||||
size_type begin = e1.index1_data () [j];
|
||||
size_type end = e1.index1_data () [j + 1];
|
||||
for (size_type i = begin; i < end; ++ i)
|
||||
v (e1.index2_data () [i]) += e1.value_data () [i] * e2 () (j);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
// Dispatcher
|
||||
template<class V, class T1, class L1, class IA1, class TA1, class E2>
|
||||
BOOST_UBLAS_INLINE
|
||||
V &
|
||||
axpy_prod (const compressed_matrix<T1, L1, 0, IA1, TA1> &e1,
|
||||
const vector_expression<E2> &e2,
|
||||
V &v, bool init = true) {
|
||||
typedef typename V::value_type value_type;
|
||||
typedef typename L1::orientation_category orientation_category;
|
||||
|
||||
if (init)
|
||||
v.assign (zero_vector<value_type> (e1.size1 ()));
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
vector<value_type> cv (v);
|
||||
typedef typename type_traits<value_type>::real_type real_type;
|
||||
real_type verrorbound (norm_1 (v) + norm_1 (e1) * norm_1 (e2));
|
||||
indexing_vector_assign<scalar_plus_assign> (cv, prod (e1, e2));
|
||||
#endif
|
||||
axpy_prod (e1, e2, v, orientation_category ());
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
BOOST_UBLAS_CHECK (norm_1 (v - cv) <= 2 * std::numeric_limits<real_type>::epsilon () * verrorbound, internal_logic ());
|
||||
#endif
|
||||
return v;
|
||||
}
|
||||
template<class V, class T1, class L1, class IA1, class TA1, class E2>
|
||||
BOOST_UBLAS_INLINE
|
||||
V
|
||||
axpy_prod (const compressed_matrix<T1, L1, 0, IA1, TA1> &e1,
|
||||
const vector_expression<E2> &e2) {
|
||||
typedef V vector_type;
|
||||
|
||||
vector_type v (e1.size1 ());
|
||||
return axpy_prod (e1, e2, v, true);
|
||||
}
|
||||
|
||||
template<class V, class T1, class L1, class IA1, class TA1, class E2>
|
||||
BOOST_UBLAS_INLINE
|
||||
V &
|
||||
axpy_prod (const coordinate_matrix<T1, L1, 0, IA1, TA1> &e1,
|
||||
const vector_expression<E2> &e2,
|
||||
V &v, bool init = true) {
|
||||
typedef typename V::size_type size_type;
|
||||
typedef typename V::value_type value_type;
|
||||
typedef L1 layout_type;
|
||||
|
||||
size_type size1 = e1.size1();
|
||||
size_type size2 = e1.size2();
|
||||
|
||||
if (init) {
|
||||
noalias(v) = zero_vector<value_type>(size1);
|
||||
}
|
||||
|
||||
for (size_type i = 0; i < e1.nnz(); ++i) {
|
||||
size_type row_index = layout_type::index_M( e1.index1_data () [i], e1.index2_data () [i] );
|
||||
size_type col_index = layout_type::index_m( e1.index1_data () [i], e1.index2_data () [i] );
|
||||
v( row_index ) += e1.value_data () [i] * e2 () (col_index);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
template<class V, class E1, class E2>
|
||||
BOOST_UBLAS_INLINE
|
||||
V &
|
||||
axpy_prod (const matrix_expression<E1> &e1,
|
||||
const vector_expression<E2> &e2,
|
||||
V &v, packed_random_access_iterator_tag, row_major_tag) {
|
||||
typedef const E1 expression1_type;
|
||||
typedef const E2 expression2_type;
|
||||
typedef typename V::size_type size_type;
|
||||
|
||||
typename expression1_type::const_iterator1 it1 (e1 ().begin1 ());
|
||||
typename expression1_type::const_iterator1 it1_end (e1 ().end1 ());
|
||||
while (it1 != it1_end) {
|
||||
size_type index1 (it1.index1 ());
|
||||
#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
|
||||
typename expression1_type::const_iterator2 it2 (it1.begin ());
|
||||
typename expression1_type::const_iterator2 it2_end (it1.end ());
|
||||
#else
|
||||
typename expression1_type::const_iterator2 it2 (boost::numeric::ublas::begin (it1, iterator1_tag ()));
|
||||
typename expression1_type::const_iterator2 it2_end (boost::numeric::ublas::end (it1, iterator1_tag ()));
|
||||
#endif
|
||||
while (it2 != it2_end) {
|
||||
v (index1) += *it2 * e2 () (it2.index2 ());
|
||||
++ it2;
|
||||
}
|
||||
++ it1;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
template<class V, class E1, class E2>
|
||||
BOOST_UBLAS_INLINE
|
||||
V &
|
||||
axpy_prod (const matrix_expression<E1> &e1,
|
||||
const vector_expression<E2> &e2,
|
||||
V &v, packed_random_access_iterator_tag, column_major_tag) {
|
||||
typedef const E1 expression1_type;
|
||||
typedef const E2 expression2_type;
|
||||
typedef typename V::size_type size_type;
|
||||
|
||||
typename expression1_type::const_iterator2 it2 (e1 ().begin2 ());
|
||||
typename expression1_type::const_iterator2 it2_end (e1 ().end2 ());
|
||||
while (it2 != it2_end) {
|
||||
size_type index2 (it2.index2 ());
|
||||
#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
|
||||
typename expression1_type::const_iterator1 it1 (it2.begin ());
|
||||
typename expression1_type::const_iterator1 it1_end (it2.end ());
|
||||
#else
|
||||
typename expression1_type::const_iterator1 it1 (boost::numeric::ublas::begin (it2, iterator2_tag ()));
|
||||
typename expression1_type::const_iterator1 it1_end (boost::numeric::ublas::end (it2, iterator2_tag ()));
|
||||
#endif
|
||||
while (it1 != it1_end) {
|
||||
v (it1.index1 ()) += *it1 * e2 () (index2);
|
||||
++ it1;
|
||||
}
|
||||
++ it2;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
template<class V, class E1, class E2>
|
||||
BOOST_UBLAS_INLINE
|
||||
V &
|
||||
axpy_prod (const matrix_expression<E1> &e1,
|
||||
const vector_expression<E2> &e2,
|
||||
V &v, sparse_bidirectional_iterator_tag) {
|
||||
typedef const E1 expression1_type;
|
||||
typedef const E2 expression2_type;
|
||||
typedef typename V::size_type size_type;
|
||||
|
||||
typename expression2_type::const_iterator it (e2 ().begin ());
|
||||
typename expression2_type::const_iterator it_end (e2 ().end ());
|
||||
while (it != it_end) {
|
||||
v.plus_assign (column (e1 (), it.index ()) * *it);
|
||||
++ it;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
// Dispatcher
|
||||
template<class V, class E1, class E2>
|
||||
BOOST_UBLAS_INLINE
|
||||
V &
|
||||
axpy_prod (const matrix_expression<E1> &e1,
|
||||
const vector_expression<E2> &e2,
|
||||
V &v, packed_random_access_iterator_tag) {
|
||||
typedef typename E1::orientation_category orientation_category;
|
||||
return axpy_prod (e1, e2, v, packed_random_access_iterator_tag (), orientation_category ());
|
||||
}
|
||||
|
||||
|
||||
/** \brief computes <tt>v += A x</tt> or <tt>v = A x</tt> in an
|
||||
optimized fashion.
|
||||
|
||||
\param e1 the matrix expression \c A
|
||||
\param e2 the vector expression \c x
|
||||
\param v the result vector \c v
|
||||
\param init a boolean parameter
|
||||
|
||||
<tt>axpy_prod(A, x, v, init)</tt> implements the well known
|
||||
axpy-product. Setting \a init to \c true is equivalent to call
|
||||
<tt>v.clear()</tt> before <tt>axpy_prod</tt>. Currently \a init
|
||||
defaults to \c true, but this may change in the future.
|
||||
|
||||
Up to now there are some specialisation for compressed
|
||||
matrices that give a large speed up compared to prod.
|
||||
|
||||
\ingroup blas2
|
||||
|
||||
\internal
|
||||
|
||||
template parameters:
|
||||
\param V type of the result vector \c v
|
||||
\param E1 type of a matrix expression \c A
|
||||
\param E2 type of a vector expression \c x
|
||||
*/
|
||||
template<class V, class E1, class E2>
|
||||
BOOST_UBLAS_INLINE
|
||||
V &
|
||||
axpy_prod (const matrix_expression<E1> &e1,
|
||||
const vector_expression<E2> &e2,
|
||||
V &v, bool init = true) {
|
||||
typedef typename V::value_type value_type;
|
||||
typedef typename E2::const_iterator::iterator_category iterator_category;
|
||||
|
||||
if (init)
|
||||
v.assign (zero_vector<value_type> (e1 ().size1 ()));
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
vector<value_type> cv (v);
|
||||
typedef typename type_traits<value_type>::real_type real_type;
|
||||
real_type verrorbound (norm_1 (v) + norm_1 (e1) * norm_1 (e2));
|
||||
indexing_vector_assign<scalar_plus_assign> (cv, prod (e1, e2));
|
||||
#endif
|
||||
axpy_prod (e1, e2, v, iterator_category ());
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
BOOST_UBLAS_CHECK (norm_1 (v - cv) <= 2 * std::numeric_limits<real_type>::epsilon () * verrorbound, internal_logic ());
|
||||
#endif
|
||||
return v;
|
||||
}
|
||||
template<class V, class E1, class E2>
|
||||
BOOST_UBLAS_INLINE
|
||||
V
|
||||
axpy_prod (const matrix_expression<E1> &e1,
|
||||
const vector_expression<E2> &e2) {
|
||||
typedef V vector_type;
|
||||
|
||||
vector_type v (e1 ().size1 ());
|
||||
return axpy_prod (e1, e2, v, true);
|
||||
}
|
||||
|
||||
template<class V, class E1, class T2, class IA2, class TA2>
|
||||
BOOST_UBLAS_INLINE
|
||||
V &
|
||||
axpy_prod (const vector_expression<E1> &e1,
|
||||
const compressed_matrix<T2, column_major, 0, IA2, TA2> &e2,
|
||||
V &v, column_major_tag) {
|
||||
typedef typename V::size_type size_type;
|
||||
typedef typename V::value_type value_type;
|
||||
|
||||
for (size_type j = 0; j < e2.filled1 () -1; ++ j) {
|
||||
size_type begin = e2.index1_data () [j];
|
||||
size_type end = e2.index1_data () [j + 1];
|
||||
value_type t (v (j));
|
||||
for (size_type i = begin; i < end; ++ i)
|
||||
t += e2.value_data () [i] * e1 () (e2.index2_data () [i]);
|
||||
v (j) = t;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
template<class V, class E1, class T2, class IA2, class TA2>
|
||||
BOOST_UBLAS_INLINE
|
||||
V &
|
||||
axpy_prod (const vector_expression<E1> &e1,
|
||||
const compressed_matrix<T2, row_major, 0, IA2, TA2> &e2,
|
||||
V &v, row_major_tag) {
|
||||
typedef typename V::size_type size_type;
|
||||
|
||||
for (size_type i = 0; i < e2.filled1 () -1; ++ i) {
|
||||
size_type begin = e2.index1_data () [i];
|
||||
size_type end = e2.index1_data () [i + 1];
|
||||
for (size_type j = begin; j < end; ++ j)
|
||||
v (e2.index2_data () [j]) += e2.value_data () [j] * e1 () (i);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
// Dispatcher
|
||||
template<class V, class E1, class T2, class L2, class IA2, class TA2>
|
||||
BOOST_UBLAS_INLINE
|
||||
V &
|
||||
axpy_prod (const vector_expression<E1> &e1,
|
||||
const compressed_matrix<T2, L2, 0, IA2, TA2> &e2,
|
||||
V &v, bool init = true) {
|
||||
typedef typename V::value_type value_type;
|
||||
typedef typename L2::orientation_category orientation_category;
|
||||
|
||||
if (init)
|
||||
v.assign (zero_vector<value_type> (e2.size2 ()));
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
vector<value_type> cv (v);
|
||||
typedef typename type_traits<value_type>::real_type real_type;
|
||||
real_type verrorbound (norm_1 (v) + norm_1 (e1) * norm_1 (e2));
|
||||
indexing_vector_assign<scalar_plus_assign> (cv, prod (e1, e2));
|
||||
#endif
|
||||
axpy_prod (e1, e2, v, orientation_category ());
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
BOOST_UBLAS_CHECK (norm_1 (v - cv) <= 2 * std::numeric_limits<real_type>::epsilon () * verrorbound, internal_logic ());
|
||||
#endif
|
||||
return v;
|
||||
}
|
||||
template<class V, class E1, class T2, class L2, class IA2, class TA2>
|
||||
BOOST_UBLAS_INLINE
|
||||
V
|
||||
axpy_prod (const vector_expression<E1> &e1,
|
||||
const compressed_matrix<T2, L2, 0, IA2, TA2> &e2) {
|
||||
typedef V vector_type;
|
||||
|
||||
vector_type v (e2.size2 ());
|
||||
return axpy_prod (e1, e2, v, true);
|
||||
}
|
||||
|
||||
template<class V, class E1, class E2>
|
||||
BOOST_UBLAS_INLINE
|
||||
V &
|
||||
axpy_prod (const vector_expression<E1> &e1,
|
||||
const matrix_expression<E2> &e2,
|
||||
V &v, packed_random_access_iterator_tag, column_major_tag) {
|
||||
typedef const E1 expression1_type;
|
||||
typedef const E2 expression2_type;
|
||||
typedef typename V::size_type size_type;
|
||||
|
||||
typename expression2_type::const_iterator2 it2 (e2 ().begin2 ());
|
||||
typename expression2_type::const_iterator2 it2_end (e2 ().end2 ());
|
||||
while (it2 != it2_end) {
|
||||
size_type index2 (it2.index2 ());
|
||||
#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
|
||||
typename expression2_type::const_iterator1 it1 (it2.begin ());
|
||||
typename expression2_type::const_iterator1 it1_end (it2.end ());
|
||||
#else
|
||||
typename expression2_type::const_iterator1 it1 (boost::numeric::ublas::begin (it2, iterator2_tag ()));
|
||||
typename expression2_type::const_iterator1 it1_end (boost::numeric::ublas::end (it2, iterator2_tag ()));
|
||||
#endif
|
||||
while (it1 != it1_end) {
|
||||
v (index2) += *it1 * e1 () (it1.index1 ());
|
||||
++ it1;
|
||||
}
|
||||
++ it2;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
template<class V, class E1, class E2>
|
||||
BOOST_UBLAS_INLINE
|
||||
V &
|
||||
axpy_prod (const vector_expression<E1> &e1,
|
||||
const matrix_expression<E2> &e2,
|
||||
V &v, packed_random_access_iterator_tag, row_major_tag) {
|
||||
typedef const E1 expression1_type;
|
||||
typedef const E2 expression2_type;
|
||||
typedef typename V::size_type size_type;
|
||||
|
||||
typename expression2_type::const_iterator1 it1 (e2 ().begin1 ());
|
||||
typename expression2_type::const_iterator1 it1_end (e2 ().end1 ());
|
||||
while (it1 != it1_end) {
|
||||
size_type index1 (it1.index1 ());
|
||||
#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
|
||||
typename expression2_type::const_iterator2 it2 (it1.begin ());
|
||||
typename expression2_type::const_iterator2 it2_end (it1.end ());
|
||||
#else
|
||||
typename expression2_type::const_iterator2 it2 (boost::numeric::ublas::begin (it1, iterator1_tag ()));
|
||||
typename expression2_type::const_iterator2 it2_end (boost::numeric::ublas::end (it1, iterator1_tag ()));
|
||||
#endif
|
||||
while (it2 != it2_end) {
|
||||
v (it2.index2 ()) += *it2 * e1 () (index1);
|
||||
++ it2;
|
||||
}
|
||||
++ it1;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
template<class V, class E1, class E2>
|
||||
BOOST_UBLAS_INLINE
|
||||
V &
|
||||
axpy_prod (const vector_expression<E1> &e1,
|
||||
const matrix_expression<E2> &e2,
|
||||
V &v, sparse_bidirectional_iterator_tag) {
|
||||
typedef const E1 expression1_type;
|
||||
typedef const E2 expression2_type;
|
||||
typedef typename V::size_type size_type;
|
||||
|
||||
typename expression1_type::const_iterator it (e1 ().begin ());
|
||||
typename expression1_type::const_iterator it_end (e1 ().end ());
|
||||
while (it != it_end) {
|
||||
v.plus_assign (*it * row (e2 (), it.index ()));
|
||||
++ it;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
// Dispatcher
|
||||
template<class V, class E1, class E2>
|
||||
BOOST_UBLAS_INLINE
|
||||
V &
|
||||
axpy_prod (const vector_expression<E1> &e1,
|
||||
const matrix_expression<E2> &e2,
|
||||
V &v, packed_random_access_iterator_tag) {
|
||||
typedef typename E2::orientation_category orientation_category;
|
||||
return axpy_prod (e1, e2, v, packed_random_access_iterator_tag (), orientation_category ());
|
||||
}
|
||||
|
||||
|
||||
/** \brief computes <tt>v += A<sup>T</sup> x</tt> or <tt>v = A<sup>T</sup> x</tt> in an
|
||||
optimized fashion.
|
||||
|
||||
\param e1 the vector expression \c x
|
||||
\param e2 the matrix expression \c A
|
||||
\param v the result vector \c v
|
||||
\param init a boolean parameter
|
||||
|
||||
<tt>axpy_prod(x, A, v, init)</tt> implements the well known
|
||||
axpy-product. Setting \a init to \c true is equivalent to call
|
||||
<tt>v.clear()</tt> before <tt>axpy_prod</tt>. Currently \a init
|
||||
defaults to \c true, but this may change in the future.
|
||||
|
||||
Up to now there are some specialisation for compressed
|
||||
matrices that give a large speed up compared to prod.
|
||||
|
||||
\ingroup blas2
|
||||
|
||||
\internal
|
||||
|
||||
template parameters:
|
||||
\param V type of the result vector \c v
|
||||
\param E1 type of a vector expression \c x
|
||||
\param E2 type of a matrix expression \c A
|
||||
*/
|
||||
template<class V, class E1, class E2>
|
||||
BOOST_UBLAS_INLINE
|
||||
V &
|
||||
axpy_prod (const vector_expression<E1> &e1,
|
||||
const matrix_expression<E2> &e2,
|
||||
V &v, bool init = true) {
|
||||
typedef typename V::value_type value_type;
|
||||
typedef typename E1::const_iterator::iterator_category iterator_category;
|
||||
|
||||
if (init)
|
||||
v.assign (zero_vector<value_type> (e2 ().size2 ()));
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
vector<value_type> cv (v);
|
||||
typedef typename type_traits<value_type>::real_type real_type;
|
||||
real_type verrorbound (norm_1 (v) + norm_1 (e1) * norm_1 (e2));
|
||||
indexing_vector_assign<scalar_plus_assign> (cv, prod (e1, e2));
|
||||
#endif
|
||||
axpy_prod (e1, e2, v, iterator_category ());
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
BOOST_UBLAS_CHECK (norm_1 (v - cv) <= 2 * std::numeric_limits<real_type>::epsilon () * verrorbound, internal_logic ());
|
||||
#endif
|
||||
return v;
|
||||
}
|
||||
template<class V, class E1, class E2>
|
||||
BOOST_UBLAS_INLINE
|
||||
V
|
||||
axpy_prod (const vector_expression<E1> &e1,
|
||||
const matrix_expression<E2> &e2) {
|
||||
typedef V vector_type;
|
||||
|
||||
vector_type v (e2 ().size2 ());
|
||||
return axpy_prod (e1, e2, v, true);
|
||||
}
|
||||
|
||||
template<class M, class E1, class E2, class TRI>
|
||||
BOOST_UBLAS_INLINE
|
||||
M &
|
||||
axpy_prod (const matrix_expression<E1> &e1,
|
||||
const matrix_expression<E2> &e2,
|
||||
M &m, TRI,
|
||||
dense_proxy_tag, row_major_tag) {
|
||||
typedef M matrix_type;
|
||||
typedef const E1 expression1_type;
|
||||
typedef const E2 expression2_type;
|
||||
typedef typename M::size_type size_type;
|
||||
typedef typename M::value_type value_type;
|
||||
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
matrix<value_type, row_major> cm (m);
|
||||
typedef typename type_traits<value_type>::real_type real_type;
|
||||
real_type merrorbound (norm_1 (m) + norm_1 (e1) * norm_1 (e2));
|
||||
indexing_matrix_assign<scalar_plus_assign> (cm, prod (e1, e2), row_major_tag ());
|
||||
#endif
|
||||
size_type size1 (e1 ().size1 ());
|
||||
size_type size2 (e1 ().size2 ());
|
||||
for (size_type i = 0; i < size1; ++ i)
|
||||
for (size_type j = 0; j < size2; ++ j)
|
||||
row (m, i).plus_assign (e1 () (i, j) * row (e2 (), j));
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
BOOST_UBLAS_CHECK (norm_1 (m - cm) <= 2 * std::numeric_limits<real_type>::epsilon () * merrorbound, internal_logic ());
|
||||
#endif
|
||||
return m;
|
||||
}
|
||||
template<class M, class E1, class E2, class TRI>
|
||||
BOOST_UBLAS_INLINE
|
||||
M &
|
||||
axpy_prod (const matrix_expression<E1> &e1,
|
||||
const matrix_expression<E2> &e2,
|
||||
M &m, TRI,
|
||||
sparse_proxy_tag, row_major_tag) {
|
||||
typedef M matrix_type;
|
||||
typedef TRI triangular_restriction;
|
||||
typedef const E1 expression1_type;
|
||||
typedef const E2 expression2_type;
|
||||
typedef typename M::size_type size_type;
|
||||
typedef typename M::value_type value_type;
|
||||
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
matrix<value_type, row_major> cm (m);
|
||||
typedef typename type_traits<value_type>::real_type real_type;
|
||||
real_type merrorbound (norm_1 (m) + norm_1 (e1) * norm_1 (e2));
|
||||
indexing_matrix_assign<scalar_plus_assign> (cm, prod (e1, e2), row_major_tag ());
|
||||
#endif
|
||||
typename expression1_type::const_iterator1 it1 (e1 ().begin1 ());
|
||||
typename expression1_type::const_iterator1 it1_end (e1 ().end1 ());
|
||||
while (it1 != it1_end) {
|
||||
#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
|
||||
typename expression1_type::const_iterator2 it2 (it1.begin ());
|
||||
typename expression1_type::const_iterator2 it2_end (it1.end ());
|
||||
#else
|
||||
typename expression1_type::const_iterator2 it2 (boost::numeric::ublas::begin (it1, iterator1_tag ()));
|
||||
typename expression1_type::const_iterator2 it2_end (boost::numeric::ublas::end (it1, iterator1_tag ()));
|
||||
#endif
|
||||
while (it2 != it2_end) {
|
||||
// row (m, it1.index1 ()).plus_assign (*it2 * row (e2 (), it2.index2 ()));
|
||||
matrix_row<expression2_type> mr (e2 (), it2.index2 ());
|
||||
typename matrix_row<expression2_type>::const_iterator itr (mr.begin ());
|
||||
typename matrix_row<expression2_type>::const_iterator itr_end (mr.end ());
|
||||
while (itr != itr_end) {
|
||||
if (triangular_restriction::other (it1.index1 (), itr.index ()))
|
||||
m (it1.index1 (), itr.index ()) += *it2 * *itr;
|
||||
++ itr;
|
||||
}
|
||||
++ it2;
|
||||
}
|
||||
++ it1;
|
||||
}
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
BOOST_UBLAS_CHECK (norm_1 (m - cm) <= 2 * std::numeric_limits<real_type>::epsilon () * merrorbound, internal_logic ());
|
||||
#endif
|
||||
return m;
|
||||
}
|
||||
|
||||
template<class M, class E1, class E2, class TRI>
|
||||
BOOST_UBLAS_INLINE
|
||||
M &
|
||||
axpy_prod (const matrix_expression<E1> &e1,
|
||||
const matrix_expression<E2> &e2,
|
||||
M &m, TRI,
|
||||
dense_proxy_tag, column_major_tag) {
|
||||
typedef M matrix_type;
|
||||
typedef const E1 expression1_type;
|
||||
typedef const E2 expression2_type;
|
||||
typedef typename M::size_type size_type;
|
||||
typedef typename M::value_type value_type;
|
||||
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
matrix<value_type, column_major> cm (m);
|
||||
typedef typename type_traits<value_type>::real_type real_type;
|
||||
real_type merrorbound (norm_1 (m) + norm_1 (e1) * norm_1 (e2));
|
||||
indexing_matrix_assign<scalar_plus_assign> (cm, prod (e1, e2), column_major_tag ());
|
||||
#endif
|
||||
size_type size1 (e2 ().size1 ());
|
||||
size_type size2 (e2 ().size2 ());
|
||||
for (size_type j = 0; j < size2; ++ j)
|
||||
for (size_type i = 0; i < size1; ++ i)
|
||||
column (m, j).plus_assign (e2 () (i, j) * column (e1 (), i));
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
BOOST_UBLAS_CHECK (norm_1 (m - cm) <= 2 * std::numeric_limits<real_type>::epsilon () * merrorbound, internal_logic ());
|
||||
#endif
|
||||
return m;
|
||||
}
|
||||
template<class M, class E1, class E2, class TRI>
|
||||
BOOST_UBLAS_INLINE
|
||||
M &
|
||||
axpy_prod (const matrix_expression<E1> &e1,
|
||||
const matrix_expression<E2> &e2,
|
||||
M &m, TRI,
|
||||
sparse_proxy_tag, column_major_tag) {
|
||||
typedef M matrix_type;
|
||||
typedef TRI triangular_restriction;
|
||||
typedef const E1 expression1_type;
|
||||
typedef const E2 expression2_type;
|
||||
typedef typename M::size_type size_type;
|
||||
typedef typename M::value_type value_type;
|
||||
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
matrix<value_type, column_major> cm (m);
|
||||
typedef typename type_traits<value_type>::real_type real_type;
|
||||
real_type merrorbound (norm_1 (m) + norm_1 (e1) * norm_1 (e2));
|
||||
indexing_matrix_assign<scalar_plus_assign> (cm, prod (e1, e2), column_major_tag ());
|
||||
#endif
|
||||
typename expression2_type::const_iterator2 it2 (e2 ().begin2 ());
|
||||
typename expression2_type::const_iterator2 it2_end (e2 ().end2 ());
|
||||
while (it2 != it2_end) {
|
||||
#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
|
||||
typename expression2_type::const_iterator1 it1 (it2.begin ());
|
||||
typename expression2_type::const_iterator1 it1_end (it2.end ());
|
||||
#else
|
||||
typename expression2_type::const_iterator1 it1 (boost::numeric::ublas::begin (it2, iterator2_tag ()));
|
||||
typename expression2_type::const_iterator1 it1_end (boost::numeric::ublas::end (it2, iterator2_tag ()));
|
||||
#endif
|
||||
while (it1 != it1_end) {
|
||||
// column (m, it2.index2 ()).plus_assign (*it1 * column (e1 (), it1.index1 ()));
|
||||
matrix_column<expression1_type> mc (e1 (), it1.index1 ());
|
||||
typename matrix_column<expression1_type>::const_iterator itc (mc.begin ());
|
||||
typename matrix_column<expression1_type>::const_iterator itc_end (mc.end ());
|
||||
while (itc != itc_end) {
|
||||
if(triangular_restriction::other (itc.index (), it2.index2 ()))
|
||||
m (itc.index (), it2.index2 ()) += *it1 * *itc;
|
||||
++ itc;
|
||||
}
|
||||
++ it1;
|
||||
}
|
||||
++ it2;
|
||||
}
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
BOOST_UBLAS_CHECK (norm_1 (m - cm) <= 2 * std::numeric_limits<real_type>::epsilon () * merrorbound, internal_logic ());
|
||||
#endif
|
||||
return m;
|
||||
}
|
||||
|
||||
// Dispatcher
|
||||
template<class M, class E1, class E2, class TRI>
|
||||
BOOST_UBLAS_INLINE
|
||||
M &
|
||||
axpy_prod (const matrix_expression<E1> &e1,
|
||||
const matrix_expression<E2> &e2,
|
||||
M &m, TRI, bool init = true) {
|
||||
typedef typename M::value_type value_type;
|
||||
typedef typename M::storage_category storage_category;
|
||||
typedef typename M::orientation_category orientation_category;
|
||||
typedef TRI triangular_restriction;
|
||||
|
||||
if (init)
|
||||
m.assign (zero_matrix<value_type> (e1 ().size1 (), e2 ().size2 ()));
|
||||
return axpy_prod (e1, e2, m, triangular_restriction (), storage_category (), orientation_category ());
|
||||
}
|
||||
template<class M, class E1, class E2, class TRI>
|
||||
BOOST_UBLAS_INLINE
|
||||
M
|
||||
axpy_prod (const matrix_expression<E1> &e1,
|
||||
const matrix_expression<E2> &e2,
|
||||
TRI) {
|
||||
typedef M matrix_type;
|
||||
typedef TRI triangular_restriction;
|
||||
|
||||
matrix_type m (e1 ().size1 (), e2 ().size2 ());
|
||||
return axpy_prod (e1, e2, m, triangular_restriction (), true);
|
||||
}
|
||||
|
||||
/** \brief computes <tt>M += A X</tt> or <tt>M = A X</tt> in an
|
||||
optimized fashion.
|
||||
|
||||
\param e1 the matrix expression \c A
|
||||
\param e2 the matrix expression \c X
|
||||
\param m the result matrix \c M
|
||||
\param init a boolean parameter
|
||||
|
||||
<tt>axpy_prod(A, X, M, init)</tt> implements the well known
|
||||
axpy-product. Setting \a init to \c true is equivalent to call
|
||||
<tt>M.clear()</tt> before <tt>axpy_prod</tt>. Currently \a init
|
||||
defaults to \c true, but this may change in the future.
|
||||
|
||||
Up to now there are no specialisations.
|
||||
|
||||
\ingroup blas3
|
||||
|
||||
\internal
|
||||
|
||||
template parameters:
|
||||
\param M type of the result matrix \c M
|
||||
\param E1 type of a matrix expression \c A
|
||||
\param E2 type of a matrix expression \c X
|
||||
*/
|
||||
template<class M, class E1, class E2>
|
||||
BOOST_UBLAS_INLINE
|
||||
M &
|
||||
axpy_prod (const matrix_expression<E1> &e1,
|
||||
const matrix_expression<E2> &e2,
|
||||
M &m, bool init = true) {
|
||||
typedef typename M::value_type value_type;
|
||||
typedef typename M::storage_category storage_category;
|
||||
typedef typename M::orientation_category orientation_category;
|
||||
|
||||
if (init)
|
||||
m.assign (zero_matrix<value_type> (e1 ().size1 (), e2 ().size2 ()));
|
||||
return axpy_prod (e1, e2, m, full (), storage_category (), orientation_category ());
|
||||
}
|
||||
template<class M, class E1, class E2>
|
||||
BOOST_UBLAS_INLINE
|
||||
M
|
||||
axpy_prod (const matrix_expression<E1> &e1,
|
||||
const matrix_expression<E2> &e2) {
|
||||
typedef M matrix_type;
|
||||
|
||||
matrix_type m (e1 ().size1 (), e2 ().size2 ());
|
||||
return axpy_prod (e1, e2, m, full (), true);
|
||||
}
|
||||
|
||||
|
||||
template<class M, class E1, class E2>
|
||||
BOOST_UBLAS_INLINE
|
||||
M &
|
||||
opb_prod (const matrix_expression<E1> &e1,
|
||||
const matrix_expression<E2> &e2,
|
||||
M &m,
|
||||
dense_proxy_tag, row_major_tag) {
|
||||
typedef M matrix_type;
|
||||
typedef const E1 expression1_type;
|
||||
typedef const E2 expression2_type;
|
||||
typedef typename M::size_type size_type;
|
||||
typedef typename M::value_type value_type;
|
||||
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
matrix<value_type, row_major> cm (m);
|
||||
typedef typename type_traits<value_type>::real_type real_type;
|
||||
real_type merrorbound (norm_1 (m) + norm_1 (e1) * norm_1 (e2));
|
||||
indexing_matrix_assign<scalar_plus_assign> (cm, prod (e1, e2), row_major_tag ());
|
||||
#endif
|
||||
size_type size (BOOST_UBLAS_SAME (e1 ().size2 (), e2 ().size1 ()));
|
||||
for (size_type k = 0; k < size; ++ k) {
|
||||
vector<value_type> ce1 (column (e1 (), k));
|
||||
vector<value_type> re2 (row (e2 (), k));
|
||||
m.plus_assign (outer_prod (ce1, re2));
|
||||
}
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
BOOST_UBLAS_CHECK (norm_1 (m - cm) <= 2 * std::numeric_limits<real_type>::epsilon () * merrorbound, internal_logic ());
|
||||
#endif
|
||||
return m;
|
||||
}
|
||||
|
||||
template<class M, class E1, class E2>
|
||||
BOOST_UBLAS_INLINE
|
||||
M &
|
||||
opb_prod (const matrix_expression<E1> &e1,
|
||||
const matrix_expression<E2> &e2,
|
||||
M &m,
|
||||
dense_proxy_tag, column_major_tag) {
|
||||
typedef M matrix_type;
|
||||
typedef const E1 expression1_type;
|
||||
typedef const E2 expression2_type;
|
||||
typedef typename M::size_type size_type;
|
||||
typedef typename M::value_type value_type;
|
||||
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
matrix<value_type, column_major> cm (m);
|
||||
typedef typename type_traits<value_type>::real_type real_type;
|
||||
real_type merrorbound (norm_1 (m) + norm_1 (e1) * norm_1 (e2));
|
||||
indexing_matrix_assign<scalar_plus_assign> (cm, prod (e1, e2), column_major_tag ());
|
||||
#endif
|
||||
size_type size (BOOST_UBLAS_SAME (e1 ().size2 (), e2 ().size1 ()));
|
||||
for (size_type k = 0; k < size; ++ k) {
|
||||
vector<value_type> ce1 (column (e1 (), k));
|
||||
vector<value_type> re2 (row (e2 (), k));
|
||||
m.plus_assign (outer_prod (ce1, re2));
|
||||
}
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
BOOST_UBLAS_CHECK (norm_1 (m - cm) <= 2 * std::numeric_limits<real_type>::epsilon () * merrorbound, internal_logic ());
|
||||
#endif
|
||||
return m;
|
||||
}
|
||||
|
||||
// Dispatcher
|
||||
|
||||
/** \brief computes <tt>M += A X</tt> or <tt>M = A X</tt> in an
|
||||
optimized fashion.
|
||||
|
||||
\param e1 the matrix expression \c A
|
||||
\param e2 the matrix expression \c X
|
||||
\param m the result matrix \c M
|
||||
\param init a boolean parameter
|
||||
|
||||
<tt>opb_prod(A, X, M, init)</tt> implements the well known
|
||||
axpy-product. Setting \a init to \c true is equivalent to call
|
||||
<tt>M.clear()</tt> before <tt>opb_prod</tt>. Currently \a init
|
||||
defaults to \c true, but this may change in the future.
|
||||
|
||||
This function may give a speedup if \c A has less columns than
|
||||
rows, because the product is computed as a sum of outer
|
||||
products.
|
||||
|
||||
\ingroup blas3
|
||||
|
||||
\internal
|
||||
|
||||
template parameters:
|
||||
\param M type of the result matrix \c M
|
||||
\param E1 type of a matrix expression \c A
|
||||
\param E2 type of a matrix expression \c X
|
||||
*/
|
||||
template<class M, class E1, class E2>
|
||||
BOOST_UBLAS_INLINE
|
||||
M &
|
||||
opb_prod (const matrix_expression<E1> &e1,
|
||||
const matrix_expression<E2> &e2,
|
||||
M &m, bool init = true) {
|
||||
typedef typename M::value_type value_type;
|
||||
typedef typename M::storage_category storage_category;
|
||||
typedef typename M::orientation_category orientation_category;
|
||||
|
||||
if (init)
|
||||
m.assign (zero_matrix<value_type> (e1 ().size1 (), e2 ().size2 ()));
|
||||
return opb_prod (e1, e2, m, storage_category (), orientation_category ());
|
||||
}
|
||||
template<class M, class E1, class E2>
|
||||
BOOST_UBLAS_INLINE
|
||||
M
|
||||
opb_prod (const matrix_expression<E1> &e1,
|
||||
const matrix_expression<E2> &e2) {
|
||||
typedef M matrix_type;
|
||||
|
||||
matrix_type m (e1 ().size1 (), e2 ().size2 ());
|
||||
return opb_prod (e1, e2, m, true);
|
||||
}
|
||||
|
||||
}}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,318 @@
|
||||
/**
|
||||
* -*- c++ -*-
|
||||
*
|
||||
* \file begin.hpp
|
||||
*
|
||||
* \brief The \c begin operation.
|
||||
*
|
||||
* Copyright (c) 2009, Marco Guazzone
|
||||
*
|
||||
* 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)
|
||||
*
|
||||
* \author Marco Guazzone, marco.guazzone@gmail.com
|
||||
*/
|
||||
|
||||
#ifndef BOOST_NUMERIC_UBLAS_OPERATION_BEGIN_HPP
|
||||
#define BOOST_NUMERIC_UBLAS_OPERATION_BEGIN_HPP
|
||||
|
||||
|
||||
#include <boost/numeric/ublas/expression_types.hpp>
|
||||
#include <boost/numeric/ublas/fwd.hpp>
|
||||
#include <boost/numeric/ublas/traits/const_iterator_type.hpp>
|
||||
#include <boost/numeric/ublas/traits/iterator_type.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace numeric { namespace ublas {
|
||||
|
||||
namespace detail {
|
||||
|
||||
/**
|
||||
* \brief Auxiliary class for implementing the \c begin operation.
|
||||
* \tparam CategoryT The expression category type (e.g., vector_tag).
|
||||
* \tparam TagT The dimension type tag (e.g., tag::major).
|
||||
* \tparam OrientationT The orientation category type (e.g., row_major_tag).
|
||||
*/
|
||||
template <typename CategoryT, typename TagT=void, typename OrientationT=void>
|
||||
struct begin_impl;
|
||||
|
||||
|
||||
/// \brief Specialization of \c begin_impl for iterating vector expressions.
|
||||
template <>
|
||||
struct begin_impl<vector_tag,void,void>
|
||||
{
|
||||
/**
|
||||
* \brief Return an iterator to the first element of the given vector
|
||||
* expression.
|
||||
* \tparam ExprT A model of VectorExpression type.
|
||||
* \param e A vector expression.
|
||||
* \return An iterator over the given vector expression.
|
||||
*/
|
||||
template <typename ExprT>
|
||||
static typename ExprT::iterator apply(ExprT& e)
|
||||
{
|
||||
return e.begin();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Return a const iterator to the first element of the given vector
|
||||
* expression.
|
||||
* \tparam ExprT A model of VectorExpression type.
|
||||
* \param e A vector expression.
|
||||
* \return A const iterator to the first element of the given vector
|
||||
* expression.
|
||||
*/
|
||||
template <typename ExprT>
|
||||
static typename ExprT::const_iterator apply(ExprT const& e)
|
||||
{
|
||||
return e.begin();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/// \brief Specialization of \c begin_impl for iterating matrix expressions with
|
||||
/// a row-major orientation over the major dimension.
|
||||
template <>
|
||||
struct begin_impl<matrix_tag,tag::major,row_major_tag>
|
||||
{
|
||||
/**
|
||||
* \brief Return an iterator to the first element of the given row-major
|
||||
* matrix expression over the major dimension.
|
||||
* \tparam ExprT A model of MatrixExpression type.
|
||||
* \param e A matrix expression.
|
||||
* \return An iterator over the major dimension of the given matrix
|
||||
* expression.
|
||||
*/
|
||||
template <typename ExprT>
|
||||
static typename ExprT::iterator1 apply(ExprT& e)
|
||||
{
|
||||
return e.begin1();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Return a const iterator to the first element of the given
|
||||
* row-major matrix expression over the major dimension.
|
||||
* \tparam ExprT A model of MatrixExpression type.
|
||||
* \param e A matrix expression.
|
||||
* \return A const iterator over the major dimension of the given matrix
|
||||
* expression.
|
||||
*/
|
||||
template <typename ExprT>
|
||||
static typename ExprT::const_iterator1 apply(ExprT const& e)
|
||||
{
|
||||
return e.begin1();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/// \brief Specialization of \c begin_impl for iterating matrix expressions with
|
||||
/// a column-major orientation over the major dimension.
|
||||
template <>
|
||||
struct begin_impl<matrix_tag,tag::major,column_major_tag>
|
||||
{
|
||||
/**
|
||||
* \brief Return an iterator to the first element of the given column-major
|
||||
* matrix expression over the major dimension.
|
||||
* \tparam ExprT A model of MatrixExpression type.
|
||||
* \param e A matrix expression.
|
||||
* \return An iterator over the major dimension of the given matrix
|
||||
* expression.
|
||||
*/
|
||||
template <typename ExprT>
|
||||
static typename ExprT::iterator2 apply(ExprT& e)
|
||||
{
|
||||
return e.begin2();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Return a const iterator to the first element of the given
|
||||
* column-major matrix expression over the major dimension.
|
||||
* \tparam ExprT A model of MatrixExpression type.
|
||||
* \param e A matrix expression.
|
||||
* \return A const iterator over the major dimension of the given matrix
|
||||
* expression.
|
||||
*/
|
||||
template <typename ExprT>
|
||||
static typename ExprT::const_iterator2 apply(ExprT const& e)
|
||||
{
|
||||
return e.begin2();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/// \brief Specialization of \c begin_impl for iterating matrix expressions with
|
||||
/// a row-major orientation over the minor dimension.
|
||||
template <>
|
||||
struct begin_impl<matrix_tag,tag::minor,row_major_tag>
|
||||
{
|
||||
/**
|
||||
* \brief Return an iterator to the first element of the given row-major
|
||||
* matrix expression over the minor dimension.
|
||||
* \tparam ExprT A model of MatrixExpression type.
|
||||
* \param e A matrix expression.
|
||||
* \return An iterator over the minor dimension of the given matrix
|
||||
* expression.
|
||||
*/
|
||||
template <typename ExprT>
|
||||
static typename ExprT::iterator2 apply(ExprT& e)
|
||||
{
|
||||
return e.begin2();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Return a const iterator to the first element of the given
|
||||
* row-major matrix expression over the minor dimension.
|
||||
* \tparam ExprT A model of MatrixExpression type.
|
||||
* \param e A matrix expression.
|
||||
* \return A const iterator over the minor dimension of the given matrix
|
||||
* expression.
|
||||
*/
|
||||
template <typename ExprT>
|
||||
static typename ExprT::const_iterator2 apply(ExprT const& e)
|
||||
{
|
||||
return e.begin2();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// \brief Specialization of \c begin_impl for iterating matrix expressions with
|
||||
/// a column-major orientation over the minor dimension.
|
||||
template <>
|
||||
struct begin_impl<matrix_tag,tag::minor,column_major_tag>
|
||||
{
|
||||
/**
|
||||
* \brief Return an iterator to the first element of the given column-major
|
||||
* matrix expression over the minor dimension.
|
||||
* \tparam ExprT A model of MatrixExpression type.
|
||||
* \param e A matrix expression.
|
||||
* \return An iterator over the minor dimension of the given matrix
|
||||
* expression.
|
||||
*/
|
||||
template <typename ExprT>
|
||||
static typename ExprT::iterator1 apply(ExprT& e)
|
||||
{
|
||||
return e.begin1();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Return a const iterator to the first element of the given
|
||||
* column-major matrix expression over the minor dimension.
|
||||
* \tparam ExprT A model of MatrixExpression type.
|
||||
* \param e A matrix expression.
|
||||
* \return A const iterator over the minor dimension of the given matrix
|
||||
* expression.
|
||||
*/
|
||||
template <typename ExprT>
|
||||
static typename ExprT::const_iterator1 apply(ExprT const& e)
|
||||
{
|
||||
return e.begin1();
|
||||
}
|
||||
};
|
||||
|
||||
} // Namespace detail
|
||||
|
||||
|
||||
/**
|
||||
* \brief An iterator to the first element of the given vector expression.
|
||||
* \tparam ExprT A model of VectorExpression type.
|
||||
* \param e A vector expression.
|
||||
* \return An iterator to the first element of the given vector expression.
|
||||
*/
|
||||
template <typename ExprT>
|
||||
BOOST_UBLAS_INLINE
|
||||
typename ExprT::iterator begin(vector_expression<ExprT>& e)
|
||||
{
|
||||
return detail::begin_impl<typename ExprT::type_category>::apply(e());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief A const iterator to the first element of the given vector expression.
|
||||
* \tparam ExprT A model of VectorExpression type.
|
||||
* \param e A vector expression.
|
||||
* \return A const iterator to the first element of the given vector expression.
|
||||
*/
|
||||
template <typename ExprT>
|
||||
BOOST_UBLAS_INLINE
|
||||
typename ExprT::const_iterator begin(vector_expression<ExprT> const& e)
|
||||
{
|
||||
return detail::begin_impl<typename ExprT::type_category>::apply(e());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief An iterator to the first element of the given matrix expression
|
||||
* according to its orientation.
|
||||
* \tparam DimTagT A dimension tag type (e.g., tag::major).
|
||||
* \tparam ExprT A model of MatrixExpression type.
|
||||
* \param e A matrix expression.
|
||||
* \return An iterator to the first element of the given matrix expression
|
||||
* according to its orientation.
|
||||
*/
|
||||
template <typename TagT, typename ExprT>
|
||||
BOOST_UBLAS_INLINE
|
||||
typename iterator_type<ExprT,TagT>::type begin(matrix_expression<ExprT>& e)
|
||||
{
|
||||
return detail::begin_impl<typename ExprT::type_category, TagT, typename ExprT::orientation_category>::apply(e());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief A const iterator to the first element of the given matrix expression
|
||||
* according to its orientation.
|
||||
* \tparam TagT A dimension tag type (e.g., tag::major).
|
||||
* \tparam ExprT A model of MatrixExpression type.
|
||||
* \param e A matrix expression.
|
||||
* \return A const iterator to the first element of the given matrix expression
|
||||
* according to its orientation.
|
||||
*/
|
||||
template <typename TagT, typename ExprT>
|
||||
BOOST_UBLAS_INLINE
|
||||
typename const_iterator_type<ExprT,TagT>::type begin(matrix_expression<ExprT> const& e)
|
||||
{
|
||||
return detail::begin_impl<typename ExprT::type_category, TagT, typename ExprT::orientation_category>::apply(e());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief An iterator to the first element over the dual dimension of the given
|
||||
* iterator.
|
||||
* \tparam IteratorT A model of Iterator type.
|
||||
* \param it An iterator.
|
||||
* \return An iterator to the first element over the dual dimension of the given
|
||||
* iterator.
|
||||
*/
|
||||
template <typename IteratorT>
|
||||
BOOST_UBLAS_INLINE
|
||||
typename IteratorT::dual_iterator_type begin(IteratorT& it)
|
||||
{
|
||||
return it.begin();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief A const iterator to the first element over the dual dimension of the
|
||||
* given iterator.
|
||||
* \tparam IteratorT A model of Iterator type.
|
||||
* \param it An iterator.
|
||||
* \return A const iterator to the first element over the dual dimension of the
|
||||
* given iterator.
|
||||
*/
|
||||
template <typename IteratorT>
|
||||
BOOST_UBLAS_INLINE
|
||||
typename IteratorT::dual_iterator_type begin(IteratorT const& it)
|
||||
{
|
||||
return it.begin();
|
||||
}
|
||||
|
||||
}}} // Namespace boost::numeric::ublas
|
||||
|
||||
|
||||
#endif // BOOST_NUMERIC_UBLAS_OPERATION_BEGIN_HPP
|
||||
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* -*- c++ -*-
|
||||
*
|
||||
* \file c_array.hpp
|
||||
*
|
||||
* \brief provides specializations of matrix and vector operations for c arrays and c matrices.
|
||||
*
|
||||
* Copyright (c) 2009, Gunter Winkler
|
||||
*
|
||||
* 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)
|
||||
*
|
||||
* \author Gunter Winkler (guwi17 at gmx dot de)
|
||||
*/
|
||||
|
||||
#ifndef BOOST_NUMERIC_UBLAS_OPERATION_C_ARRAY_HPP
|
||||
#define BOOST_NUMERIC_UBLAS_OPERATION_C_ARRAY_HPP
|
||||
|
||||
#include <boost/numeric/ublas/traits/c_array.hpp>
|
||||
|
||||
namespace boost { namespace numeric { namespace ublas {
|
||||
|
||||
namespace detail {
|
||||
|
||||
|
||||
|
||||
} // namespace boost::numeric::ublas::detail
|
||||
|
||||
|
||||
template <typename T>
|
||||
BOOST_UBLAS_INLINE
|
||||
typename ExprT::const_iterator begin(vector_expression<ExprT> const& e)
|
||||
{
|
||||
return detail::begin_impl<typename ExprT::type_category>::apply(e());
|
||||
}
|
||||
|
||||
|
||||
}}} // Namespace boost::numeric::ublas
|
||||
|
||||
#endif
|
||||
318
project/jni/boost/include/boost/numeric/ublas/operation/end.hpp
Normal file
318
project/jni/boost/include/boost/numeric/ublas/operation/end.hpp
Normal file
@@ -0,0 +1,318 @@
|
||||
/**
|
||||
* -*- c++ -*-
|
||||
*
|
||||
* \file end.hpp
|
||||
*
|
||||
* \brief The \c end operation.
|
||||
*
|
||||
* Copyright (c) 2009, Marco Guazzone
|
||||
*
|
||||
* 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)
|
||||
*
|
||||
* \author Marco Guazzone, marco.guazzone@gmail.com
|
||||
*/
|
||||
|
||||
|
||||
#ifndef BOOST_NUMERIC_UBLAS_OPERATION_END_HPP
|
||||
#define BOOST_NUMERIC_UBLAS_OPERATION_END_HPP
|
||||
|
||||
|
||||
#include <boost/numeric/ublas/expression_types.hpp>
|
||||
#include <boost/numeric/ublas/fwd.hpp>
|
||||
#include <boost/numeric/ublas/traits/const_iterator_type.hpp>
|
||||
#include <boost/numeric/ublas/traits/iterator_type.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace numeric { namespace ublas {
|
||||
|
||||
namespace detail {
|
||||
|
||||
/**
|
||||
* \brief Auxiliary class for implementing the \c end operation.
|
||||
* \tparam CategoryT The expression category type (e.g., vector_tag).
|
||||
* \tparam TagT The dimension type tag (e.g., tag::major).
|
||||
* \tparam OrientationT The orientation category type (e.g., row_major_tag).
|
||||
*/
|
||||
template <typename CategoryT, typename TagT=void, typename OrientationT=void>
|
||||
struct end_impl;
|
||||
|
||||
|
||||
/// \brief Specialization of \c end_impl for iterating vector expressions.
|
||||
template <>
|
||||
struct end_impl<vector_tag,void,void>
|
||||
{
|
||||
/**
|
||||
* \brief Return an iterator to the last element of the given vector
|
||||
* expression.
|
||||
* \tparam ExprT A model of VectorExpression type.
|
||||
* \param e A vector expression.
|
||||
* \return An iterator over the given vector expression.
|
||||
*/
|
||||
template <typename ExprT>
|
||||
static typename ExprT::iterator apply(ExprT& e)
|
||||
{
|
||||
return e.end();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Return a const iterator to the last element of the given vector
|
||||
* expression.
|
||||
* \tparam ExprT A model of VectorExpression type.
|
||||
* \param e A vector expression.
|
||||
* \return A const iterator to the first element of the given vector
|
||||
* expression.
|
||||
*/
|
||||
template <typename ExprT>
|
||||
static typename ExprT::const_iterator apply(ExprT const& e)
|
||||
{
|
||||
return e.end();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/// \brief Specialization of \c end_impl for iterating matrix expressions with a
|
||||
/// row-major orientation over the major dimension.
|
||||
template <>
|
||||
struct end_impl<matrix_tag,tag::major,row_major_tag>
|
||||
{
|
||||
/**
|
||||
* \brief Return an iterator to the last element of the given row-major
|
||||
* matrix expression over the major dimension.
|
||||
* \tparam ExprT A model of MatrixExpression type.
|
||||
* \param e A matrix expression.
|
||||
* \return An iterator over the major dimension of the given matrix
|
||||
* expression.
|
||||
*/
|
||||
template <typename ExprT>
|
||||
static typename ExprT::iterator1 apply(ExprT& e)
|
||||
{
|
||||
return e.end1();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Return a const iterator to the last element of the given row-major
|
||||
* matrix expression over the major dimension.
|
||||
* \tparam ExprT A model of MatrixExpression type.
|
||||
* \param e A matrix expression.
|
||||
* \return A const iterator over the major dimension of the given matrix
|
||||
* expression.
|
||||
*/
|
||||
template <typename ExprT>
|
||||
static typename ExprT::const_iterator1 apply(ExprT const& e)
|
||||
{
|
||||
return e.end1();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/// \brief Specialization of \c end_impl for iterating matrix expressions with a
|
||||
/// column-major orientation over the major dimension.
|
||||
template <>
|
||||
struct end_impl<matrix_tag,tag::major,column_major_tag>
|
||||
{
|
||||
/**
|
||||
* \brief Return an iterator to the last element of the given column-major
|
||||
* matrix expression over the major dimension.
|
||||
* \tparam ExprT A model of MatrixExpression type.
|
||||
* \param e A matrix expression.
|
||||
* \return An iterator over the major dimension of the given matrix
|
||||
* expression.
|
||||
*/
|
||||
template <typename ExprT>
|
||||
static typename ExprT::iterator2 apply(ExprT& e)
|
||||
{
|
||||
return e.end2();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Return a const iterator to the last element of the given
|
||||
* column-major matrix expression over the major dimension.
|
||||
* \tparam ExprT A model of MatrixExpression type.
|
||||
* \param e A matrix expression.
|
||||
* \return A const iterator over the major dimension of the given matrix
|
||||
* expression.
|
||||
*/
|
||||
template <typename ExprT>
|
||||
static typename ExprT::const_iterator2 apply(ExprT const& e)
|
||||
{
|
||||
return e.end2();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/// \brief Specialization of \c end_impl for iterating matrix expressions with a
|
||||
/// row-major orientation over the minor dimension.
|
||||
template <>
|
||||
struct end_impl<matrix_tag,tag::minor,row_major_tag>
|
||||
{
|
||||
/**
|
||||
* \brief Return an iterator to the last element of the given row-major
|
||||
* matrix expression over the minor dimension.
|
||||
* \tparam ExprT A model of MatrixExpression type.
|
||||
* \param e A matrix expression.
|
||||
* \return An iterator over the minor dimension of the given matrix
|
||||
* expression.
|
||||
*/
|
||||
template <typename ExprT>
|
||||
static typename ExprT::iterator2 apply(ExprT& e)
|
||||
{
|
||||
return e.end2();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Return a const iterator to the last element of the given
|
||||
* row-minor matrix expression over the major dimension.
|
||||
* \tparam ExprT A model of MatrixExpression type.
|
||||
* \param e A matrix expression.
|
||||
* \return A const iterator over the minor dimension of the given matrix
|
||||
* expression.
|
||||
*/
|
||||
template <typename ExprT>
|
||||
static typename ExprT::const_iterator2 apply(ExprT const& e)
|
||||
{
|
||||
return e.end2();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/// \brief Specialization of \c end_impl for iterating matrix expressions with a
|
||||
/// column-major orientation over the minor dimension.
|
||||
template <>
|
||||
struct end_impl<matrix_tag,tag::minor,column_major_tag>
|
||||
{
|
||||
/**
|
||||
* \brief Return an iterator to the last element of the given column-major
|
||||
* matrix expression over the minor dimension.
|
||||
* \tparam ExprT A model of MatrixExpression type.
|
||||
* \param e A matrix expression.
|
||||
* \return An iterator over the minor dimension of the given matrix
|
||||
* expression.
|
||||
*/
|
||||
template <typename ExprT>
|
||||
static typename ExprT::iterator1 apply(ExprT& e)
|
||||
{
|
||||
return e.end1();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Return a const iterator to the last element of the given
|
||||
* column-minor matrix expression over the major dimension.
|
||||
* \tparam ExprT A model of MatrixExpression type.
|
||||
* \param e A matrix expression.
|
||||
* \return A const iterator over the minor dimension of the given matrix
|
||||
* expression.
|
||||
*/
|
||||
template <typename ExprT>
|
||||
static typename ExprT::const_iterator1 apply(ExprT const& e)
|
||||
{
|
||||
return e.end1();
|
||||
}
|
||||
};
|
||||
|
||||
} // Namespace detail
|
||||
|
||||
|
||||
/**
|
||||
* \brief An iterator to the last element of the given vector expression.
|
||||
* \tparam ExprT A model of VectorExpression type.
|
||||
* \param e A vector expression.
|
||||
* \return An iterator to the last element of the given vector expression.
|
||||
*/
|
||||
template <typename ExprT>
|
||||
BOOST_UBLAS_INLINE
|
||||
typename ExprT::iterator end(vector_expression<ExprT>& e)
|
||||
{
|
||||
return detail::end_impl<typename ExprT::type_category>::apply(e());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief A const iterator to the last element of the given vector expression.
|
||||
* \tparam ExprT A model of VectorExpression type.
|
||||
* \param e A vector expression.
|
||||
* \return A const iterator to the last element of the given vector expression.
|
||||
*/
|
||||
template <typename ExprT>
|
||||
BOOST_UBLAS_INLINE
|
||||
typename ExprT::const_iterator end(vector_expression<ExprT> const& e)
|
||||
{
|
||||
return detail::end_impl<typename ExprT::type_category>::apply(e());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief An iterator to the last element of the given matrix expression
|
||||
* according to its orientation.
|
||||
* \tparam DimTagT A dimension tag type (e.g., tag::major).
|
||||
* \tparam ExprT A model of MatrixExpression type.
|
||||
* \param e A matrix expression.
|
||||
* \return An iterator to the last element of the given matrix expression
|
||||
* according to its orientation.
|
||||
*/
|
||||
template <typename TagT, typename ExprT>
|
||||
BOOST_UBLAS_INLINE
|
||||
typename iterator_type<ExprT,TagT>::type end(matrix_expression<ExprT>& e)
|
||||
{
|
||||
return detail::end_impl<typename ExprT::type_category, TagT, typename ExprT::orientation_category>::apply(e());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief A const iterator to the last element of the given matrix expression
|
||||
* according to its orientation.
|
||||
* \tparam TagT A dimension tag type (e.g., tag::major).
|
||||
* \tparam ExprT A model of MatrixExpression type.
|
||||
* \param e A matrix expression.
|
||||
* \return A const iterator to the last element of the given matrix expression
|
||||
* according to its orientation.
|
||||
*/
|
||||
template <typename TagT, typename ExprT>
|
||||
BOOST_UBLAS_INLINE
|
||||
typename const_iterator_type<ExprT,TagT>::type end(matrix_expression<ExprT> const& e)
|
||||
{
|
||||
return detail::end_impl<typename ExprT::type_category, TagT, typename ExprT::orientation_category>::apply(e());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief An iterator to the last element over the dual dimension of the given
|
||||
* iterator.
|
||||
* \tparam IteratorT A model of Iterator type.
|
||||
* \param it An iterator.
|
||||
* \return An iterator to the last element over the dual dimension of the given
|
||||
* iterator.
|
||||
*/
|
||||
template <typename IteratorT>
|
||||
BOOST_UBLAS_INLINE
|
||||
typename IteratorT::dual_iterator_type end(IteratorT& it)
|
||||
{
|
||||
return it.end();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief A const iterator to the last element over the dual dimension of the
|
||||
* given iterator.
|
||||
* \tparam IteratorT A model of Iterator type.
|
||||
* \param it An iterator.
|
||||
* \return A const iterator to the last element over the dual dimension of the
|
||||
* given iterator.
|
||||
*/
|
||||
template <typename IteratorT>
|
||||
BOOST_UBLAS_INLINE
|
||||
typename IteratorT::dual_iterator_type end(IteratorT const& it)
|
||||
{
|
||||
return it.end();
|
||||
}
|
||||
|
||||
}}} // Namespace boost::numeric::ublas
|
||||
|
||||
|
||||
#endif // BOOST_NUMERIC_UBLAS_OPERATION_END_HPP
|
||||
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* -*- c++ -*-
|
||||
*
|
||||
* \file num_columns.hpp
|
||||
*
|
||||
* \brief The \c num_columns operation.
|
||||
*
|
||||
* Copyright (c) 2009, Marco Guazzone
|
||||
*
|
||||
* 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)
|
||||
*
|
||||
* \author Marco Guazzone, marco.guazzone@gmail.com
|
||||
*/
|
||||
|
||||
|
||||
#ifndef BOOST_NUMERIC_UBLAS_OPERATION_NUM_COLUMNS_HPP
|
||||
#define BOOST_NUMERIC_UBLAS_OPERATION_NUM_COLUMNS_HPP
|
||||
|
||||
|
||||
#include <boost/numeric/ublas/detail/config.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace numeric { namespace ublas {
|
||||
|
||||
/**
|
||||
* \brief Return the number of columns.
|
||||
* \tparam MatrixExprT A type which models the matrix expression concept.
|
||||
* \param m A matrix expression.
|
||||
* \return The number of columns.
|
||||
*/
|
||||
template <typename MatrixExprT>
|
||||
BOOST_UBLAS_INLINE
|
||||
typename MatrixExprT::size_type num_columns(MatrixExprT const& m)
|
||||
{
|
||||
return m.size2();
|
||||
}
|
||||
|
||||
}}} // Namespace boost::numeric::ublas
|
||||
|
||||
|
||||
#endif // BOOST_NUMERIC_UBLAS_OPERATION_NUM_COLUMNS_HPP
|
||||
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* -*- c++ -*-
|
||||
*
|
||||
* \file num_rows.hpp
|
||||
*
|
||||
* \brief The \c num_rows operation.
|
||||
*
|
||||
* Copyright (c) 2009, Marco Guazzone
|
||||
*
|
||||
* 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)
|
||||
*
|
||||
* \author Marco Guazzone, marco.guazzone@gmail.com
|
||||
*/
|
||||
|
||||
#ifndef BOOST_NUMERIC_UBLAS_OPERATION_NUM_ROWS_HPP
|
||||
#define BOOST_NUMERIC_UBLAS_OPERATION_NUM_ROWS_HPP
|
||||
|
||||
|
||||
#include <boost/numeric/ublas/detail/config.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace numeric { namespace ublas {
|
||||
|
||||
/**
|
||||
* \brief Return the number of rows.
|
||||
* \tparam MatrixExprT A type which models the matrix expression concept.
|
||||
* \param m A matrix expression.
|
||||
* \return The number of rows.
|
||||
*/
|
||||
template <typename MatrixExprT>
|
||||
BOOST_UBLAS_INLINE
|
||||
typename MatrixExprT::size_type num_rows(MatrixExprT const& m)
|
||||
{
|
||||
return m.size1();
|
||||
}
|
||||
|
||||
}}} // Namespace boost::numeric::ublas
|
||||
|
||||
|
||||
#endif // BOOST_NUMERIC_UBLAS_OPERATION_NUM_ROWS_HPP
|
||||
350
project/jni/boost/include/boost/numeric/ublas/operation/size.hpp
Normal file
350
project/jni/boost/include/boost/numeric/ublas/operation/size.hpp
Normal file
@@ -0,0 +1,350 @@
|
||||
/**
|
||||
* \file size.hpp
|
||||
*
|
||||
* \brief The family of \c size operations.
|
||||
*
|
||||
* Copyright (c) 2009-2010, Marco Guazzone
|
||||
*
|
||||
* 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)
|
||||
*
|
||||
* \author Marco Guazzone, marco.guazzone@gmail.com
|
||||
*/
|
||||
|
||||
#ifndef BOOST_NUMERIC_UBLAS_OPERATION_SIZE_HPP
|
||||
#define BOOST_NUMERIC_UBLAS_OPERATION_SIZE_HPP
|
||||
|
||||
|
||||
#include <boost/mpl/has_xxx.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/numeric/ublas/detail/config.hpp>
|
||||
#include <boost/numeric/ublas/expression_types.hpp>
|
||||
#include <boost/numeric/ublas/fwd.hpp>
|
||||
#include <boost/numeric/ublas/tags.hpp>
|
||||
#include <boost/numeric/ublas/traits.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
|
||||
namespace boost { namespace numeric { namespace ublas {
|
||||
|
||||
namespace detail { namespace /*<unnamed>*/ {
|
||||
|
||||
/// Define a \c has_size_type trait class.
|
||||
BOOST_MPL_HAS_XXX_TRAIT_DEF(size_type)
|
||||
|
||||
|
||||
/**
|
||||
* \brief Wrapper type-traits used in \c boost::lazy_enabled_if for getting the
|
||||
* size type (see below).
|
||||
* \tparam VectorT A vector type.
|
||||
*/
|
||||
template <typename VectorT>
|
||||
struct vector_size_type
|
||||
{
|
||||
/// The size type.
|
||||
typedef typename vector_traits<VectorT>::size_type type;
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Wrapper type-traits used in \c boost::lazy_enabled_if for getting the
|
||||
* size type (see below).
|
||||
* \tparam MatrixT A matrix type.
|
||||
*/
|
||||
template <typename MatrixT>
|
||||
struct matrix_size_type
|
||||
{
|
||||
/// The size type.
|
||||
typedef typename matrix_traits<MatrixT>::size_type type;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* \brief Auxiliary class for computing the size of the given dimension for
|
||||
* a container of the given category.
|
||||
* \tparam Dim The dimension number (starting from 1).
|
||||
* \tparam CategoryT The category type (e.g., vector_tag).
|
||||
*/
|
||||
template <std::size_t Dim, typename CategoryT>
|
||||
struct size_by_dim_impl;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Auxiliary class for computing the size of the given dimension for
|
||||
* a container of the given category and with the given orientation.
|
||||
* \tparam Dim The dimension number (starting from 1).
|
||||
* \tparam CategoryT The category type (e.g., vector_tag).
|
||||
* \tparam OrientationT The orientation category type (e.g., row_major_tag).
|
||||
*/
|
||||
template <typename TagT, typename CategoryT, typename OrientationT>
|
||||
struct size_by_tag_impl;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Specialization of \c size_by_dim_impl for computing the size of a
|
||||
* vector.
|
||||
*/
|
||||
template <>
|
||||
struct size_by_dim_impl<1, vector_tag>
|
||||
{
|
||||
/**
|
||||
* \brief Compute the size of the given vector.
|
||||
* \tparam ExprT A vector expression type.
|
||||
* \pre ExprT must be a model of VectorExpression.
|
||||
*/
|
||||
template <typename ExprT>
|
||||
BOOST_UBLAS_INLINE
|
||||
static typename vector_traits<ExprT>::size_type apply(vector_expression<ExprT> const& ve)
|
||||
{
|
||||
return ve().size();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* \brief Specialization of \c size_by_dim_impl for computing the number of
|
||||
* rows of a matrix
|
||||
*/
|
||||
template <>
|
||||
struct size_by_dim_impl<1, matrix_tag>
|
||||
{
|
||||
/**
|
||||
* \brief Compute the number of rows of the given matrix.
|
||||
* \tparam ExprT A matrix expression type.
|
||||
* \pre ExprT must be a model of MatrixExpression.
|
||||
*/
|
||||
template <typename ExprT>
|
||||
BOOST_UBLAS_INLINE
|
||||
static typename matrix_traits<ExprT>::size_type apply(matrix_expression<ExprT> const& me)
|
||||
{
|
||||
return me().size1();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* \brief Specialization of \c size_by_dim_impl for computing the number of
|
||||
* columns of a matrix
|
||||
*/
|
||||
template <>
|
||||
struct size_by_dim_impl<2, matrix_tag>
|
||||
{
|
||||
/**
|
||||
* \brief Compute the number of columns of the given matrix.
|
||||
* \tparam ExprT A matrix expression type.
|
||||
* \pre ExprT must be a model of MatrixExpression.
|
||||
*/
|
||||
template <typename ExprT>
|
||||
BOOST_UBLAS_INLINE
|
||||
static typename matrix_traits<ExprT>::size_type apply(matrix_expression<ExprT> const& me)
|
||||
{
|
||||
return me().size2();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* \brief Specialization of \c size_by_tag_impl for computing the size of the
|
||||
* major dimension of a row-major oriented matrix.
|
||||
*/
|
||||
template <>
|
||||
struct size_by_tag_impl<tag::major, matrix_tag, row_major_tag>
|
||||
{
|
||||
/**
|
||||
* \brief Compute the number of rows of the given matrix.
|
||||
* \tparam ExprT A matrix expression type.
|
||||
* \pre ExprT must be a model of MatrixExpression.
|
||||
*/
|
||||
template <typename ExprT>
|
||||
BOOST_UBLAS_INLINE
|
||||
static typename matrix_traits<ExprT>::size_type apply(matrix_expression<ExprT> const& me)
|
||||
{
|
||||
return me().size1();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* \brief Specialization of \c size_by_tag_impl for computing the size of the
|
||||
* minor dimension of a row-major oriented matrix.
|
||||
*/
|
||||
template <>
|
||||
struct size_by_tag_impl<tag::minor, matrix_tag, row_major_tag>
|
||||
{
|
||||
/**
|
||||
* \brief Compute the number of columns of the given matrix.
|
||||
* \tparam ExprT A matrix expression type.
|
||||
* \pre ExprT must be a model of MatrixExpression.
|
||||
*/
|
||||
template <typename ExprT>
|
||||
BOOST_UBLAS_INLINE
|
||||
static typename matrix_traits<ExprT>::size_type apply(matrix_expression<ExprT> const& me)
|
||||
{
|
||||
return me().size2();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* \brief Specialization of \c size_by_tag_impl for computing the size of the
|
||||
* leading dimension of a row-major oriented matrix.
|
||||
*/
|
||||
template <>
|
||||
struct size_by_tag_impl<tag::leading, matrix_tag, row_major_tag>
|
||||
{
|
||||
/**
|
||||
* \brief Compute the number of columns of the given matrix.
|
||||
* \tparam ExprT A matrix expression type.
|
||||
* \pre ExprT must be a model of MatrixExpression.
|
||||
*/
|
||||
template <typename ExprT>
|
||||
BOOST_UBLAS_INLINE
|
||||
static typename matrix_traits<ExprT>::size_type apply(matrix_expression<ExprT> const& me)
|
||||
{
|
||||
return me().size2();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/// \brief Specialization of \c size_by_tag_impl for computing the size of the
|
||||
/// major dimension of a column-major oriented matrix.
|
||||
template <>
|
||||
struct size_by_tag_impl<tag::major, matrix_tag, column_major_tag>
|
||||
{
|
||||
/**
|
||||
* \brief Compute the number of columns of the given matrix.
|
||||
* \tparam ExprT A matrix expression type.
|
||||
* \pre ExprT must be a model of MatrixExpression.
|
||||
*/
|
||||
template <typename ExprT>
|
||||
BOOST_UBLAS_INLINE
|
||||
static typename matrix_traits<ExprT>::size_type apply(matrix_expression<ExprT> const& me)
|
||||
{
|
||||
return me().size2();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/// \brief Specialization of \c size_by_tag_impl for computing the size of the
|
||||
/// minor dimension of a column-major oriented matrix.
|
||||
template <>
|
||||
struct size_by_tag_impl<tag::minor, matrix_tag, column_major_tag>
|
||||
{
|
||||
/**
|
||||
* \brief Compute the number of rows of the given matrix.
|
||||
* \tparam ExprT A matrix expression type.
|
||||
* \pre ExprT must be a model of MatrixExpression.
|
||||
*/
|
||||
template <typename ExprT>
|
||||
BOOST_UBLAS_INLINE
|
||||
static typename matrix_traits<ExprT>::size_type apply(matrix_expression<ExprT> const& me)
|
||||
{
|
||||
return me().size1();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/// \brief Specialization of \c size_by_tag_impl for computing the size of the
|
||||
/// leading dimension of a column-major oriented matrix.
|
||||
template <>
|
||||
struct size_by_tag_impl<tag::leading, matrix_tag, column_major_tag>
|
||||
{
|
||||
/**
|
||||
* \brief Compute the number of rows of the given matrix.
|
||||
* \tparam ExprT A matrix expression type.
|
||||
* \pre ExprT must be a model of MatrixExpression.
|
||||
*/
|
||||
template <typename ExprT>
|
||||
BOOST_UBLAS_INLINE
|
||||
static typename matrix_traits<ExprT>::size_type apply(matrix_expression<ExprT> const& me)
|
||||
{
|
||||
return me().size1();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/// \brief Specialization of \c size_by_tag_impl for computing the size of the
|
||||
/// given dimension of a unknown oriented expression.
|
||||
template <typename TagT, typename CategoryT>
|
||||
struct size_by_tag_impl<TagT, CategoryT, unknown_orientation_tag>: size_by_tag_impl<TagT, CategoryT, row_major_tag>
|
||||
{
|
||||
// Empty
|
||||
};
|
||||
|
||||
}} // Namespace detail::<unnamed>
|
||||
|
||||
|
||||
/**
|
||||
* \brief Return the number of columns.
|
||||
* \tparam VectorExprT A type which models the vector expression concept.
|
||||
* \param ve A vector expression.
|
||||
* \return The length of the input vector expression.
|
||||
*/
|
||||
template <typename VectorExprT>
|
||||
BOOST_UBLAS_INLINE
|
||||
typename ::boost::lazy_enable_if_c<
|
||||
detail::has_size_type<VectorExprT>::value,
|
||||
detail::vector_size_type<VectorExprT>
|
||||
>::type size(vector_expression<VectorExprT> const& ve)
|
||||
{
|
||||
return ve().size();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Return the size of the given dimension for the given vector
|
||||
* expression.
|
||||
* \tparam Dim The dimension number (starting from 1).
|
||||
* \tparam VectorExprT A vector expression type.
|
||||
* \param ve A vector expression.
|
||||
* \return The length of the input vector expression.
|
||||
*/
|
||||
template <std::size_t Dim, typename VectorExprT>
|
||||
BOOST_UBLAS_INLINE
|
||||
typename vector_traits<VectorExprT>::size_type size(vector_expression<VectorExprT> const& ve)
|
||||
{
|
||||
return detail::size_by_dim_impl<Dim, vector_tag>::template apply(ve);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Return the size of the given dimension for the given matrix
|
||||
* expression.
|
||||
* \tparam Dim The dimension number (starting from 1).
|
||||
* \tparam MatrixExprT A matrix expression type.
|
||||
* \param e A matrix expression.
|
||||
* \return The size of the input matrix expression associated to the dimension
|
||||
* \a Dim.
|
||||
*/
|
||||
template <std::size_t Dim, typename MatrixExprT>
|
||||
BOOST_UBLAS_INLINE
|
||||
typename matrix_traits<MatrixExprT>::size_type size(matrix_expression<MatrixExprT> const& me)
|
||||
{
|
||||
return detail::size_by_dim_impl<Dim, matrix_tag>::template apply(me);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Return the size of the given dimension tag for the given matrix
|
||||
* expression.
|
||||
* \tparam TagT The dimension tag type (e.g., tag::major).
|
||||
* \tparam MatrixExprT A matrix expression type.
|
||||
* \param e A matrix expression.
|
||||
* \return The size of the input matrix expression associated to the dimension
|
||||
* tag \a TagT.
|
||||
*/
|
||||
template <typename TagT, typename MatrixExprT>
|
||||
BOOST_UBLAS_INLINE
|
||||
typename ::boost::lazy_enable_if_c<
|
||||
detail::has_size_type<MatrixExprT>::value,
|
||||
detail::matrix_size_type<MatrixExprT>
|
||||
>::type size(matrix_expression<MatrixExprT> const& me)
|
||||
{
|
||||
return detail::size_by_tag_impl<TagT, matrix_tag, typename matrix_traits<MatrixExprT>::orientation_category>::template apply(me);
|
||||
}
|
||||
|
||||
}}} // Namespace boost::numeric::ublas
|
||||
|
||||
|
||||
#endif // BOOST_NUMERIC_UBLAS_OPERATION_SIZE_HPP
|
||||
@@ -0,0 +1,266 @@
|
||||
//
|
||||
// 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_OPERATION_BLOCKED_
|
||||
#define _BOOST_UBLAS_OPERATION_BLOCKED_
|
||||
|
||||
#include <boost/numeric/ublas/traits.hpp>
|
||||
#include <boost/numeric/ublas/detail/vector_assign.hpp> // indexing_vector_assign
|
||||
#include <boost/numeric/ublas/detail/matrix_assign.hpp> // indexing_matrix_assign
|
||||
|
||||
|
||||
namespace boost { namespace numeric { namespace ublas {
|
||||
|
||||
template<class V, typename V::size_type BS, class E1, class E2>
|
||||
BOOST_UBLAS_INLINE
|
||||
V
|
||||
block_prod (const matrix_expression<E1> &e1,
|
||||
const vector_expression<E2> &e2) {
|
||||
typedef V vector_type;
|
||||
typedef const E1 expression1_type;
|
||||
typedef const E2 expression2_type;
|
||||
typedef typename V::size_type size_type;
|
||||
typedef typename V::value_type value_type;
|
||||
const size_type block_size = BS;
|
||||
|
||||
V v (e1 ().size1 ());
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
vector<value_type> cv (v.size ());
|
||||
typedef typename type_traits<value_type>::real_type real_type;
|
||||
real_type verrorbound (norm_1 (v) + norm_1 (e1) * norm_1 (e2));
|
||||
indexing_vector_assign<scalar_assign> (cv, prod (e1, e2));
|
||||
#endif
|
||||
size_type i_size = e1 ().size1 ();
|
||||
size_type j_size = BOOST_UBLAS_SAME (e1 ().size2 (), e2 ().size ());
|
||||
for (size_type i_begin = 0; i_begin < i_size; i_begin += block_size) {
|
||||
size_type i_end = i_begin + (std::min) (i_size - i_begin, block_size);
|
||||
// FIX: never ignore Martin Weiser's advice ;-(
|
||||
#ifdef BOOST_UBLAS_NO_CACHE
|
||||
vector_range<vector_type> v_range (v, range (i_begin, i_end));
|
||||
#else
|
||||
// vector<value_type, bounded_array<value_type, block_size> > v_range (i_end - i_begin);
|
||||
vector<value_type> v_range (i_end - i_begin);
|
||||
#endif
|
||||
v_range.assign (zero_vector<value_type> (i_end - i_begin));
|
||||
for (size_type j_begin = 0; j_begin < j_size; j_begin += block_size) {
|
||||
size_type j_end = j_begin + (std::min) (j_size - j_begin, block_size);
|
||||
#ifdef BOOST_UBLAS_NO_CACHE
|
||||
const matrix_range<expression1_type> e1_range (e1 (), range (i_begin, i_end), range (j_begin, j_end));
|
||||
const vector_range<expression2_type> e2_range (e2 (), range (j_begin, j_end));
|
||||
v_range.plus_assign (prod (e1_range, e2_range));
|
||||
#else
|
||||
// const matrix<value_type, row_major, bounded_array<value_type, block_size * block_size> > e1_range (project (e1 (), range (i_begin, i_end), range (j_begin, j_end)));
|
||||
// const vector<value_type, bounded_array<value_type, block_size> > e2_range (project (e2 (), range (j_begin, j_end)));
|
||||
const matrix<value_type, row_major> e1_range (project (e1 (), range (i_begin, i_end), range (j_begin, j_end)));
|
||||
const vector<value_type> e2_range (project (e2 (), range (j_begin, j_end)));
|
||||
v_range.plus_assign (prod (e1_range, e2_range));
|
||||
#endif
|
||||
}
|
||||
#ifndef BOOST_UBLAS_NO_CACHE
|
||||
project (v, range (i_begin, i_end)).assign (v_range);
|
||||
#endif
|
||||
}
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
BOOST_UBLAS_CHECK (norm_1 (v - cv) <= 2 * std::numeric_limits<real_type>::epsilon () * verrorbound, internal_logic ());
|
||||
#endif
|
||||
return v;
|
||||
}
|
||||
|
||||
template<class V, typename V::size_type BS, class E1, class E2>
|
||||
BOOST_UBLAS_INLINE
|
||||
V
|
||||
block_prod (const vector_expression<E1> &e1,
|
||||
const matrix_expression<E2> &e2) {
|
||||
typedef V vector_type;
|
||||
typedef const E1 expression1_type;
|
||||
typedef const E2 expression2_type;
|
||||
typedef typename V::size_type size_type;
|
||||
typedef typename V::value_type value_type;
|
||||
const size_type block_size = BS;
|
||||
|
||||
V v (e2 ().size2 ());
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
vector<value_type> cv (v.size ());
|
||||
typedef typename type_traits<value_type>::real_type real_type;
|
||||
real_type verrorbound (norm_1 (v) + norm_1 (e1) * norm_1 (e2));
|
||||
indexing_vector_assign<scalar_assign> (cv, prod (e1, e2));
|
||||
#endif
|
||||
size_type i_size = BOOST_UBLAS_SAME (e1 ().size (), e2 ().size1 ());
|
||||
size_type j_size = e2 ().size2 ();
|
||||
for (size_type j_begin = 0; j_begin < j_size; j_begin += block_size) {
|
||||
size_type j_end = j_begin + (std::min) (j_size - j_begin, block_size);
|
||||
// FIX: never ignore Martin Weiser's advice ;-(
|
||||
#ifdef BOOST_UBLAS_NO_CACHE
|
||||
vector_range<vector_type> v_range (v, range (j_begin, j_end));
|
||||
#else
|
||||
// vector<value_type, bounded_array<value_type, block_size> > v_range (j_end - j_begin);
|
||||
vector<value_type> v_range (j_end - j_begin);
|
||||
#endif
|
||||
v_range.assign (zero_vector<value_type> (j_end - j_begin));
|
||||
for (size_type i_begin = 0; i_begin < i_size; i_begin += block_size) {
|
||||
size_type i_end = i_begin + (std::min) (i_size - i_begin, block_size);
|
||||
#ifdef BOOST_UBLAS_NO_CACHE
|
||||
const vector_range<expression1_type> e1_range (e1 (), range (i_begin, i_end));
|
||||
const matrix_range<expression2_type> e2_range (e2 (), range (i_begin, i_end), range (j_begin, j_end));
|
||||
#else
|
||||
// const vector<value_type, bounded_array<value_type, block_size> > e1_range (project (e1 (), range (i_begin, i_end)));
|
||||
// const matrix<value_type, column_major, bounded_array<value_type, block_size * block_size> > e2_range (project (e2 (), range (i_begin, i_end), range (j_begin, j_end)));
|
||||
const vector<value_type> e1_range (project (e1 (), range (i_begin, i_end)));
|
||||
const matrix<value_type, column_major> e2_range (project (e2 (), range (i_begin, i_end), range (j_begin, j_end)));
|
||||
#endif
|
||||
v_range.plus_assign (prod (e1_range, e2_range));
|
||||
}
|
||||
#ifndef BOOST_UBLAS_NO_CACHE
|
||||
project (v, range (j_begin, j_end)).assign (v_range);
|
||||
#endif
|
||||
}
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
BOOST_UBLAS_CHECK (norm_1 (v - cv) <= 2 * std::numeric_limits<real_type>::epsilon () * verrorbound, internal_logic ());
|
||||
#endif
|
||||
return v;
|
||||
}
|
||||
|
||||
template<class M, typename M::size_type BS, class E1, class E2>
|
||||
BOOST_UBLAS_INLINE
|
||||
M
|
||||
block_prod (const matrix_expression<E1> &e1,
|
||||
const matrix_expression<E2> &e2,
|
||||
row_major_tag) {
|
||||
typedef M matrix_type;
|
||||
typedef const E1 expression1_type;
|
||||
typedef const E2 expression2_type;
|
||||
typedef typename M::size_type size_type;
|
||||
typedef typename M::value_type value_type;
|
||||
const size_type block_size = BS;
|
||||
|
||||
M m (e1 ().size1 (), e2 ().size2 ());
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
matrix<value_type, row_major> cm (m.size1 (), m.size2 ());
|
||||
typedef typename type_traits<value_type>::real_type real_type;
|
||||
real_type merrorbound (norm_1 (m) + norm_1 (e1) * norm_1 (e2));
|
||||
indexing_matrix_assign<scalar_assign> (cm, prod (e1, e2), row_major_tag ());
|
||||
disable_type_check<bool>::value = true;
|
||||
#endif
|
||||
size_type i_size = e1 ().size1 ();
|
||||
size_type j_size = e2 ().size2 ();
|
||||
size_type k_size = BOOST_UBLAS_SAME (e1 ().size2 (), e2 ().size1 ());
|
||||
for (size_type i_begin = 0; i_begin < i_size; i_begin += block_size) {
|
||||
size_type i_end = i_begin + (std::min) (i_size - i_begin, block_size);
|
||||
for (size_type j_begin = 0; j_begin < j_size; j_begin += block_size) {
|
||||
size_type j_end = j_begin + (std::min) (j_size - j_begin, block_size);
|
||||
// FIX: never ignore Martin Weiser's advice ;-(
|
||||
#ifdef BOOST_UBLAS_NO_CACHE
|
||||
matrix_range<matrix_type> m_range (m, range (i_begin, i_end), range (j_begin, j_end));
|
||||
#else
|
||||
// matrix<value_type, row_major, bounded_array<value_type, block_size * block_size> > m_range (i_end - i_begin, j_end - j_begin);
|
||||
matrix<value_type, row_major> m_range (i_end - i_begin, j_end - j_begin);
|
||||
#endif
|
||||
m_range.assign (zero_matrix<value_type> (i_end - i_begin, j_end - j_begin));
|
||||
for (size_type k_begin = 0; k_begin < k_size; k_begin += block_size) {
|
||||
size_type k_end = k_begin + (std::min) (k_size - k_begin, block_size);
|
||||
#ifdef BOOST_UBLAS_NO_CACHE
|
||||
const matrix_range<expression1_type> e1_range (e1 (), range (i_begin, i_end), range (k_begin, k_end));
|
||||
const matrix_range<expression2_type> e2_range (e2 (), range (k_begin, k_end), range (j_begin, j_end));
|
||||
#else
|
||||
// const matrix<value_type, row_major, bounded_array<value_type, block_size * block_size> > e1_range (project (e1 (), range (i_begin, i_end), range (k_begin, k_end)));
|
||||
// const matrix<value_type, column_major, bounded_array<value_type, block_size * block_size> > e2_range (project (e2 (), range (k_begin, k_end), range (j_begin, j_end)));
|
||||
const matrix<value_type, row_major> e1_range (project (e1 (), range (i_begin, i_end), range (k_begin, k_end)));
|
||||
const matrix<value_type, column_major> e2_range (project (e2 (), range (k_begin, k_end), range (j_begin, j_end)));
|
||||
#endif
|
||||
m_range.plus_assign (prod (e1_range, e2_range));
|
||||
}
|
||||
#ifndef BOOST_UBLAS_NO_CACHE
|
||||
project (m, range (i_begin, i_end), range (j_begin, j_end)).assign (m_range);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
disable_type_check<bool>::value = false;
|
||||
BOOST_UBLAS_CHECK (norm_1 (m - cm) <= 2 * std::numeric_limits<real_type>::epsilon () * merrorbound, internal_logic ());
|
||||
#endif
|
||||
return m;
|
||||
}
|
||||
|
||||
template<class M, typename M::size_type BS, class E1, class E2>
|
||||
BOOST_UBLAS_INLINE
|
||||
M
|
||||
block_prod (const matrix_expression<E1> &e1,
|
||||
const matrix_expression<E2> &e2,
|
||||
column_major_tag) {
|
||||
typedef M matrix_type;
|
||||
typedef const E1 expression1_type;
|
||||
typedef const E2 expression2_type;
|
||||
typedef typename M::size_type size_type;
|
||||
typedef typename M::value_type value_type;
|
||||
const size_type block_size = BS;
|
||||
|
||||
M m (e1 ().size1 (), e2 ().size2 ());
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
matrix<value_type, column_major> cm (m.size1 (), m.size2 ());
|
||||
typedef typename type_traits<value_type>::real_type real_type;
|
||||
real_type merrorbound (norm_1 (m) + norm_1 (e1) * norm_1 (e2));
|
||||
indexing_matrix_assign<scalar_assign> (cm, prod (e1, e2), column_major_tag ());
|
||||
disable_type_check<bool>::value = true;
|
||||
#endif
|
||||
size_type i_size = e1 ().size1 ();
|
||||
size_type j_size = e2 ().size2 ();
|
||||
size_type k_size = BOOST_UBLAS_SAME (e1 ().size2 (), e2 ().size1 ());
|
||||
for (size_type j_begin = 0; j_begin < j_size; j_begin += block_size) {
|
||||
size_type j_end = j_begin + (std::min) (j_size - j_begin, block_size);
|
||||
for (size_type i_begin = 0; i_begin < i_size; i_begin += block_size) {
|
||||
size_type i_end = i_begin + (std::min) (i_size - i_begin, block_size);
|
||||
// FIX: never ignore Martin Weiser's advice ;-(
|
||||
#ifdef BOOST_UBLAS_NO_CACHE
|
||||
matrix_range<matrix_type> m_range (m, range (i_begin, i_end), range (j_begin, j_end));
|
||||
#else
|
||||
// matrix<value_type, column_major, bounded_array<value_type, block_size * block_size> > m_range (i_end - i_begin, j_end - j_begin);
|
||||
matrix<value_type, column_major> m_range (i_end - i_begin, j_end - j_begin);
|
||||
#endif
|
||||
m_range.assign (zero_matrix<value_type> (i_end - i_begin, j_end - j_begin));
|
||||
for (size_type k_begin = 0; k_begin < k_size; k_begin += block_size) {
|
||||
size_type k_end = k_begin + (std::min) (k_size - k_begin, block_size);
|
||||
#ifdef BOOST_UBLAS_NO_CACHE
|
||||
const matrix_range<expression1_type> e1_range (e1 (), range (i_begin, i_end), range (k_begin, k_end));
|
||||
const matrix_range<expression2_type> e2_range (e2 (), range (k_begin, k_end), range (j_begin, j_end));
|
||||
#else
|
||||
// const matrix<value_type, row_major, bounded_array<value_type, block_size * block_size> > e1_range (project (e1 (), range (i_begin, i_end), range (k_begin, k_end)));
|
||||
// const matrix<value_type, column_major, bounded_array<value_type, block_size * block_size> > e2_range (project (e2 (), range (k_begin, k_end), range (j_begin, j_end)));
|
||||
const matrix<value_type, row_major> e1_range (project (e1 (), range (i_begin, i_end), range (k_begin, k_end)));
|
||||
const matrix<value_type, column_major> e2_range (project (e2 (), range (k_begin, k_end), range (j_begin, j_end)));
|
||||
#endif
|
||||
m_range.plus_assign (prod (e1_range, e2_range));
|
||||
}
|
||||
#ifndef BOOST_UBLAS_NO_CACHE
|
||||
project (m, range (i_begin, i_end), range (j_begin, j_end)).assign (m_range);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
disable_type_check<bool>::value = false;
|
||||
BOOST_UBLAS_CHECK (norm_1 (m - cm) <= 2 * std::numeric_limits<real_type>::epsilon () * merrorbound, internal_logic ());
|
||||
#endif
|
||||
return m;
|
||||
}
|
||||
|
||||
// Dispatcher
|
||||
template<class M, typename M::size_type BS, class E1, class E2>
|
||||
BOOST_UBLAS_INLINE
|
||||
M
|
||||
block_prod (const matrix_expression<E1> &e1,
|
||||
const matrix_expression<E2> &e2) {
|
||||
typedef typename M::orientation_category orientation_category;
|
||||
return block_prod<M, BS> (e1, e2, orientation_category ());
|
||||
}
|
||||
|
||||
}}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,198 @@
|
||||
//
|
||||
// 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_OPERATION_SPARSE_
|
||||
#define _BOOST_UBLAS_OPERATION_SPARSE_
|
||||
|
||||
#include <boost/numeric/ublas/traits.hpp>
|
||||
|
||||
// These scaled additions were borrowed from MTL unashamedly.
|
||||
// But Alexei Novakov had a lot of ideas to improve these. Thanks.
|
||||
|
||||
namespace boost { namespace numeric { namespace ublas {
|
||||
|
||||
template<class M, class E1, class E2, class TRI>
|
||||
BOOST_UBLAS_INLINE
|
||||
M &
|
||||
sparse_prod (const matrix_expression<E1> &e1,
|
||||
const matrix_expression<E2> &e2,
|
||||
M &m, TRI,
|
||||
row_major_tag) {
|
||||
typedef M matrix_type;
|
||||
typedef TRI triangular_restriction;
|
||||
typedef const E1 expression1_type;
|
||||
typedef const E2 expression2_type;
|
||||
typedef typename M::size_type size_type;
|
||||
typedef typename M::value_type value_type;
|
||||
|
||||
// ISSUE why is there a dense vector here?
|
||||
vector<value_type> temporary (e2 ().size2 ());
|
||||
temporary.clear ();
|
||||
typename expression1_type::const_iterator1 it1 (e1 ().begin1 ());
|
||||
typename expression1_type::const_iterator1 it1_end (e1 ().end1 ());
|
||||
while (it1 != it1_end) {
|
||||
size_type jb (temporary.size ());
|
||||
size_type je (0);
|
||||
#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
|
||||
typename expression1_type::const_iterator2 it2 (it1.begin ());
|
||||
typename expression1_type::const_iterator2 it2_end (it1.end ());
|
||||
#else
|
||||
typename expression1_type::const_iterator2 it2 (boost::numeric::ublas::begin (it1, iterator1_tag ()));
|
||||
typename expression1_type::const_iterator2 it2_end (boost::numeric::ublas::end (it1, iterator1_tag ()));
|
||||
#endif
|
||||
while (it2 != it2_end) {
|
||||
// temporary.plus_assign (*it2 * row (e2 (), it2.index2 ()));
|
||||
matrix_row<expression2_type> mr (e2 (), it2.index2 ());
|
||||
typename matrix_row<expression2_type>::const_iterator itr (mr.begin ());
|
||||
typename matrix_row<expression2_type>::const_iterator itr_end (mr.end ());
|
||||
while (itr != itr_end) {
|
||||
size_type j (itr.index ());
|
||||
temporary (j) += *it2 * *itr;
|
||||
jb = (std::min) (jb, j);
|
||||
je = (std::max) (je, j);
|
||||
++ itr;
|
||||
}
|
||||
++ it2;
|
||||
}
|
||||
for (size_type j = jb; j < je + 1; ++ j) {
|
||||
if (temporary (j) != value_type/*zero*/()) {
|
||||
// FIXME we'll need to extend the container interface!
|
||||
// m.push_back (it1.index1 (), j, temporary (j));
|
||||
// FIXME What to do with adaptors?
|
||||
// m.insert (it1.index1 (), j, temporary (j));
|
||||
if (triangular_restriction::other (it1.index1 (), j))
|
||||
m (it1.index1 (), j) = temporary (j);
|
||||
temporary (j) = value_type/*zero*/();
|
||||
}
|
||||
}
|
||||
++ it1;
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
template<class M, class E1, class E2, class TRI>
|
||||
BOOST_UBLAS_INLINE
|
||||
M &
|
||||
sparse_prod (const matrix_expression<E1> &e1,
|
||||
const matrix_expression<E2> &e2,
|
||||
M &m, TRI,
|
||||
column_major_tag) {
|
||||
typedef M matrix_type;
|
||||
typedef TRI triangular_restriction;
|
||||
typedef const E1 expression1_type;
|
||||
typedef const E2 expression2_type;
|
||||
typedef typename M::size_type size_type;
|
||||
typedef typename M::value_type value_type;
|
||||
|
||||
// ISSUE why is there a dense vector here?
|
||||
vector<value_type> temporary (e1 ().size1 ());
|
||||
temporary.clear ();
|
||||
typename expression2_type::const_iterator2 it2 (e2 ().begin2 ());
|
||||
typename expression2_type::const_iterator2 it2_end (e2 ().end2 ());
|
||||
while (it2 != it2_end) {
|
||||
size_type ib (temporary.size ());
|
||||
size_type ie (0);
|
||||
#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
|
||||
typename expression2_type::const_iterator1 it1 (it2.begin ());
|
||||
typename expression2_type::const_iterator1 it1_end (it2.end ());
|
||||
#else
|
||||
typename expression2_type::const_iterator1 it1 (boost::numeric::ublas::begin (it2, iterator2_tag ()));
|
||||
typename expression2_type::const_iterator1 it1_end (boost::numeric::ublas::end (it2, iterator2_tag ()));
|
||||
#endif
|
||||
while (it1 != it1_end) {
|
||||
// column (m, it2.index2 ()).plus_assign (*it1 * column (e1 (), it1.index1 ()));
|
||||
matrix_column<expression1_type> mc (e1 (), it1.index1 ());
|
||||
typename matrix_column<expression1_type>::const_iterator itc (mc.begin ());
|
||||
typename matrix_column<expression1_type>::const_iterator itc_end (mc.end ());
|
||||
while (itc != itc_end) {
|
||||
size_type i (itc.index ());
|
||||
temporary (i) += *it1 * *itc;
|
||||
ib = (std::min) (ib, i);
|
||||
ie = (std::max) (ie, i);
|
||||
++ itc;
|
||||
}
|
||||
++ it1;
|
||||
}
|
||||
for (size_type i = ib; i < ie + 1; ++ i) {
|
||||
if (temporary (i) != value_type/*zero*/()) {
|
||||
// FIXME we'll need to extend the container interface!
|
||||
// m.push_back (i, it2.index2 (), temporary (i));
|
||||
// FIXME What to do with adaptors?
|
||||
// m.insert (i, it2.index2 (), temporary (i));
|
||||
if (triangular_restriction::other (i, it2.index2 ()))
|
||||
m (i, it2.index2 ()) = temporary (i);
|
||||
temporary (i) = value_type/*zero*/();
|
||||
}
|
||||
}
|
||||
++ it2;
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
// Dispatcher
|
||||
template<class M, class E1, class E2, class TRI>
|
||||
BOOST_UBLAS_INLINE
|
||||
M &
|
||||
sparse_prod (const matrix_expression<E1> &e1,
|
||||
const matrix_expression<E2> &e2,
|
||||
M &m, TRI, bool init = true) {
|
||||
typedef typename M::value_type value_type;
|
||||
typedef TRI triangular_restriction;
|
||||
typedef typename M::orientation_category orientation_category;
|
||||
|
||||
if (init)
|
||||
m.assign (zero_matrix<value_type> (e1 ().size1 (), e2 ().size2 ()));
|
||||
return sparse_prod (e1, e2, m, triangular_restriction (), orientation_category ());
|
||||
}
|
||||
template<class M, class E1, class E2, class TRI>
|
||||
BOOST_UBLAS_INLINE
|
||||
M
|
||||
sparse_prod (const matrix_expression<E1> &e1,
|
||||
const matrix_expression<E2> &e2,
|
||||
TRI) {
|
||||
typedef M matrix_type;
|
||||
typedef TRI triangular_restriction;
|
||||
|
||||
matrix_type m (e1 ().size1 (), e2 ().size2 ());
|
||||
// FIXME needed for c_matrix?!
|
||||
// return sparse_prod (e1, e2, m, triangular_restriction (), false);
|
||||
return sparse_prod (e1, e2, m, triangular_restriction (), true);
|
||||
}
|
||||
template<class M, class E1, class E2>
|
||||
BOOST_UBLAS_INLINE
|
||||
M &
|
||||
sparse_prod (const matrix_expression<E1> &e1,
|
||||
const matrix_expression<E2> &e2,
|
||||
M &m, bool init = true) {
|
||||
typedef typename M::value_type value_type;
|
||||
typedef typename M::orientation_category orientation_category;
|
||||
|
||||
if (init)
|
||||
m.assign (zero_matrix<value_type> (e1 ().size1 (), e2 ().size2 ()));
|
||||
return sparse_prod (e1, e2, m, full (), orientation_category ());
|
||||
}
|
||||
template<class M, class E1, class E2>
|
||||
BOOST_UBLAS_INLINE
|
||||
M
|
||||
sparse_prod (const matrix_expression<E1> &e1,
|
||||
const matrix_expression<E2> &e2) {
|
||||
typedef M matrix_type;
|
||||
|
||||
matrix_type m (e1 ().size1 (), e2 ().size2 ());
|
||||
// FIXME needed for c_matrix?!
|
||||
// return sparse_prod (e1, e2, m, full (), false);
|
||||
return sparse_prod (e1, e2, m, full (), true);
|
||||
}
|
||||
|
||||
}}}
|
||||
|
||||
#endif
|
||||
26
project/jni/boost/include/boost/numeric/ublas/operations.hpp
Normal file
26
project/jni/boost/include/boost/numeric/ublas/operations.hpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* -*- c++ -*-
|
||||
*
|
||||
* \file operations.hpp
|
||||
*
|
||||
* \brief This header includes several headers from the operation directory.
|
||||
*
|
||||
* Copyright (c) 2009, Gunter Winkler
|
||||
*
|
||||
* 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)
|
||||
*
|
||||
* \author Gunter Winkler (guwi17 at gmx dot de)
|
||||
*/
|
||||
|
||||
#ifndef BOOST_NUMERIC_UBLAS_OPERATIONS_HPP
|
||||
#define BOOST_NUMERIC_UBLAS_OPERATIONS_HPP
|
||||
|
||||
#include <boost/numeric/ublas/operation/begin.hpp>
|
||||
#include <boost/numeric/ublas/operation/end.hpp>
|
||||
#include <boost/numeric/ublas/operation/num_columns.hpp>
|
||||
#include <boost/numeric/ublas/operation/num_rows.hpp>
|
||||
#include <boost/numeric/ublas/operation/size.hpp>
|
||||
|
||||
#endif
|
||||
1915
project/jni/boost/include/boost/numeric/ublas/storage.hpp
Normal file
1915
project/jni/boost/include/boost/numeric/ublas/storage.hpp
Normal file
File diff suppressed because it is too large
Load Diff
562
project/jni/boost/include/boost/numeric/ublas/storage_sparse.hpp
Normal file
562
project/jni/boost/include/boost/numeric/ublas/storage_sparse.hpp
Normal file
@@ -0,0 +1,562 @@
|
||||
//
|
||||
// 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_STORAGE_SPARSE_
|
||||
#define _BOOST_UBLAS_STORAGE_SPARSE_
|
||||
|
||||
#include <map>
|
||||
#include <boost/serialization/collection_size_type.hpp>
|
||||
#include <boost/serialization/nvp.hpp>
|
||||
#include <boost/serialization/array.hpp>
|
||||
#include <boost/serialization/map.hpp>
|
||||
#include <boost/serialization/base_object.hpp>
|
||||
|
||||
#include <boost/numeric/ublas/storage.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace numeric { namespace ublas {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class I, class T, class C>
|
||||
BOOST_UBLAS_INLINE
|
||||
I lower_bound (const I &begin, const I &end, const T &t, C compare) {
|
||||
// t <= *begin <=> ! (*begin < t)
|
||||
if (begin == end || ! compare (*begin, t))
|
||||
return begin;
|
||||
if (compare (*(end - 1), t))
|
||||
return end;
|
||||
return std::lower_bound (begin, end, t, compare);
|
||||
}
|
||||
template<class I, class T, class C>
|
||||
BOOST_UBLAS_INLINE
|
||||
I upper_bound (const I &begin, const I &end, const T &t, C compare) {
|
||||
if (begin == end || compare (t, *begin))
|
||||
return begin;
|
||||
// (*end - 1) <= t <=> ! (t < *end)
|
||||
if (! compare (t, *(end - 1)))
|
||||
return end;
|
||||
return std::upper_bound (begin, end, t, compare);
|
||||
}
|
||||
|
||||
template<class P>
|
||||
struct less_pair {
|
||||
BOOST_UBLAS_INLINE
|
||||
bool operator () (const P &p1, const P &p2) {
|
||||
return p1.first < p2.first;
|
||||
}
|
||||
};
|
||||
template<class T>
|
||||
struct less_triple {
|
||||
BOOST_UBLAS_INLINE
|
||||
bool operator () (const T &t1, const T &t2) {
|
||||
return t1.first.first < t2.first.first ||
|
||||
(t1.first.first == t2.first.first && t1.first.second < t2.first.second);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#ifdef BOOST_UBLAS_STRICT_MAP_ARRAY
|
||||
template<class A>
|
||||
class sparse_storage_element:
|
||||
public container_reference<A> {
|
||||
public:
|
||||
typedef A array_type;
|
||||
typedef typename A::key_type index_type;
|
||||
typedef typename A::mapped_type data_value_type;
|
||||
// typedef const data_value_type &data_const_reference;
|
||||
typedef typename type_traits<data_value_type>::const_reference data_const_reference;
|
||||
typedef data_value_type &data_reference;
|
||||
typedef typename A::value_type value_type;
|
||||
typedef value_type *pointer;
|
||||
|
||||
// Construction and destruction
|
||||
BOOST_UBLAS_INLINE
|
||||
sparse_storage_element (array_type &a, pointer it):
|
||||
container_reference<array_type> (a), it_ (it), i_ (it->first), d_ (it->second), dirty_ (false) {}
|
||||
BOOST_UBLAS_INLINE
|
||||
sparse_storage_element (array_type &a, index_type i):
|
||||
container_reference<array_type> (a), it_ (), i_ (i), d_ (), dirty_ (false) {
|
||||
pointer it = (*this) ().find (i_);
|
||||
if (it == (*this) ().end ())
|
||||
it = (*this) ().insert ((*this) ().end (), value_type (i_, d_));
|
||||
d_ = it->second;
|
||||
}
|
||||
BOOST_UBLAS_INLINE
|
||||
~sparse_storage_element () {
|
||||
if (dirty_) {
|
||||
if (! it_)
|
||||
it_ = (*this) ().find (i_);
|
||||
BOOST_UBLAS_CHECK (it_ != (*this) ().end (), internal_logic ());
|
||||
it_->second = d_;
|
||||
}
|
||||
}
|
||||
|
||||
// Element access - only if data_const_reference is defined
|
||||
BOOST_UBLAS_INLINE
|
||||
typename data_value_type::data_const_reference
|
||||
operator [] (index_type i) const {
|
||||
return d_ [i];
|
||||
}
|
||||
|
||||
// Assignment
|
||||
BOOST_UBLAS_INLINE
|
||||
sparse_storage_element &operator = (const sparse_storage_element &p) {
|
||||
// Overide the implict copy assignment
|
||||
d_ = p.d_;
|
||||
dirty_ = true;
|
||||
return *this;
|
||||
}
|
||||
template<class D>
|
||||
BOOST_UBLAS_INLINE
|
||||
sparse_storage_element &operator = (const D &d) {
|
||||
d_ = d;
|
||||
dirty_ = true;
|
||||
return *this;
|
||||
}
|
||||
template<class D>
|
||||
BOOST_UBLAS_INLINE
|
||||
sparse_storage_element &operator += (const D &d) {
|
||||
d_ += d;
|
||||
dirty_ = true;
|
||||
return *this;
|
||||
}
|
||||
template<class D>
|
||||
BOOST_UBLAS_INLINE
|
||||
sparse_storage_element &operator -= (const D &d) {
|
||||
d_ -= d;
|
||||
dirty_ = true;
|
||||
return *this;
|
||||
}
|
||||
template<class D>
|
||||
BOOST_UBLAS_INLINE
|
||||
sparse_storage_element &operator *= (const D &d) {
|
||||
d_ *= d;
|
||||
dirty_ = true;
|
||||
return *this;
|
||||
}
|
||||
template<class D>
|
||||
BOOST_UBLAS_INLINE
|
||||
sparse_storage_element &operator /= (const D &d) {
|
||||
d_ /= d;
|
||||
dirty_ = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Comparison
|
||||
template<class D>
|
||||
BOOST_UBLAS_INLINE
|
||||
bool operator == (const D &d) const {
|
||||
return d_ == d;
|
||||
}
|
||||
template<class D>
|
||||
BOOST_UBLAS_INLINE
|
||||
bool operator != (const D &d) const {
|
||||
return d_ != d;
|
||||
}
|
||||
|
||||
// Conversion
|
||||
BOOST_UBLAS_INLINE
|
||||
operator data_const_reference () const {
|
||||
return d_;
|
||||
}
|
||||
|
||||
// Swapping
|
||||
BOOST_UBLAS_INLINE
|
||||
void swap (sparse_storage_element p) {
|
||||
if (this != &p) {
|
||||
dirty_ = true;
|
||||
p.dirty_ = true;
|
||||
std::swap (d_, p.d_);
|
||||
}
|
||||
}
|
||||
BOOST_UBLAS_INLINE
|
||||
friend void swap (sparse_storage_element p1, sparse_storage_element p2) {
|
||||
p1.swap (p2);
|
||||
}
|
||||
|
||||
private:
|
||||
pointer it_;
|
||||
index_type i_;
|
||||
data_value_type d_;
|
||||
bool dirty_;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
// Default map type is simply forwarded to std::map
|
||||
// FIXME should use ALLOC for map but std::allocator of std::pair<const I, T> and std::pair<I,T> fail to compile
|
||||
template<class I, class T, class ALLOC>
|
||||
class map_std : public std::map<I, T /*, ALLOC */> {
|
||||
public:
|
||||
// Serialization
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int /* file_version */){
|
||||
ar & serialization::make_nvp("base", boost::serialization::base_object< std::map<I, T /*, ALLOC */> >(*this));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
// Map array
|
||||
// Implementation requires pair<I, T> allocator definition (without const)
|
||||
template<class I, class T, class ALLOC>
|
||||
class map_array {
|
||||
public:
|
||||
typedef ALLOC allocator_type;
|
||||
typedef typename ALLOC::size_type size_type;
|
||||
typedef typename ALLOC::difference_type difference_type;
|
||||
typedef std::pair<I,T> value_type;
|
||||
typedef I key_type;
|
||||
typedef T mapped_type;
|
||||
typedef const value_type &const_reference;
|
||||
typedef value_type &reference;
|
||||
typedef const value_type *const_pointer;
|
||||
typedef value_type *pointer;
|
||||
// Iterators simply are pointers.
|
||||
typedef const_pointer const_iterator;
|
||||
typedef pointer iterator;
|
||||
|
||||
typedef const T &data_const_reference;
|
||||
#ifndef BOOST_UBLAS_STRICT_MAP_ARRAY
|
||||
typedef T &data_reference;
|
||||
#else
|
||||
typedef sparse_storage_element<map_array> data_reference;
|
||||
#endif
|
||||
|
||||
// Construction and destruction
|
||||
BOOST_UBLAS_INLINE
|
||||
map_array (const ALLOC &a = ALLOC()):
|
||||
alloc_(a), capacity_ (0), size_ (0) {
|
||||
data_ = 0;
|
||||
}
|
||||
BOOST_UBLAS_INLINE
|
||||
map_array (const map_array &c):
|
||||
alloc_ (c.alloc_), capacity_ (c.size_), size_ (c.size_) {
|
||||
if (capacity_) {
|
||||
data_ = alloc_.allocate (capacity_);
|
||||
std::uninitialized_copy (data_, data_ + capacity_, c.data_);
|
||||
// capacity != size_ requires uninitialized_fill (size_ to capacity_)
|
||||
}
|
||||
else
|
||||
data_ = 0;
|
||||
}
|
||||
BOOST_UBLAS_INLINE
|
||||
~map_array () {
|
||||
if (capacity_) {
|
||||
std::for_each (data_, data_ + capacity_, static_destroy);
|
||||
alloc_.deallocate (data_, capacity_);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
// Resizing - implicitly exposses uninitialized (but default constructed) mapped_type
|
||||
BOOST_UBLAS_INLINE
|
||||
void resize (size_type size) {
|
||||
BOOST_UBLAS_CHECK (size_ <= capacity_, internal_logic ());
|
||||
if (size > capacity_) {
|
||||
const size_type capacity = size << 1;
|
||||
BOOST_UBLAS_CHECK (capacity, internal_logic ());
|
||||
pointer data = alloc_.allocate (capacity);
|
||||
std::uninitialized_copy (data_, data_ + (std::min) (size, size_), data);
|
||||
std::uninitialized_fill (data + (std::min) (size, size_), data + capacity, value_type ());
|
||||
|
||||
if (capacity_) {
|
||||
std::for_each (data_, data_ + capacity_, static_destroy);
|
||||
alloc_.deallocate (data_, capacity_);
|
||||
}
|
||||
capacity_ = capacity;
|
||||
data_ = data;
|
||||
}
|
||||
size_ = size;
|
||||
BOOST_UBLAS_CHECK (size_ <= capacity_, internal_logic ());
|
||||
}
|
||||
public:
|
||||
|
||||
// Reserving
|
||||
BOOST_UBLAS_INLINE
|
||||
void reserve (size_type capacity) {
|
||||
BOOST_UBLAS_CHECK (size_ <= capacity_, internal_logic ());
|
||||
// Reduce capacity_ if size_ allows
|
||||
BOOST_UBLAS_CHECK (capacity >= size_, bad_size ());
|
||||
pointer data;
|
||||
if (capacity) {
|
||||
data = alloc_.allocate (capacity);
|
||||
std::uninitialized_copy (data_, data_ + size_, data);
|
||||
std::uninitialized_fill (data + size_, data + capacity, value_type ());
|
||||
}
|
||||
else
|
||||
data = 0;
|
||||
|
||||
if (capacity_) {
|
||||
std::for_each (data_, data_ + capacity_, static_destroy);
|
||||
alloc_.deallocate (data_, capacity_);
|
||||
}
|
||||
capacity_ = capacity;
|
||||
data_ = data;
|
||||
BOOST_UBLAS_CHECK (size_ <= capacity_, internal_logic ());
|
||||
}
|
||||
|
||||
// Random Access Container
|
||||
BOOST_UBLAS_INLINE
|
||||
size_type size () const {
|
||||
return size_;
|
||||
}
|
||||
BOOST_UBLAS_INLINE
|
||||
size_type capacity () const {
|
||||
return capacity_;
|
||||
}
|
||||
BOOST_UBLAS_INLINE
|
||||
size_type max_size () const {
|
||||
return 0; //TODO
|
||||
}
|
||||
|
||||
BOOST_UBLAS_INLINE
|
||||
bool empty () const {
|
||||
return size_ == 0;
|
||||
}
|
||||
|
||||
// Element access
|
||||
BOOST_UBLAS_INLINE
|
||||
data_reference operator [] (key_type i) {
|
||||
#ifndef BOOST_UBLAS_STRICT_MAP_ARRAY
|
||||
pointer it = find (i);
|
||||
if (it == end ())
|
||||
it = insert (end (), value_type (i, mapped_type (0)));
|
||||
BOOST_UBLAS_CHECK (it != end (), internal_logic ());
|
||||
return it->second;
|
||||
#else
|
||||
return data_reference (*this, i);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Assignment
|
||||
BOOST_UBLAS_INLINE
|
||||
map_array &operator = (const map_array &a) {
|
||||
if (this != &a) {
|
||||
resize (a.size_);
|
||||
std::copy (a.data_, a.data_ + a.size_, data_);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
BOOST_UBLAS_INLINE
|
||||
map_array &assign_temporary (map_array &a) {
|
||||
swap (a);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Swapping
|
||||
BOOST_UBLAS_INLINE
|
||||
void swap (map_array &a) {
|
||||
if (this != &a) {
|
||||
std::swap (capacity_, a.capacity_);
|
||||
std::swap (data_, a.data_);
|
||||
std::swap (size_, a.size_);
|
||||
}
|
||||
}
|
||||
BOOST_UBLAS_INLINE
|
||||
friend void swap (map_array &a1, map_array &a2) {
|
||||
a1.swap (a2);
|
||||
}
|
||||
|
||||
// Element insertion and deletion
|
||||
|
||||
// From Back Insertion Sequence concept
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
iterator push_back (iterator it, const value_type &p) {
|
||||
if (size () == 0 || (it = end () - 1)->first < p.first) {
|
||||
resize (size () + 1);
|
||||
*(it = end () - 1) = p;
|
||||
return it;
|
||||
}
|
||||
external_logic ().raise ();
|
||||
return it;
|
||||
}
|
||||
// Form Unique Associative Container concept
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
std::pair<iterator,bool> insert (const value_type &p) {
|
||||
iterator it = detail::lower_bound (begin (), end (), p, detail::less_pair<value_type> ());
|
||||
if (it != end () && it->first == p.first)
|
||||
return std::make_pair (it, false);
|
||||
difference_type n = it - begin ();
|
||||
resize (size () + 1);
|
||||
it = begin () + n; // allow for invalidation
|
||||
std::copy_backward (it, end () - 1, end ());
|
||||
*it = p;
|
||||
return std::make_pair (it, true);
|
||||
}
|
||||
// Form Sorted Associative Container concept
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
iterator insert (iterator hint, const value_type &p) {
|
||||
return insert (p).first;
|
||||
}
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
void erase (iterator it) {
|
||||
BOOST_UBLAS_CHECK (begin () <= it && it < end (), bad_index ());
|
||||
std::copy (it + 1, end (), it);
|
||||
resize (size () - 1);
|
||||
}
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
void erase (iterator it1, iterator it2) {
|
||||
if (it1 == it2) return /* nothing to erase */;
|
||||
BOOST_UBLAS_CHECK (begin () <= it1 && it1 < it2 && it2 <= end (), bad_index ());
|
||||
std::copy (it2, end (), it1);
|
||||
resize (size () - (it2 - it1));
|
||||
}
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
void clear () {
|
||||
resize (0);
|
||||
}
|
||||
|
||||
// Element lookup
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
const_iterator find (key_type i) const {
|
||||
const_iterator it (detail::lower_bound (begin (), end (), value_type (i, mapped_type (0)), detail::less_pair<value_type> ()));
|
||||
if (it == end () || it->first != i)
|
||||
it = end ();
|
||||
return it;
|
||||
}
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
iterator find (key_type i) {
|
||||
iterator it (detail::lower_bound (begin (), end (), value_type (i, mapped_type (0)), detail::less_pair<value_type> ()));
|
||||
if (it == end () || it->first != i)
|
||||
it = end ();
|
||||
return it;
|
||||
}
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
const_iterator lower_bound (key_type i) const {
|
||||
return detail::lower_bound (begin (), end (), value_type (i, mapped_type (0)), detail::less_pair<value_type> ());
|
||||
}
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
iterator lower_bound (key_type i) {
|
||||
return detail::lower_bound (begin (), end (), value_type (i, mapped_type (0)), detail::less_pair<value_type> ());
|
||||
}
|
||||
|
||||
BOOST_UBLAS_INLINE
|
||||
const_iterator begin () const {
|
||||
return data_;
|
||||
}
|
||||
BOOST_UBLAS_INLINE
|
||||
const_iterator end () const {
|
||||
return data_ + size_;
|
||||
}
|
||||
|
||||
BOOST_UBLAS_INLINE
|
||||
iterator begin () {
|
||||
return data_;
|
||||
}
|
||||
BOOST_UBLAS_INLINE
|
||||
iterator end () {
|
||||
return data_ + size_;
|
||||
}
|
||||
|
||||
// Reverse iterators
|
||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
typedef std::reverse_iterator<iterator> reverse_iterator;
|
||||
|
||||
BOOST_UBLAS_INLINE
|
||||
const_reverse_iterator rbegin () const {
|
||||
return const_reverse_iterator (end ());
|
||||
}
|
||||
BOOST_UBLAS_INLINE
|
||||
const_reverse_iterator rend () const {
|
||||
return const_reverse_iterator (begin ());
|
||||
}
|
||||
BOOST_UBLAS_INLINE
|
||||
reverse_iterator rbegin () {
|
||||
return reverse_iterator (end ());
|
||||
}
|
||||
BOOST_UBLAS_INLINE
|
||||
reverse_iterator rend () {
|
||||
return reverse_iterator (begin ());
|
||||
}
|
||||
|
||||
// Allocator
|
||||
allocator_type get_allocator () {
|
||||
return alloc_;
|
||||
}
|
||||
|
||||
// Serialization
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int /* file_version */){
|
||||
serialization::collection_size_type s (size_);
|
||||
ar & serialization::make_nvp("size",s);
|
||||
if (Archive::is_loading::value) {
|
||||
resize(s);
|
||||
}
|
||||
ar & serialization::make_array(data_, s);
|
||||
}
|
||||
|
||||
private:
|
||||
// Provide destroy as a non member function
|
||||
BOOST_UBLAS_INLINE
|
||||
static void static_destroy (reference p) {
|
||||
(&p) -> ~value_type ();
|
||||
}
|
||||
ALLOC alloc_;
|
||||
size_type capacity_;
|
||||
pointer data_;
|
||||
size_type size_;
|
||||
};
|
||||
|
||||
|
||||
namespace detail {
|
||||
template<class A, class T>
|
||||
struct map_traits {
|
||||
typedef typename A::mapped_type &reference;
|
||||
};
|
||||
template<class I, class T, class ALLOC>
|
||||
struct map_traits<map_array<I, T, ALLOC>, T > {
|
||||
typedef typename map_array<I, T, ALLOC>::data_reference reference;
|
||||
};
|
||||
|
||||
// reserve helpers for map_array and generic maps
|
||||
// ISSUE should be in map_traits but want to use on all compilers
|
||||
|
||||
template<class M>
|
||||
BOOST_UBLAS_INLINE
|
||||
void map_reserve (M &/* m */, typename M::size_type /* capacity */) {
|
||||
}
|
||||
template<class I, class T, class ALLOC>
|
||||
BOOST_UBLAS_INLINE
|
||||
void map_reserve (map_array<I, T, ALLOC> &m, typename map_array<I, T, ALLOC>::size_type capacity) {
|
||||
m.reserve (capacity);
|
||||
}
|
||||
|
||||
template<class M>
|
||||
struct map_capacity_traits {
|
||||
typedef typename M::size_type type ;
|
||||
type operator() ( M const& m ) const {
|
||||
return m.size ();
|
||||
}
|
||||
} ;
|
||||
|
||||
template<class I, class T, class ALLOC>
|
||||
struct map_capacity_traits< map_array<I, T, ALLOC> > {
|
||||
typedef typename map_array<I, T, ALLOC>::size_type type ;
|
||||
type operator() ( map_array<I, T, ALLOC> const& m ) const {
|
||||
return m.capacity ();
|
||||
}
|
||||
} ;
|
||||
|
||||
template<class M>
|
||||
BOOST_UBLAS_INLINE
|
||||
typename map_capacity_traits<M>::type map_capacity (M const& m) {
|
||||
return map_capacity_traits<M>() ( m );
|
||||
}
|
||||
}
|
||||
|
||||
}}}
|
||||
|
||||
#endif
|
||||
2134
project/jni/boost/include/boost/numeric/ublas/symmetric.hpp
Normal file
2134
project/jni/boost/include/boost/numeric/ublas/symmetric.hpp
Normal file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user