Boost logo

Boost Users :

Subject: [Boost-users] [units] conversion_factor in the two directions
From: alfC (alfredo.correa_at_[hidden])
Date: 2010-02-25 23:05:04


Hi,

 I managed to make CONVERSION_FACTOR definitions to work between to
unit systems (atomic and SI). I definied atomic system by following
the si example. I can manage to transform lengths (probably because
they are base dimensions in both systems, but when I try to do the
same for energies (that is a base_dimension only in the atomic system)
I can't compile the line with the declaration "en3".

The first question is why the first ...CONVERSION_FACTOR doesn't work
in the two directions (as it did for lengths). second, why the
second ...CONVERSION_FACTOR doesn't help to compile en3.

BOOST_UNITS_DEFINE_CONVERSION_FACTOR(
        atomic::hartree_energy_base_unit,
        si::energy,
        double, 4.359744e-18
);

//compiles but doesn't help for en3
BOOST_UNITS_DEFINE_CONVERSION_FACTOR(
        si::energy,
        atomic::hartree_energy_base_unit,
        double, 1./4.359744e-18
);

int main(){
        quantity<si::length> l1(1.*si::meter); //works
        quantity<si::length> l2(1.*atomic::bohr); //works
        quantity<atomic::length> l3(1.*atomic::bohr); //works
        quantity<atomic::length> l4(1.*si::meter); //works

        quantity<si::energy> en1(1.*si::joules); //works
        quantity<si::energy> en2(1.*atomic::hartree); //works
        quantity<atomic::energy> en3(1.*atomic::hartree); //work
        quantity<atomic::energy> en4(1.*si::joules); //does not work,
compilation error
        return 0;
}

Thank you,
Alfredo


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net