# Linear Algebra

User Q-functions often perform small (1x1, 2x2, or 3x3) linear algebra operations (determinant, matrix-vector product, etc.) at every Q-point. For good performance, it is important to use specialized versions of these operations for the given size.

If the matrix or vector is given in a statically sized container (e.g. using StaticArrays.jl) then this happens automatically. However, if the matrix is not statically sized, and instead is given as, for example, a view into a larger array, then LibCEED.jl provides some convenient specialized functions.

In order to allow for generic code, the CeedDim struct is used for dispatch. An object D = CeedDim(dim) can be created, and passed as a second argument to functions like det to choose the specialized implementations. In this case, dim should be known as a compile-time constant, otherwise it will result in a type instability, and give poor performance.

For example:

julia> using LibCEED, LinearAlgebra

julia> dim = 3;

julia> J = rand(dim, dim);

julia> det(J) # Slow!
-0.0016429068227922581

julia> det(J, CeedDim(dim)) # Fast!
-0.0016429068227922596
LibCEED.CeedDimType
CeedDim(dim)

The singleton object of type CeedDim{dim}, used for dispatch to linear algebra operations specialized for small matrices (1, 2, or 3 dimensions).

source
LibCEED.setvoigtFunction
setvoigt(J::StaticArray{Tuple{D,D},T,2})
setvoigt(J, ::CeedDim{dim})

Given a symmetric matrix J, return a SVector that encodes J using the Voigt convention.

The size of the symmetric matrix J must be known statically, either specified using CeedDim or StaticArray.

source