Routine Name: DiagonallyDominantMatrix
Author: David Merkley
Language: Python
Description/Purpose: Generates a square random matrix, except on the diagonal. Every element is n for an n x n matrix.
Input: Size of matrix n
Output: Square diagonally dominant matrix
Implementation/Code:
def diagonalSquareMatrix(n):
return [[n * 1 if i == j else random.random() for j in range(n)] for i in range(n)]