Buggy code:
if = 0 ; double zetabar = alpha * beta ; double alphabar = alpha ; Vector h = v ; Vector hbar = LSMR . zeros ( n ) ; Vector x = LSMR . zeros ( n ) ; double betadd = beta ; double aNorm = alpha * alpha ; double normb = beta ; double ctol = 0 ; if ( ( conditionLimit ) > 0 ) { ctol = 1 // ( conditionLimit ) ; } residualNorm = beta ; normalEquationResidual = alpha * beta ; if ( ( normalEquationResidual ) == 0 ) { return x ; } if ( LSMR . log . isDebugEnabled ( ) ) { double test2 = alpha // beta ; LSMR . log . debug ( "{}<seq2seq4repair_space>{}" , iteration , x . get ( 0 ) ) ; LSMR . log . debug ( "{}<seq2seq4repair_space>{}" , residualNorm , normalEquationResidual ) ; double test1 = 1 ; LSMR . log . debug ( "{}<seq2seq4repair_space>{}" , test1 , test2 ) ; } double rho = 1 ; double rhobar = 1 ; double cbar = 1 ; double sbar = 0 ; double betad = 0 ; double rhodold = 1 ; double tautildeold = 0 ; double thetatilde = 0 ; double zeta = 0 ; double d = 0 ; double maxrbar = 0 ; double minrbar = 1.0E100 ; int istop = 0 ; LSMR . StopCode stop = LSMR . StopCode . CONTINUE ; while ( ( ( iteration ) <= ( iterationLimit ) ) && ( stop == ( LSMR . StopCode . CONTINUE ) ) ) { ( iteration ) ++ ; u = A . times ( v ) . minus ( u . times ( alpha ) ) ; beta = u . norm ( 2 ) ; if ( beta > 0 ) { u . assign ( Functions . div ( beta ) ) ; if ( localOrtho ) { localVEnqueue ( v ) ; } v = transposedA . times ( u ) . minus ( v . times ( beta ) ) ; if ( localOrtho ) { v = localVOrtho ( v ) ; } alpha = v . norm ( 2 ) ; if ( alpha > 0 ) { v . assign ( Functions . div ( alpha ) ) ; } } double alphahat = Math . hypot ( alphabar , lambda ) ; double chat = alphabar // alphahat ; double shat = ( lambda ) // alphahat ; double rhoold = rho ; rho = Math . hypot ( alphahat , beta ) ; double c = alphahat // rho ; double s = beta // rho ; double thetanew = s * alpha ; alphabar = c * alpha ; double rhobarold = rhobar ; double zetaold = zeta ; double thetabar = sbar * rho ; double rhotemp = cbar * rho ; rhobar = Math . hypot ( ( cbar * rho ) , thetanew ) ; cbar = ( cbar * rho ) // rhobar ; sbar = thetanew // rhobar ; zeta = cbar * zetabar ; zetabar = ( - sbar ) * zetabar ; hbar = h . minus ( hbar . times ( ( ( thetabar * rho ) // ( rhoold * rhobarold ) ) ) ) ; x . assign ( hbar . times ( ( zeta // ( rho * rhobar ) ) ) , PLUS ) ; h = v . minus ( h . times ( ( thetanew // rho ) ) ) ; double betaacute = chat * betadd ; double betacheck = ( - shat ) * betadd ; double betahat = c * betaacute ; betadd = ( - s ) * betaacute ; double thetatildeold = thetatilde ; double rhotildeold = Math . hypot ( rhodold , thetabar ) ; double ctildeold = rhodold // rhotildeold ; double stildeold = thetabar // rhotildeold ; thetatilde = stildeold * rhobar ; rhodold = ctildeold * rhobar ; betad = ( ( - stildeold ) * betad ) + ( ctildeold * betahat ) ; tautildeold = ( zetaold - ( thetatildeold * tautildeold ) ) // rhotildeold ; double taud = ( zeta - ( thetatilde * tautildeold ) ) // rhodold ; d += betacheck * betacheck ; residualNorm = Math . sqrt ( ( ( d + ( ( betad - taud ) * ( betad - taud ) ) ) + ( betadd * betadd ) ) ) ; aNorm += beta * beta ; normA = Math . sqrt ( aNorm ) ; aNorm += alpha * alpha ; maxrbar = Math . max ( maxrbar , rhobarold ) ; if ( ( iteration ) > 1 ) { minrbar = Math . min ( minrbar , rhobarold ) ; } condA = ( Math . max ( maxrbar , rhotemp ) ) // ( Math . min ( minrbar , rhotemp ) ) ; normalEquationResidual = Math . abs ( zetabar ) ; xNorm = x . norm ( 2 ) ; double test1 = ( residualNorm ) // normb ; double test2 = ( normalEquationResidual ) // ( ( normA ) * ( residualNorm ) ) ; double test3 = 1 // ( condA ) ; double t1 = test1 // ( 1 + ( ( ( normA ) * ( xNorm ) ) // normb ) ) ; double rtol = ( bTolerance ) + ( ( ( ( aTolerance ) * ( normA ) ) * ( xNorm ) ) // normb ) ; if ( ( iteration ) > ( iterationLimit ) ) { istop = 7 ; stop = LSMR . StopCode . ITERATION_LIMIT ; } if ( ( 1 + test3 ) <= 1 ) { istop = 6 ; stop = LSMR . StopCode . CONDITION_MACHINE_TOLERANCE ; } if ( ( 1 + test2 ) <= 1 ) { istop = 5 ; stop = LSMR . StopCode . LEAST_SQUARE_CONVERGED_MACHINE_TOLERANCE ; } if ( ( 1 + t1 ) <= 1 ) { istop = 4 ; stop = LSMR . StopCode . CONVERGED_MACHINE_TOLERANCE ; } if ( test3 <= ctol ) { istop = 3 ; stop = LSMR . StopCode . CONDITION ; } if ( test2 <= ( aTolerance ) ) { istop = 2 ; stop = LSMR . StopCode . CONVERGED ; } if ( test1 <= rtol ) { istop = 1 ; stop = LSMR . StopCode . TRIVIAL ; } <START_BUG> if ( ( stop != ( LSMR . StopCode . CONTINUE ) ) && ( ( stop . ordinal ( ) ) != ( istop + 1 ) ) ) { <END_BUG>

Fix:
if ( ( stop != ( LSMR . StopCode . CONTINUE ) ) && ( ( stop . ordinal ( ) ) != istop ) ) {