1 #ifndef ARRAY_WITH_UNIT_H 2 #define ARRAY_WITH_UNIT_H 6 #include <blitz/array.h> 14 template<
class T,
int D>
16 boost::field_operators<ArrayWithUnit<T, D> > {
23 ArrayWithUnit(
const blitz::Array<T, D>& Value,
const std::string& Value_units_name)
24 :
value(Value.copy()),
units(Value_units_name) { }
33 { value.reference(V.
value.copy()); units = V.
units;
return *
this;}
39 { value *= V.
value; units *= V.
units;
return *
this;}
41 { value /= V.
value; units /= V.
units;
return *
this;}
73 template<
class I,
class J>
77 template<
class I,
class J>
80 template<
class I,
class J>
83 template<
class I,
class J>
87 template<
class I,
class J>
90 template<
class I,
class J>
93 template<
class I,
class J>
128 int rows()
const {
return value.rows();}
129 int cols()
const {
return value.cols();}
130 int depth()
const {
return value.depth();}
132 void print(std::ostream& Os)
const {
133 Os <<
"ArrayWithUnit:\n" 134 <<
"Value: " << value <<
"\n" ArrayWithUnit< T, D > & operator*=(const ArrayWithUnit< T, D > &V)
Basic math operators for class.
ArrayWithUnit(const blitz::Array< T, D > &Value, const std::string &Value_units_name)
DoubleWithUnit operator()(int i1, int i2, int i3, int i4) const
DoubleWithUnit operator()(int i1) const
We frequently have a array of numbers with units associated with them.
ArrayWithUnit< T, D-1 > operator()(J i1, I i2, I i3) const
ArrayWithUnit< T, D > operator()(I i1, I i2) const
ArrayWithUnit< T, D-2 > operator()(J i1, I i2, J i3) const
double conversion(const Unit &Dunit_from, const Unit &Dunit_to)
Return conversion factor to go from one unit to another.
ArrayWithUnit< T, D-1 > operator()(I i1, J i2) const
This is a Mixin for classes that can be printed.
blitz::Array< T, D > value
ArrayWithUnit< T, D > operator()(I i1, I i2, I i3) const
ArrayWithUnit< T, D > & operator+=(const ArrayWithUnit< T, D > &V)
ArrayWithUnit< T, D > & operator-=(const ArrayWithUnit< T, D > &V)
ArrayWithUnit< T, D > operator()(I i1, I i2, I i3, I i4) const
DoubleWithUnit operator()(int i1, int i2) const
ArrayWithUnit< T, D-2 > operator()(I i1, J i2, J i3) const
We frequently have a double with units associated with it.
ArrayWithUnit< T, D-2 > operator()(J i1, J i2, I i3) const
DoubleWithUnit operator()(int i1, int i2, int i3) const
ArrayWithUnit< T, D > & operator/=(const ArrayWithUnit< T, D > &V)
ArrayWithUnit< T, D > operator()(I i1) const
ArrayWithUnit< T, D-1 > operator()(I i1, J i2, I i3) const
ArrayWithUnit< T, D > & operator=(const ArrayWithUnit< T, D > &V)
Assignment operator so internals are correctly set.
Libraries such as boost::units allow unit handling where we know the units at compile time...
bool is_commensurate(const Unit &Units) const
Test if this set of units is commensurate with another set.
Contains classes to abstract away details in various Spurr Radiative Transfer software.
void print(std::ostream &Os) const
ArrayWithUnit< T, D-1 > operator()(I i1, I i2, J i3) const
ArrayWithUnit(const blitz::Array< T, D > &Value, const Unit &Value_units)
ArrayWithUnit< T, D > convert_wave(const Unit &R) const
We often need to handle conversion from wavenumber to/from wavelength.
ArrayWithUnit< T, D > convert(const Unit &R) const
Convert to the given units.
ArrayWithUnit(const ArrayWithUnit< T, D > &V)