
Boost : 
From: Andy Little (andy_at_[hidden])
Date: 20040110 16:55:06
"Matthias Schabel" <boost_at_[hidden]> wrote in message
news:B53A713E43A311D88726000393DC6706_at_schabelfamily.org...
> >> // test ideal gas law
> >> SI<double>::temperature T = (273.+37.)*_kelvin;
> >> SI<double>::pressure P = 1.01325e5*_pascals;
> >> SI<double>::length r = 0.5e6*_meters;
> >> SI<double>::volume V = (4.0/3.0)*3.141592*power<3>(r);
> >> SI<double>::quantity n(idealGasLaw(P,V,T));
How about ...
q_temperature::K T(273. + 37.);
q_pressure::Pa P(1.01325e5);
q_length::m r(0.5e6);
q_volume::m3 V = (4.0/3.0) * 3.141592 * power<3>(r);
p_quantity<
abstract_pq<
2,2,1,1,0,1,0
>,
double
> const R(8.314); // gasconstant J.mol1.K1
q_substance::mol subst = P * V / (R * T);
I have opted to apply the units at compile time.
Then I can do this:
std::complex<q_voltage::V> V;
std::complex<q_current::A> I;
typedef std::complex<q_resistance::R> impedance;
impedance Z = V / I;
I hope I can get that working in my next version.
> > BTW I looked into your ct problems. VC 7.1 has some neat
> > specialisations.
> > (Doesnt work on gcc)
> > have you tried masks?
> > Basically 7 dimensions > 127 (I think) mask possibilities
> > If interested Will try to look out the code.
>
> Not sure how that will help with userdefined quantities outside of SI.
Don't know, but thought it had some flavour of what you are after.
Its basically a hashmap, with the mask as the hash code.
That may be better than a map. Of course a hashmap is bigger
than a map(exemplified by big header in this case...which is trivial)...
but much faster.
regards
Andy Little
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk