code: public static void addIdentity(DMatrix1Row A , DMatrix1Row B , double alpha )
      {
          if( A.numCols != A.numRows )
              throw new IllegalArgumentException("A must be square");
          if( B.numCols != A.numCols || B.numRows != A.numRows )
              throw new IllegalArgumentException("B must be the same shape as A");
  
          int n = A.numCols;
  
          int index = 0;
          for( int i = 0; i < n; i++ ) {
              for( int j = 0; j < n; j++ , index++) {
                  if( i == j ) {
                      B.set( index , A.get(index) + alpha);
                  } else {
                      B.set( index , A.get(index) );
                  }
              }
          }
      }
docs: <p>
  Performs the following operation:<br>
  <br>
  B = A + &alpha;I
  <p>
  
  @param A A square matrix.  Not modified.
  @param B A square matrix that the results are saved to.  Modified.
  @param alpha Scaling factor for the identity matrix.