Myers.calculate_block: def of bend-edit-distance@0.2.2.0 Import: import bend-edit-distance@0.2.2.0/src/Myers.bend as Myers Lines 94-111 of bend-edit-distance@0.2.2.0/src/Myers.bend: https://jend.leeeet.dev/read.txt?path=bend-edit-distance@0.2.2.0/src/Myers.bend&start_line=94&end_line=111 import Base # calculateBlock / Advance_Block from Myers. Addition intentionally wraps # at 32 bits. Xv uses the original Eq, before the negative carry is added. def calculate_block(block: Block, +eq: U32, hin: Carry) -> Block & Carry: Block{+pv, +mv, score} = block Carry{hin_positive, +hin_negative} = hin +xv = U32.or(eq, mv) +eq_in = U32.or(eq, hin_negative) +xh = (U32.xor(U32.add(U32.and(eq_in, pv), pv), pv) .|. eq_in : U32) +ph = U32.or(mv, U32.not(U32.or(xh, pv))) +mh = U32.and(pv, xh) +hout_positive = U32.shrn(ph, 31n) +hout_negative = U32.shrn(mh, 31n) +ph_shifted = U32.or(U32.shl(ph), hin_positive) mh_shifted = U32.or(U32.shl(mh), hin_negative) next_pv = U32.or(mh_shifted, U32.not(U32.or(xv, ph_shifted))) next_mv = U32.and(ph_shifted, xv) (Block{next_pv, next_mv, U32.sub(U32.add(score, hout_positive), hout_negative)}, Carry{hout_positive, hout_negative}) Uses (13): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Pair https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Sigma https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.add https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.and https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.not https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.or https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.shl https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.shrn https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.sub https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.xor https://jend.leeeet.dev/definition.txt?path=bend-edit-distance@0.2.2.0/src/Myers.bend&name=Block https://jend.leeeet.dev/definition.txt?path=bend-edit-distance@0.2.2.0/src/Myers.bend&name=Carry