Alexej Moskovka, Talal Rahman, Jan Valdman, Jon Eivind Vatne
{"title":"关于用于 MATLAB 代码原型开发的矢量化基本线性代数软件包","authors":"Alexej Moskovka, Talal Rahman, Jan Valdman, Jon Eivind Vatne","doi":"arxiv-2404.16039","DOIUrl":null,"url":null,"abstract":"When writing high-performance code for numerical computation in a scripting\nlanguage like MATLAB, it is crucial to have the operations in a large for-loop\nvectorized. If not, the code becomes too slow to use, even for a moderately\nlarge problem. However, in the process of vectorizing, the code often loses its\noriginal structure and becomes less readable. This is particularly true in the\ncase of a finite element implementation, even though finite element methods are\ninherently structured. A basic remedy to this is the separation of the\nvectorization part from the mathematics part of the code, which is easily\nachieved through building the code on top of the basic linear algebra\nsubprograms that are already vectorized codes, an idea that has been used in a\nseries of papers over the last fifteen years, developing codes that are fast\nand still structured and readable. We discuss the vectorized basic linear\nalgebra package and introduce a formalism using multi-linear algebra to explain\nand define formally the functions in the package, as well as MATLAB pagetime\nfunctions. We provide examples from computations of varying complexity,\nincluding the computation of normal vectors, volumes, and finite element\nmethods. Benchmarking shows that we also get fast computations. Using the\nlibrary, we can write codes that closely follow our mathematical thinking,\nmaking writing, following, reusing, and extending the code easier.","PeriodicalId":501256,"journal":{"name":"arXiv - CS - Mathematical Software","volume":"105 1","pages":""},"PeriodicalIF":0.0000,"publicationDate":"2024-03-15","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":"{\"title\":\"On a vectorized basic linear algebra package for prototyping codes in MATLAB\",\"authors\":\"Alexej Moskovka, Talal Rahman, Jan Valdman, Jon Eivind Vatne\",\"doi\":\"arxiv-2404.16039\",\"DOIUrl\":null,\"url\":null,\"abstract\":\"When writing high-performance code for numerical computation in a scripting\\nlanguage like MATLAB, it is crucial to have the operations in a large for-loop\\nvectorized. If not, the code becomes too slow to use, even for a moderately\\nlarge problem. However, in the process of vectorizing, the code often loses its\\noriginal structure and becomes less readable. This is particularly true in the\\ncase of a finite element implementation, even though finite element methods are\\ninherently structured. A basic remedy to this is the separation of the\\nvectorization part from the mathematics part of the code, which is easily\\nachieved through building the code on top of the basic linear algebra\\nsubprograms that are already vectorized codes, an idea that has been used in a\\nseries of papers over the last fifteen years, developing codes that are fast\\nand still structured and readable. We discuss the vectorized basic linear\\nalgebra package and introduce a formalism using multi-linear algebra to explain\\nand define formally the functions in the package, as well as MATLAB pagetime\\nfunctions. We provide examples from computations of varying complexity,\\nincluding the computation of normal vectors, volumes, and finite element\\nmethods. Benchmarking shows that we also get fast computations. Using the\\nlibrary, we can write codes that closely follow our mathematical thinking,\\nmaking writing, following, reusing, and extending the code easier.\",\"PeriodicalId\":501256,\"journal\":{\"name\":\"arXiv - CS - Mathematical Software\",\"volume\":\"105 1\",\"pages\":\"\"},\"PeriodicalIF\":0.0000,\"publicationDate\":\"2024-03-15\",\"publicationTypes\":\"Journal Article\",\"fieldsOfStudy\":null,\"isOpenAccess\":false,\"openAccessPdf\":\"\",\"citationCount\":\"0\",\"resultStr\":null,\"platform\":\"Semanticscholar\",\"paperid\":null,\"PeriodicalName\":\"arXiv - CS - Mathematical Software\",\"FirstCategoryId\":\"1085\",\"ListUrlMain\":\"https://doi.org/arxiv-2404.16039\",\"RegionNum\":0,\"RegionCategory\":null,\"ArticlePicture\":[],\"TitleCN\":null,\"AbstractTextCN\":null,\"PMCID\":null,\"EPubDate\":\"\",\"PubModel\":\"\",\"JCR\":\"\",\"JCRName\":\"\",\"Score\":null,\"Total\":0}","platform":"Semanticscholar","paperid":null,"PeriodicalName":"arXiv - CS - Mathematical Software","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/arxiv-2404.16039","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 0
摘要
在 MATLAB 等脚本语言中编写高性能数值计算代码时,将大型 for 循环中的操作矢量化至关重要。否则,即使是处理中等规模的问题,代码也会变得太慢而无法使用。然而,在矢量化的过程中,代码往往会失去原有的结构,可读性也会降低。这在有限元实现中尤为明显,尽管有限元方法本身就是结构化的。解决这一问题的基本方法是将代码的矢量化部分与数学部分分离,这可以通过在已经是矢量化代码的基本线性代数子程序之上构建代码来轻松实现,过去 15 年中的一系列论文都采用了这一思路,开发出了既快速又具有结构性和可读性的代码。我们讨论了矢量化基本线性代数软件包,并介绍了一种使用多线性代数的形式主义,以正式解释和定义软件包中的函数以及 MATLAB 分页函数。我们提供了不同复杂度的计算实例,包括法向量、体积和有限元素方法的计算。基准测试表明,我们也能获得快速计算。使用该库,我们可以编写紧跟数学思维的代码,使代码的编写、跟踪、重用和扩展变得更加容易。
On a vectorized basic linear algebra package for prototyping codes in MATLAB
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.