31 std::fill(exponents_.begin(), exponents_.end(), 0);
61 return dimensionless();
139 return unit_symbols[idx];
145 ASSERT(is_def()).error(
"UnitSI object must be defined!");
147 std::stringstream output;
170 if (output.str().size() > 0) output << form.
delimiter;
171 output << unit_symbol(i);
172 if (exponents_[i] != 1) output << form.
exp_open << exponents_[i] << form.
exp_close;
175 if (output.str().size()==0) {
186 for(
unsigned int i=0; i < n_base_units; i++ ) {
187 if (i!=0) ss <<
", ";
206 for(
unsigned int i=0; i < n_base_units; i++ ) {
213 std::fill(exponents_.begin(), exponents_.end(), 0);
219 double coef = converter.
convert(actual_unit);
221 if ( converter.
unit_si() == (*
this) ) {
224 THROW( ExcNoncorrespondingUnit() << EI_UnitDefinition(converter.
unit_si().
format_text()) << EI_ExpectedUnit(this->format_text()) );
240 for (
unsigned int i=0; i<7; i++) {
253 for (
unsigned int i=0; i<7; i++) {
UnitSI unit_si() const
Return unit_si_.
double convert(std::string actual_unit)
Class for representation SI units of Fields.
std::vector< int > exponents_
bool operator==(const UnitSI &other) const
Comparison operator.
std::string format_text() const
std::string format_latex() const
static const std::string & unit_symbol(unsigned int idx)
static UnitSI & J()
Returns Joule.
void undef(bool val=true)
bool is_def() const
Return true if the unit is defined.
static UnitSI & one()
Returns dimensionless unit.
static UnitSI & W()
Returns Watt.
UnitSI & m(int exp=1)
Methods set values of exponents for SI units with similar name.
double convert_unit_from(std::string actual_unit) const
Convert and check user-defined unit.
void reset()
Reset UnitSI object (set vector of exponents to zeros and set undef flag)
static UnitSI & dimensionless()
Returns dimensionless unit.
UnitSI & md(int exp=-1)
The dimension dependent meter: md^y = m^(yd), where 'd' is dimension.
void multiply(const UnitSI &other, int exp=1)
Multiply with power of given unit.
std::string format(OutputFormat form) const
Generic output formating method.
static UnitSI & Pa()
Returns Pascal.
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.
manipulators::Array< T, Delim > format(T const &deduce, Delim delim=", ")
UnitSI operator*(const UnitSI &a, const UnitSI &b)
Product of two units.
UnitSI operator/(const UnitSI &a, const UnitSI &b)
Proportion of two units.