Skip to content

Instantly share code, notes, and snippets.

@minoki
minoki / ghc-ieee754.md
Last active Feb 20, 2022
IEEE 754 conformance of GHC primitives
View ghc-ieee754.md

Literal

-0.0## under NegativeLiterals+MagicHash yields positive 0.0##.

Optimization

Constant folding

Fragile to negative zero and infinity and NaN (LitFloat/LitDouble cannot express them). cf. #9811, #18897.

@minoki
minoki / expr-test.tex
Created Dec 15, 2021
Standard ML on LuaTeX: math formula
View expr-test.tex
\documentclass{article}
\usepackage{amsmath}
\usepackage{luacode}
\begin{document}
\begin{luacode*}
local M = require "expr"
function diff(expr, var)
local result = M.parse(expr)
if result.tag == "Ok" then
local e = M.simplify(M.diff(var)(result.payload))
@minoki
minoki / seki-bernoulli.lua
Last active Dec 15, 2021
Standard ML on LuaTeX: Bernoulli numbers
View seki-bernoulli.lua
local assert = assert
local error = error
local getmetatable = getmetatable
local pairs = pairs
local pcall = pcall
local setmetatable = setmetatable
local math = math
local math_abs = math.abs
local math_type = math.type
local math_maxinteger = math.maxinteger
@minoki
minoki / test_cblas.c
Created Jan 27, 2021
BLASなんもわからん
View test_cblas.c
#include <cblas_openblas.h>
#include <stdio.h>
#include <math.h>
int main(void)
{
double A[3][3] = {
{1.0, 2.0, 3.0},
{2.0, 3.0, 4.0},
{4.0, 5.0, 6.0},
@minoki
minoki / timer-remote.ino
Created Dec 17, 2020
M5Stackで作るタイマーリモコン
View timer-remote.ino
#include <M5Stack.h>
#include <utility/M5Timer.h>
const int SHUTTER_PIN = 12;
const int FOCUS_PIN = 5;
const int LEVER_UP = 13;
const int LEVER_PUSH = 0;
const int LEVER_DOWN = 34;
View Sing.hs
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE TypeOperators, NoStarIsType #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# OPTIONS_GHC -fplugin GHC.TypeLits.Normalise #-}
{-# OPTIONS_GHC -fplugin GHC.TypeLits.KnownNat.Solver #-}
module Sing where
import qualified Data.Singletons.Prelude as S
@minoki
minoki / sin-test.c
Created Nov 6, 2020
libmのsinの実装が x=2^n (-1000≤n≤1000)の形の入力に対して「正しく丸められた値」からどのぐらいずれているか検査するやつ
View sin-test.c
// Written by @mod_poppo
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <mpfr.h>
#include <gmp.h>
static void to_normalized_hex(char *buf, mpfr_t a, int mant)
{
// assume a is positive
@minoki
minoki / atcoder-code-prettify.user.js
Last active Sep 5, 2020
AtCoderのシンタックスハイライトをちゃんと言語に応じて動作させるUserScriptです
View atcoder-code-prettify.user.js
// ==UserScript==
// @name AtCoder Code Prettify
// @namespace https://miz-ar.info/
// @include https://atcoder.jp/contests/*/submissions/*
// @version 3
// @grant none
// @run-at document-start
// ==/UserScript==
console.debug("AtCoder Code Prettify is running");
View test-x87-double-rounding.c
#include <stdint.h>
#include <float.h>
#include <stdlib.h>
#include <stdio.h>
#include <fenv.h>
#pragma STDC FENV_ACCESS ON
#if defined(__x86_64__) && defined(__GNUC__)
#define HAS_X87
static void set_x87_prec_24(void)
View float-commutativity.c
#include <stdio.h>
#include <math.h>
#include <inttypes.h>
#if defined(__GNUC__)
#define NOINLINE __attribute__((noinline))
#else
#define NOINLINE
#endif