29 std::fill(exponents_.begin(), exponents_.end(), 0);
59 return dimensionless();
137 return unit_symbols[idx];
143 ASSERT(is_def()).error(
"UnitSI object must be defined!");
145 std::stringstream output;
150 if (exponents_[
UnitSI::order_m ]!=1 || exponents_[ UnitSI::order_md ]) {
154 if (exponents_[ UnitSI::order_md ]>0) output <<
"+";
156 if (exponents_[ UnitSI::order_md ]) {
157 if (exponents_[ UnitSI::order_md ]==-1) output <<
"-";
158 else if (exponents_[ UnitSI::order_md ]!=1) output << exponents_[
UnitSI::order_md ];
168 if (output.str().size() > 0) output << form.
delimiter;
169 output << unit_symbol(i);
170 if (exponents_[i] != 1) output << form.
exp_open << exponents_[i] << form.
exp_close;
173 if (output.str().size()==0) {
184 for(
unsigned int i=0; i < n_base_units; i++ ) {
185 if (i!=0) ss <<
", ";
209 for (
unsigned int i=0; i<7; i++) {
222 for (
unsigned int i=0; i<7; i++) {
std::string format(OutputFormat form) const
Generic output formating method.
bool is_def() const
Return true if the unit is defined.
std::string format_text() const
std::vector< int > exponents_
static UnitSI & Pa()
Returns Pascal.
static UnitSI & one()
Returns dimensionless unit.
std::string format(CStringRef format_str, ArgList args)
std::string format_latex() const
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library...
UnitSI operator*(const UnitSI &a, const UnitSI &b)
Product of two units.
UnitSI operator/(const UnitSI &a, const UnitSI &b)
Proportion of two units.
static UnitSI & W()
Returns Watt.
static UnitSI & J()
Returns Joule.
static const std::string & unit_symbol(unsigned int idx)
UnitSI & m(int exp=1)
Methods set values of exponents for SI units with similar name.
Class for representation SI units of Fields.
UnitSI & md(int exp=-1)
The dimension dependent meter: md^y = m^(yd), where 'd' is dimension.
static UnitSI & dimensionless()
Returns dimensionless unit.
void undef(bool val=true)