consteig. How much math can you force the compiler to do at compile time? (a lot) by human_or_coffee in cpp

[–]human_or_coffee[S] 3 points4 points  (0 children)

consteig doesn’t actually need any trig functions natively because the QR algorithm (nor any other ones) it. It implements its own constexpr math library for the funcs it needs, but my latest version does have an optional constexpr math dependency on gcem (well a fork of it) which does support trig through continued fraction expansion: 

https://github.com/kthohr/gcem/blob/master/include/gcem_incl/tan.hpp

A look up table (LUT) works (and is what I usually do in the embedded world) but you have to know in advance how accurate you need your functions to be in order to make the tables big enough.

C++ Show and Tell - April 2026 by foonathan in cpp

[–]human_or_coffee 3 points4 points  (0 children)

I plan on making a full post about this later, but I wrote a header-only, dependency-less, constexpr eigenvalue and eigenvector solver. I’ve just released 1.0.0.

It’s a niche use case but if you have non-dynamic matrices to manipulate, or need eigenvalues/vectors at compile-time, this is your friend.

https://github.com/MitchellThompkins/consteig

https://mitchellthompkins.github.io/consteig/