boost-units

Eigen norm() with Boost.Units

旧时模样 提交于 2020-07-18 06:42:29
问题 I am trying to use Boost.Units with Eigen 3.3.1, but after following the instructions here, and some pieces of informations found around, I still cannot figure out how to make norm() work. Here is what I have so far (sorry for the long code block): #include <boost/units/quantity.hpp> #include <boost/units/systems/si/length.hpp> #include <boost/units/systems/si/area.hpp> #include <boost/units/cmath.hpp> #include <Eigen/Geometry> namespace Eigen { //specialization of numeric traits using boost:

Eigen norm() with Boost.Units

时光总嘲笑我的痴心妄想 提交于 2020-07-18 06:42:18
问题 I am trying to use Boost.Units with Eigen 3.3.1, but after following the instructions here, and some pieces of informations found around, I still cannot figure out how to make norm() work. Here is what I have so far (sorry for the long code block): #include <boost/units/quantity.hpp> #include <boost/units/systems/si/length.hpp> #include <boost/units/systems/si/area.hpp> #include <boost/units/cmath.hpp> #include <Eigen/Geometry> namespace Eigen { //specialization of numeric traits using boost:

Millimeters in boost::units

99封情书 提交于 2020-01-11 02:20:47
问题 I want to use boost::units for some SI metrics. However our code mostly deals with millimeters and instead of using quantity<length> value = 1*milli*meter; we would prefer something like quantity<length> value = 1*millimeter; However I am not sure how to define "millimeter" (without using #define). Secondly, what is the overhead in using prefixed units? Update: This needs to run without C++11 features (i.e. no UDL) 回答1: I am using the following approach: // your namespace name for units

How to properly define a derived unit in Boost Unit

随声附和 提交于 2019-12-11 06:54:23
问题 I am trying to create a derived_dimension in boost::units for mass flow rate for si system. I cannot find any documentation on how to do this simple task. This is what I have so far but I am getting errors during the compilation. typedef boost::units::derived_dimension< boost::units::mass_base_dimension, 3, boost::units::time_base_dimension, -1 >::type mass_flow_rate_dimension; typedef boost::units::unit< mass_flow_rate_dimension, boost::units::si::system > mass_flow_rate_unit; typedef boost:

Add minutes and seconds. Display in hours

会有一股神秘感。 提交于 2019-12-10 22:53:14
问题 Let's suppose I'd like to add 29 minutes and 60 seconds and display the result in hours. Here's something that appears to work: cout << static_cast<quantity<hour_base_unit::unit_type>> (quantity<time>{29.0 * minute_base_unit::unit_type()} + 60.0 * seconds) << endl; The following is displayed on the console: 0.5 h Is this the recommended approach? Is there a better or more idiomatic way? The entire program illustrating the above example is below. #include <iostream> #include <boost/units

How does Boost.Units come up with this imprecise result of conversion?

ぐ巨炮叔叔 提交于 2019-12-10 17:22:43
问题 Consider the following code: #include <boost/units/io.hpp> #include <boost/units/systems/si/plane_angle.hpp> #include <boost/units/systems/angle/degrees.hpp> #include <iostream> #include <cmath> #include <limits> int main() { using namespace boost::units; std::cout.precision(std::numeric_limits<double>::digits10); std::cout << "Everyone knows that 180 deg = " << std::acos(-1.) << " rad\n"; std::cout << "Boost thinks that 180 deg = " << quantity<si::plane_angle,double>(180.*degree::degree) <<

Casting boost::units::quantity to double

橙三吉。 提交于 2019-12-10 13:25:05
问题 I need to pass the value of a quantity to a library for evaluation. The boost units library takes double values in SI, so the boost units library is very appealing in ensuring that requirement. However, how should I cast the quantity to a double value? The documentation and example seems to avoid this since the intent is to, rightfully so, maintain the units. Something like: quantity<pressure> p(101.1 * kilo * pascals); double dblP = static_cast<double>(p); // double value in Pascals Going

Passing runtime parameters to odeint integrator

点点圈 提交于 2019-12-02 03:45:12
I would like to use the odeint boost integrator to look at geodesic curves in the Kerr spacetime. This necessitates running an integrator for a variety of parameter values (I have initial conditions and initial momentum vectors so the angular momentum of the system will vary depending how I would like to start it) I've been following the excellent examples laid out here http://headmyshoulder.github.io/odeint-v2/examples.html specifically the Lorenz attractor example. The first thing I note (in my Kerr system, not the Lorenz) is that for some initial conditions I get NaN after the t=0 time

Passing runtime parameters to odeint integrator

一笑奈何 提交于 2019-12-02 02:52:32
问题 I would like to use the odeint boost integrator to look at geodesic curves in the Kerr spacetime. This necessitates running an integrator for a variety of parameter values (I have initial conditions and initial momentum vectors so the angular momentum of the system will vary depending how I would like to start it) I've been following the excellent examples laid out here http://headmyshoulder.github.io/odeint-v2/examples.html specifically the Lorenz attractor example. The first thing I note

Millimeters in boost::units

大兔子大兔子 提交于 2019-11-30 20:35:17
I want to use boost::units for some SI metrics. However our code mostly deals with millimeters and instead of using quantity<length> value = 1*milli*meter; we would prefer something like quantity<length> value = 1*millimeter; However I am not sure how to define "millimeter" (without using #define). Secondly, what is the overhead in using prefixed units? Update: This needs to run without C++11 features (i.e. no UDL) I am using the following approach: // your namespace name for units namespace outernamespace { namespace millimeter_system { typedef boost::units::scaled_base_unit<boost::units::si: