[DEV] add v1.76.0

This commit is contained in:
2021-10-05 21:37:46 +02:00
parent a97e9ae7d4
commit d0115b733d
45133 changed files with 4744437 additions and 1026325 deletions

View File

@@ -54,20 +54,20 @@ meter
struct byte_base_unit : boost::units::base_unit<byte_base_unit, boost::units::dimensionless_type, 3>
{
static const char* name() { return("byte"); }
static const char* symbol() { return("b"); }
static constexpr const char* name() { return("byte"); }
static constexpr const char* symbol() { return("b"); }
};
struct thing_base_unit : boost::units::base_unit<thing_base_unit, boost::units::dimensionless_type, 4>
{
static const char* name() { return("thing"); }
static const char* symbol() { return(""); }
static constexpr const char* name() { return("thing"); }
static constexpr const char* symbol() { return(""); }
};
struct euro_base_unit : boost::units::base_unit<euro_base_unit, boost::units::dimensionless_type, 5>
{
static const char* name() { return("EUR"); }
static const char* symbol() { return("<EFBFBD>"); }
static constexpr const char* name() { return("EUR"); }
static constexpr const char* symbol() { return(""); }
};
int main()
@@ -140,7 +140,7 @@ int main()
quantity<euro_base_unit::unit_type> ce = 2048. * euro_base_unit::unit_type();
cout << name_format << engineering_prefix << ce << endl; // 2.048 kiloEUR
cout << symbol_format << engineering_prefix << ce << endl; // 2.048 k<EFBFBD>
cout << symbol_format << engineering_prefix << ce << endl; // 2.048 k
return 0;

View File

