-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [feat]: init add qfvm clifford * [feat]: add simulate circuit using clifford * [fix]: fix compile bugs * [feat]: init add python * [feat]: add naive final measure * style: format code * fix: ms aligned malloc * fix: apple align malloc * ci: update macos os version to latest * ci: update macos os version to latest * ci: update eigen version * ci: update macos version min version * ci: update macos version min * ci: update pyproject * ci: update pyproject * feat: fix bugs, add clifford test
- Loading branch information
1 parent
ca9e491
commit 6b148d5
Showing
22 changed files
with
3,614 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#ifndef BIT_H_ | ||
#define BIT_H_ | ||
|
||
#include <cstddef> | ||
#include <cstdint> | ||
|
||
// bit in byte | ||
struct bit { | ||
uint8_t* byte; | ||
uint8_t byte_index; | ||
|
||
bit(void* ptr, size_t offset) | ||
: byte(((uint8_t*)ptr + (offset / 8))), byte_index(offset & 7) {} | ||
|
||
// copy assignment for bit in byte | ||
inline bit& operator=(bool value) { | ||
// make bit be 0 | ||
*byte &= ~((uint8_t)1 << byte_index); | ||
// assignment | ||
*byte |= uint8_t(value) << byte_index; | ||
return *this; | ||
} | ||
|
||
inline bit& operator=(const bit& other) { | ||
*this = bool(other); | ||
return *this; | ||
} | ||
|
||
// bit operator | ||
inline bit& operator^=(bool value) { | ||
*byte ^= uint8_t(value) << byte_index; | ||
return *this; | ||
} | ||
|
||
inline bit& operator&=(bool value) { | ||
*byte &= (uint8_t(value) << byte_index) | ~(uint8_t(1) << byte_index); | ||
return *this; | ||
} | ||
|
||
inline bit& operator|=(bool value) { | ||
*byte |= uint8_t(value) << byte_index; | ||
return *this; | ||
} | ||
|
||
// conversion operator | ||
inline operator bool() const { return (*byte >> byte_index) & 1; } | ||
|
||
void swap(bit other) { | ||
bool b = bool(other); | ||
other = bool(*this); | ||
*this = b; | ||
} | ||
}; | ||
|
||
#endif |
Oops, something went wrong.