|
MTL5 -- Matrix Template Library C++ API
mtl:: -- C++20 header-only linear algebra for mixed-precision algorithm design
|
A type that forms a mathematical field: division is defined AND invertible. More...
#include <scalar.hpp>
A type that forms a mathematical field: division is defined AND invertible.
Integral types are excluded, and that exclusion is the point. int satisfies the syntax – a / b compiles and yields an int – so a purely syntactic Field admitted the integers, which are a RING, not a field: 3/2*2 == 2, and only 1 and -1 have inverses. Every algorithm that says requires Field means "I will divide and expect the quotient back", and on integers it silently gets a truncated one. That is how lu_factor(dense2D<int>) used to compile and return confident nonsense.
Custom number types (posit, LNS, fixpnt, rationals) are unaffected: they are not std::is_integral and their division is the operation they advertise.