yade.math module¶
This python module exposes all C++ math functions for Real and Complex types to python.
In fact it sort of duplicates import math, import cmath or import mpmath.
Also it facilitates migration of old python scripts to high precision calculations.
This module has following purposes:
To reliably test all C++ math functions of arbitrary precision Real and Complex types against mpmath.
To act as a “migration helper” for python scripts which call python mathematical functions that do not work well with mpmath. As an example see math.linspace below and this merge request
To allow writing python math code in a way that mirrors C++ math code in Yade. As a bonus it will be faster than mpmath because mpmath is a purely python library (which was one of the main difficulties when writing lib/high-precision/ToFromPythonConverter.hpp)
To test Eigen NumTraits
To test CGAL NumTraits
If another C++ math function is needed it should be added to following files:
If another python math function does not work well with mpmath it should be added below, and original
calls to this function should call this function instead, e.g. numpy.linspace(…) is replaced with yade.math.linspace(…).
The RealHP<n> higher precision math functions can be accessed in python by using the .HPn module scope. For example:
import yade.math as mth
mth.HP2.sqrt(2) # produces square root of 2 using RealHP<2> precision
mth.sqrt(2) # without using HPn module scope it defaults to RealHP<1>
- yade.math.Real1(arg)¶
This function is for compatibility of calls like:
g = yade.math.toHP1("-9.81"). If yade is compiled with defaultRealprecision set asdouble, then python won’t accept string arguments as numbers. However when using higher precisions only callsyade.math.toHP1("1.234567890123456789012345678901234567890")do not cut to the first 15 decimal places. The calls such asyade.math.toHP1(1.234567890123456789012345678901234567890)will use defaultpython↔doubleconversion and will cut the number to its first 15 digits.If you are debugging a high precision python script, and have difficulty finding places where such cuts have happened you should use
yade.math.toHP1(string)for declaring all python floating point numbers which are physically important in the simulation. This function will throw exception if bad conversion is about to take place.Also see example high precision check checkGravityRungeKuttaCashKarp54.py.
- yade.math.degrees(arg)¶
- Returns:
arg in radians converted to degrees, using yade.math.Real precision.
- yade.math.degreesHP1(arg)[source]¶
- Returns:
arg in radians converted to degrees, using yade.math.Real precision.
- yade.math.eig(a)[source]¶
This function calls
numpy.linalg.eig(…)ormpmath.eig(…), becausenumpy.linalg.eigfunction does not work with mpmath.
- yade.math.getRealHPCppDigits10()[source]¶
- Returns:
tuple containing amount of decimal digits supported on C++ side by Eigen and CGAL.
- yade.math.getRealHPPythonDigits10()[source]¶
- Returns:
tuple containing amount of decimal digits supported on python side by yade.minieigenHP.
- yade.math.linspace(a, b, num)[source]¶
This function calls
numpy.linspace(…)ormpmath.linspace(…), becausenumpy.linspacefunction does not work with mpmath.
- yade.math.needsMpmathAtN(N)[source]¶
- Parameters:
N – The
intN value ofRealHP<N>in question. Must beN >= 1.- Returns:
TrueorFalsewith information if usingmpmathis necessary to avoid losing precision when working withRealHP<N>.
- yade.math.radians(arg)¶
The default python function
import math ; math.radians(arg)only works on 15 digitdoubleprecision. If you want to carry on calculations in higher precision it is advisable to use this functionyade.math.radiansHP1(arg)instead. It uses full yadeRealprecision numbers.NOTE: in the future this function may replace
radians(…)function which is called in yade in many scripts, and which in fact is a call to native pythonmath.radians. We only need to find the best backward compatible approach for this. The functionyade.math.radiansHP1(arg)will remain as the function which uses native yadeRealprecision.
- yade.math.radiansHP1(arg)[source]¶
The default python function
import math ; math.radians(arg)only works on 15 digitdoubleprecision. If you want to carry on calculations in higher precision it is advisable to use this functionyade.math.radiansHP1(arg)instead. It uses full yadeRealprecision numbers.NOTE: in the future this function may replace
radians(…)function which is called in yade in many scripts, and which in fact is a call to native pythonmath.radians. We only need to find the best backward compatible approach for this. The functionyade.math.radiansHP1(arg)will remain as the function which uses native yadeRealprecision.
- yade.math.toHP1(arg)[source]¶
This function is for compatibility of calls like:
g = yade.math.toHP1("-9.81"). If yade is compiled with defaultRealprecision set asdouble, then python won’t accept string arguments as numbers. However when using higher precisions only callsyade.math.toHP1("1.234567890123456789012345678901234567890")do not cut to the first 15 decimal places. The calls such asyade.math.toHP1(1.234567890123456789012345678901234567890)will use defaultpython↔doubleconversion and will cut the number to its first 15 digits.If you are debugging a high precision python script, and have difficulty finding places where such cuts have happened you should use
yade.math.toHP1(string)for declaring all python floating point numbers which are physically important in the simulation. This function will throw exception if bad conversion is about to take place.Also see example high precision check checkGravityRungeKuttaCashKarp54.py.
- yade.math.usesHP()[source]¶
- Returns:
Trueif yade is using defaultRealprecision higher than 15 digit (53 bits)doubletype.
- yade._math.CGAL_Is_finite((float)x) bool¶
CGAL’s function
Is_finite, as described in CGAL algebraic foundations exposed to python for testing of CGAL numerical traits.- Returns:
boolindicating if theRealargument is finite.
- yade._math.CGAL_Is_valid((float)x) bool¶
CGAL’s function
Is_valid, as described in CGAL algebraic foundations exposed to python for testing of CGAL numerical traits.- Returns:
boolindicating if theRealargument is valid. Checks are performed against NaN and Inf.
- yade._math.CGAL_Kth_root((int)arg1, (float)x) float¶
CGAL’s function
Kth_root, as described in CGAL algebraic foundations exposed to python for testing of CGAL numerical traits.- Returns:
Realthe k-th root of argument.
- yade._math.CGAL_Sgn((float)x) int¶
CGAL’s function
Sgn, as described in CGAL algebraic foundations exposed to python for testing of CGAL numerical traits.- Returns:
sign of the argument, can be
-1,0or1. Not very useful in python. In C++ it is useful to obtain a sign of an expression with exact accuracy, CGAL starts using MPFR internally for this when the approximate interval contains zero inside it.
- yade._math.CGAL_Sqrt((float)x) float¶
CGAL’s function
Sqrt, as described in CGAL algebraic foundations exposed to python for testing of CGAL numerical traits.- Returns:
Realthe square root of argument.
- yade._math.CGAL_Square((float)x) float¶
CGAL’s function
Square, as described in CGAL algebraic foundations exposed to python for testing of CGAL numerical traits.- Returns:
Realthe argument squared.
- yade._math.CGAL_To_interval((float)x) tuple¶
CGAL’s function
To_interval, as described in CGAL algebraic foundations exposed to python for testing of CGAL numerical traits.- Returns:
(double,double)tuple inside which the high-precisionRealargument resides.
- yade._math.CGAL_simpleTest() float¶
Tests a simple CGAL calculation. Distance between plane and point, uses CGAL’s sqrt and pow.
- Returns:
3.0
- yade._math.Catalan([(int)Precision=53]) float¶
- Returns:
RealThe catalan constant, exposed to python for testing of eigen numerical traits.
- yade._math.Euler([(int)Precision=53]) float¶
- Returns:
RealThe Euler–Mascheroni constant, exposed to python for testing of eigen numerical traits.
- class yade._math.HP1¶
- AddCost = 1¶
- CGAL_Is_finite((float)x) bool :¶
CGAL’s function
Is_finite, as described in CGAL algebraic foundations exposed to python for testing of CGAL numerical traits.- Returns:
boolindicating if theRealargument is finite.
- CGAL_Is_valid((float)x) bool :¶
CGAL’s function
Is_valid, as described in CGAL algebraic foundations exposed to python for testing of CGAL numerical traits.- Returns:
boolindicating if theRealargument is valid. Checks are performed against NaN and Inf.
- CGAL_Kth_root((int)arg1, (float)x) float :¶
CGAL’s function
Kth_root, as described in CGAL algebraic foundations exposed to python for testing of CGAL numerical traits.- Returns:
Realthe k-th root of argument.
- CGAL_Sgn((float)x) int :¶
CGAL’s function
Sgn, as described in CGAL algebraic foundations exposed to python for testing of CGAL numerical traits.- Returns:
sign of the argument, can be
-1,0or1. Not very useful in python. In C++ it is useful to obtain a sign of an expression with exact accuracy, CGAL starts using MPFR internally for this when the approximate interval contains zero inside it.
- CGAL_Sqrt((float)x) float :¶
CGAL’s function
Sqrt, as described in CGAL algebraic foundations exposed to python for testing of CGAL numerical traits.- Returns:
Realthe square root of argument.
- CGAL_Square((float)x) float :¶
CGAL’s function
Square, as described in CGAL algebraic foundations exposed to python for testing of CGAL numerical traits.- Returns:
Realthe argument squared.
- CGAL_To_interval((float)x) tuple :¶
CGAL’s function
To_interval, as described in CGAL algebraic foundations exposed to python for testing of CGAL numerical traits.- Returns:
(double,double)tuple inside which the high-precisionRealargument resides.
- CGAL_simpleTest() float :¶
Tests a simple CGAL calculation. Distance between plane and point, uses CGAL’s sqrt and pow.
- Returns:
3.0
- Catalan([(int)Precision=53]) float :¶
- Returns:
RealThe catalan constant, exposed to python for testing of eigen numerical traits.
- Complex¶
alias of
complex
- ComplexAddCost = 2¶
- ComplexMulCost = 6¶
- ComplexReadCost = 2¶
- Euler([(int)Precision=53]) float :¶
- Returns:
RealThe Euler–Mascheroni constant, exposed to python for testing of eigen numerical traits.
- IsComplex = 0¶
- IsInteger = 0¶
- IsSigned = 1¶
- Log2([(int)Precision=53]) float :¶
- Returns:
Realnatural logarithm of 2, exposed to python for testing of eigen numerical traits.
- MulCost = 1¶
- Pi([(int)Precision=53]) float :¶
- Returns:
RealThe π constant, exposed to python for testing of eigen numerical traits.
- ReadCost = 1¶
- Real¶
alias of
float
- RequireInitialization = 0¶
- class Var¶
The
Varclass is used to test to/from python converters for arbitrary precisionReal- property cpl¶
one
Complexvariable to test reading from and writing to it.
- property val¶
one
Realvariable for testing.
- abs((complex)x) float :¶
- Returns:
the
Realabsolute value of theComplexargument. Depending on compilation options wraps::boost::multiprecision::abs(…)or std::abs(…) function.
- abs( (float)x) -> float :
- return:
the
Realabsolute value of theRealargument. Depending on compilation options wraps::boost::multiprecision::abs(…)or std::abs(…) function.
- acos((complex)x) complex :¶
- Returns:
Complexthe arc-cosine of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::acos(…)or std::acos(…) function.
- acos( (float)x) -> float :
- return:
Realthe arcus cosine of the argument. Depending on compilation options wraps::boost::multiprecision::acos(…)or std::acos(…) function.
- acosh((complex)x) complex :¶
- Returns:
Complexthe arc-hyperbolic cosine of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::acosh(…)or std::acosh(…) function.
- acosh( (float)x) -> float :
- return:
Realthe hyperbolic arcus cosine of the argument. Depending on compilation options wraps::boost::multiprecision::acosh(…)or std::acosh(…) function.
- arg((complex)x) float :¶
- Returns:
Realthe arg (Phase angle of complex in radians) of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::arg(…)or std::arg(…) function.
- asin((complex)x) complex :¶
- Returns:
Complexthe arc-sine of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::asin(…)or std::asin(…) function.
- asin( (float)x) -> float :
- return:
Realthe arcus sine of the argument. Depending on compilation options wraps::boost::multiprecision::asin(…)or std::asin(…) function.
- asinh((complex)x) complex :¶
- Returns:
Complexthe arc-hyperbolic sine of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::asinh(…)or std::asinh(…) function.
- asinh( (float)x) -> float :
- return:
Realthe hyperbolic arcus sine of the argument. Depending on compilation options wraps::boost::multiprecision::asinh(…)or std::asinh(…) function.
- atan((complex)x) complex :¶
- Returns:
Complexthe arc-tangent of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::atan(…)or std::atan(…) function.
- atan( (float)x) -> float :
- return:
Realthe arcus tangent of the argument. Depending on compilation options wraps::boost::multiprecision::atan(…)or std::atan(…) function.
- atan2((float)x, (float)y) float :¶
- Returns:
Realthe arc tangent of y/x using the signs of the argumentsxandyto determine the correct quadrant. Depending on compilation options wraps::boost::multiprecision::atan2(…)or std::atan2(…) function.
- atanh((complex)x) complex :¶
- Returns:
Complexthe arc-hyperbolic tangent of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::atanh(…)or std::atanh(…) function.
- atanh( (float)x) -> float :
- return:
Realthe hyperbolic arcus tangent of the argument. Depending on compilation options wraps::boost::multiprecision::atanh(…)or std::atanh(…) function.
- cbrt((float)x) float :¶
- Returns:
Realcubic root of the argument. Depending on compilation options wraps::boost::multiprecision::cbrt(…)or std::cbrt(…) function.
- ceil((float)x) float :¶
- Returns:
RealComputes the smallest integer value not less than arg. Depending on compilation options wraps::boost::multiprecision::ceil(…)or std::ceil(…) function.
- conj((complex)x) complex :¶
- Returns:
the complex conjugation a
Complexargument. Depending on compilation options wraps::boost::multiprecision::conj(…)or std::conj(…) function.
- cos((complex)x) complex :¶
- Returns:
Complexthe cosine of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::cos(…)or std::cos(…) function.
- cos( (float)x) -> float :
- return:
Realthe cosine of theRealargument in radians. Depending on compilation options wraps::boost::multiprecision::cos(…)or std::cos(…) function.
- cosh((complex)x) complex :¶
- Returns:
Complexthe hyperbolic cosine of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::cosh(…)or std::cosh(…) function.
- cosh( (float)x) -> float :
- return:
Realthe hyperbolic cosine of theRealargument in radians. Depending on compilation options wraps::boost::multiprecision::cosh(…)or std::cosh(…) function.
- cylBesselJ((int)k, (float)x) float :¶
- Returns:
Realthe Bessel Functions of the First Kind of the orderkand theRealargument. See: <https://www.boost.org/doc/libs/1_77_0/libs/math/doc/html/math_toolkit/bessel/bessel_first.html>`__
- defprec = 53¶
- dummy_precision() float :¶
- Returns:
similar to the function
epsilon, but assumes that last 10% of bits contain the numerical error only. This is sometimes used by Eigen when callingisEqualFuzzyto determine if values differ a lot or if they are vaguely close to each other.
- epsilon([(int)Precision=53]) float :¶
- Returns:
Realreturns the difference between1.0and the next representable value of theRealtype. Wraps std::numeric_limits<Real>::epsilon() function.
- epsilon( (float)x) -> float :
- return:
Realreturns the difference between1.0and the next representable value of theRealtype. Wraps std::numeric_limits<Real>::epsilon() function.
- erf((float)x) float :¶
- Returns:
RealComputes the error function of argument. Depending on compilation options wraps::boost::multiprecision::erf(…)or std::erf(…) function.
- erfc((float)x) float :¶
- Returns:
RealComputes the complementary error function of argument, that is1.0-erf(arg). Depending on compilation options wraps::boost::multiprecision::erfc(…)or std::erfc(…) function.
- exp((complex)x) complex :¶
- Returns:
the base e exponential of a
Complexargument. Depending on compilation options wraps::boost::multiprecision::exp(…)or std::exp(…) function.
- exp( (float)x) -> float :
- return:
the base e exponential of a
Realargument. Depending on compilation options wraps::boost::multiprecision::exp(…)or std::exp(…) function.
- exp2((float)x) float :¶
- Returns:
the base 2 exponential of a
Realargument. Depending on compilation options wraps::boost::multiprecision::exp2(…)or std::exp2(…) function.
- expm1((float)x) float :¶
- Returns:
the base e exponential of a
Realargument minus1.0. Depending on compilation options wraps::boost::multiprecision::expm1(…)or std::expm1(…) function.
- fabs((float)x) float :¶
- Returns:
the
Realabsolute value of the argument. Depending on compilation options wraps::boost::multiprecision::abs(…)or std::abs(…) function.
- factorial((int)x) float :¶
- Returns:
Realthe factorial of theRealargument. See: <https://www.boost.org/doc/libs/1_77_0/libs/math/doc/html/math_toolkit/factorials/sf_factorial.html>`__
- floor((float)x) float :¶
- Returns:
RealComputes the largest integer value not greater than arg. Depending on compilation options wraps::boost::multiprecision::floor(…)or std::floor(…) function.
- fma((float)x, (float)y, (float)z) float :¶
- Returns:
Real- computes(x*y) + zas if to infinite precision and rounded only once to fit the result type. Depending on compilation options wraps::boost::multiprecision::fma(…)or std::fma(…) function.
- fmod((float)x, (float)y) float :¶
- Returns:
Realthe floating-point remainder of the division operationx/yof the argumentsxandy. Depending on compilation options wraps::boost::multiprecision::fmod(…)or std::fmod(…) function.
- frexp((float)x) tuple :¶
- Returns:
tuple of
(Real,int), decomposes given floating pointRealargument into a normalized fraction and an integral power of two. Depending on compilation options wraps::boost::multiprecision::frexp(…)or std::frexp(…) function.
- fromBits((str)bits[, (int)exp=0[, (int)sign=1]]) float :¶
- Parameters:
bits –
str- a string containing ‘0’, ‘1’ characters.exp –
int- the binary exponent which shifts the bits.sign –
int- the sign, should be -1 or +1, but it is not checked. It multiplies the result when construction from bits is finished.
- Returns:
RealHP<N>constructed from string containing ‘0’, ‘1’ bits. This is for debugging purposes, rather slow.
- getDecomposedReal((float)x) dict :¶
- Returns:
dict- the dictionary with the debug information how the DecomposedReal class sees this type. This is for debugging purposes, rather slow. Includes result from fpclassify function call, a binary representation and other useful info. See also fromBits.
- getDemangledName() str :¶
- Returns:
string- the demangled C++ typnename ofRealHP<N>.
- getDemangledNameComplex() str :¶
- Returns:
string- the demangled C++ typnename ofComplexHP<N>.
- getFloatDistanceULP((float)arg1, (float)arg2) float :¶
- Returns:
an integer value stored in
RealHP<N>, the ULP distance calculated by boost::math::float_distance, also see Floating-point Comparison and Prof. Kahan paper about this topic.
Warning
The returned value is the directed distance between two arguments, this means that it can be negative.
- getRawBits((float)x) str :¶
- Returns:
string- the raw bits in memory representing this type. Be careful: it only checks the system endianness and either prints bytes in reverse order or not. Does not make any attempts to further interpret the bits of: sign, exponent or significand (on a typical x86 processor they are printed in that order), and different processors might store them differently. It is not useful for types which internally use a pointer because for them this function prints not the floating point number but a pointer. This is for debugging purposes.
- hasInfinityNan = True¶
- highest([(int)Precision=53]) float :¶
- Returns:
Realreturns the largest finite value of theRealtype. Wraps std::numeric_limits<Real>::max() function.
- hypot((float)x, (float)y) float :¶
- Returns:
Realthe square root of the sum of the squares ofxandy, without undue overflow or underflow at intermediate stages of the computation. Depending on compilation options wraps::boost::multiprecision::hypot(…)or std::hypot(…) function.
- ilogb((float)x) float :¶
- Returns:
Realextracts the value of the unbiased exponent from the floating-point argument arg, and returns it as a signed integer value. Depending on compilation options wraps::boost::multiprecision::ilogb(…)or std::ilogb(…) function.
- imag((complex)x) float :¶
- Returns:
the imag part of a
Complexargument. Depending on compilation options wraps::boost::multiprecision::imag(…)or std::imag(…) function.
- isApprox((float)a, (float)b, (float)eps) bool :¶
- Returns:
bool, True ifais approximately equalbwith providedeps, see also here
- isApproxOrLessThan((float)a, (float)b, (float)eps) bool :¶
- Returns:
bool, True ifais approximately less than or equalbwith providedeps, see also here
- isEqualFuzzy((float)arg1, (float)arg2, (float)arg3) bool :¶
- Returns:
bool,Trueif the absolute difference between two numbers is smaller than std::numeric_limits<Real>::epsilon()
- isMuchSmallerThan((float)a, (float)b, (float)eps) bool :¶
- Returns:
bool, True ifais less thanbwith providedeps, see also here
- isfinite((float)x) bool :¶
- Returns:
boolindicating if theRealargument is Inf. Depending on compilation options wraps::boost::multiprecision::isfinite(…)or std::isfinite(…) function.
- isinf((float)x) bool :¶
- Returns:
boolindicating if theRealargument is Inf. Depending on compilation options wraps::boost::multiprecision::isinf(…)or std::isinf(…) function.
- isnan((float)x) bool :¶
- Returns:
boolindicating if theRealargument is NaN. Depending on compilation options wraps::boost::multiprecision::isnan(…)or std::isnan(…) function.
- laguerre((int)n, (int)m, (float)x) float :¶
- Returns:
Realthe Laguerre polynomial of the ordersn,mand theRealargument. See: <https://www.boost.org/doc/libs/1_77_0/libs/math/doc/html/math_toolkit/sf_poly/laguerre.html>`__
- ldexp((float)x, (int)y) float :¶
- Returns:
Multiplies a floating point value
xby the number 2 raised to theexppower. Depending on compilation options wraps::boost::multiprecision::ldexp(…)or std::ldexp(…) function.
- lgamma((float)x) float :¶
- Returns:
RealComputes the natural logarithm of the absolute value of the gamma function of arg. Depending on compilation options wraps::boost::multiprecision::lgamma(…)or std::lgamma(…) function.
- log((complex)x) complex :¶
- Returns:
the
Complexnatural (base e) logarithm of a complex value z with a branch cut along the negative real axis. Depending on compilation options wraps::boost::multiprecision::log(…)or std::log(…) function.
- log( (float)x) -> float :
- return:
the
Realnatural (base e) logarithm of a real value. Depending on compilation options wraps::boost::multiprecision::log(…)or std::log(…) function.
- log10((complex)x) complex :¶
- Returns:
the
Complex(base 10) logarithm of a complex value z with a branch cut along the negative real axis. Depending on compilation options wraps::boost::multiprecision::log10(…)or std::log10(…) function.
- log10( (float)x) -> float :
- return:
the
Realdecimal (base10) logarithm of a real value. Depending on compilation options wraps::boost::multiprecision::log10(…)or std::log10(…) function.
- log1p((float)x) float :¶
- Returns:
the
Realnatural (base e) logarithm of1+argument. Depending on compilation options wraps::boost::multiprecision::log1p(…)or std::log1p(…) function.
- log2((float)x) float :¶
- Returns:
the
Realbinary (base2) logarithm of a real value. Depending on compilation options wraps::boost::multiprecision::log2(…)or std::log2(…) function.
- logb((float)x) float :¶
- Returns:
Extracts the value of the unbiased radix-independent exponent from the floating-point argument arg, and returns it as a floating-point value. Depending on compilation options wraps
::boost::multiprecision::logb(…)or std::logb(…) function.
- lowest([(int)Precision=53]) float :¶
- Returns:
Realreturns the lowest (negative) finite value of theRealtype. Wraps std::numeric_limits<Real>::lowest() function.
- max((float)x, (float)y) float :¶
- Returns:
Reallarger of the two arguments. Depending on compilation options wraps::boost::multiprecision::max(…)or std::max(…) function.
- max_exp2 = 1024¶
- min((float)x, (float)y) float :¶
- Returns:
Realsmaller of the two arguments. Depending on compilation options wraps::boost::multiprecision::min(…)or std::min(…) function.
- modf((float)x) tuple :¶
- Returns:
tuple of
(Real,Real), decomposes given floating pointRealinto integral and fractional parts, each having the same type and sign as x. Depending on compilation options wraps::boost::multiprecision::modf(…)or std::modf(…) function.
- polar((float)x, (float)y) complex :¶
- Returns:
Complexthe polar (Complex from polar components) of theRealrho (length),Realtheta (angle) arguments in radians. Depending on compilation options wraps::boost::multiprecision::polar(…)or std::polar(…) function.
- pow((complex)x, (complex)pow) complex :¶
- Returns:
the
Complexcomplex arg1 raised to theComplexpower arg2. Depending on compilation options wraps::boost::multiprecision::pow(…)or std::pow(…) function.
- pow( (float)x, (float)y) -> float :
- return:
Realthe value ofbaseraised to the powerexp. Depending on compilation options wraps::boost::multiprecision::pow(…)or std::pow(…) function.
- proj((complex)x) complex :¶
- Returns:
Complexthe proj (projection of the complex number onto the Riemann sphere) of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::proj(…)or std::proj(…) function.
- random() float :¶
- Returns:
Reala symmetric random number in interval(-1,1). Used by Eigen.
- random( (float)a, (float)b) -> float :
- return:
Reala random number in interval(a,b). Used by Eigen.
- real((complex)x) float :¶
- Returns:
the real part of a
Complexargument. Depending on compilation options wraps::boost::multiprecision::real(…)or std::real(…) function.
- remainder((float)x, (float)y) float :¶
- Returns:
Realthe IEEE remainder of the floating point division operationx/y. Depending on compilation options wraps::boost::multiprecision::remainder(…)or std::remainder(…) function.
- remquo((float)x, (float)y) tuple :¶
- Returns:
tuple of
(Real,long), the floating-point remainder of the division operationx/yas the std::remainder() function does. Additionally, the sign and at least the three of the last bits ofx/yare returned, sufficient to determine the octant of the result within a period. Depending on compilation options wraps::boost::multiprecision::remquo(…)or std::remquo(…) function.
- rint((float)x) float :¶
- Returns:
Rounds the floating-point argument arg to an integer value (in floating-point format), using the current rounding mode. Depending on compilation options wraps
::boost::multiprecision::rint(…)or std::rint(…) function.
- round((float)x) float :¶
- Returns:
Realthe nearest integer value to arg (in floating-point format), rounding halfway cases away from zero, regardless of the current rounding mode.. Depending on compilation options wraps::boost::multiprecision::round(…)or std::round(…) function.
- roundTrip((float)x) float :¶
- Returns:
Realreturns the argumentx. Can be used to convert type to native RealHP<N> accuracy.
- sgn((float)x) int :¶
- Returns:
intthe sign of the argument:-1,0or1.
- sign((float)x) int :¶
- Returns:
intthe sign of the argument:-1,0or1.
- sin((complex)x) complex :¶
- Returns:
Complexthe sine of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::sin(…)or std::sin(…) function.
- sin( (float)x) -> float :
- return:
Realthe sine of theRealargument in radians. Depending on compilation options wraps::boost::multiprecision::sin(…)or std::sin(…) function.
- sinh((complex)x) complex :¶
- Returns:
Complexthe hyperbolic sine of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::sinh(…)or std::sinh(…) function.
- sinh( (float)x) -> float :
- return:
Realthe hyperbolic sine of theRealargument in radians. Depending on compilation options wraps::boost::multiprecision::sinh(…)or std::sinh(…) function.
- smallest_positive() float :¶
- Returns:
Realthe smallest number greater than zero. Wraps std::numeric_limits<Real>::min()
- sphericalHarmonic((int)l, (int)m, (float)theta, (float)phi) complex :¶
- Returns:
Realthe spherical harmonic polynomial of the ordersl(unsigned int),m(signed int) and theRealargumentsthetaandphi. See: <https://www.boost.org/doc/libs/1_77_0/libs/math/doc/html/math_toolkit/sf_poly/sph_harm.html>`__
- sqrt((complex)x) complex :¶
- Returns:
the
Complexsquare root ofComplexargument. Depending on compilation options wraps::boost::multiprecision::sqrt(…)or std::sqrt(…) function.
- sqrt( (float)x) -> float :
- return:
Realsquare root of the argument. Depending on compilation options wraps::boost::multiprecision::sqrt(…)or std::sqrt(…) function.
- squaredNorm((complex)x) float :¶
- Returns:
Realthe norm (squared magnitude) of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::norm(…)or std::norm(…) function.
- tan((complex)x) complex :¶
- Returns:
Complexthe tangent of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::tan(…)or std::tan(…) function.
- tan( (float)x) -> float :
- return:
Realthe tangent of theRealargument in radians. Depending on compilation options wraps::boost::multiprecision::tan(…)or std::tan(…) function.
- tanh((complex)x) complex :¶
- Returns:
Complexthe hyperbolic tangent of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::tanh(…)or std::tanh(…) function.
- tanh( (float)x) -> float :
- return:
Realthe hyperbolic tangent of theRealargument in radians. Depending on compilation options wraps::boost::multiprecision::tanh(…)or std::tanh(…) function.
- testArray() None :¶
This function tests call to
std::vector::data(…)function in order to extract the array.
- testCgalNumTraits = True¶
- testConstants() None :¶
This function tests lib/high-precision/Constants.hpp, the yade::math::ConstantsHP<N>, former yade::Mathr constants.
- tgamma((float)x) float :¶
- Returns:
RealComputes the gamma function of arg. Depending on compilation options wraps::boost::multiprecision::tgamma(…)or std::tgamma(…) function.
- toDouble((float)x) float :¶
- Returns:
floatconvertsRealtype todoubleand returns a native pythonfloat.
- toHP1((float)x) float :¶
- Returns:
RealHP<1>converted from argumentRealHP<1>as a result ofstatic_cast<RealHP<1>>(arg).
- toHP2((float)x) Real :¶
- Returns:
RealHP<2>converted from argumentRealHP<1>as a result ofstatic_cast<RealHP<2>>(arg).
- toInt((float)x) int :¶
- Returns:
intconvertsRealtype tointand returns a native pythonint.
- toLong((float)x) int :¶
- Returns:
intconvertsRealtype tolong intand returns a native pythonint.
- toLongDouble((float)x) float :¶
- Returns:
floatconvertsRealtype tolong doubleand returns a native pythonfloat.
- trunc((float)x) float :¶
- Returns:
Realthe nearest integer not greater in magnitude than arg. Depending on compilation options wraps::boost::multiprecision::trunc(…)or std::trunc(…) function.
- class yade._math.HP2¶
- AddCost = 2¶
- CGAL_Is_finite((Real)x) bool :¶
CGAL’s function
Is_finite, as described in CGAL algebraic foundations exposed to python for testing of CGAL numerical traits.- Returns:
boolindicating if theRealargument is finite.
- CGAL_Is_valid((Real)x) bool :¶
CGAL’s function
Is_valid, as described in CGAL algebraic foundations exposed to python for testing of CGAL numerical traits.- Returns:
boolindicating if theRealargument is valid. Checks are performed against NaN and Inf.
- CGAL_Kth_root((int)arg1, (Real)x) Real :¶
CGAL’s function
Kth_root, as described in CGAL algebraic foundations exposed to python for testing of CGAL numerical traits.- Returns:
Realthe k-th root of argument.
- CGAL_Sgn((Real)x) int :¶
CGAL’s function
Sgn, as described in CGAL algebraic foundations exposed to python for testing of CGAL numerical traits.- Returns:
sign of the argument, can be
-1,0or1. Not very useful in python. In C++ it is useful to obtain a sign of an expression with exact accuracy, CGAL starts using MPFR internally for this when the approximate interval contains zero inside it.
- CGAL_Sqrt((Real)x) Real :¶
CGAL’s function
Sqrt, as described in CGAL algebraic foundations exposed to python for testing of CGAL numerical traits.- Returns:
Realthe square root of argument.
- CGAL_Square((Real)x) Real :¶
CGAL’s function
Square, as described in CGAL algebraic foundations exposed to python for testing of CGAL numerical traits.- Returns:
Realthe argument squared.
- CGAL_To_interval((Real)x) tuple :¶
CGAL’s function
To_interval, as described in CGAL algebraic foundations exposed to python for testing of CGAL numerical traits.- Returns:
(double,double)tuple inside which the high-precisionRealargument resides.
- CGAL_simpleTest() Real :¶
Tests a simple CGAL calculation. Distance between plane and point, uses CGAL’s sqrt and pow.
- Returns:
3.0
- Catalan([(int)Precision=113]) Real :¶
- Returns:
RealThe catalan constant, exposed to python for testing of eigen numerical traits.
- class Complex¶
The Complex type.
- __init__((object)arg1) None¶
__init__( (object)arg1, (object)obj) -> object
__init__( (object)arg1, (complex)z) -> object
__init__( (object)arg1, (float)d) -> object
__init__( (object)arg1, (int)i) -> object
__init__( (object)arg1, (str)str) -> object
__init__( (object)arg1, (object)re, (object)im) -> object
__init__( (object)arg1, (float)a, (float)b) -> object
__init__( (object)arg1, (int)i, (int)j) -> object
__init__( (object)arg1, (str)str1, (str)str2) -> object
- property imag¶
- levelComplexHPMethod((Complex)arg1) int¶
- property levelHP¶
- property real¶
- ComplexAddCost = 4¶
- ComplexMulCost = 12¶
- ComplexReadCost = 2¶
- Euler([(int)Precision=113]) Real :¶
- Returns:
RealThe Euler–Mascheroni constant, exposed to python for testing of eigen numerical traits.
- IsComplex = 0¶
- IsInteger = 0¶
- IsSigned = 1¶
- Log2([(int)Precision=113]) Real :¶
- Returns:
Realnatural logarithm of 2, exposed to python for testing of eigen numerical traits.
- MulCost = 2¶
- Pi([(int)Precision=113]) Real :¶
- Returns:
RealThe π constant, exposed to python for testing of eigen numerical traits.
- ReadCost = 1¶
- class Real¶
The Real type.
- __init__((object)arg1) None¶
__init__( (object)arg1, (object)obj) -> object
__init__( (object)arg1, (float)d) -> object
__init__( (object)arg1, (int)i) -> object
__init__( (object)arg1, (str)str) -> object
- property imag¶
- property levelHP¶
- levelRealHPMethod((Real)arg1) int¶
- property real¶
- RequireInitialization = 1¶
- class Var¶
The
Varclass is used to test to/from python converters for arbitrary precisionReal- property cpl¶
one
Complexvariable to test reading from and writing to it.
- property val¶
one
Realvariable for testing.
- abs((Complex)x) Real :¶
- Returns:
the
Realabsolute value of theComplexargument. Depending on compilation options wraps::boost::multiprecision::abs(…)or std::abs(…) function.
- abs( (Real)x) -> Real :
- return:
the
Realabsolute value of theRealargument. Depending on compilation options wraps::boost::multiprecision::abs(…)or std::abs(…) function.
- acos((Complex)x) Complex :¶
- Returns:
Complexthe arc-cosine of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::acos(…)or std::acos(…) function.
- acos( (Real)x) -> Real :
- return:
Realthe arcus cosine of the argument. Depending on compilation options wraps::boost::multiprecision::acos(…)or std::acos(…) function.
- acosh((Complex)x) Complex :¶
- Returns:
Complexthe arc-hyperbolic cosine of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::acosh(…)or std::acosh(…) function.
- acosh( (Real)x) -> Real :
- return:
Realthe hyperbolic arcus cosine of the argument. Depending on compilation options wraps::boost::multiprecision::acosh(…)or std::acosh(…) function.
- arg((Complex)x) Real :¶
- Returns:
Realthe arg (Phase angle of complex in radians) of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::arg(…)or std::arg(…) function.
- asin((Complex)x) Complex :¶
- Returns:
Complexthe arc-sine of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::asin(…)or std::asin(…) function.
- asin( (Real)x) -> Real :
- return:
Realthe arcus sine of the argument. Depending on compilation options wraps::boost::multiprecision::asin(…)or std::asin(…) function.
- asinh((Complex)x) Complex :¶
- Returns:
Complexthe arc-hyperbolic sine of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::asinh(…)or std::asinh(…) function.
- asinh( (Real)x) -> Real :
- return:
Realthe hyperbolic arcus sine of the argument. Depending on compilation options wraps::boost::multiprecision::asinh(…)or std::asinh(…) function.
- atan((Complex)x) Complex :¶
- Returns:
Complexthe arc-tangent of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::atan(…)or std::atan(…) function.
- atan( (Real)x) -> Real :
- return:
Realthe arcus tangent of the argument. Depending on compilation options wraps::boost::multiprecision::atan(…)or std::atan(…) function.
- atan2((Real)x, (Real)y) Real :¶
- Returns:
Realthe arc tangent of y/x using the signs of the argumentsxandyto determine the correct quadrant. Depending on compilation options wraps::boost::multiprecision::atan2(…)or std::atan2(…) function.
- atanh((Complex)x) Complex :¶
- Returns:
Complexthe arc-hyperbolic tangent of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::atanh(…)or std::atanh(…) function.
- atanh( (Real)x) -> Real :
- return:
Realthe hyperbolic arcus tangent of the argument. Depending on compilation options wraps::boost::multiprecision::atanh(…)or std::atanh(…) function.
- cbrt((Real)x) Real :¶
- Returns:
Realcubic root of the argument. Depending on compilation options wraps::boost::multiprecision::cbrt(…)or std::cbrt(…) function.
- ceil((Real)x) Real :¶
- Returns:
RealComputes the smallest integer value not less than arg. Depending on compilation options wraps::boost::multiprecision::ceil(…)or std::ceil(…) function.
- conj((Complex)x) Complex :¶
- Returns:
the complex conjugation a
Complexargument. Depending on compilation options wraps::boost::multiprecision::conj(…)or std::conj(…) function.
- cos((Complex)x) Complex :¶
- Returns:
Complexthe cosine of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::cos(…)or std::cos(…) function.
- cos( (Real)x) -> Real :
- return:
Realthe cosine of theRealargument in radians. Depending on compilation options wraps::boost::multiprecision::cos(…)or std::cos(…) function.
- cosh((Complex)x) Complex :¶
- Returns:
Complexthe hyperbolic cosine of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::cosh(…)or std::cosh(…) function.
- cosh( (Real)x) -> Real :
- return:
Realthe hyperbolic cosine of theRealargument in radians. Depending on compilation options wraps::boost::multiprecision::cosh(…)or std::cosh(…) function.
- cylBesselJ((int)k, (Real)x) Real :¶
- Returns:
Realthe Bessel Functions of the First Kind of the orderkand theRealargument. See: <https://www.boost.org/doc/libs/1_77_0/libs/math/doc/html/math_toolkit/bessel/bessel_first.html>`__
- defprec = 113¶
- dummy_precision() Real :¶
- Returns:
similar to the function
epsilon, but assumes that last 10% of bits contain the numerical error only. This is sometimes used by Eigen when callingisEqualFuzzyto determine if values differ a lot or if they are vaguely close to each other.
- epsilon([(int)Precision=113]) Real :¶
- Returns:
Realreturns the difference between1.0and the next representable value of theRealtype. Wraps std::numeric_limits<Real>::epsilon() function.
- epsilon( (Real)x) -> Real :
- return:
Realreturns the difference between1.0and the next representable value of theRealtype. Wraps std::numeric_limits<Real>::epsilon() function.
- erf((Real)x) Real :¶
- Returns:
RealComputes the error function of argument. Depending on compilation options wraps::boost::multiprecision::erf(…)or std::erf(…) function.
- erfc((Real)x) Real :¶
- Returns:
RealComputes the complementary error function of argument, that is1.0-erf(arg). Depending on compilation options wraps::boost::multiprecision::erfc(…)or std::erfc(…) function.
- exp((Complex)x) Complex :¶
- Returns:
the base e exponential of a
Complexargument. Depending on compilation options wraps::boost::multiprecision::exp(…)or std::exp(…) function.
- exp( (Real)x) -> Real :
- return:
the base e exponential of a
Realargument. Depending on compilation options wraps::boost::multiprecision::exp(…)or std::exp(…) function.
- exp2((Real)x) Real :¶
- Returns:
the base 2 exponential of a
Realargument. Depending on compilation options wraps::boost::multiprecision::exp2(…)or std::exp2(…) function.
- expm1((Real)x) Real :¶
- Returns:
the base e exponential of a
Realargument minus1.0. Depending on compilation options wraps::boost::multiprecision::expm1(…)or std::expm1(…) function.
- fabs((Real)x) Real :¶
- Returns:
the
Realabsolute value of the argument. Depending on compilation options wraps::boost::multiprecision::abs(…)or std::abs(…) function.
- factorial((int)x) Real :¶
- Returns:
Realthe factorial of theRealargument. See: <https://www.boost.org/doc/libs/1_77_0/libs/math/doc/html/math_toolkit/factorials/sf_factorial.html>`__
- floor((Real)x) Real :¶
- Returns:
RealComputes the largest integer value not greater than arg. Depending on compilation options wraps::boost::multiprecision::floor(…)or std::floor(…) function.
- fma((Real)x, (Real)y, (Real)z) Real :¶
- Returns:
Real- computes(x*y) + zas if to infinite precision and rounded only once to fit the result type. Depending on compilation options wraps::boost::multiprecision::fma(…)or std::fma(…) function.
- fmod((Real)x, (Real)y) Real :¶
- Returns:
Realthe floating-point remainder of the division operationx/yof the argumentsxandy. Depending on compilation options wraps::boost::multiprecision::fmod(…)or std::fmod(…) function.
- frexp((Real)x) tuple :¶
- Returns:
tuple of
(Real,int), decomposes given floating pointRealargument into a normalized fraction and an integral power of two. Depending on compilation options wraps::boost::multiprecision::frexp(…)or std::frexp(…) function.
- fromBits((str)bits[, (int)exp=0[, (int)sign=1]]) Real :¶
- Parameters:
bits –
str- a string containing ‘0’, ‘1’ characters.exp –
int- the binary exponent which shifts the bits.sign –
int- the sign, should be -1 or +1, but it is not checked. It multiplies the result when construction from bits is finished.
- Returns:
RealHP<N>constructed from string containing ‘0’, ‘1’ bits. This is for debugging purposes, rather slow.
- getDecomposedReal((Real)x) dict :¶
- Returns:
dict- the dictionary with the debug information how the DecomposedReal class sees this type. This is for debugging purposes, rather slow. Includes result from fpclassify function call, a binary representation and other useful info. See also fromBits.
- getDemangledName() str :¶
- Returns:
string- the demangled C++ typnename ofRealHP<N>.
- getDemangledNameComplex() str :¶
- Returns:
string- the demangled C++ typnename ofComplexHP<N>.
- getFloatDistanceULP((Real)arg1, (Real)arg2) Real :¶
- Returns:
an integer value stored in
RealHP<N>, the ULP distance calculated by boost::math::float_distance, also see Floating-point Comparison and Prof. Kahan paper about this topic.
Warning
The returned value is the directed distance between two arguments, this means that it can be negative.
- getRawBits((Real)x) str :¶
- Returns:
string- the raw bits in memory representing this type. Be careful: it only checks the system endianness and either prints bytes in reverse order or not. Does not make any attempts to further interpret the bits of: sign, exponent or significand (on a typical x86 processor they are printed in that order), and different processors might store them differently. It is not useful for types which internally use a pointer because for them this function prints not the floating point number but a pointer. This is for debugging purposes.
- hasInfinityNan = True¶
- highest([(int)Precision=113]) Real :¶
- Returns:
Realreturns the largest finite value of theRealtype. Wraps std::numeric_limits<Real>::max() function.
- hypot((Real)x, (Real)y) Real :¶
- Returns:
Realthe square root of the sum of the squares ofxandy, without undue overflow or underflow at intermediate stages of the computation. Depending on compilation options wraps::boost::multiprecision::hypot(…)or std::hypot(…) function.
- ilogb((Real)x) Real :¶
- Returns:
Realextracts the value of the unbiased exponent from the floating-point argument arg, and returns it as a signed integer value. Depending on compilation options wraps::boost::multiprecision::ilogb(…)or std::ilogb(…) function.
- imag((Complex)x) Real :¶
- Returns:
the imag part of a
Complexargument. Depending on compilation options wraps::boost::multiprecision::imag(…)or std::imag(…) function.
- isApprox((Real)a, (Real)b, (Real)eps) bool :¶
- Returns:
bool, True ifais approximately equalbwith providedeps, see also here
- isApproxOrLessThan((Real)a, (Real)b, (Real)eps) bool :¶
- Returns:
bool, True ifais approximately less than or equalbwith providedeps, see also here
- isEqualFuzzy((Real)arg1, (Real)arg2, (Real)arg3) bool :¶
- Returns:
bool,Trueif the absolute difference between two numbers is smaller than std::numeric_limits<Real>::epsilon()
- isMuchSmallerThan((Real)a, (Real)b, (Real)eps) bool :¶
- Returns:
bool, True ifais less thanbwith providedeps, see also here
- isfinite((Real)x) bool :¶
- Returns:
boolindicating if theRealargument is Inf. Depending on compilation options wraps::boost::multiprecision::isfinite(…)or std::isfinite(…) function.
- isinf((Real)x) bool :¶
- Returns:
boolindicating if theRealargument is Inf. Depending on compilation options wraps::boost::multiprecision::isinf(…)or std::isinf(…) function.
- isnan((Real)x) bool :¶
- Returns:
boolindicating if theRealargument is NaN. Depending on compilation options wraps::boost::multiprecision::isnan(…)or std::isnan(…) function.
- laguerre((int)n, (int)m, (Real)x) Real :¶
- Returns:
Realthe Laguerre polynomial of the ordersn,mand theRealargument. See: <https://www.boost.org/doc/libs/1_77_0/libs/math/doc/html/math_toolkit/sf_poly/laguerre.html>`__
- ldexp((Real)x, (int)y) Real :¶
- Returns:
Multiplies a floating point value
xby the number 2 raised to theexppower. Depending on compilation options wraps::boost::multiprecision::ldexp(…)or std::ldexp(…) function.
- lgamma((Real)x) Real :¶
- Returns:
RealComputes the natural logarithm of the absolute value of the gamma function of arg. Depending on compilation options wraps::boost::multiprecision::lgamma(…)or std::lgamma(…) function.
- log((Complex)x) Complex :¶
- Returns:
the
Complexnatural (base e) logarithm of a complex value z with a branch cut along the negative real axis. Depending on compilation options wraps::boost::multiprecision::log(…)or std::log(…) function.
- log( (Real)x) -> Real :
- return:
the
Realnatural (base e) logarithm of a real value. Depending on compilation options wraps::boost::multiprecision::log(…)or std::log(…) function.
- log10((Complex)x) Complex :¶
- Returns:
the
Complex(base 10) logarithm of a complex value z with a branch cut along the negative real axis. Depending on compilation options wraps::boost::multiprecision::log10(…)or std::log10(…) function.
- log10( (Real)x) -> Real :
- return:
the
Realdecimal (base10) logarithm of a real value. Depending on compilation options wraps::boost::multiprecision::log10(…)or std::log10(…) function.
- log1p((Real)x) Real :¶
- Returns:
the
Realnatural (base e) logarithm of1+argument. Depending on compilation options wraps::boost::multiprecision::log1p(…)or std::log1p(…) function.
- log2((Real)x) Real :¶
- Returns:
the
Realbinary (base2) logarithm of a real value. Depending on compilation options wraps::boost::multiprecision::log2(…)or std::log2(…) function.
- logb((Real)x) Real :¶
- Returns:
Extracts the value of the unbiased radix-independent exponent from the floating-point argument arg, and returns it as a floating-point value. Depending on compilation options wraps
::boost::multiprecision::logb(…)or std::logb(…) function.
- lowest([(int)Precision=113]) Real :¶
- Returns:
Realreturns the lowest (negative) finite value of theRealtype. Wraps std::numeric_limits<Real>::lowest() function.
- max((Real)x, (Real)y) Real :¶
- Returns:
Reallarger of the two arguments. Depending on compilation options wraps::boost::multiprecision::max(…)or std::max(…) function.
- max_exp2 = 16384¶
- min((Real)x, (Real)y) Real :¶
- Returns:
Realsmaller of the two arguments. Depending on compilation options wraps::boost::multiprecision::min(…)or std::min(…) function.
- modf((Real)x) tuple :¶
- Returns:
tuple of
(Real,Real), decomposes given floating pointRealinto integral and fractional parts, each having the same type and sign as x. Depending on compilation options wraps::boost::multiprecision::modf(…)or std::modf(…) function.
- polar((Real)x, (Real)y) Complex :¶
- Returns:
Complexthe polar (Complex from polar components) of theRealrho (length),Realtheta (angle) arguments in radians. Depending on compilation options wraps::boost::multiprecision::polar(…)or std::polar(…) function.
- pow((Complex)x, (Complex)pow) Complex :¶
- Returns:
the
Complexcomplex arg1 raised to theComplexpower arg2. Depending on compilation options wraps::boost::multiprecision::pow(…)or std::pow(…) function.
- pow( (Real)x, (Real)y) -> Real :
- return:
Realthe value ofbaseraised to the powerexp. Depending on compilation options wraps::boost::multiprecision::pow(…)or std::pow(…) function.
- proj((Complex)x) Complex :¶
- Returns:
Complexthe proj (projection of the complex number onto the Riemann sphere) of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::proj(…)or std::proj(…) function.
- random() Real :¶
- Returns:
Reala symmetric random number in interval(-1,1). Used by Eigen.
- random( (Real)a, (Real)b) -> Real :
- return:
Reala random number in interval(a,b). Used by Eigen.
- real((Complex)x) Real :¶
- Returns:
the real part of a
Complexargument. Depending on compilation options wraps::boost::multiprecision::real(…)or std::real(…) function.
- remainder((Real)x, (Real)y) Real :¶
- Returns:
Realthe IEEE remainder of the floating point division operationx/y. Depending on compilation options wraps::boost::multiprecision::remainder(…)or std::remainder(…) function.
- remquo((Real)x, (Real)y) tuple :¶
- Returns:
tuple of
(Real,long), the floating-point remainder of the division operationx/yas the std::remainder() function does. Additionally, the sign and at least the three of the last bits ofx/yare returned, sufficient to determine the octant of the result within a period. Depending on compilation options wraps::boost::multiprecision::remquo(…)or std::remquo(…) function.
- rint((Real)x) Real :¶
- Returns:
Rounds the floating-point argument arg to an integer value (in floating-point format), using the current rounding mode. Depending on compilation options wraps
::boost::multiprecision::rint(…)or std::rint(…) function.
- round((Real)x) Real :¶
- Returns:
Realthe nearest integer value to arg (in floating-point format), rounding halfway cases away from zero, regardless of the current rounding mode.. Depending on compilation options wraps::boost::multiprecision::round(…)or std::round(…) function.
- roundTrip((Real)x) Real :¶
- Returns:
Realreturns the argumentx. Can be used to convert type to native RealHP<N> accuracy.
- sgn((Real)x) int :¶
- Returns:
intthe sign of the argument:-1,0or1.
- sign((Real)x) int :¶
- Returns:
intthe sign of the argument:-1,0or1.
- sin((Complex)x) Complex :¶
- Returns:
Complexthe sine of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::sin(…)or std::sin(…) function.
- sin( (Real)x) -> Real :
- return:
Realthe sine of theRealargument in radians. Depending on compilation options wraps::boost::multiprecision::sin(…)or std::sin(…) function.
- sinh((Complex)x) Complex :¶
- Returns:
Complexthe hyperbolic sine of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::sinh(…)or std::sinh(…) function.
- sinh( (Real)x) -> Real :
- return:
Realthe hyperbolic sine of theRealargument in radians. Depending on compilation options wraps::boost::multiprecision::sinh(…)or std::sinh(…) function.
- smallest_positive() Real :¶
- Returns:
Realthe smallest number greater than zero. Wraps std::numeric_limits<Real>::min()
- sphericalHarmonic((int)l, (int)m, (Real)theta, (Real)phi) Complex :¶
- Returns:
Realthe spherical harmonic polynomial of the ordersl(unsigned int),m(signed int) and theRealargumentsthetaandphi. See: <https://www.boost.org/doc/libs/1_77_0/libs/math/doc/html/math_toolkit/sf_poly/sph_harm.html>`__
- sqrt((Complex)x) Complex :¶
- Returns:
the
Complexsquare root ofComplexargument. Depending on compilation options wraps::boost::multiprecision::sqrt(…)or std::sqrt(…) function.
- sqrt( (Real)x) -> Real :
- return:
Realsquare root of the argument. Depending on compilation options wraps::boost::multiprecision::sqrt(…)or std::sqrt(…) function.
- squaredNorm((Complex)x) Real :¶
- Returns:
Realthe norm (squared magnitude) of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::norm(…)or std::norm(…) function.
- tan((Complex)x) Complex :¶
- Returns:
Complexthe tangent of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::tan(…)or std::tan(…) function.
- tan( (Real)x) -> Real :
- return:
Realthe tangent of theRealargument in radians. Depending on compilation options wraps::boost::multiprecision::tan(…)or std::tan(…) function.
- tanh((Complex)x) Complex :¶
- Returns:
Complexthe hyperbolic tangent of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::tanh(…)or std::tanh(…) function.
- tanh( (Real)x) -> Real :
- return:
Realthe hyperbolic tangent of theRealargument in radians. Depending on compilation options wraps::boost::multiprecision::tanh(…)or std::tanh(…) function.
- testArray() None :¶
This function tests call to
std::vector::data(…)function in order to extract the array.
- testCgalNumTraits = True¶
- testConstants() None :¶
This function tests lib/high-precision/Constants.hpp, the yade::math::ConstantsHP<N>, former yade::Mathr constants.
- tgamma((Real)x) Real :¶
- Returns:
RealComputes the gamma function of arg. Depending on compilation options wraps::boost::multiprecision::tgamma(…)or std::tgamma(…) function.
- toDouble((Real)x) float :¶
- Returns:
floatconvertsRealtype todoubleand returns a native pythonfloat.
- toHP1((Real)x) float :¶
- Returns:
RealHP<1>converted from argumentRealHP<2>as a result ofstatic_cast<RealHP<1>>(arg).
- toHP2((Real)x) Real :¶
- Returns:
RealHP<2>converted from argumentRealHP<2>as a result ofstatic_cast<RealHP<2>>(arg).
- toInt((Real)x) int :¶
- Returns:
intconvertsRealtype tointand returns a native pythonint.
- toLong((Real)x) int :¶
- Returns:
intconvertsRealtype tolong intand returns a native pythonint.
- toLongDouble((Real)x) float :¶
- Returns:
floatconvertsRealtype tolong doubleand returns a native pythonfloat.
- trunc((Real)x) Real :¶
- Returns:
Realthe nearest integer not greater in magnitude than arg. Depending on compilation options wraps::boost::multiprecision::trunc(…)or std::trunc(…) function.
- yade._math.Log2([(int)Precision=53]) float¶
- Returns:
Realnatural logarithm of 2, exposed to python for testing of eigen numerical traits.
- yade._math.Pi([(int)Precision=53]) float¶
- Returns:
RealThe π constant, exposed to python for testing of eigen numerical traits.
- class yade._math.RealHPConfig¶
RealHPConfigclass provides information about RealHP<N> type.- Variables:
extraStringDigits10 – this static variable allows to control how many extra digits to use when converting to decimal strings. Assign a different value to it to affect the string conversion done in C++ ↔ python conversions as well as in all other conversions. Be careful, because values smaller than 3 can fail the round trip conversion test.
isFloat128Broken – provides runtime information if Yade was compiled with g++ version < 9.2.1 and thus
boost::multiprecision::float128cannot work.isEnabledRealHP – provides runtime information
RealHP<N>is available for N higher than 1.workaroundSlowBoostBinFloat –
boost::multiprecision::cpp_bin_floathas some problem that importing it in python is very slow when these functions are exported: erf, erfc, lgamma, tgamma. In such case the pythonimport yade.mathcan take more than minute. The workaround is to make them unavailable in python for higher N values. See invocation of IfConstexprForSlowFunctions in _math.cpp. This variable contains the highest N in which these functions are available. It equals to highest N whenboost::multiprecision::cpp_bin_floatis not used.
- extraStringDigits10 = 4¶
- getDigits10((int)N) int :¶
This is a yade.math.RealHPConfig diagnostic function.
- Parameters:
N –
int- the value ofNinRealHP<N>.- Returns:
the
intrepresentingstd::numeric_limits<RealHP<N>>::digits10
- getDigits2((int)N) int :¶
This is a yade.math.RealHPConfig diagnostic function.
- Parameters:
N –
int- the value ofNinRealHP<N>.- Returns:
the
intrepresentingstd::numeric_limits<RealHP<N>>::digits, which corresponds to the number of significand bits used by this type.
- getSupportedByEigenCgal() tuple :¶
- Returns:
the
tuplecontainingNfromRealHP<N>precisions supported by Eigen and CGAL
- getSupportedByMinieigen() tuple :¶
- Returns:
the
tuplecontainingNfromRealHP<N>precisions supported by minieigenHP
- isEnabledRealHP = True¶
- isFloat128Broken = False¶
- isFloat128Present = True¶
- workaroundSlowBoostBinFloat = 2¶
- class yade._math.Var¶
The
Varclass is used to test to/from python converters for arbitrary precisionReal- property cpl¶
one
Complexvariable to test reading from and writing to it.
- property val¶
one
Realvariable for testing.
- yade._math.abs((complex)x) float¶
- return:
the
Realabsolute value of theComplexargument. Depending on compilation options wraps::boost::multiprecision::abs(…)or std::abs(…) function.
- abs( (float)x) → float :
- return:
the
Realabsolute value of theRealargument. Depending on compilation options wraps::boost::multiprecision::abs(…)or std::abs(…) function.
- yade._math.acos((complex)x) complex¶
- return:
Complexthe arc-cosine of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::acos(…)or std::acos(…) function.
- acos( (float)x) → float :
- return:
Realthe arcus cosine of the argument. Depending on compilation options wraps::boost::multiprecision::acos(…)or std::acos(…) function.
- yade._math.acosh((complex)x) complex¶
- return:
Complexthe arc-hyperbolic cosine of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::acosh(…)or std::acosh(…) function.
- acosh( (float)x) → float :
- return:
Realthe hyperbolic arcus cosine of the argument. Depending on compilation options wraps::boost::multiprecision::acosh(…)or std::acosh(…) function.
- yade._math.arg((complex)x) float¶
- Returns:
Realthe arg (Phase angle of complex in radians) of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::arg(…)or std::arg(…) function.
- yade._math.asin((complex)x) complex¶
- return:
Complexthe arc-sine of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::asin(…)or std::asin(…) function.
- asin( (float)x) → float :
- return:
Realthe arcus sine of the argument. Depending on compilation options wraps::boost::multiprecision::asin(…)or std::asin(…) function.
- yade._math.asinh((complex)x) complex¶
- return:
Complexthe arc-hyperbolic sine of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::asinh(…)or std::asinh(…) function.
- asinh( (float)x) → float :
- return:
Realthe hyperbolic arcus sine of the argument. Depending on compilation options wraps::boost::multiprecision::asinh(…)or std::asinh(…) function.
- yade._math.atan((complex)x) complex¶
- return:
Complexthe arc-tangent of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::atan(…)or std::atan(…) function.
- atan( (float)x) → float :
- return:
Realthe arcus tangent of the argument. Depending on compilation options wraps::boost::multiprecision::atan(…)or std::atan(…) function.
- yade._math.atan2((float)x, (float)y) float¶
- Returns:
Realthe arc tangent of y/x using the signs of the argumentsxandyto determine the correct quadrant. Depending on compilation options wraps::boost::multiprecision::atan2(…)or std::atan2(…) function.
- yade._math.atanh((complex)x) complex¶
- return:
Complexthe arc-hyperbolic tangent of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::atanh(…)or std::atanh(…) function.
- atanh( (float)x) → float :
- return:
Realthe hyperbolic arcus tangent of the argument. Depending on compilation options wraps::boost::multiprecision::atanh(…)or std::atanh(…) function.
- yade._math.cbrt((float)x) float¶
- Returns:
Realcubic root of the argument. Depending on compilation options wraps::boost::multiprecision::cbrt(…)or std::cbrt(…) function.
- yade._math.ceil((float)x) float¶
- Returns:
RealComputes the smallest integer value not less than arg. Depending on compilation options wraps::boost::multiprecision::ceil(…)or std::ceil(…) function.
- yade._math.conj((complex)x) complex¶
- Returns:
the complex conjugation a
Complexargument. Depending on compilation options wraps::boost::multiprecision::conj(…)or std::conj(…) function.
- yade._math.cos((complex)x) complex¶
- return:
Complexthe cosine of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::cos(…)or std::cos(…) function.
- cos( (float)x) → float :
- return:
Realthe cosine of theRealargument in radians. Depending on compilation options wraps::boost::multiprecision::cos(…)or std::cos(…) function.
- yade._math.cosh((complex)x) complex¶
- return:
Complexthe hyperbolic cosine of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::cosh(…)or std::cosh(…) function.
- cosh( (float)x) → float :
- return:
Realthe hyperbolic cosine of theRealargument in radians. Depending on compilation options wraps::boost::multiprecision::cosh(…)or std::cosh(…) function.
- yade._math.cylBesselJ((int)k, (float)x) float¶
- Returns:
Realthe Bessel Functions of the First Kind of the orderkand theRealargument. See: <https://www.boost.org/doc/libs/1_77_0/libs/math/doc/html/math_toolkit/bessel/bessel_first.html>`__
- yade._math.dummy_precision() float¶
- Returns:
similar to the function
epsilon, but assumes that last 10% of bits contain the numerical error only. This is sometimes used by Eigen when callingisEqualFuzzyto determine if values differ a lot or if they are vaguely close to each other.
- yade._math.epsilon([(int)Precision=53]) float¶
- return:
Realreturns the difference between1.0and the next representable value of theRealtype. Wraps std::numeric_limits<Real>::epsilon() function.
- epsilon( (float)x) → float :
- return:
Realreturns the difference between1.0and the next representable value of theRealtype. Wraps std::numeric_limits<Real>::epsilon() function.
- yade._math.erf((float)x) float¶
- Returns:
RealComputes the error function of argument. Depending on compilation options wraps::boost::multiprecision::erf(…)or std::erf(…) function.
- yade._math.erfc((float)x) float¶
- Returns:
RealComputes the complementary error function of argument, that is1.0-erf(arg). Depending on compilation options wraps::boost::multiprecision::erfc(…)or std::erfc(…) function.
- yade._math.exp((complex)x) complex¶
- return:
the base e exponential of a
Complexargument. Depending on compilation options wraps::boost::multiprecision::exp(…)or std::exp(…) function.
- exp( (float)x) → float :
- return:
the base e exponential of a
Realargument. Depending on compilation options wraps::boost::multiprecision::exp(…)or std::exp(…) function.
- yade._math.exp2((float)x) float¶
- Returns:
the base 2 exponential of a
Realargument. Depending on compilation options wraps::boost::multiprecision::exp2(…)or std::exp2(…) function.
- yade._math.expm1((float)x) float¶
- Returns:
the base e exponential of a
Realargument minus1.0. Depending on compilation options wraps::boost::multiprecision::expm1(…)or std::expm1(…) function.
- yade._math.fabs((float)x) float¶
- Returns:
the
Realabsolute value of the argument. Depending on compilation options wraps::boost::multiprecision::abs(…)or std::abs(…) function.
- yade._math.factorial((int)x) float¶
- Returns:
Realthe factorial of theRealargument. See: <https://www.boost.org/doc/libs/1_77_0/libs/math/doc/html/math_toolkit/factorials/sf_factorial.html>`__
- yade._math.floor((float)x) float¶
- Returns:
RealComputes the largest integer value not greater than arg. Depending on compilation options wraps::boost::multiprecision::floor(…)or std::floor(…) function.
- yade._math.fma((float)x, (float)y, (float)z) float¶
- Returns:
Real- computes(x*y) + zas if to infinite precision and rounded only once to fit the result type. Depending on compilation options wraps::boost::multiprecision::fma(…)or std::fma(…) function.
- yade._math.fmod((float)x, (float)y) float¶
- Returns:
Realthe floating-point remainder of the division operationx/yof the argumentsxandy. Depending on compilation options wraps::boost::multiprecision::fmod(…)or std::fmod(…) function.
- yade._math.frexp((float)x) tuple¶
- Returns:
tuple of
(Real,int), decomposes given floating pointRealargument into a normalized fraction and an integral power of two. Depending on compilation options wraps::boost::multiprecision::frexp(…)or std::frexp(…) function.
- yade._math.fromBits((str)bits[, (int)exp=0[, (int)sign=1]]) float¶
- Parameters:
bits –
str- a string containing ‘0’, ‘1’ characters.exp –
int- the binary exponent which shifts the bits.sign –
int- the sign, should be -1 or +1, but it is not checked. It multiplies the result when construction from bits is finished.
- Returns:
RealHP<N>constructed from string containing ‘0’, ‘1’ bits. This is for debugging purposes, rather slow.
- yade._math.getDecomposedReal((float)x) dict¶
- Returns:
dict- the dictionary with the debug information how the DecomposedReal class sees this type. This is for debugging purposes, rather slow. Includes result from fpclassify function call, a binary representation and other useful info. See also fromBits.
- yade._math.getDemangledName() str¶
- Returns:
string- the demangled C++ typnename ofRealHP<N>.
- yade._math.getDemangledNameComplex() str¶
- Returns:
string- the demangled C++ typnename ofComplexHP<N>.
- yade._math.getEigenFlags() dict¶
- Returns:
A python dictionary listing flags for all types, see: https://eigen.tuxfamily.org/dox/group__flags.html
- yade._math.getEigenStorageOrders() dict¶
- Returns:
A python dictionary listing options for all types, see: https://eigen.tuxfamily.org/dox/group__TopicStorageOrders.html
- yade._math.getFloatDistanceULP((float)arg1, (float)arg2) float¶
- Returns:
an integer value stored in
RealHP<N>, the ULP distance calculated by boost::math::float_distance, also see Floating-point Comparison and Prof. Kahan paper about this topic.
The returned value is the directed distance between two arguments, this means that it can be negative.
- yade._math.getRawBits((float)x) str¶
- Returns:
string- the raw bits in memory representing this type. Be careful: it only checks the system endianness and either prints bytes in reverse order or not. Does not make any attempts to further interpret the bits of: sign, exponent or significand (on a typical x86 processor they are printed in that order), and different processors might store them differently. It is not useful for types which internally use a pointer because for them this function prints not the floating point number but a pointer. This is for debugging purposes.
- yade._math.getRealHPErrors((list)testLevelsHP[, (int)testCount=10[, (float)minX=-10.0[, (float)maxX=10.0[, (bool)useRandomArgs=False[, (int)printEveryNth=1000[, (bool)collectArgs=False[, (bool)extraChecks=False]]]]]]]) dict¶
Tests mathematical functions against the highest precision in argument
testLevelsHPand returns the largest ULP distance found with getFloatDistanceULP. AtestCountrandomized tries with function arguments in rangeminX ... maxXare performed on theRealHP<N>types whereNis from the list provided intestLevelsHPargument.- Parameters:
testLevelsHP – a
listofintvalues consisting of high precision levelsN(inRealHP<N>) for which the tests should be done. Must consist at least of two elements so that there is a higher precision type available against which to perform the tests.testCount –
int- specifies how many randomized tests of each function to perform.minX –
Real- start of the range in which the random arguments are generated.maxX –
Real- end of that range.useRandomArgs – If
False(default) thenminX ... maxXis divided intotestCountequidistant points. IfTruethen each call is a random number. This applies only to the first argument of a function, if a function takes more than one argument, then remaining arguments are random - 2D scans are not performed.printEveryNth – will print using
LOG_INFOthe progress information every Nth step in thetestCountloop. To see it e.g. start usingyade -f6, also see logger documentation.collectArgs – if
Truethen in returned results will be a longer list of arguments that produce incorrect results.extraChecks – will perform extra checks while executing this funcion. Useful only for debugging of getRealHPErrors.
- Returns:
A python dictionary with the largest ULP distance to the correct function value. For each function name there is a dictionary consisting of: how many binary digits (bits) are in the tested
RealHP<N>type, the worst arguments for this function, and the ULP distance to the reference value.
The returned ULP error is an absolute value, as opposed to getFloatDistanceULP which is signed.
- yade._math.highest([(int)Precision=53]) float¶
- Returns:
Realreturns the largest finite value of theRealtype. Wraps std::numeric_limits<Real>::max() function.
- yade._math.hypot((float)x, (float)y) float¶
- Returns:
Realthe square root of the sum of the squares ofxandy, without undue overflow or underflow at intermediate stages of the computation. Depending on compilation options wraps::boost::multiprecision::hypot(…)or std::hypot(…) function.
- yade._math.ilogb((float)x) float¶
- Returns:
Realextracts the value of the unbiased exponent from the floating-point argument arg, and returns it as a signed integer value. Depending on compilation options wraps::boost::multiprecision::ilogb(…)or std::ilogb(…) function.
- yade._math.imag((complex)x) float¶
- Returns:
the imag part of a
Complexargument. Depending on compilation options wraps::boost::multiprecision::imag(…)or std::imag(…) function.
- yade._math.isApprox((float)a, (float)b, (float)eps) bool¶
- Returns:
bool, True ifais approximately equalbwith providedeps, see also here
- yade._math.isApproxOrLessThan((float)a, (float)b, (float)eps) bool¶
- Returns:
bool, True ifais approximately less than or equalbwith providedeps, see also here
- yade._math.isEqualFuzzy((float)arg1, (float)arg2, (float)arg3) bool¶
- Returns:
bool,Trueif the absolute difference between two numbers is smaller than std::numeric_limits<Real>::epsilon()
- yade._math.isMuchSmallerThan((float)a, (float)b, (float)eps) bool¶
- Returns:
bool, True ifais less thanbwith providedeps, see also here
- yade._math.isThisSystemLittleEndian() bool¶
- Returns:
Trueif this system uses little endian architecture,Falseotherwise.
- yade._math.isfinite((float)x) bool¶
- Returns:
boolindicating if theRealargument is Inf. Depending on compilation options wraps::boost::multiprecision::isfinite(…)or std::isfinite(…) function.
- yade._math.isinf((float)x) bool¶
- Returns:
boolindicating if theRealargument is Inf. Depending on compilation options wraps::boost::multiprecision::isinf(…)or std::isinf(…) function.
- yade._math.isnan((float)x) bool¶
- Returns:
boolindicating if theRealargument is NaN. Depending on compilation options wraps::boost::multiprecision::isnan(…)or std::isnan(…) function.
- yade._math.laguerre((int)n, (int)m, (float)x) float¶
- Returns:
Realthe Laguerre polynomial of the ordersn,mand theRealargument. See: <https://www.boost.org/doc/libs/1_77_0/libs/math/doc/html/math_toolkit/sf_poly/laguerre.html>`__
- yade._math.ldexp((float)x, (int)y) float¶
- Returns:
Multiplies a floating point value
xby the number 2 raised to theexppower. Depending on compilation options wraps::boost::multiprecision::ldexp(…)or std::ldexp(…) function.
- yade._math.lgamma((float)x) float¶
- Returns:
RealComputes the natural logarithm of the absolute value of the gamma function of arg. Depending on compilation options wraps::boost::multiprecision::lgamma(…)or std::lgamma(…) function.
- yade._math.log((complex)x) complex¶
- return:
the
Complexnatural (base e) logarithm of a complex value z with a branch cut along the negative real axis. Depending on compilation options wraps::boost::multiprecision::log(…)or std::log(…) function.
- log( (float)x) → float :
- return:
the
Realnatural (base e) logarithm of a real value. Depending on compilation options wraps::boost::multiprecision::log(…)or std::log(…) function.
- yade._math.log10((complex)x) complex¶
- return:
the
Complex(base 10) logarithm of a complex value z with a branch cut along the negative real axis. Depending on compilation options wraps::boost::multiprecision::log10(…)or std::log10(…) function.
- log10( (float)x) → float :
- return:
the
Realdecimal (base10) logarithm of a real value. Depending on compilation options wraps::boost::multiprecision::log10(…)or std::log10(…) function.
- yade._math.log1p((float)x) float¶
- Returns:
the
Realnatural (base e) logarithm of1+argument. Depending on compilation options wraps::boost::multiprecision::log1p(…)or std::log1p(…) function.
- yade._math.log2((float)x) float¶
- Returns:
the
Realbinary (base2) logarithm of a real value. Depending on compilation options wraps::boost::multiprecision::log2(…)or std::log2(…) function.
- yade._math.logb((float)x) float¶
- Returns:
Extracts the value of the unbiased radix-independent exponent from the floating-point argument arg, and returns it as a floating-point value. Depending on compilation options wraps
::boost::multiprecision::logb(…)or std::logb(…) function.
- yade._math.lowest([(int)Precision=53]) float¶
- Returns:
Realreturns the lowest (negative) finite value of theRealtype. Wraps std::numeric_limits<Real>::lowest() function.
- yade._math.max((float)x, (float)y) float¶
- Returns:
Reallarger of the two arguments. Depending on compilation options wraps::boost::multiprecision::max(…)or std::max(…) function.
- yade._math.min((float)x, (float)y) float¶
- Returns:
Realsmaller of the two arguments. Depending on compilation options wraps::boost::multiprecision::min(…)or std::min(…) function.
- yade._math.modf((float)x) tuple¶
- Returns:
tuple of
(Real,Real), decomposes given floating pointRealinto integral and fractional parts, each having the same type and sign as x. Depending on compilation options wraps::boost::multiprecision::modf(…)or std::modf(…) function.
- yade._math.polar((float)x, (float)y) complex¶
- Returns:
Complexthe polar (Complex from polar components) of theRealrho (length),Realtheta (angle) arguments in radians. Depending on compilation options wraps::boost::multiprecision::polar(…)or std::polar(…) function.
- yade._math.pow((complex)x, (complex)pow) complex¶
- return:
the
Complexcomplex arg1 raised to theComplexpower arg2. Depending on compilation options wraps::boost::multiprecision::pow(…)or std::pow(…) function.
- pow( (float)x, (float)y) → float :
- return:
Realthe value ofbaseraised to the powerexp. Depending on compilation options wraps::boost::multiprecision::pow(…)or std::pow(…) function.
- yade._math.proj((complex)x) complex¶
- Returns:
Complexthe proj (projection of the complex number onto the Riemann sphere) of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::proj(…)or std::proj(…) function.
- yade._math.random() float¶
- return:
Reala symmetric random number in interval(-1,1). Used by Eigen.
- random( (float)a, (float)b) → float :
- return:
Reala random number in interval(a,b). Used by Eigen.
- yade._math.real((complex)x) float¶
- Returns:
the real part of a
Complexargument. Depending on compilation options wraps::boost::multiprecision::real(…)or std::real(…) function.
- yade._math.remainder((float)x, (float)y) float¶
- Returns:
Realthe IEEE remainder of the floating point division operationx/y. Depending on compilation options wraps::boost::multiprecision::remainder(…)or std::remainder(…) function.
- yade._math.remquo((float)x, (float)y) tuple¶
- Returns:
tuple of
(Real,long), the floating-point remainder of the division operationx/yas the std::remainder() function does. Additionally, the sign and at least the three of the last bits ofx/yare returned, sufficient to determine the octant of the result within a period. Depending on compilation options wraps::boost::multiprecision::remquo(…)or std::remquo(…) function.
- yade._math.rint((float)x) float¶
- Returns:
Rounds the floating-point argument arg to an integer value (in floating-point format), using the current rounding mode. Depending on compilation options wraps
::boost::multiprecision::rint(…)or std::rint(…) function.
- yade._math.round((float)x) float¶
- Returns:
Realthe nearest integer value to arg (in floating-point format), rounding halfway cases away from zero, regardless of the current rounding mode.. Depending on compilation options wraps::boost::multiprecision::round(…)or std::round(…) function.
- yade._math.roundTrip((float)x) float¶
- Returns:
Realreturns the argumentx. Can be used to convert type to native RealHP<N> accuracy.
- yade._math.sgn((float)x) int¶
- Returns:
intthe sign of the argument:-1,0or1.
- yade._math.sign((float)x) int¶
- Returns:
intthe sign of the argument:-1,0or1.
- yade._math.sin((complex)x) complex¶
- return:
Complexthe sine of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::sin(…)or std::sin(…) function.
- sin( (float)x) → float :
- return:
Realthe sine of theRealargument in radians. Depending on compilation options wraps::boost::multiprecision::sin(…)or std::sin(…) function.
- yade._math.sinh((complex)x) complex¶
- return:
Complexthe hyperbolic sine of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::sinh(…)or std::sinh(…) function.
- sinh( (float)x) → float :
- return:
Realthe hyperbolic sine of theRealargument in radians. Depending on compilation options wraps::boost::multiprecision::sinh(…)or std::sinh(…) function.
- yade._math.smallest_positive() float¶
- Returns:
Realthe smallest number greater than zero. Wraps std::numeric_limits<Real>::min()
- yade._math.sphericalHarmonic((int)l, (int)m, (float)theta, (float)phi) complex¶
- Returns:
Realthe spherical harmonic polynomial of the ordersl(unsigned int),m(signed int) and theRealargumentsthetaandphi. See: <https://www.boost.org/doc/libs/1_77_0/libs/math/doc/html/math_toolkit/sf_poly/sph_harm.html>`__
- yade._math.sqrt((complex)x) complex¶
- return:
the
Complexsquare root ofComplexargument. Depending on compilation options wraps::boost::multiprecision::sqrt(…)or std::sqrt(…) function.
- sqrt( (float)x) → float :
- return:
Realsquare root of the argument. Depending on compilation options wraps::boost::multiprecision::sqrt(…)or std::sqrt(…) function.
- yade._math.squaredNorm((complex)x) float¶
- Returns:
Realthe norm (squared magnitude) of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::norm(…)or std::norm(…) function.
- yade._math.tan((complex)x) complex¶
- return:
Complexthe tangent of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::tan(…)or std::tan(…) function.
- tan( (float)x) → float :
- return:
Realthe tangent of theRealargument in radians. Depending on compilation options wraps::boost::multiprecision::tan(…)or std::tan(…) function.
- yade._math.tanh((complex)x) complex¶
- return:
Complexthe hyperbolic tangent of theComplexargument in radians. Depending on compilation options wraps::boost::multiprecision::tanh(…)or std::tanh(…) function.
- tanh( (float)x) → float :
- return:
Realthe hyperbolic tangent of theRealargument in radians. Depending on compilation options wraps::boost::multiprecision::tanh(…)or std::tanh(…) function.
- yade._math.testArray() None¶
This function tests call to
std::vector::data(…)function in order to extract the array.
- yade._math.testConstants() None¶
This function tests lib/high-precision/Constants.hpp, the yade::math::ConstantsHP<N>, former yade::Mathr constants.
- yade._math.testLoopRealHP() None¶
This function tests lib/high-precision/Constants.hpp, but the C++ side: all precisions, even those inaccessible from python
- yade._math.tgamma((float)x) float¶
- Returns:
RealComputes the gamma function of arg. Depending on compilation options wraps::boost::multiprecision::tgamma(…)or std::tgamma(…) function.
- yade._math.toDouble((float)x) float¶
- Returns:
floatconvertsRealtype todoubleand returns a native pythonfloat.
- yade._math.toHP1((float)x) float¶
- Returns:
RealHP<1>converted from argumentRealHP<1>as a result ofstatic_cast<RealHP<1>>(arg).
- yade._math.toHP2((float)x) Real¶
- Returns:
RealHP<2>converted from argumentRealHP<1>as a result ofstatic_cast<RealHP<2>>(arg).
- yade._math.toInt((float)x) int¶
- Returns:
intconvertsRealtype tointand returns a native pythonint.
- yade._math.toLong((float)x) int¶
- Returns:
intconvertsRealtype tolong intand returns a native pythonint.
- yade._math.toLongDouble((float)x) float¶
- Returns:
floatconvertsRealtype tolong doubleand returns a native pythonfloat.
- yade._math.trunc((float)x) float¶
- Returns:
Realthe nearest integer not greater in magnitude than arg. Depending on compilation options wraps::boost::multiprecision::trunc(…)or std::trunc(…) function.