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
" Lint .h files as C++, not C | |
let g:ale_pattern_options_enabled = 1 | |
let g:ale_pattern_options = { '\.h$': { 'ale_linters': { 'cpp' : ['cc', 'gcc', 'clang'] } } } | |
" Set flags for gcc/clang | |
let opts = '-std=c++17 -Wall -Wextra' | |
let g:ale_linters = { 'cpp': ['cc', 'gcc', 'clang'] } | |
let g:ale_cpp_cc_options = opts | |
let g:ale_cpp_gcc_options = opts | |
let g:ale_cpp_clang_options = opts |
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 <stdint.h> | |
#include <inttypes.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
static inline uint64_t split(uint64_t x, int log_bits) { | |
uint64_t mask = (UINT64_C(1) << (1 << log_bits)) - 1; | |
for (int i = log_bits, n = 1 << log_bits; i > 0; --i, n >>= 1) { | |
mask = (mask | (mask << n)) & ~(mask << (n / 2)); | |
x = (x | (x << n)) & mask; |
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 <stdlib.h> | |
#include <stdio.h> | |
#include <stdint.h> | |
#include <stdbool.h> | |
#include <inttypes.h> | |
#include <limits.h> | |
#include <assert.h> | |
typedef struct op_s op_t; |
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 <memory> | |
#include <iostream> | |
#include <algorithm> | |
#include <climits> | |
#define SWAP(T, x, y) \ | |
{ \ | |
T z = x; \ | |
(x) = y; \ | |
(y) = z; \ |
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
// g++ -std=c++17 ir.cpp -pedantic -Wall -Wextra -g -o ir | |
#include <type_traits> | |
#include <unordered_set> | |
#include <cassert> | |
#include <cstdint> | |
#include <iostream> | |
// Def is just exposing the data, nothing more | |
struct Def { | |
uint32_t gid; |
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
-- Compile and run with: | |
-- ghc Simplify.hs | |
-- ./Simplify | |
import Data.Bits | |
import Data.List | |
import Data.Maybe | |
import Data.Function | |
import System.Random | |
import Control.Monad | |
import Debug.Trace |
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.Polynomial | |
import Math.Polynomial.Chebyshev | |
coeff f n j = (2 / nf) * (sum [f(xk) * yk | (xk, yk) <- zip x y]) | |
where | |
x = map ((\x -> cos (pi * (x + 0.5) / nf)) . fromIntegral) [0..n-1] | |
y = map ((\x -> cos (jf * pi * (x + 0.5) / nf)) . fromIntegral) [0..n-1] | |
nf = fromIntegral n | |
jf = fromIntegral j |
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 <stdint.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <stddef.h> | |
#include <stdbool.h> | |
#include <string.h> | |
#include <inttypes.h> | |
#include <assert.h> | |
static inline uint8_t first_bit_set(uint32_t 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
def insert(p, i, m, n): | |
q = [] | |
for j in range(0, n): | |
if j == i: | |
s = set(p[j]) | |
s.add(m) | |
q.append(s) | |
else: | |
q.append(p[j]) | |
return q |
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 <iostream> | |
#include <fstream> | |
#include <memory> | |
#include <string> | |
#include <algorithm> | |
#include <cmath> | |
#include <png.h> | |
struct Image { |