C语言 如何确定单个数组中位的重复模式



所以这就是问题所在,我正在用 C 构建 128 位的数组来表示节拍分区,这些分区可以在逻辑上相互对抗和/或/或/异或,所以你可以得到如下结果。 我遇到的问题是,如何确定模式何时重复,以及第一个重复部分的开始/结束索引是什么,以便我可以只循环该部分以防止在达到最大值时发生奇怪的事情(目前为 128(。

似乎我需要将大小增加到 256 或更大,以解决更复杂的嵌套逻辑创建一段时间不重复的模式的情况。 寻找有关如何在位数组中检测模式算法的建议。

2:              01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101
3:              00100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100
3 OR  2:        01110101110101110101110101110101110101110101110101110101110101110101110101110101110101110101110101110101110101110101110101110101
3 AND 2:        00000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100
3 XOR 2:        01110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001
||    ||    ||    ||    || ...
5:              00001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000
5 OR (3 XOR 2): 01111001110001110001110011110101111001110001110001110011110101111001110001110001110011110101111001110001110001110011110101111001
||                            ||                            ||                            ||                            ||
5 OR (3 OR 2):  01111101110101110101110111110101111101110101110101110111110101111101110101110101110111110101111101110101110101110111110101111101
||                            ||                            ||                            ||
5:              00001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000
6:              00000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100
5 OR 6:         00001100010100100101000110000100001100010100100101000110000100001100010100100101000110000100001100010100100101000110000100001100
||                            ||                            ||                            ||                            ||
7:              00000010000001000000100000010000001000000100000010000001000000100000010000001000000100000010000001000000100000010000001000000100
7 XOR (5 OR 6): 00001110010101100101100110010100000100010000100111000111000100101100000100101101000110000110001101010100000101010110001100001000
shoot, 7 XOR (5 OR 6) doesn't repeat within 128 bits..
8:              00000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001
16:             00000000000000010000000000000001000000000000000100000000000000010000000000000001000000000000000100000000000000010000000000000001

为了提供更多上下文,这是我为音乐模块(https://llllllll.co/t/chrono-sage-meadowphysics-logical-clock-divider-v1-2-5/27182(编写的逻辑时钟分频器,我试图解决的问题是能够将这些节拍分区的逻辑/嵌套逻辑组合对齐,以便在模式环绕时不会出现卡顿。

Ian Abbott评论说,"重复模式不应长于M和N的最小公倍数"(我假设M和N是两米,尽管你已经展示了组合两个以上的例子(。事实上,超过一米的朴素组合正好是长度等于它们最小公倍数的重复模式。

但看起来你正在做出额外的、任意的选择,由示例中的行指示,关于你想要"悲观"的地方。从表面上看,如果没有更多的澄清,我们很难告诉计算机这些标准是什么。你在想什么(或者更好的是,听到(建议你把悲观的声音放在你做过的地方,而不是在例子的开头?还是问题在于我们无法访问合并的原始仪表?

3/4 x . x|x . x|x . x|x . x
4/4 x . x x|x . x x|x . x x
(lcm = 12)

相关内容

  • 没有找到相关文章

最新更新