Questions tagged [boost-units]
67 questions
3
votes
1 answer
Eigen norm() with Boost.Units
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…

matpen
- 281
- 2
- 15
3
votes
2 answers
Passing runtime parameters to odeint integrator
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…

zylatis
- 448
- 3
- 14
3
votes
1 answer
multiplying a scalar by a boost.units.quantity (automatic type conversion issues?)
This is a really minimalist example. I'm using Boost.Units in the following way:
#define REAL double
...
using namespace boost::units;
quantity v;
then sometimes I need to have something like
quantity…

sinad
- 137
- 10
2
votes
1 answer
How do I assign a value to a boost::units::si::angular_acceleration?
In boost units, I usually assign values by multiplying with one of the static consts:
e.g.
using namespace boost::units;
quantity av = 0.5 * si::radians_per_second;
But how can I do it when there is no multiplier const…

Matthew Smith
- 6,165
- 6
- 34
- 35
2
votes
1 answer
How to make scaled units in Boost Units convertable to string
I want to define the unit Watt hours which has the same dimensions as Joule but needs a conversion factor of 3600. Therefore, I want to define it as a scaled unit.
I've defined my unit as follows:
namespace si = boost::units::si;
typedef…

nbwbx
- 23
- 4
2
votes
0 answers
Forward Declarations of recursive templates using Boost::Units
as i am seeking to reduce the compile times of our code, i am currently trying to reduce heavy includes in header files. For this, i am forward declaring function parameters as in this example:
// Class A.h
class B;
class A
{
...
void…

SegfaultCreator
- 21
- 1
2
votes
1 answer
How to do numeric differentiation using Boost Units?
I would like to perform a numeric differentiation in C++. For type safety, I'd like to use boost::units to avoid mixing units but also boost::units::absolute to avoid mixing relative and absolute units.
A minimal example is to calculate the velocity…

user2968115
- 135
- 9
2
votes
1 answer
Using boost units: Is it possible to formulate a cast to dimensionless for composite types
We want to use boost::units for strong types but also resort to dimensionless types for compatibility e.g. with other libraries.
Is there any way to implement this in a generic fashion ?
Something along the lines of the following code
(which…

Martin
- 4,738
- 4
- 28
- 57
2
votes
1 answer
Converting between boost units and durations
I am working on a project involving many measurements and I would like to use boost units to ensure that units are converted correctly. I started by introducing some typedefs to simplify notation:
#include
#include…

hfhc2
- 4,182
- 2
- 27
- 56
2
votes
1 answer
Electron volts with boost::units?
Does boost::units have an option to express energy in electron volts (eV)? I can't seem to find the right header file for that

T-Rex96
- 355
- 4
- 15
2
votes
0 answers
Run-time overhead with boost.units?
I'm seeing some 10% run-time overhead when using a clone of a constexpr enhanced boost.units with the float value type using clang and -O3 level optimization. This is showing up with some of the more elaborate applications of a library that I've…

Louis Langholtz
- 2,913
- 3
- 17
- 40
2
votes
1 answer
Get power of base unit of a given quantity with boost-unit
I'm trying to figure out if boost-unit can be used in one of my projects. With most of the functions I'm quite satisfied. But one features I'm really unable to make on my own.
Especially, I'm looking for an easy to use function that gives me the…

Aleph0
- 5,816
- 4
- 29
- 80
2
votes
1 answer
Add minutes and seconds. Display in hours
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

dharmatech
- 8,979
- 8
- 42
- 88
2
votes
1 answer
Boost heterogeneous unit - Bar per Minute
I need to create a unit which represents pressure per time, specifically Bar per Minute.
I tried creating it in the same way as I created similar units before:
typedef boost::units::derived_dimension

Dina
- 1,346
- 1
- 15
- 35
2
votes
0 answers
Enforcing rational-based conversions between custom-unit-based quantities in Boost.Units
I have a custom unit system defined, which derives from boost::units::si::time.
Child units are defined using boost::units::make_scaled_unit, hence the conversion factors are specified using boost::units::scale and boost::units::static_rational,…

Wojciech Migda
- 738
- 7
- 16