Skip to content

Commit

Permalink
XorBasis
Browse files Browse the repository at this point in the history
  • Loading branch information
knshnb committed May 7, 2021
1 parent 2eb4753 commit fc222bd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Math/XorBasis.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
template <class T> std::vector<T> xor_basis(const std::vector<T>& a) {
std::vector<T> regularized, original_basis;
for (const T x : a) {
T sweeped = x;
for (const T b : regularized) sweeped = std::min(sweeped, sweeped ^ b);
if (sweeped) regularized.push_back(sweeped), original_basis.push_back(x);
}
return original_basis;
}
8 changes: 8 additions & 0 deletions src/Math/XorBasis.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

---
title: XOR Basis
documentation_of: ./XorBasis.hpp
---

## 概要
掃き出し法によりXORの基底を求める。

0 comments on commit fc222bd

Please sign in to comment.