This file contains hidden or 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
| import csv | |
| import pathlib | |
| import time | |
| from dataclasses import dataclass | |
| from typing import Callable, List, Dict, Any, Set, FrozenSet, Iterable, Tuple | |
| import math | |
| import pymatching | |
| import networkx as nx | |
| import stim | |
| import matplotlib.pyplot as plt |
This file contains hidden or 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
| #include <chrono> | |
| #include <iostream> | |
| #include <random> | |
| #include <bit> | |
| #include "immintrin.h" | |
| #include <algorithm> | |
| __m256i countl_zero_vec(__m256i x) { | |
| // Tried doing vectorized bit twiddling instead, but it was slower. |
This file contains hidden or 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
| # coding=utf-8 | |
| import math | |
| import itertools | |
| def evaluate_circuit(gates, initial_bits=None): | |
| """ | |
| :param gates: [( [controls], [targets] )] | |
| :param initial_bits: set(on_bits) |
This file contains hidden or 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
| import collections | |
| import numpy as np | |
| import sinter | |
| import stim | |
| import pathlib | |
| from matplotlib import pyplot as plt | |
| workspace = pathlib.Path("google_qec3v5_experiment_data") |
This file contains hidden or 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
| import Mathlib.Data.Nat.Basic | |
| import Mathlib.Tactic.Linarith | |
| ----------------- DEFINE PROBABILITY -------------------- | |
| structure Chance where | |
| p : Rat | |
| v : (p >= 0) ∧ (p <= 1) | |
| def Chance.le (a b : Chance) : Bool := a.p <= b.p | |
| infixl:45 " ≤ " => Chance.le |
This file contains hidden or 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
| import Mathlib | |
| import Mathlib.Data.Nat.Basic | |
| import Mathlib.Data.Rat.Basic | |
| import Mathlib.Data.Rat.Order | |
| theorem le_pin (a b : Nat) (h1 : a <= b) (h2 : b <= a) | |
| : a = b | |
| := by | |
| apply Nat.eq_or_lt_of_le at h1 | |
| cases h : (decide (a = b)) |
This file contains hidden or 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
| import Mathlib | |
| import Mathlib.Data.Nat.Basic | |
| import Mathlib.Data.Rat.Basic | |
| import Mathlib.Data.Rat.Order | |
| ----------------- BASIC DATA TYPES AND COMBINATORS -------------------- | |
| structure Odds where | |
| lose : Nat | |
| win : Nat | |
| valid : (lose != 0) ∨ (win != 0) |
This file contains hidden or 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
| import math | |
| from typing import Union | |
| from typing import Tuple | |
| def zalka_imul_mod_low_workspace(*, dst: 'Quint', factor: int, modulus: int) -> None: | |
| """Performs an inplace modular multiplication using n/2 + O(1) workspace.""" | |
| assert factor < modulus | |
| assert math.gcd(factor, modulus) == 1 | |
| assert len(dst) >= modulus.bit_length() * 3 // 2 + 2 |
This file contains hidden or 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
| import math | |
| from numpy import array, hstack, vstack | |
| import numpy as np | |
| from PIL import Image | |
| # these two methods were copied from https://github.com/dmishin/fft-image-experiments | |
| def hilbert_indices(N): | |
| """Genrate 2^N x 2^N integer array, filled with values from 0 to 4^N along hilbert curve""" | |
| m = array([[0]], dtype=np.int) |
This file contains hidden or 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
| from manim import * | |
| class SquareToCircle(Scene): | |
| def construct(self): | |
| n = 5 | |
| h = n // 2 | |
| bits = [MathTex("0") for k in range(n)] | |
| bits2 = [MathTex(f"b_{{{k+1}}}") for k in range(n)] | |
| dt = 20 |
NewerOlder