Questions tagged [boost-units]

67 questions
2
votes
1 answer

How to convert boost::units::metric::hour_base_unit to boost::units::si::time?

I would like to make the following code compile properly: #include #include int main(int argc, char **argv) { using namespace boost::units; quantity t = 2.0 *…
João Leal
  • 123
  • 1
  • 7
2
votes
0 answers

Mixing scaled and derived units un boost::units

I would like to use a boost::units in a project to use dimensional analysis and automatic conversions between unit systems. I would like to express quantities in the code with standard engineering units, that are often scaled versions of other…
maxdebayser
  • 1,066
  • 7
  • 10
2
votes
2 answers

How to store a boost::quantity with possible different boost::dimension

I am using boost::units library to enforce physical consistency in a scientific project. I have read and tried several examples from boost documentation. I am able to create my dimensions, units and quantities. I did some calculus, it works very…
jlandercy
  • 7,183
  • 1
  • 39
  • 57
2
votes
2 answers

Simplest way to convert between two quantities with Boost::units?

If I just want to convert a value from one unit to another, what's the simplest (ideally one-line) way of doing this? For instance, i want to store a value in meters, but specify it in miles. Most examples for doing this seem to be many lines long,…
Riot
  • 15,723
  • 4
  • 60
  • 67
2
votes
1 answer

How to define a derived dimension from another derived dimension in Boost Units?

In my business field, I have values that are expressed as W.mˆ-2.Kˆ-1. In a 'base dimensions' point of view, these values are expressed as kg.sˆ-3.Kˆ-1 (W = kg.mˆ2.sˆ-3) How do I implement this dimension and this unit with Boost Unit? The only…
Mankalas
  • 390
  • 4
  • 13
2
votes
1 answer

Using Boost.Units and Boost.Multiprecision

I am attempting to write a molecular dynamics program, and I thought that Boost.Units was a logical choice for the variables, and I also decided that Boost.Multiprecision offered a better option than double or long double with respect to round off…
Tim
  • 107
  • 1
  • 10
2
votes
2 answers

Boost Units Usage Questions - hash_value, count multiplication

I'm trying to teach myself Boost Unit, but I am having some problems when it comes to using units as a float replacement. I'm using a custom dalton/amu unit for calculations. My old code works like float baseMass = 14.95; float totalMass =…
notwithoutend
  • 235
  • 1
  • 9
1
vote
1 answer

Unable to identify solution to compiler error using Boost Units

Boost Units version: 1.45 Compiler: Visual Studio 2008 Platform: Windows 7 Error: When compiling the following code I get an error C2440 "initializing' : cannot convert from 'boost::units::quantity' to 'boost::units::quantity'…
Stephen
  • 71
  • 1
  • 4
1
vote
1 answer

how to keep unit conversions in boost::units in single-precision floats?

I have aliases for radians and degrees that use float as the storage type. When I convert between these two units I see the assembly promote the values to doubles and then back to floats when doing conversions. Q: How can I make sure that all…
CJCombrink
  • 3,738
  • 1
  • 22
  • 38
1
vote
1 answer

boost::hash for tuple containing boost units

I want to use a tbb::concurrent_hash_map with a key of std::tuple where A... will include boost unit types. The HashCompare struct I'm using at the moment looks like this: template struct HashCompare { static size_t hash( const…
Lorico
  • 25
  • 5
1
vote
1 answer

Can I retrieve base units from divide_typeof_helper?

We did define the relevant units (base and derived) that we plan to use in our application. Some derived units have been defined using divide_typeof_helper (e.g km_per_hour_unit for speed quantities). using namespace boost::units; namespace…
BaroneAshura
  • 191
  • 1
  • 1
  • 14
1
vote
1 answer

Computations using derived units

I used this approach in order to define a new derived dimension mass flow which should have units kg / s: include #include #include #include #include…
hfhc2
  • 4,182
  • 2
  • 27
  • 56
1
vote
1 answer

conversion factor for units in boost.units

I just started using boost-units, and I am trying to understand what code I should write to get the conversion factor between units. Following the Runtime Units Example, I managed to get what I need for base_units. As an example, for length I can…
BaroneAshura
  • 191
  • 1
  • 1
  • 14
1
vote
1 answer

How to use Boost.Unit with ratios in the same unit

I have a very simple use case for using Boost.Unit, but not sure if there is a better/easier way to get the same done. I want to convert between the same units, but different ratios. For example, hertz to kilohertz to megahertz. From my…
CJCombrink
  • 3,738
  • 1
  • 22
  • 38
1
vote
1 answer

How to properly define a derived unit in Boost Unit

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…
A.Agan
  • 103
  • 6