Many numerical methods for evaluating matrix functions can be naturally viewed as computational graphs. Rephrasing these methods as directed acyclic graphs (DAGs) is a particularly effective approach to study existing techniques, improve them, and eventually derive new ones. The accuracy of these matrix techniques can be characterized by the accuracy of their scalar counterparts, thus designing algorithms for matrix functions can be regarded as a scalar-valued optimization problem. The derivatives needed during the optimization can be calculated automatically by exploiting the structure of the DAG, in a fashion analogous to backpropagation. This paper describes GraphMatFun.jl, a Julia package that offers the means to generate and manipulate computational graphs, optimize their coefficients, and generate Julia, MATLAB, and C code to evaluate them efficiently at a matrix argument. The software also provides tools to estimate the accuracy of a graph-based algorithm and thus obtain numerically reliable methods. For the exponential, for example, using a particular form (degree-optimal) of polynomials produces implementations that in many cases are cheaper, in terms of computational cost, than the Pad\'e-based techniques typically used in mathematical software. The optimized graphs and the corresponding generated code are available online.
翻译:用于评估矩阵功能的许多数字方法可以自然地被视为计算图。将这些方法改写成定向单环图(DAGs)是一种特别有效的方法,可以研究现有技术,改进这些技术,并最终得出新的技术。这些矩阵技术的准确性可以用其缩标对应方的准确性来描述,因此,为矩阵功能设计算法可以被视为一个以缩略图估价的优化问题。优化期间所需的衍生物可以通过利用DAG结构,以类似于反向分析的方式自动计算。本文描述了GapMatFun.jl,这是一个Julia软件包,它提供生成和操作计算图、优化其系数和生成朱丽亚、MATLAB和C代码的手段,以便用矩阵参数来有效评估这些技术。软件还提供了工具,用以估计基于图表的算法的准确性,从而获得数字上可靠的方法。例如,对指数来说,使用一种特定的形式(度-最佳)多数值分析方法,在很多情况下,在计算成本方面比较便宜,优化其系数,并生成朱丽亚、MadLAB 典型的数学方法。