User blog comment:QuasarBooster/Bashicu matrix version 4 in Python!/@comment-30846880-20191110043015

Your algorithm is same as BM2.2. Check the result with S=(0,0)(1,1)(2,0)(1,1). (in python, S=0,1,2,1],[0,1,0,1 ) It is the first difference between BM2.2 and BM4 and it should be expanded into (0,0)(1,1)(2,0)(1,0)(2,1)(3,0)... in BM4.

BMS Calculator might help you checking. cf. http://gyafun.jp/ln/basmat.cgi?ini=%280%2C0%29%281%2C1%29%282%2C0%29%281%2C1%29%5B1%5D&max=20&inc=1&version=4.0