Two containers for one system
A dense matrix preallocates n² cells. Triplet assembly reserves linear arrays for element contributions only.
Element chain and global degrees of freedom
Select a member: its four coefficients will be highlighted in both representations.
Full system matrix
Easy to read, but memory is also allocated for every zero.
MKE-F sparse assembly
Linear buffers → combine addresses → sparse matrix.
DOF map and ndgrid
One color links the row, column and value of one triplet. A 2 × 2 matrix produces four address pairs.
Triplets before summation
Select an element in the chainglobalK = sparse(rows, columns, stiffnessValues, n, n);
GNU Octave’s library function accepts coordinates and values, sums entries sharing an address and creates a sparse matrix of the specified size.
After sparse()
rows, columns, K values and M values; four entries per 2 × 2 element matrix.
sparse() constructs the matrix but does not solve the system
After assembly, a sparse matrix behaves like an ordinary matrix: extract Kff, multiply by a vector or pass it to the standard solve operator. Octave recognizes sparse storage and selects appropriate numerical algorithms without requiring you to recreate a square array of zeros.
Static system
The first DOF is fixed and the last is loaded. Only the free part is solved.