|
Boost : |
From: Andy Little (andy_at_[hidden])
Date: 2004-01-18 18:40:07
Hi,
The latest version of pqs, 'pqs-100-02' is up on the files section...
'pqs' directory. This version uses rational powers derived from
static_rationals as shown in the example. Tested on VC7.1 and gcc3.2. Also
includes in examples a runtime modifiable quantity using the p_quantity type
as a basis and a very quick demo of an impedance using
std::complex<q_resistance::R> Z=V/I ;//etc, which I hope to do more on.
The fact that it was actually relatively easy to modify the code for
rationals rather than integer 'powers-of-dimension' (involving the
'abstract' part of the type)suggests that, implementation of 'user defined'
dimensions systems may not be too complicated in this and other versions of
D.A./units types... Will be yet easier when integrated better with MPL. The
major work in a user-defined system would seem to be input/output which
probably needs to be implemented at least for debug purposes.
In this version of pqs there are some traces of MPL showing through, but
nothing too major yet. Some huge improvements have been made over the
original version,pqs-1-00-00 both in terms of run-time speed and numeric
accuracy.There is also a distinct lack of testing. I need to spend time how
boost goes about its tests. Also there are as yet no user-configurable
conversions, or safe numeric conversions. I hope to work on those in the
near future.
Next job is to make the units into a type parameter and the value_type into
a value_type_traits, with the goal of user configurability in both these
areas. and of course ... get on with improving the documentation.
regards
Andy Little
--------------------------
//demo showing changed layout of constants defined in source code
int main()
{
q_temperature::K T(310);
q_pressure::Pa P(1.01325e5);
q_length::m r(0.5e-6);
q_volume::m3 V = 4/3 * 3.141592 * power<3>(r);
p_quantity< //raw pq used as a contant
abstract_pq<
length_pwr<2>,
time_pwr<-2>,
mass_pwr<1>,
temperature_pwr<-1>,
current_pwr<0>,
substance_pwr<-1>,
intensity_pwr<0>
>,
double
> const R(8.314); // gas constant
q_substance::mol subst = P * V /(R * T);
std::cout << subst << '\n';
}
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk