scifir-units 2.0.0
scifir-units is a library of units of measurement, angles, coordinates, fields, and related data, all lightweight, that help in the development of scientific software and scientific machines
|
#include "./dimension.hpp"
#include "./prefix.hpp"
#include "../util/is_number.hpp"
#include <cmath>
#include <map>
#include <string>
#include <iostream>
#include <sstream>
#include <string_view>
#include <vector>
Go to the source code of this file.
Classes | |
class | scifir::scalar_unit |
Class that allows to create scalar units, which are composed of a value (as a float) and dimensions. The dimensions can be of any number, and be simple dimensions, composite dimensions and/or special names of dimensions. All base and derived scalar unit classes inherit from scalar_unit. Initialization string example: "1 N". More... | |
Namespaces | |
namespace | scifir |
The namespace scifir contains all scifir-units, excepting the string literals, which are outside. | |
Macros | |
#define | SCALAR_UNIT_HPP_BEGIN(name) |
#define | SCALAR_UNIT_HPP_END() |
#define | SCALAR_UNIT_HPP(name) |
#define | SCALAR_UNIT_CPP(name, init_real_dimensions) |
Functions | |
string | scifir::to_string (const scalar_unit &x) |
Generates a string representation of the scalar_unit, it uses the display of the scalar_unit with 2 decimals, without brackets and without a close prefix. | |
bool | scifir::is_scalar_unit (const string &init_scalar) |
Checks if an string is an initialization string of a scalar_unit. | |
float | scifir::abs (const scalar_unit &x) |
Returns the absolute value of the scalar_unit, without dimensions. | |
scalar_unit | scifir::pow (const scalar_unit &x, int exponent) |
Exponentiates a scalar_unit to some numeric type, the dimensions are also exponentiated. | |
scalar_unit | scifir::sqrt (const scalar_unit &x) |
Square root of a scalar_unit, it squares the dimensions too. | |
scalar_unit | scifir::sqrt_nth (const scalar_unit &x, int index) |
Nth root of a scalar_unit to any numeric value, it squares the dimensions too. | |
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type> | |
scifir::scalar_unit | operator+ (const T &y, const scifir::scalar_unit &x) |
Sums a numeric type y with an scalar_unit x, returns that result as a new scalar_unit with the same dimensions of x. | |
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type> | |
scifir::scalar_unit | operator- (const T &y, const scifir::scalar_unit &x) |
Substracts a scalar_unit x to a numeric type y, returns that result as a new scalar_unit with the same dimensions of x. | |
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type> | |
scifir::scalar_unit | operator* (const T &y, const scifir::scalar_unit &x) |
Multiplies a numeric type y with an scalar_unit x, returns that result as a new scalar_unit with the same dimensions of x. | |
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type> | |
scifir::scalar_unit | operator/ (const T &y, const scifir::scalar_unit &x) |
Divides a numeric type y with an scalar_unit x, returns that result as a new scalar_unit with the same dimensions of x. | |
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type> | |
float | operator^ (const T &x, const scifir::scalar_unit &y) |
Exponentiates a numeric type x with a scalar_unit y, only if that scalar_unit as empty dimensions, returns a float as the result of the calculation. | |
bool | operator!= (const scifir::scalar_unit &x, scifir::scalar_unit y) |
Returns true if two scalar_unit classes doesn't have the same value when changed to same dimensions. If their basic dimensions are different, it returns false. | |
bool | operator< (const scifir::scalar_unit &x, const scifir::scalar_unit &y) |
Returns true if x has a lower value than y, compared with the same dimensions. If their dimensions are not equal, they are changed to be equal in order to do the comparison. | |
bool | operator> (const scifir::scalar_unit &x, const scifir::scalar_unit &y) |
Returns true if x has a greather value than y, compared with the same dimensions. If their dimensions are not equal, they are changed to be equal in order to do the comparison. | |
bool | operator<= (const scifir::scalar_unit &x, const scifir::scalar_unit &y) |
Returns true if x has a lower or equal value than y, compared with the same dimensions. If their dimensions are not equal, they are changed to be equal in order to do the comparison. | |
bool | operator>= (const scifir::scalar_unit &x, const scifir::scalar_unit &y) |
Returns true if x has a greather or equal value than y, compared with the same dimensions. If their dimensions are not equal, they are changed to be equal in order to do the comparison. | |
bool | operator== (const scifir::scalar_unit &x, const string &init_scalar) |
Returns true if x is equal to the scalar_unit initialized with the string being compared. The display() function is not used, and so the values are compared with all its decimal numbers. | |
bool | operator!= (const scifir::scalar_unit &x, const string &init_scalar) |
Returns true if x is not equal to the scalar_unit initialized with the string being compared. The display() function is not used, and so the values are compared with all its decimal numbers. | |
bool | operator< (const scifir::scalar_unit &x, const string &init_scalar) |
Returns true if x is lower than the scalar_unit initialized with the string being compared. | |
bool | operator> (const scifir::scalar_unit &x, const string &init_scalar) |
Returns true if x is greather than the scalar_unit initialized with the string being compared. | |
bool | operator<= (const scifir::scalar_unit &x, const string &init_scalar) |
Returns true if x is lower or equal to the scalar_unit initialized with the string being compared. | |
bool | operator>= (const scifir::scalar_unit &x, const string &init_scalar) |
Returns true if x is greather or equal to the scalar_unit initialized with the string being compared. | |
bool | operator== (const string &init_scalar, const scifir::scalar_unit &x) |
Returns true if x is equal to the scalar_unit initialized with the string being compared. The display() function is not used, and so the values are compared with all its decimal numbers. | |
bool | operator!= (const string &init_scalar, const scifir::scalar_unit &x) |
Returns true if x is not equal to the scalar_unit initialized with the string being compared. The display() function is not used, and so the values are compared with all its decimal numbers. | |
bool | operator< (const string &init_scalar, const scifir::scalar_unit &x) |
Returns true if x is greather than the scalar_unit initialized with the string being compared. | |
bool | operator> (const string &init_scalar, const scifir::scalar_unit &x) |
Returns true if x is lower than the scalar_unit initialized with the string being compared. | |
bool | operator<= (const string &init_scalar, const scifir::scalar_unit &x) |
Returns true if x is greather or equal to the scalar_unit initialized with the string being compared. | |
bool | operator>= (const string &init_scalar, const scifir::scalar_unit &x) |
Returns true if x is lower or equal to the scalar_unit initialized with the string being compared. | |
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type> | |
bool | operator== (const T &x, const scifir::scalar_unit &y) |
Returns true if the value of the scalar_unit is equal to the numeric type, ignoring the dimensions. | |
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type> | |
bool | operator!= (const T &x, const scifir::scalar_unit &y) |
Returns true if the value of the scalar_unit is not equal to the numeric type, ignoring the dimensions. | |
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type> | |
bool | operator< (const T &x, const scifir::scalar_unit &y) |
Returns true if the value of y is greather than the numeric type, ignoring the dimensions. | |
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type> | |
bool | operator> (const T &x, const scifir::scalar_unit &y) |
Returns true if the value of y is lower than the numeric type, ignoring the dimensions. | |
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type> | |
bool | operator<= (const T &x, const scifir::scalar_unit &y) |
Returns true if the value of y is lower or equal than the numeric type, ignoring the dimensions. | |
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type> | |
bool | operator>= (const T &x, const scifir::scalar_unit &y) |
Returns true if the value of y is equal or greather than the numeric type, ignoring the dimensions. | |
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type> | |
bool | operator== (const scifir::scalar_unit &x, const T &y) |
Returns true if the value of the scalar_unit is equal to the numeric type, ignoring the dimensions. | |
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type> | |
bool | operator!= (const scifir::scalar_unit &x, const T &y) |
Returns true if the value of the scalar_unit is not equal to the numeric type, ignoring the dimensions. | |
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type> | |
bool | operator< (const scifir::scalar_unit &x, const T &y) |
Returns true if the value of x is lower than the numeric type, ignoring the dimensions. | |
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type> | |
bool | operator> (const scifir::scalar_unit &x, const T &y) |
Returns true if the value of x is greather than the numeric type, ignoring the dimensions. | |
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type> | |
bool | operator<= (const scifir::scalar_unit &x, const T &y) |
Returns true if the value of x is lower or equal than the numeric type, ignoring the dimensions. | |
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type> | |
bool | operator>= (const scifir::scalar_unit &x, const T &y) |
Returns true if the value of x is equal or greather than the numeric type, ignoring the dimensions. | |
void | operator+= (string &x, const scifir::scalar_unit &y) |
Concatenates the string representation of the scalar_unit y to the string x. | |
string | operator+ (const string &x, const scifir::scalar_unit &y) |
Creates a new string as the concatenation of the string x with the representation string of the scalar_unit y. | |
string | operator+ (const scifir::scalar_unit &y, const string &x) |
Creates a new string as the concatenation of the string x with the representation string of the scalar_unit y. | |
ostream & | operator<< (ostream &os, const scifir::scalar_unit &x) |
Adds the string representation of the scalar_unit x to an output stream os. | |
istream & | operator>> (istream &is, scifir::scalar_unit &x) |
Allows that an istream initializes by string a scalar_unit x. | |
#define SCALAR_UNIT_CPP | ( | name, | |
init_real_dimensions | |||
) |
Definition at line 81 of file scalar_unit.hpp.
#define SCALAR_UNIT_HPP | ( | name | ) |
Definition at line 50 of file scalar_unit.hpp.
#define SCALAR_UNIT_HPP_BEGIN | ( | name | ) |
Definition at line 16 of file scalar_unit.hpp.
#define SCALAR_UNIT_HPP_END | ( | ) |
Definition at line 43 of file scalar_unit.hpp.
bool operator!= | ( | const scifir::scalar_unit & | x, |
const string & | init_scalar | ||
) |
Returns true if x is not equal to the scalar_unit initialized with the string being compared. The display() function is not used, and so the values are compared with all its decimal numbers.
Definition at line 1021 of file scalar_unit.cpp.
bool operator!= | ( | const scifir::scalar_unit & | x, |
const T & | y | ||
) |
Returns true if the value of the scalar_unit is not equal to the numeric type, ignoring the dimensions.
Definition at line 641 of file scalar_unit.hpp.
bool operator!= | ( | const scifir::scalar_unit & | x, |
scifir::scalar_unit | y | ||
) |
Returns true if two scalar_unit classes doesn't have the same value when changed to same dimensions. If their basic dimensions are different, it returns false.
Definition at line 964 of file scalar_unit.cpp.
bool operator!= | ( | const string & | init_scalar, |
const scifir::scalar_unit & | x | ||
) |
Returns true if x is not equal to the scalar_unit initialized with the string being compared. The display() function is not used, and so the values are compared with all its decimal numbers.
Definition at line 1053 of file scalar_unit.cpp.
bool operator!= | ( | const T & | x, |
const scifir::scalar_unit & | y | ||
) |
Returns true if the value of the scalar_unit is not equal to the numeric type, ignoring the dimensions.
Definition at line 605 of file scalar_unit.hpp.
scifir::scalar_unit operator* | ( | const T & | y, |
const scifir::scalar_unit & | x | ||
) |
Multiplies a numeric type y with an scalar_unit x, returns that result as a new scalar_unit with the same dimensions of x.
Definition at line 551 of file scalar_unit.hpp.
string operator+ | ( | const scifir::scalar_unit & | y, |
const string & | x | ||
) |
Creates a new string as the concatenation of the string x with the representation string of the scalar_unit y.
Definition at line 1095 of file scalar_unit.cpp.
string operator+ | ( | const string & | x, |
const scifir::scalar_unit & | y | ||
) |
Creates a new string as the concatenation of the string x with the representation string of the scalar_unit y.
Definition at line 1087 of file scalar_unit.cpp.
scifir::scalar_unit operator+ | ( | const T & | y, |
const scifir::scalar_unit & | x | ||
) |
Sums a numeric type y with an scalar_unit x, returns that result as a new scalar_unit with the same dimensions of x.
Definition at line 535 of file scalar_unit.hpp.
void operator+= | ( | string & | x, |
const scifir::scalar_unit & | y | ||
) |
Concatenates the string representation of the scalar_unit y to the string x.
Definition at line 1080 of file scalar_unit.cpp.
scifir::scalar_unit operator- | ( | const T & | y, |
const scifir::scalar_unit & | x | ||
) |
Substracts a scalar_unit x to a numeric type y, returns that result as a new scalar_unit with the same dimensions of x.
Definition at line 543 of file scalar_unit.hpp.
scifir::scalar_unit operator/ | ( | const T & | y, |
const scifir::scalar_unit & | x | ||
) |
Divides a numeric type y with an scalar_unit x, returns that result as a new scalar_unit with the same dimensions of x.
Definition at line 559 of file scalar_unit.hpp.
bool operator< | ( | const scifir::scalar_unit & | x, |
const scifir::scalar_unit & | y | ||
) |
Returns true if x has a lower value than y, compared with the same dimensions. If their dimensions are not equal, they are changed to be equal in order to do the comparison.
Definition at line 969 of file scalar_unit.cpp.
bool operator< | ( | const scifir::scalar_unit & | x, |
const string & | init_scalar | ||
) |
Returns true if x is lower than the scalar_unit initialized with the string being compared.
Definition at line 1026 of file scalar_unit.cpp.
bool operator< | ( | const scifir::scalar_unit & | x, |
const T & | y | ||
) |
Returns true if the value of x is lower than the numeric type, ignoring the dimensions.
Definition at line 647 of file scalar_unit.hpp.
bool operator< | ( | const string & | init_scalar, |
const scifir::scalar_unit & | x | ||
) |
Returns true if x is greather than the scalar_unit initialized with the string being compared.
Definition at line 1058 of file scalar_unit.cpp.
bool operator< | ( | const T & | x, |
const scifir::scalar_unit & | y | ||
) |
Returns true if the value of y is greather than the numeric type, ignoring the dimensions.
Definition at line 611 of file scalar_unit.hpp.
ostream & operator<< | ( | ostream & | os, |
const scifir::scalar_unit & | x | ||
) |
Adds the string representation of the scalar_unit x to an output stream os.
Definition at line 1103 of file scalar_unit.cpp.
bool operator<= | ( | const scifir::scalar_unit & | x, |
const scifir::scalar_unit & | y | ||
) |
Returns true if x has a lower or equal value than y, compared with the same dimensions. If their dimensions are not equal, they are changed to be equal in order to do the comparison.
Definition at line 1005 of file scalar_unit.cpp.
bool operator<= | ( | const scifir::scalar_unit & | x, |
const string & | init_scalar | ||
) |
Returns true if x is lower or equal to the scalar_unit initialized with the string being compared.
Definition at line 1038 of file scalar_unit.cpp.
bool operator<= | ( | const scifir::scalar_unit & | x, |
const T & | y | ||
) |
Returns true if the value of x is lower or equal than the numeric type, ignoring the dimensions.
Definition at line 659 of file scalar_unit.hpp.
bool operator<= | ( | const string & | init_scalar, |
const scifir::scalar_unit & | x | ||
) |
Returns true if x is greather or equal to the scalar_unit initialized with the string being compared.
Definition at line 1070 of file scalar_unit.cpp.
bool operator<= | ( | const T & | x, |
const scifir::scalar_unit & | y | ||
) |
Returns true if the value of y is lower or equal than the numeric type, ignoring the dimensions.
Definition at line 623 of file scalar_unit.hpp.
bool operator== | ( | const scifir::scalar_unit & | x, |
const string & | init_scalar | ||
) |
Returns true if x is equal to the scalar_unit initialized with the string being compared. The display() function is not used, and so the values are compared with all its decimal numbers.
Definition at line 1015 of file scalar_unit.cpp.
bool operator== | ( | const scifir::scalar_unit & | x, |
const T & | y | ||
) |
Returns true if the value of the scalar_unit is equal to the numeric type, ignoring the dimensions.
Definition at line 635 of file scalar_unit.hpp.
bool operator== | ( | const string & | init_scalar, |
const scifir::scalar_unit & | x | ||
) |
Returns true if x is equal to the scalar_unit initialized with the string being compared. The display() function is not used, and so the values are compared with all its decimal numbers.
Definition at line 1048 of file scalar_unit.cpp.
bool operator== | ( | const T & | x, |
const scifir::scalar_unit & | y | ||
) |
Returns true if the value of the scalar_unit is equal to the numeric type, ignoring the dimensions.
Definition at line 599 of file scalar_unit.hpp.
bool operator> | ( | const scifir::scalar_unit & | x, |
const scifir::scalar_unit & | y | ||
) |
Returns true if x has a greather value than y, compared with the same dimensions. If their dimensions are not equal, they are changed to be equal in order to do the comparison.
Definition at line 987 of file scalar_unit.cpp.
bool operator> | ( | const scifir::scalar_unit & | x, |
const string & | init_scalar | ||
) |
Returns true if x is greather than the scalar_unit initialized with the string being compared.
Definition at line 1032 of file scalar_unit.cpp.
bool operator> | ( | const scifir::scalar_unit & | x, |
const T & | y | ||
) |
Returns true if the value of x is greather than the numeric type, ignoring the dimensions.
Definition at line 653 of file scalar_unit.hpp.
bool operator> | ( | const string & | init_scalar, |
const scifir::scalar_unit & | x | ||
) |
Returns true if x is lower than the scalar_unit initialized with the string being compared.
Definition at line 1064 of file scalar_unit.cpp.
bool operator> | ( | const T & | x, |
const scifir::scalar_unit & | y | ||
) |
Returns true if the value of y is lower than the numeric type, ignoring the dimensions.
Definition at line 617 of file scalar_unit.hpp.
bool operator>= | ( | const scifir::scalar_unit & | x, |
const scifir::scalar_unit & | y | ||
) |
Returns true if x has a greather or equal value than y, compared with the same dimensions. If their dimensions are not equal, they are changed to be equal in order to do the comparison.
Definition at line 1010 of file scalar_unit.cpp.
bool operator>= | ( | const scifir::scalar_unit & | x, |
const string & | init_scalar | ||
) |
Returns true if x is greather or equal to the scalar_unit initialized with the string being compared.
Definition at line 1043 of file scalar_unit.cpp.
bool operator>= | ( | const scifir::scalar_unit & | x, |
const T & | y | ||
) |
Returns true if the value of x is equal or greather than the numeric type, ignoring the dimensions.
Definition at line 665 of file scalar_unit.hpp.
bool operator>= | ( | const string & | init_scalar, |
const scifir::scalar_unit & | x | ||
) |
Returns true if x is lower or equal to the scalar_unit initialized with the string being compared.
Definition at line 1075 of file scalar_unit.cpp.
bool operator>= | ( | const T & | x, |
const scifir::scalar_unit & | y | ||
) |
Returns true if the value of y is equal or greather than the numeric type, ignoring the dimensions.
Definition at line 629 of file scalar_unit.hpp.
istream & operator>> | ( | istream & | is, |
scifir::scalar_unit & | x | ||
) |
Allows that an istream initializes by string a scalar_unit x.
Definition at line 1108 of file scalar_unit.cpp.
float operator^ | ( | const T & | x, |
const scifir::scalar_unit & | y | ||
) |
Exponentiates a numeric type x with a scalar_unit y, only if that scalar_unit as empty dimensions, returns a float as the result of the calculation.
Definition at line 566 of file scalar_unit.hpp.