Skip to content

Instantly share code, notes, and snippets.

View jdh8's full-sized avatar
🐱
Kocham cię wyderko

Chen-Pang He jdh8

🐱
Kocham cię wyderko
View GitHub Profile
@jdh8
jdh8 / Convolution.cpp
Last active August 15, 2016 19:06
Snippet for convolution filter
template<int>
struct image_filter_vector;
template<>
struct image_filter_vector<ColMajor, DirectAccessBit>
{
template<typename Lhs, typename Rhs, typename Destination>
static void run(const Lhs&, const Rhs&, Destination&);
};
@jdh8
jdh8 / tchisla.cpp
Last active August 8, 2016 13:00
Solve Tchisla with bottom-up dynamic programming
// This gist is no longer maintained.
// Please move to [jdh8/chic][chic].
//
// [chic]: https://github.com/jdh8/chic
#include <map>
#include <vector>
#include <iostream>
#include <sstream>
#include <cstdint>
#include <ios>
#include <string>
#include <unistd.h>
template<bool>
class FileDescriptor
{
private:
int _fd;
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// Copyright (C) 2016 Chen-Pang He <chen.pang.he@jdh8.org>
//
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
#ifndef EIGEN_MATRIX_SIGN_ITERATION
@jdh8
jdh8 / analytic.mac
Last active June 8, 2016 18:55
Wave packet generator
load("fft");
g(x):= exp(-x^2 /2) / sqrt(2 * %pi);
plot(n, k):= plot2d(['discrete, realpart(fft(makelist(g(i-k+n) + g(i-k) + g(i-k-n), i, 0, n-1))) * n], ['x, 1, n]);
@jdh8
jdh8 / prime.c
Created June 29, 2014 06:54
Generate the first n prime numbers
/* Generate the first n prime numbers.
*
* Copyright (C) 2013 Chen-Pang He <jdh8@ms63.hinet.net>
* Don’t copy-paste the email. It won’t work.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
@jdh8
jdh8 / miller-rabin.c
Created June 29, 2014 06:43
Primality test
/* Primality test.
*
* Copyright (C) 2013 Chen-Pang He <jdh8@ms63.hinet.net>
* Don’t copy-paste the email. It won’t work.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*