$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Andy Little (andy_at_[hidden])
Date: 2004-01-10 16:55:06
"Matthias Schabel" <boost_at_[hidden]> wrote in message
news:B53A713E-43A3-11D8-8726-000393DC6706_at_schabel-family.org...
> >>      // test ideal gas law
> >>      SI<double>::temperature    T = (273.+37.)*_kelvin;
> >>      SI<double>::pressure       P = 1.01325e5*_pascals;
> >>      SI<double>::length         r = 0.5e-6*_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.5e-6);
  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); // gas-constant  J.mol-1.K-1
  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 user-defined 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