Table of Contents
Fetching ...

On a vectorized basic linear algebra package for prototyping codes in MATLAB

Alexej Moskovka, Talal Rahman, Jan Valdman, Jon Eivind Vatne

TL;DR

The paper tackles the slowdown of MATLAB FEM codes caused by loops and the interleaving of vectorization with mathematical formulations. It proposes a vectorized basic linear algebra package built on page-wise tensor operations, enabling code that mirrors mathematical expressions while maintaining speed, exemplified by a multilinear-algebra framework for $U\otimes V$ type structures. The framework is demonstrated through 3D geometry and FEM applications, including normals, volumes, volume and surface integrals, and stiffness/mass matrix assemblies, with benchmarks indicating speedups. The work offers practical benefits for readability, portability, and extensibility of MATLAB prototypes in FEM and related computational geometry tasks.

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.

On a vectorized basic linear algebra package for prototyping codes in MATLAB

TL;DR

The paper tackles the slowdown of MATLAB FEM codes caused by loops and the interleaving of vectorization with mathematical formulations. It proposes a vectorized basic linear algebra package built on page-wise tensor operations, enabling code that mirrors mathematical expressions while maintaining speed, exemplified by a multilinear-algebra framework for type structures. The framework is demonstrated through 3D geometry and FEM applications, including normals, volumes, volume and surface integrals, and stiffness/mass matrix assemblies, with benchmarks indicating speedups. The work offers practical benefits for readability, portability, and extensibility of MATLAB prototypes in FEM and related computational geometry tasks.

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.
Paper Structure (16 sections, 89 equations, 8 figures, 4 tables)

This paper contains 16 sections, 89 equations, 8 figures, 4 tables.

Figures (8)

  • Figure 1: Example of 3D uniformly refined tetrahedral meshes (levels 1, 2, 3) of a sphere domain.
  • Figure 2: Normals of the reference tetrahedron (left) and normals of a single regular tetrahedron (right).
  • Figure 3: Examples of 3D meshes and underlying outer normals.
  • Figure 4: A torus domain rotating around x-axis.
  • Figure 5: Vector field \ref{['vector_field']} depicted on a torus domain.
  • ...and 3 more figures

Theorems & Definitions (4)

  • Remark 1
  • Example 1
  • Remark 2
  • Remark 3