code: public static void setIdentity( DMatrix1Row mat )
      {
          int width = mat.numRows < mat.numCols ? mat.numRows : mat.numCols;
  
          Arrays.fill(mat.data,0,mat.getNumElements(),0);
  
          int index = 0;
          for( int i = 0; i < width; i++ , index += mat.numCols + 1) {
              mat.data[index] = 1;
          }
      }
docs: Sets all the diagonal elements equal to one and everything else equal to zero.
  If this is a square matrix then it will be an identity matrix.
  
  @see #identity(int)
  
  @param mat A square matrix.