-
Compile time conditionals in C++
Often when doing template metaprogramming in C++, we run into the issue of dealing with compile-time conditionals. Though we can use
std::conditional
as a compile-time equivalent toif
, there isn’t a compile-time equivalent toswitch
in the standard library which, in my opinion, could lead to more succinct and readable code. -
Automatic differentiation with nilpotent numbers
When first learning about derivatives in calculus, we often see a definition along the lines of
\[f'(x) \equiv \lim_{h \to 0} \frac{f(x + h) - f(x)}{h}.\]This definition works just fine, and gives a good intuition for what a derivative is. However, it isn’t a definition can be readily implemented in some programmatic way. The most obvious way to do this is through forward finite differences: we choose some small value for \(h\), and then compute the above expression (without the limit) directly. The quality of the approximation will depend on the function and on the value of \(h\) that is chosen.
- •
- 1
- •