@@ -72,10 +72,10 @@ class complex
public:
typedef complex<T> this_type;
complex(const T& r = 0,const T& i = 0) : r_(r),i_(i) { }
complex(const this_type& source) : r_(source.r_),i_(source.i_) { }
constexpr complex(const T& r = 0,const T& i = 0) : r_(r),i_(i) { }
constexpr complex(const this_type& source) : r_(source.r_),i_(source.i_) { }
this_type& operator=(const this_type& source)
constexpr this_type& operator=(const this_type& source)
{
if (this == &source) return *this;
@@ -85,59 +85,59 @@ class complex
return *this;
}
T& real() { return r_; }
T& imag() { return i_; }
constexpr T& real() { return r_; }
constexpr T& imag() { return i_; }
const T& real() const { return r_; }
const T& imag() const { return i_; }
constexpr const T& real() const { return r_; }
constexpr const T& imag() const { return i_; }
this_type& operator+=(const T& val)
constexpr this_type& operator+=(const T& val)
{
r_ += val;
return *this;
}
this_type& operator-=(const T& val)
constexpr this_type& operator-=(const T& val)
{
r_ -= val;
return *this;
}
this_type& operator*=(const T& val)
constexpr this_type& operator*=(const T& val)
{
r_ *= val;
i_ *= val;
return *this;
}
this_type& operator/=(const T& val)
constexpr this_type& operator/=(const T& val)
{
r_ /= val;
i_ /= val;
return *this;
}
this_type& operator+=(const this_type& source)
constexpr this_type& operator+=(const this_type& source)
{
r_ += source.r_;
i_ += source.i_;
return *this;
}
this_type& operator-=(const this_type& source)
constexpr this_type& operator-=(const this_type& source)
{
r_ -= source.r_;
i_ -= source.i_;
return *this;
}
this_type& operator*=(const this_type& source)
constexpr this_type& operator*=(const this_type& source)
{
*this = *this * source;
return *this;
}
this_type& operator/=(const this_type& source)
constexpr this_type& operator/=(const this_type& source)
{
*this = *this / source;
return *this;
@@ -164,6 +164,7 @@ namespace boost {
namespace units {
template<class X>
constexpr
complex<typename unary_plus_typeof_helper<X>::type>
operator+(const complex<X>& x)
{
@@ -173,6 +174,7 @@ operator+(const complex<X>& x)
}
template<class X>
constexpr
complex<typename unary_minus_typeof_helper<X>::type>
operator-(const complex<X>& x)
{
@@ -182,6 +184,7 @@ operator-(const complex<X>& x)
}
template<class X,class Y>
constexpr
complex<typename add_typeof_helper<X,Y>::type>
operator+(const complex<X>& x,const complex<Y>& y)
{
@@ -191,6 +194,7 @@ operator+(const complex<X>& x,const complex<Y>& y)
}
template<class X,class Y>
constexpr
complex<typename boost::units::subtract_typeof_helper<X,Y>::type>
operator-(const complex<X>& x,const complex<Y>& y)
{
@@ -200,6 +204,7 @@ operator-(const complex<X>& x,const complex<Y>& y)
}
template<class X,class Y>
constexpr
complex<typename boost::units::multiply_typeof_helper<X,Y>::type>
operator*(const complex<X>& x,const complex<Y>& y)
{
@@ -226,6 +231,7 @@ operator*(const complex<X>& x,const complex<Y>& y)
}
template<class X,class Y>
constexpr
complex<typename boost::units::divide_typeof_helper<X,Y>::type>
operator/(const complex<X>& x,const complex<Y>& y)
{
@@ -368,7 +374,6 @@ struct root_typeof_helper<complex<quantity<Unit,Y> >,static_rational<N,D> >
int main(void)
{
using namespace boost::math;
using namespace boost::units;
using namespace boost::units::test;
@@ -376,7 +381,7 @@ int main(void)
//[complex_snippet_1
typedef quantity<length,complex<double> > length_dimension;
length_dimension L(complex<double>(2.0,1.0)*meters);
const length_dimension L(complex<double>(2.0,1.0)*meters);
//]
std::cout << "+L = " << +L << std::endl
@@ -396,7 +401,7 @@ int main(void)
//[complex_snippet_2
typedef complex<quantity<length> > length_dimension;
length_dimension L(2.0*meters,1.0*meters);
const length_dimension L(2.0*meters,1.0*meters);
//]
std::cout << "+L = " << +L << std::endl

View File

@@ -37,6 +37,7 @@ entropy in bytes= 0.125 B
#include <iostream>
using std::cout;
using std::endl;
using std::log;
#include <boost/units/quantity.hpp>
#include <boost/units/io.hpp>
@@ -59,6 +60,7 @@ using namespace bu::information;
// must be a unit of information. Conversion to the requested return unit is
// accomplished automatically by the boost::units library.
template <typename Sys>
constexpr
quantity<bu::unit<bu::information_dimension, Sys> >
bernoulli_entropy(double p, const bu::unit<bu::information_dimension, Sys>&) {
typedef bu::unit<bu::information_dimension, Sys> requested_unit;

View File

@@ -200,6 +200,7 @@ namespace units {
//[kitchen_sink_function_snippet_3
/// the physical definition of work - computed for an arbitrary unit system
template<class System,class Y>
constexpr
quantity<unit<energy_dimension,System>,Y>
work(quantity<unit<force_dimension,System>,Y> F,
quantity<unit<length_dimension,System>,Y> dx)
@@ -211,6 +212,7 @@ work(quantity<unit<force_dimension,System>,Y> F,
//[kitchen_sink_function_snippet_4
/// the ideal gas law in si units
template<class Y>
constexpr
quantity<si::amount,Y>
idealGasLaw(const quantity<si::pressure,Y>& P,
const quantity<si::volume,Y>& V,

View File

@@ -26,6 +26,7 @@ namespace units {
namespace sqr_namespace /**/ {
template<class Y>
constexpr
Y sqr(Y val)
{ return val*val; }
@@ -40,20 +41,20 @@ class measurement
typedef measurement<Y> this_type;
typedef Y value_type;
measurement(const value_type& val = value_type(),
constexpr measurement(const value_type& val = value_type(),
const value_type& err = value_type()) :
value_(val),
uncertainty_(std::abs(err))
{ }
measurement(const this_type& source) :
constexpr measurement(const this_type& source) :
value_(source.value_),
uncertainty_(source.uncertainty_)
{ }
//~measurement() { }
this_type& operator=(const this_type& source)
constexpr this_type& operator=(const this_type& source)
{
if (this == &source) return *this;
@@ -63,43 +64,43 @@ class measurement
return *this;
}
operator value_type() const { return value_; }
constexpr operator value_type() const { return value_; }
value_type value() const { return value_; }
value_type uncertainty() const { return uncertainty_; }
value_type lower_bound() const { return value_-uncertainty_; }
value_type upper_bound() const { return value_+uncertainty_; }
constexpr value_type value() const { return value_; }
constexpr value_type uncertainty() const { return uncertainty_; }
constexpr value_type lower_bound() const { return value_-uncertainty_; }
constexpr value_type upper_bound() const { return value_+uncertainty_; }
this_type& operator+=(const value_type& val)
constexpr this_type& operator+=(const value_type& val)
{
value_ += val;
return *this;
}
this_type& operator-=(const value_type& val)
constexpr this_type& operator-=(const value_type& val)
{
value_ -= val;
return *this;
}
this_type& operator*=(const value_type& val)
constexpr this_type& operator*=(const value_type& val)
{
value_ *= val;
uncertainty_ *= val;
return *this;
}
this_type& operator/=(const value_type& val)
constexpr this_type& operator/=(const value_type& val)
{
value_ /= val;
uncertainty_ /= val;
return *this;
}
this_type& operator+=(const this_type& /*source*/);
this_type& operator-=(const this_type& /*source*/);
this_type& operator*=(const this_type& /*source*/);
this_type& operator/=(const this_type& /*source*/);
constexpr this_type& operator+=(const this_type& /*source*/);
constexpr this_type& operator-=(const this_type& /*source*/);
constexpr this_type& operator*=(const this_type& /*source*/);
constexpr this_type& operator/=(const this_type& /*source*/);
private:
value_type value_,
@@ -122,6 +123,7 @@ namespace units {
template<class Y>
inline
constexpr
measurement<Y>&
measurement<Y>::operator+=(const this_type& source)
{
@@ -133,6 +135,7 @@ measurement<Y>::operator+=(const this_type& source)
template<class Y>
inline
constexpr
measurement<Y>&
measurement<Y>::operator-=(const this_type& source)
{
@@ -144,6 +147,7 @@ measurement<Y>::operator-=(const this_type& source)
template<class Y>
inline
constexpr
measurement<Y>&
measurement<Y>::operator*=(const this_type& source)
{
@@ -157,6 +161,7 @@ measurement<Y>::operator*=(const this_type& source)
template<class Y>
inline
constexpr
measurement<Y>&
measurement<Y>::operator/=(const this_type& source)
{
@@ -171,6 +176,7 @@ measurement<Y>::operator/=(const this_type& source)
// value_type op measurement
template<class Y>
inline
constexpr
measurement<Y>
operator+(Y lhs,const measurement<Y>& rhs)
{
@@ -179,6 +185,7 @@ operator+(Y lhs,const measurement<Y>& rhs)
template<class Y>
inline
constexpr
measurement<Y>
operator-(Y lhs,const measurement<Y>& rhs)
{
@@ -187,6 +194,7 @@ operator-(Y lhs,const measurement<Y>& rhs)
template<class Y>
inline
constexpr
measurement<Y>
operator*(Y lhs,const measurement<Y>& rhs)
{
@@ -195,6 +203,7 @@ operator*(Y lhs,const measurement<Y>& rhs)
template<class Y>
inline
constexpr
measurement<Y>
operator/(Y lhs,const measurement<Y>& rhs)
{
@@ -204,6 +213,7 @@ operator/(Y lhs,const measurement<Y>& rhs)
// measurement op value_type
template<class Y>
inline
constexpr
measurement<Y>
operator+(const measurement<Y>& lhs,Y rhs)
{
@@ -212,6 +222,7 @@ operator+(const measurement<Y>& lhs,Y rhs)
template<class Y>
inline
constexpr
measurement<Y>
operator-(const measurement<Y>& lhs,Y rhs)
{
@@ -220,6 +231,7 @@ operator-(const measurement<Y>& lhs,Y rhs)
template<class Y>
inline
constexpr
measurement<Y>
operator*(const measurement<Y>& lhs,Y rhs)
{
@@ -228,6 +240,7 @@ operator*(const measurement<Y>& lhs,Y rhs)
template<class Y>
inline
constexpr
measurement<Y>
operator/(const measurement<Y>& lhs,Y rhs)
{
@@ -237,6 +250,7 @@ operator/(const measurement<Y>& lhs,Y rhs)
// measurement op measurement
template<class Y>
inline
constexpr
measurement<Y>
operator+(const measurement<Y>& lhs,const measurement<Y>& rhs)
{
@@ -245,6 +259,7 @@ operator+(const measurement<Y>& lhs,const measurement<Y>& rhs)
template<class Y>
inline
constexpr
measurement<Y>
operator-(const measurement<Y>& lhs,const measurement<Y>& rhs)
{
@@ -253,6 +268,7 @@ operator-(const measurement<Y>& lhs,const measurement<Y>& rhs)
template<class Y>
inline
constexpr
measurement<Y>
operator*(const measurement<Y>& lhs,const measurement<Y>& rhs)
{
@@ -261,6 +277,7 @@ operator*(const measurement<Y>& lhs,const measurement<Y>& rhs)
template<class Y>
inline
constexpr
measurement<Y>
operator/(const measurement<Y>& lhs,const measurement<Y>& rhs)
{
@@ -275,7 +292,7 @@ struct power_typeof_helper<measurement<Y>,static_rational<N,D> >
typename power_typeof_helper<Y,static_rational<N,D> >::type
> type;
static type value(const measurement<Y>& x)
static constexpr type value(const measurement<Y>& x)
{
const static_rational<N,D> rat;
@@ -295,7 +312,7 @@ struct root_typeof_helper<measurement<Y>,static_rational<N,D> >
typename root_typeof_helper<Y,static_rational<N,D> >::type
> type;
static type value(const measurement<Y>& x)
static constexpr type value(const measurement<Y>& x)
{
const static_rational<N,D> rat;

View File

@@ -176,6 +176,7 @@ void tiled_multiply_carray_outer(T0* first,
enum { max_value = 1000};
template<class F, class T, class N, class R>
BOOST_CXX14_CONSTEXPR
R solve_differential_equation(F f, T lower, T upper, N steps, R start) {
typedef typename F::template result<T, R>::type f_result;
T h = (upper - lower) / (1.0*steps);
@@ -197,13 +198,13 @@ using namespace boost::units;
struct f {
template<class Arg1, class Arg2> struct result;
double operator()(const double& x, const double& y) const {
BOOST_CONSTEXPR double operator()(const double& x, const double& y) const {
return(1.0 - x + 4.0 * y);
}
boost::units::quantity<boost::units::si::velocity>
operator()(const quantity<si::time>& x,
const quantity<si::length>& y) const {
BOOST_CONSTEXPR operator()(const quantity<si::time>& x,
const quantity<si::length>& y) const {
using namespace boost::units;
using namespace si;
return(1.0 * meters / second -
@@ -330,7 +331,7 @@ int main() {
}
for(int i = 0; i < max_value; ++i) {
for(int j = 0; j < max_value; ++j) {
double diff =
const double diff =
std::abs(ublas_result(i,j) - cresult[i * max_value + j]);
if(diff > ublas_result(i,j) /1e14) {
std::cout << std::setprecision(15) << "Uh Oh. ublas_result("
@@ -348,13 +349,13 @@ int main() {
std::cout << "solving y' = 1 - x + 4 * y with double: ";
boost::timer timer;
for(int i = 0; i < 1000; ++i) {
double x = .1 * i;
const double x = .1 * i;
values[i] = solve_differential_equation(f(), 0.0, x, i * 100, 1.0);
}
std::cout << timer.elapsed() << " seconds" << std::endl;
for(int i = 0; i < 1000; ++i) {
double x = .1 * i;
double value = 1.0/4.0 * x - 3.0/16.0 + 19.0/16.0 * std::exp(4 * x);
const double x = .1 * i;
const double value = 1.0/4.0 * x - 3.0/16.0 + 19.0/16.0 * std::exp(4 * x);
if(std::abs(values[i] - value) > value / 1e9) {
std::cout << std::setprecision(15) << "i = : " << i
<< ", value = " << value << " approx = " << values[i]
@@ -370,7 +371,7 @@ int main() {
std::cout << "solving y' = 1 - x + 4 * y with quantity: ";
boost::timer timer;
for(int i = 0; i < 1000; ++i) {
quantity<si::time> x = .1 * i * seconds;
const quantity<si::time> x = .1 * i * seconds;
values[i] = solve_differential_equation(
f(),
0.0 * seconds,
@@ -380,8 +381,8 @@ int main() {
}
std::cout << timer.elapsed() << " seconds" << std::endl;
for(int i = 0; i < 1000; ++i) {
double x = .1 * i;
quantity<si::length> value =
const double x = .1 * i;
const quantity<si::length> value =
(1.0/4.0 * x - 3.0/16.0 + 19.0/16.0 * std::exp(4 * x)) * meters;
if(abs(values[i] - value) > value / 1e9) {
std::cout << std::setprecision(15) << "i = : " << i

View File

@@ -100,6 +100,7 @@ BOOST_UNITS_DEFINE_CONVERSION_FACTOR(imperial::length_base_unit,
// radar beam height functions
//[radar_beam_height_function_snippet_1
template<class System,typename T>
constexpr
quantity<unit<boost::units::length_dimension,System>,T>
radar_beam_height(const quantity<unit<length_dimension,System>,T>& radar_range,
const quantity<unit<length_dimension,System>,T>& earth_radius,
@@ -112,20 +113,20 @@ radar_beam_height(const quantity<unit<length_dimension,System>,T>& radar_range,
//[radar_beam_height_function_snippet_2
template<class return_type,class System1,class System2,typename T>
constexpr
return_type
radar_beam_height(const quantity<unit<length_dimension,System1>,T>& radar_range,
const quantity<unit<length_dimension,System2>,T>& earth_radius,
T k = 4.0/3.0)
{
// need to decide which system to use for calculation
const return_type rr(radar_range),
er(earth_radius);
return return_type(pow<2>(rr)/(2.0*k*er));
return pow<2>(static_cast<return_type>(radar_range))
/ (2.0*k*static_cast<return_type>(earth_radius));
}
//]
//[radar_beam_height_function_snippet_3
constexpr
quantity<imperial::length>
radar_beam_height(const quantity<nautical::length>& range)
{

View File

@@ -28,7 +28,7 @@ namespace units {
namespace namespace_ { \
typedef make_system<unit_name_ ## _base_unit>::type unit_name_ ## system_; \
typedef unit<dimension_ ## _dimension,unit_name_ ## system_> unit_name_ ## _ ## dimension_; \
static const unit_name_ ## _ ## dimension_ unit_name_ ## s; \
static constexpr unit_name_ ## _ ## dimension_ unit_name_ ## s; \
} \
} \
} \

View File

@@ -55,6 +55,7 @@ I*Z == V? true
using namespace boost::units;
using namespace boost::units::si;
constexpr
quantity<energy>
work(const quantity<force>& F, const quantity<length>& dx)
{