Template metaprogramming is a popular technique for implementing compile time mechanisms for numerical computing. We demonstrate how expression templates can be used for compile time symbolic differentiation of algebraic expressions in C++ computer programs. Given a positive integer $N$ and an algebraic function of multiple variables, the compiler generates executable code for the $N$th partial derivatives of the function. Compile-time simplification of the derivative expressions is achieved using recursive templates. A detailed analysis indicates that current C++ compiler technology is already sufficient for practical use of our results, and highlights a number of issues where further improvements may be desirable.
翻译:模板元方案绘制是实施数字计算时间机制的流行技术。 我们演示了如何使用表达式模板来汇编C++计算机程序对代数表达式的时间符号区分。 鉴于正整数$N$和多个变量的代数函数, 编译器生成了该函数第几个部分衍生物的可执行代码。 使用循环模板可以实现衍生表达式的汇编- 时间简化。 详细分析显示, 当前的 C++ 编译器技术已经足以实际使用我们的结果, 并突出一些值得进一步改进的问题 。