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 / erfinv.jl
Created November 3, 2020 15:20
Polyfill SpecialFunctions.erfinv(::BigFloat)
using SpecialFunctions
function SpecialFunctions.erfinv(x::BigFloat)
c = √big(π) / 2
y::BigFloat = erfinv(Float64(x))
y += c * exp(y * y) * (x - erf(y))
y += c * exp(y * y) * (x - erf(y))
y += c * exp(y * y) * (x - erf(y))
return y
end
@jdh8
jdh8 / inference.py
Created July 8, 2019 10:10
ONNX operator inference by immediately constructed single-layer model
import numpy
import onnx
import onnxruntime
def infer(operator, *inputs, outputs=1, **attributes):
tags = {
numpy.void: onnx.TensorProto.UNDEFINED,
numpy.float32: onnx.TensorProto.FLOAT,
numpy.uint8: onnx.TensorProto.UINT8,
numpy.int8: onnx.TensorProto.INT8,
#include "FILE.h"
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
static uint_least32_t _modifier(unsigned c)
{
unsigned s = c - ' ';
return s < 32 ? UINT32_C(1) << s : UINT32_C(0);
@jdh8
jdh8 / f100.c
Last active March 14, 2019 02:53
Fibonacci sequence from F(0) to F(100)
#include <stdio.h>
static void print128(unsigned __int128 a)
{
const unsigned long long base = 10000000000000000000;
if (a >> 64)
printf("%llu%0.19llu\n", (unsigned long long)(a / base), (unsigned long long)(a % base));
else
printf("%llu\n", (unsigned long long)a);
@jdh8
jdh8 / chudovsky.cpp
Created January 15, 2018 15:59
Compute 2/pi
#include <gmpxx.h>
#include <limits>
#include <iostream>
#include <iomanip>
static mpq_class _rational(mp_bitcnt_t iterations)
{
mpz_class K = 6;
mpz_class M = 1;
mpz_class L = 13591409;
@jdh8
jdh8 / chebyshev.cpp
Created October 13, 2017 15:37
Chebyshev interpolation on erfc
#include <array>
#include <cmath>
#include <iostream>
#include <ccomplex>
#include <fftw3.h>
namespace {
template<typename>
class Plan;
@jdh8
jdh8 / 8char.js
Last active July 31, 2017 18:52
八字命學
function 八字命學(stdlib)
{
"use asm";
function main()
{
}
return main;
}
@jdh8
jdh8 / default.diff
Created February 26, 2017 17:45
Translate default.liquid from English to Chinese. -- https://github.com/jdh8/sweet-16/blob/master/_layouts/default.liquid
diff --git a/_layouts/default.liquid b/_layouts/default.liquid
index 2aab8d0..998ad36 100644
--- a/_layouts/default.liquid
+++ b/_layouts/default.liquid
@@ -1,5 +1,5 @@
<!DOCTYPE html>
-<html lang="en">
+<html lang="zh-Hant">
<head>
<meta charset="UTF-8">
@jdh8
jdh8 / wbr5.html
Last active December 27, 2016 09:01
<!DOCTYPE html>
<html lang="zh-TW" class="no-js">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="profile" href="http://gmpg.org/xfn/11">
<title>我方開叫一線花色</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Merriweather:,i,b,bi%7CMontserrat:,b">
<link rel='stylesheet' href='https://jdh8.org/wp-content/themes/twentysixteen/style.css?ver=4.6.1'>
<link rel="stylesheet" href="https://jdh8.github.io/css/wordpress.css">
@jdh8
jdh8 / Operators.cpp
Created August 31, 2016 08:37
Barton–Nackman trick
template<typename T>
class Comparable
{
friend bool operator!=(const T& x, const T& y) { return !(x == y); }
friend bool operator>(const T& x, const T& y) { return y < x; }
friend bool operator<=(const T& x, const T& y) { return !(y < x); }
friend bool operator>=(const T& x, const T& y) { return !(x < y); }
};
template<typename T>