5#include "boost/algorithm/string.hpp"
7#include "unicode/unistr.h"
8#include "unicode/uchar.h"
25 set<string>
dimension::prefixes_options {
"Q",
"R",
"Y",
"Z",
"E",
"P",
"T",
"G",
"M",
"k",
"h",
"d",
"c",
"m",
"\u00B5",
"u",
"n",
"p",
"f",
"a",
"z",
"y",
"r",
"q"};
36 dimension::dimension(dimension&& x) : prefix(std::move(x.prefix)),dimension_type(std::move(x.dimension_type)),dimension_position(std::move(x.dimension_position))
38 std::strncpy(
symbol, std::move(x.symbol), 3);
41 dimension::dimension(
const dimension& x) : prefix(x.prefix),dimension_type(x.dimension_type),dimension_position(x.dimension_position)
43 strncpy_s(
symbol, x.symbol, 3);
46 dimension::dimension(dimension&& x) : prefix(std::move(x.prefix)),dimension_type(std::move(x.dimension_type)),dimension_position(std::move(x.dimension_position))
48 strncpy_s(
symbol, std::move(x.symbol), 3);
332 prefix = std::move(x.prefix);
335 std::strncpy(
symbol,std::move(x.symbol),3);
344 strncpy_s(
symbol,x.symbol,3);
350 prefix = std::move(x.prefix);
353 strncpy_s(
symbol,std::move(x.symbol),3);
441 return "astronomical unit";
445 return "electron volt";
449 return "atomic mass unit";
457 return "custom-dimension";
459 return "custom-basic";
461 return "custom-full-symbol";
469 return "international-unit";
471 return "milliequivalent";
564 return "light years";
566 return "astronomical units";
570 return "electron volts";
574 return "atomic mass units";
582 return "custom-dimension";
584 return "custom-basic";
586 return "custom-full-symbol";
594 return "international-units";
596 return "milliequivalents";
724 return "custom-basic";
752 return std::numbers::pi_v<float> / 180.0l;
824 return 9.4607379375591e15;
826 return 149597870700.0l;
828 return 30856775814913673.0l;
830 return 0.0000000000000000001602176634l;
832 return 0.00000000000000000000000000166053886l;
834 return 0.00000000000000000000000000166053886l;
836 return 0.0000000000000000000000000001l;
872 return std::pow(1024,
x_prefix.get_conversion_factor() / 3);
876 return std::pow(10,
x_prefix.get_conversion_factor());
1901 return "[\frac{" +
out.str();
1905 return "\frac{" +
out.str();
1912 return "[" +
out.str();
2042 for(
unsigned int i = 0;
i < x.size();
i++)
2060 for(
unsigned int i = 0;
i < x.size();
i++)
2064 value *= x[
i].get_conversion_factor();
2065 value *= x[
i].prefix_math();
2069 value /= x[
i].get_conversion_factor();
2070 value /= x[
i].prefix_math();
2127 if ((
x_count.second % index) != 0)
2139 value *= x[
i].get_conversion_factor();
2140 value *= x[
i].prefix_math();
2144 value /= x[
i].get_conversion_factor();
2145 value /= x[
i].prefix_math();
2206 if (
new_x.size() == 1)
2211 for(
unsigned int i = 0;
i <
new_x.size();
i++)
2213 for(
unsigned int j =
i + 1;
j <
new_x.size();
j++)
2240 for(
unsigned int i = 0;
i <
new_x.size();
i++)
2262 if (
new_x.size() == 1)
2267 for(
unsigned int i = 0;
i <
new_x.size();
i++)
2269 for(
unsigned int j =
i + 1;
j <
new_x.size();
j++)
2316 for(
unsigned int i = 0;
i <
new_x.size();
i++)
2379 if (
skip.size() > 0)
2381 for (
unsigned int k = 0;
k <
skip.size();
k++)
2416 if (x.size() == y.size())
2421 for (
unsigned int j = 0;
j < y.size();
j++)
2424 if (
skip.size() > 0)
2426 for (
unsigned int k = 0;
k <
skip.size();
k++)
Class that represents dimensions of the SI system of units. Each dimension sizes 6 bytes,...
bool is_dimensionless() const
If the dimension_type is DEGREE, RADIAN or STERADIAN, it's considered dimensionless,...
position
Represents the position of the dimension, which can be at the numerator or at the denominator....
@ DENOMINATOR
The dimension is at the denominator.
@ NUMERATOR
The dimension is at the numerator.
dimension & operator=(const dimension &x)
Copy assignment. The dimension copies the dimension x.
string get_fullplural() const
Returns the plural of the dimension with the name of the prefix first.
bool is_composite_dimension() const
If the dimension has more simple dimensions, it's a composite dimension.
string get_name() const
Returns the name of the dimension.
scifir::prefix prefix
The prefix of the dimension. It's used along with the symbol of the dimension when printing it.
dimension::position dimension_position
The position of the dimension, which can be the NUMERATOR, the DENOMINATOR or NO_POSITION....
bool is_base_dimension() const
Returns true if the dimension is a base dimension, which includes all base dimensions of the SI syste...
char symbol[3]
The value of the position of the character of a custom dimension in the map of full_symbols.
string get_fullname() const
Returns the name of the dimension with the name of the prefix first.
bool is_SI_derived_dimension() const
If the dimension is not a SI base dimension, it's considered a SI derived dimension.
static int total_full_symbols
dimension::type dimension_type
The type of the dimension.
static map< string, vector< dimension > > base_dimensions
bool is_SI_base_dimension() const
Returns true if the dimension is a SI base dimension. Following the SI system of units,...
bool is_simple_dimension() const
If the dimension doesn't has more base dimensions, it's a simple dimension.
type
Represents a dimension of the SI system of units. All the dimensions of the SI system of units are su...
@ MOLARITY
Molarity, plural molarities. The derived dimensions are mol / L. Dimension of concentration of a chem...
@ NONE
No dimension. Default value for the default constructor.
@ BECQUEREL
Becquerel, plural becquerels. The derived dimensions are 1 / s. Dimension of radioactivity....
@ KATAL
Katal, plural katals. The derived dimensions are mol / s. Dimension of catalytic activity....
@ LITRE
Litre, plural litres. The derived dimensions are dm3. Dimension of volume. Symbol L.
@ LUMEN
Lumen, plural lumens. The derived dimensions are cd * sr Dimension of luminous flux....
@ MEMO
Memo, plural memos. Invented unit inside Scifir, it's not part of the SI system of units....
@ STERADIAN
Steradian, plural steradians. Dimension of solid angle. A solid angle is an angle in volume....
@ TESLA
Tesla, plural teslas. The derived dimensions are V * s / m2. Dimension of magnetic strength....
@ INTERNATIONAL_UNIT
International unit, plural international units. It measures the amount of effect or biological activi...
@ BARN
Barn, plural barns. Dimension of area. The derived dimensions are 10^-28 m2. It's used inside nuclear...
@ LIGHT_YEAR
Light year, plural light years. Dimension of length. The derived dimensions are 9,...
@ HENRY
Henry, plural henries. The derived dimensions are V * s / A. Dimension of electric inductance....
@ AMPERE
Ampere, plural amperes. The derived dimensions are C / s. Dimension of electric current....
@ MOLE
Mole, plural moles. SI dimension of quantity. Symbol mol.
@ CUSTOM_FULL_SYMBOL
Custom dimension. It's identical to a CUSTOM dimension in his use, but its symbol is stored in the st...
@ VOLT
Volt, plural volts. The derived dimensions are J / C, W / A. Dimension of voltage....
@ OHM
Ohm, plural ohms. The derived dimensions are V / A. Dimension of electric resistance....
@ COULOMB
Coulomb, plural coulombs. SI dimension of charge. Special name. Symbol C.
@ LUX
Lux, plural luxes. The derived dimensions are cd * sr / m2. Dimension of illuminance....
@ GRAY
Gray, plural grays. The derived dimensions are m2 / s2. Dimension of ionising radiation (absorbed dos...
@ ANGSTROM
Ángstrom, plural angstroms. The derived dimensions are 10^-10 m. Dimension of length,...
@ ELECTRON_VOLT
Electron volt, plural electron volts. The derived dimensions are 1.602176634 * 10^−19 J....
@ GRAM
Gram, plural grams. SI dimension of mass. Symbol g.
@ SIEVERT
Sievert, plural sieverts. The derived dimensions are J / kg. Dimension of ionising radiation (equival...
@ DALTON
Dalton, plural daltons. The derived dimensions are 1,66053886 * 10^-24. Dimension of mass....
@ MILLIEQUIVALENT
Milliequivalent, plural Milliequivalents. Amount of moles in a given chemical reaction needed to reac...
@ CELSIUS
Celsius, plural celsius. SI dimension of temperature, derived from kelvin. Symbol °C....
@ DEGREE
Degree, plural degrees. Dimension of angle. Symbol θ.
@ PASCAL
Pascal, plural pascals. The derived dimensions are kg / s2 * m. Dimension of pressure....
@ PIXEL
Pixel, plural pixels. it represents the amount of pixels, it can be used as a replacemet of the metre...
@ ATOMIC_MASS_UNIT
Atomic mass unit, plural atomic mass units. The derived dimensions are Da. Equivalent to the Dalton....
@ ASTRONOMICAL_UNIT
Astronomical unit, plural astronomical units. Dimension of length. The derived dimensions are 149,...
@ HERTZ
Hertz, plural hertz. The derived dimensions are 1 / s. Dimension of frequency. Special name....
@ DAY
Day, plural days. The derived dimensions are 86,400 s. Dimension of time. Symbol day,...
@ WATT
Watt, plural watts. The derived dimensions are kg * m2 / s3. Dimension of power. Special name....
@ NEWTON
Newton, plural newtons. The derived dimensions are kg * m / s2. Dimension of force....
@ HOUR
Hour, plural hours. The derived dimensions are 3,600 s. Dimension of time. Symbol hour,...
@ PARTICLES
Total of particles, the total amount that the mole represents. It's not exactly a dimension,...
@ MONEY
Money, plural money. The money is not specified in a specific currency, you must use the ISO 4217 of ...
@ BIT
Bit, plural bits. Dimension of amount of information, of each binary digit. Symbol bit.
@ SECOND
Second, plural seconds. SI dimension of time. Symbol s.
@ MINUTE
Minute, plural minutes. The derived dimensions are 60 s. Dimension of time. Symbol min.
@ CANDELA
Candela, plural candelas. SI dimension of luminous intensity. Symbol cd.
@ RADIAN
Radian, plural radians. Dimension of angle. Special name. Symbol rad.
@ BYTE
Byte, plural bytes. Dimension of amount of information. Symbol B.
@ SIEMENS
Siemens, plural siemens. The derived dimensions are 1 / Ω. Dimension of electric conductance....
@ JOULE
Joule, plural joules. The derived dimensions are kg * m2 / s2. Dimension of energy....
@ FARAD
Farad, plural farads. The derived dimensions are A * s / V. Dimension of electric capacitance....
@ WEBER
Weber, plural webers. The derived dimensions are T * m2. Dimension of magnetic flux....
@ KELVIN
Kelvin, plural kelvins. SI dimension of temperature. Symbol K.
@ METRE
Meter, plural meters. SI dimension of length. Symbol m.
@ PARSEC
Parsec, plural parsecs. Dimension of length. The derived dimensions are 3.2616 ly....
@ CUSTOM
Custom dimension. It means the dimension is a custom dimension, which can have any value and meaning,...
string get_symbol() const
Returns the symbol of the dimension. In the case of a custom dimension, it returns the custom dimensi...
string get_plural() const
Returns the plural of the dimension.
static set< string > prefixes_options
vector< dimension > get_base_dimensions() const
Returns the base dimensions of the dimensions, which can be the same dimension or all the base dimens...
long double get_conversion_factor() const
Returns the conversion factor of the dimension.
static map< int, string > full_symbols
bool is_derived_dimension() const
If the dimension is not a base dimension, it's considered a derived dimension.
static string get_full_symbol(const char *x_symbol)
Returns the symbol of a custom_full_symbol dimension stored in the private static map dimension::full...
dimension()
Default constructor. The dimension_type is NONE, the dimension_position is NO_POSITION,...
long double prefix_math() const
Returns the math between the prefix and the dimension, which varies if the dimension is a B or anothe...
void invert()
Changes the position of the dimension to the reverse, from the NUMERATOR to the DENOMINATOR,...
static char * create_full_symbol(const string &full_symbol)
Creates a new dimension that's stored in the private static map dimension::full_symbols.
Class that represents prefixes of the SI system of units. Each prefix sizes 1 byte....
prefix()
Default constructor. The prefix_type is set to NONE.
string get_symbol() const
Symbol of the prefix given the prefix_type. The symbol of micro is supported in his Unicode version.
string get_name() const
Name of the prefix given the prefix_type.
type
Represents a prefix of the SI system of units. All the prefixes of the SI system of units are support...
@ NONE
There is no prefix. Then, the dimension is not increased or decreased by some factor.
@ KILO
Prefix of a factor of 10^3.
bool operator!=(const scifir::dimension &x, const scifir::dimension &y)
Checks if the dimension type and the position of two dimensions are any of them different....
ostream & operator<<(ostream &os, const scifir::dimension &x)
Adds the string representation of a dimension to an output stream.
bool operator==(const scifir::dimension &x, const scifir::dimension &y)
Checks if the dimension type, the position and the prefix of two dimensions are the same.
The namespace scifir contains all scifir-units, excepting the string literals, which are outside.
bool equal_dimensions(const string &init_dimensions_x, const string &init_dimensions_y)
Checks if two initialization strings of dimensions initialize the same basic dimensions.
vector< dimension > divide_dimensions(vector< dimension > x, const vector< dimension > &y, long double &value)
Divides the first vector of dimensions with the other. The result is normalized after,...
@ NONE
No predefined astronomical body selected.
bool equal_dimensions_and_prefixes(const vector< dimension > &x, const vector< dimension > &y)
Checks if the base dimensions of two vectors of dimensions are equal, and if they have also the same ...
bool common_dimension(const dimension &x, const dimension &y)
Checks if there's an equal basic dimension between the basic dimensions of those two dimensions.
vector< dimension > normalize_dimensions(const vector< dimension > &x)
Normalizes the dimensions, which means that repited dimensions at the numerator and at the denominato...
string to_string(const aid &x)
Creates a string representation of aid, it's for aid equivalent to the display() function of aid.
vector< dimension > create_base_dimensions(const string &init_dimensions)
Creates the base dimensions from an initialization string of dimensions.
bool is_dimension_char(const UChar32 &x)
const long double AVOGADRO_CONSTANT
string to_latex(const vector< dimension > &x_dimensions, bool with_brackets)
vector< dimension > multiply_dimensions(const vector< dimension > &x, const vector< dimension > &y)
Multiplies two vectors of dimensions. The result is normalized after, which means that equal dimensio...
vector< dimension > square_dimensions(vector< dimension > x, int index, long double &value)
Squares a vector of dimensions by an index. The value is updated too related to the prefix math and t...
vector< dimension > create_dimensions(string init_dimensions)
Creates the dimensions from an initialization string of dimensions.
vector< dimension > power_dimensions(const vector< dimension > &x, int exponent)
Powers the dimensions by an exponent.