chsvlib
chsv helper source code

◆ MultiplicativeInverse()

T Chusov::Math::MultiplicativeInverse ( const T &  x)

A helper function that calculates a multiplicative inversion of a given value of a given type and returns the result.

Template Parameters
Tis a type of an object to be multiplicatively inverted. See remarks to the requirements for the type.
Parameters
xis an object to be inverted.
Returns
A result of the inversion.

If the type T is a class type which defines the method MultiplicativeInverse which, if applied to a const-qualified object of the type T, yields a new object of the type T, then the function simply calls that method and returns the result.

Otherwise, if the expression

@ multiplicative_identity
A tag to construct multiplicative identity element. See ring_concept.
Definition: chsvmath.h:1005

, where x is a value of type the T which is not an additive identity of T, is well-formed, the function evaluates the result of the expression and returns it as-is. This covers the cases for all C++ fundamental arithmetic types, for which std::is_arithmetic <T>::value is true.

Examples
chsvmath\algebraic_traits.cpp.