关于用于MATLAB中原型代码开发的向量化基本线性代数包
On a vectorized basic linear algebra package for prototyping codes in MATLAB
AI总结:
针对MATLAB向量化导致代码可读性降低的问题,提出基于基本线性代数子程序的向量化包,通过多重线性代数形式体系定义函数,实现兼顾高性能与可读性的数值计算。
摘要:
在使用MATLAB等脚本语言编写用于数值计算的高性能代码时,将大型for循环中的操作向量化至关重要。否则,即使对于中等规模的问题,代码也会变得太慢而无法使用。然而,在向量化过程中,代码往往会失去其原有结构并变得难以阅读。在有限元实现中尤其如此,尽管有限元方法本身具有内在的结构性。对此的一个基本补救措施是将代码的向量化部分与数学部分分离,这可以通过在已经向量化的基本线性代数子程序之上构建代码来轻松实现。这一想法在过去十五年间的一系列论文中被采用,开发出了既快速又保持结构化和可读性的代码。我们讨论了向量化基本线性代数包,并引入了一种使用多重线性代数的形式体系,以解释和正式定义该包中的函数以及MATLAB的pagetime函数。我们提供了来自不同复杂度计算的示例,包括法向量、体积的计算以及有限元方法。基准测试表明,我们同样获得了快速的计算速度。使用该库,我们可以编写紧密遵循数学思维的代码,从而使代码的编写、跟踪、重用和扩展变得更加容易。
英文摘要:
When writing high-performance code for numerical computation in a scripting language like MATLAB, it is crucial to have the operations in a large for-loop vectorized. If not, the code becomes too slow to use, even for a moderately large problem. However, in the process of vectorizing, the code often loses its original structure and becomes less readable. This is particularly true in the case of a finite element implementation, even though finite element methods are inherently structured. A basic remedy to this is the separation of the vectorization part from the mathematics part of the code, which is easily achieved through building the code on top of the basic linear algebra subprograms that are already vectorized codes, an idea that has been used in a series of papers over the last fifteen years, developing codes that are fast and still structured and readable. We discuss the vectorized basic linear algebra package and introduce a formalism using multi-linear algebra to explain and define formally the functions in the package, as well as MATLAB pagetime functions. We provide examples from computations of varying complexity, including the computation of normal vectors, volumes, and finite element methods. Benchmarking shows that we also get fast computations. Using the library, we can write codes that closely follow our mathematical thinking, making writing, following, reusing, and extending the code easier.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。