--- /dev/null
+A = tridiagonal(0, -1, 2, -1);
+expected = [];
+unit_test_equals("poisson tridiagonal of size zero is correct", ...
+ expected, ...
+ A);
+
+A = tridiagonal(1, -1, 2, -1);
+expected = [2];
+unit_test_equals("poisson tridiagonal of size one is correct", ...
+ expected, ...
+ A);
+
+A = tridiagonal(2, -1, 2, -1);
+expected = [2, -1; ...
+ -1, 2];
+unit_test_equals("poisson tridiagonal of size two is correct", ...
+ expected, ...
+ A);
+
+A = tridiagonal(3, -1, 2, -1);
+expected = [2, -1, 0; ...
+ -1, 2, -1;
+ 0, -1, 2];
+unit_test_equals("poisson tridiagonal of size three is correct", ...
+ expected, ...
+ A);
--- /dev/null
+function A = tridiagonal(integerN, x, y, z)
+ %
+ % Construct the integerN x integerN (square) tridiagonal matrix
+ % diag(x,y,z).
+ %
+ % INPUT:
+ %
+ % - ``integerN`` -- The dimensions of the resulting matrix.
+ %
+ % - ``x`` -- The value on the subdiagonal.
+ %
+ % - ``y`` -- The value on the diagonal.
+ %
+ % - ``z`` -- The value on the superdiagonal.
+ %
+ if (integerN < 0)
+ A = NA;
+ return;
+ end
+
+ sub_diag = repmat(x, 1, integerN-1);
+ on_diag = repmat(y, 1, integerN);
+ super_diag = repmat(z, 1, integerN-1);
+ A = diag(on_diag) + diag(super_diag, 1) + diag(sub_diag, -1);
+end