Noah said:
Can the developer easily define new units of a particular dimension?
It depends how you quantify easy. Its easy for me because its my
library I guess, and I could document it better. Anyway heres one way:
// header for si lengths etc with stream output
#include <quan/out/length.hpp>
#include <quan/out/area.hpp>
// Create a custom conversion factor.
// First rational is the exponent.
// Second is the multiplier,
// so the scaling factor to (e.g) meters
// is 10^ exponent * multiplier.
// Here we create a half a meter type
typedef quan::meta::conversion_factor<
quan::meta::rational said:
// Now create a fixed_quantity
// of required dimension
// with the half a meter conversion factor
typedef quan::fixed_quantity<
quan::meta::unit<
quan::meta::components::
of_length::abstract_quantity,
half_si_unit
// half_a_meter is a non SI unit
// so requires its own overload
// if stream output is required...
namespace quan{namespace meta{
inline std:

stream& operator <<(
std:

stream & os,
unit<
components:

f_length
::abstract_quantity,
half_si_unit
)
{
return os << "half meter";
}
}}//quan::meta
// now use ...
int main()
{
// create a variable of
// a Quan predefined length type
// for comparison
quan::length::m si_length(10);
// create a variable of
// user define half a meter length type...
half_a_meter odd_length = si_length;
// and use..
std::cout << "SI length of: " << si_length
<< " = " << odd_length << ".\n";
std::cout << "Ratio of SI length to odd length = "
<< si_length / odd_length << ".\n";
// do some calcs...
quan::area::m2 area = quan:

ow<2>(odd_length);
std::cout << "Area of a square of side " << odd_length
<< " = " << area << ".\n";
}
/*output:
SI length of: 10 m = 20 half meter.
Ratio of SI length to odd length = 1.
Area of a square of side 20 half meter = 100 m2.
*/
Can the user define new units (non-static) that work with your
dimensional quantities?
Currently I have only defined the fixed_quantity type where the units
are fixed.
The goal of fixed_quantity is to compete with double in performance.Its
a competetion I dont think I will ever actually win in, but at least
try to match them So far it seems to match doubles in a lot of cases ,
except where UDT contants are used, in place of e.g ints. Whether I can
eliminate that I don't know.
I had planned two other types, one where the unit can be runtime
modified and one where the unit and dimension could be, but so far I
havent implemented those as I am currently figuring how to get matrices
to work so that you can directly use physical quantities in matrix
calcs.
You can see the work in progress here. I'm using static doubles here ,
but Quan quantities will work equally as well, as long as you get the
dimensional analysis correct!
http://tinyurl.com/qp56p
The other thing I want is some graphics output to show off Quan, so I
am working on that too.
Because the answer seems to be no on both of those Quan doesn't work
for my, or many other, needs. It also seems overly complex for the
task.
Maybe, but it has a lot of functionality, and you will find that the
subject is more complicated than you think. Much of the bulk is due to
having predefined quantities:
http://tinyurl.com/ox3aa
There are a lot, but you only need to include the ones you need so they
only take disk space unless you actually use them.
It is cute, I'll give it that. I liked the rational number metaprogram
but then that actually comes from a different library that tries to do
the same thing.
Well, I'm not quite sure what you mean about 'different library'? The
quan::meta::rational is very handy:
http://tinyurl.com/olwfj
It was originally written by Matthias Schabel for use in his mcsunits
library, but it has had a lot of mods since. Is that what you mean?
Last I heard he was quite keen on some of the Quan stuff and was
considering moving his library to a similar approach, but you would
need to ask him about that.
On the other hand I think its coolness factor
outweighs its usefulness.
Well, at least its cool

. And of course I think its useful too. It
makes coding a lot easier.
It is good for study but I'm still working on my own.
Sure... Go for it
regards
Andy Little