Alexej Moskovka, Talal Rahman, Jan Valdman, Jon Eivind Vatne
{"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}
引用次数: 0
Abstract
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.