Skip to content

Instantly share code, notes, and snippets.

@fujidig
fujidig / Main.hx
Created March 27, 2014 14:43
usage: "haxe Main.hxml". -D dumpの効果により、dump/にマクロ展開後のASTが出力されます
@:build(MyMacro.build()) class Main {
public static function main() {
trace(hello());
}
}
var M = 100000;
var st = Date.now();
console.log(numPrimes1(M));
console.log((Date.now() - st)+" msec");
var st = Date.now();
console.log(numPrimes2(M));
console.log((Date.now() - st)+" msec");
function numPrimes1(max) {
@fujidig
fujidig / gist:11030783
Created April 18, 2014 08:06
Shumway AVM2を試す
{
v12 = new Scope($O412, this, false);
v16 = v12.findScopeProperty($O413, 'trace', 0, $O414, true);
v21 = v16.asCallProperty($O413, 'trace', 0, false, [
'Hello World'
]);
return v21;
}
domain.js
ApplicationDomain.prototype.executeAbc
executeScript
runtime.js
createFunction
useInterpreter = true;
createCompiledFunction
builder.js
require "mathn"
# 線形合同法の周期全体にわたるシリアル相関係数 (1つ次の値との相関係数)を求める
# TAOCP参照
# 「良い乗数」とされているものがとくにいい結果になるわけでもないようだ
def sigma(h, k, c)
if k == 1
0
// http://codezine.jp/article/detail/38 の移植
var VERTEX_DATA = [
[-1, 0, 0], [0, 1, 0], [0, 0, -1],
[1, 0, 0], [0, 0, 1], [0, -1, 0]
];
var FACE_DATA = [
[1, 4, 2], [1, 0, 4], [1, 2, 0], [3, 2, 4],
@fujidig
fujidig / znorder.rb
Last active December 25, 2015 20:19
require "prime"
# 参考: PARI/GPのソースコード
# http://pari.math.u-bordeaux.fr/
# http://pari.math.u-bordeaux.fr/cgi-bin/gitweb.cgi?p=pari.git;a=tree
# src/basemath/arith1.cのznorder()関数
# src/basemath/gen2.cのZ_pval()関数
# ord_m(a)を求める
# すなわちa^n ≡ 1 (mod m)となる最小のn≧1
def product(x, y)
(a, b) = x
(c, d) = y
[a*c - b*d, b*c + a*d - b*d]
end
def conj(x)
(a, b) = x
[a - b, -b]
end
#include <stdio.h>
#include <inttypes.h>
uint32_t seed = 0;
double rand() {
seed = seed * 1103515245 + 12345;
return (double)seed / 4294967296.0;
}
int main() {
uint32_t i = 0;
\documentclass{jsarticle}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{framed}
\usepackage{amssymb}
\usepackage{amsfonts}
\setlength{\textwidth}{12cm}