I could write an algorithm to generate a random symmetric positive definite matrix, but how to edit it to also have this matrix to be strictly diagonally dominant?
Here is my code:
function $A$ = generateSPDmatrix$(n)$ % Generate a dense n x n symmetric, positive definite matrix
$A = rand(n,n)$; % generate a random n x n matrix
% construct a symmetric matrix
$A = 0.5*(A+A')$;
% since $A(i,j) < 1$ by construction and a symmetric diagonally dominant matrix is symmetric positive definite, which can be ensured by adding nI
$A = A + n*eye(n)$;
end
As you have recalled it, a real symmetric (more genrally Hermitian) diagonally dominant matrix ${\displaystyle A}$ with real non-negative diagonal entries is positive semidefinite (see (https://en.wikipedia.org/wiki/Diagonally_dominant_matrix))
Here is a Matlab program giving a random matrix as you desire it, in the same spirit as you.
(I think the comments I have given are enough for following the instructions; remember that operator "sum" on a matrix gives the row vector of the sums column by column):