code: public static DMatrixRMaj diagonal(int numRows , int numCols , double min , double max , Random rand ) {
          if( max < min )
              throw new IllegalArgumentException("The max must be >= the min");
  
          DMatrixRMaj ret = new DMatrixRMaj(numRows,numCols);
  
          int N = Math.min(numRows,numCols);
  
          double r = max-min;
  
          for( int i = 0; i < N; i++ ) {
              ret.set(i,i, rand.nextDouble()*r+min);
          }
  
          return ret;
      }
docs: Creates a random matrix where all elements are zero but diagonal elements.  Diagonal elements
  randomly drawn from a uniform distribution from min to max, inclusive.
  
  @param numRows Number of rows in the returned matrix..
  @param numCols Number of columns in the returned matrix.
  @param min Minimum value of a diagonal element.
  @param max Maximum value of a diagonal element.
  @param rand Random number generator.
  @return A random diagonal matrix.