code: public static DMatrixSparseCSC diag( @Nullable DMatrixSparseCSC A ,
                                           double values[], int offset, int length) {
          int N = length;
          if( A == null )
              A = new DMatrixSparseCSC(N,N,N);
          else
              A.reshape(N,N,N);
          A.nz_length = N;
  
          for (int i = 0; i < N; i++) {
              A.col_idx[i+1] = i+1;
              A.nz_rows[i] = i;
              A.nz_values[i] = values[offset+i];
          }
  
          return A;
      }
docs: Creates a diagonal matrix from an array. Elements in the array can be offset.
  
  @param A (Optional) Storage for diagonal matrix. If null a new one will be declared.
  @param values First index in the diagonal matirx
  @param length Length of the diagonal matrix
  @param offset First index in values
  @return The diagonal matrix