createDiagMatrix method

List<List<double>> createDiagMatrix (int n, double value)

Creates n x n diagonal matrix with value.

Implementation

List<List<double>> createDiagMatrix(int n, double value) {
  List<List<double>> matrix = createMatrix(n, n, 0.0);
  for (int i = 0; i < n; i++) {
    matrix[i][i] = value;
  }
  return matrix;
}