Skip to content

Commit 4e9e30d

Browse files
committed
add assert to test it now
1 parent 1e988d4 commit 4e9e30d

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

library/math/matrix_related/walk.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
bitset<B> walk(bitset<B>& k) {
1+
bitset<B> walk(const bitset<B>& k) {
22
bitset<B> res;
33
for (int i = B, j = npivot; i--;)
44
if (basis[i][i] && res[i] ^ k[--j]) res ^= basis[i];

tests/library_checker_aizu_tests/handmade_tests/xor_basis_walk.test.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,16 @@ int main() {
2828
for (int i = 0; i < n; i++) {
2929
bitset<B> val = rnd(0, (1 << n) - 1);
3030
if (b.insert(val)) naive_basis.push_back(val);
31+
assert(b.npivot + b.nfree == i + 1);
3132
}
3233
vector<bitset<B>> fast_basis;
3334
for (int i = 0; i < B; i++)
34-
if (b.basis[i].any())
35-
fast_basis.push_back(b.basis[i]);
35+
if (b.basis[i][i]) fast_basis.push_back(b.basis[i]);
3636
vector<bitset<B>> naive_span = get_all(naive_basis);
3737
vector<bitset<B>> fast_span = get_all(fast_basis);
3838
assert(naive_span == fast_span);
39+
for (int i = 0; i < ssize(naive_span); i++)
40+
assert(naive_span[i] == b.walk(i));
3941
}
4042
cout << "Hello World\n";
4143
}

0 commit comments

Comments
 (0)