Skip to content

Instantly share code, notes, and snippets.

View soma-arc's full-sized avatar

soma soma-arc

View GitHub Profile
void setup(){
size(500, 500);
translate(250, 250);
String lines[] = loadStrings("mandelbrot.csv");
for(String line : lines){
String tmp[] = line.split(",");
float x = (float(tmp[0]));
float y = (float(tmp[1]));
int count = 0;
if(!tmp[2].equals("NIL")){
(defparameter chars (list "ムー" "チャ" "ッソ"))
(defun next (w)
(cdr (apply #'append (list w (list (nth (random (length chars)) chars))))))
(defun find-mu (w)
(if (string/= (apply #'concatenate 'string w) "ムーチャッソ")
(progn (princ (nth (1- (length w)) w))
(find-mu (next w)))
(princ (nth (1- (length w)) w))))
public class Quaternion implements Comparable<Quaternion>{
private final double re, i, j, k;
public static final Quaternion ZERO = new Quaternion(0, 0, 0, 0);
public static final Quaternion ONE = new Quaternion(1, 0, 0, 0);
public static final Quaternion I = new Quaternion(0, 1, 0, 0);
private Quaternion(double re, double i, double j, double k){
this.re = re;
this.i = i;
this.j = j;
@soma-arc
soma-arc / ConcurrencyTest.java
Last active August 29, 2015 14:05
並列和、並列プリフィクススキャン
public class ConcurrencyTest {
public static void main(String[] args) {
System.out.println("available processors "+ Runtime.getRuntime().availableProcessors());
int[] a = new int[8000000];
for(int i = 0 ; i < 800000 ; i++){
a[i] = (int) (10000 * Math.random());
}
PrefixScan s = new PrefixScan(a);
@soma-arc
soma-arc / mandelbrot.lisp
Created December 24, 2014 01:39
cl-glutによるマンデルブロ集合の描画
(ql:quickload "cl-glut")
(defparameter *width* 500)
(defparameter *height* 500)
(defparameter *magnification* 100.0)
(defun get-latice-points (width height reduction)
(apply #'append (loop for x from (* -1 (/ width 2)) below (1+ (/ width 2))
collect (loop for y from (* -1 (/ height 2)) below (1+ (/ height 2))
collect (complex (/ x reduction) (/ y reduction))))))
@soma-arc
soma-arc / draw-limiting-set.lisp
Last active August 29, 2015 14:12
クライン群の極限集合を描画する
(defparameter *inf* (* most-positive-fixnum #c(1 1)))
(defclass matrix ()
((a :accessor mat-a :initform 1 :initarg :a)
(b :accessor mat-b :initform 0 :initarg :b)
(c :accessor mat-c :initform 0 :initarg :c)
(d :accessor mat-d :initform 1 :initarg :d)))
(defgeneric mat* (a b))
(defgeneric inverse (m))
@soma-arc
soma-arc / data-racket-glut-teapot.lisp
Created August 26, 2015 06:52
DataRacket + Common Lispなサンプル
(ql:quickload '(:usocket :osc :cl-glut :cl-glu :bordeaux-threads))
(defparameter *port* 9000)
(defun create-server (port)
(usocket:socket-connect nil nil
:protocol :datagram
:element-type '(unsigned-byte 8)
:local-host "127.0.0.1"
:local-port port))
(module
(func $double-loop (param $width i32) (param $height i32) (result i32)
(local $x i32)
(local $y i32)
(local $sum i32)
(loop $x-loop
(set_local $y (i32.const 0))
(loop $y-loop
(set_local $sum (i32.add (get_local $sum) (i32.const 1)))
(set_local $y (i32.add (get_local $y) (i32.const 1)))
@soma-arc
soma-arc / momonga.pat
Created December 23, 2015 02:26
momonga AR marker pattern (16 x 16)
173 192 189 184 183 180 165 164 169 175 174 172 168 165 164 162
188 205 203 200 198 180 95 125 155 146 189 185 183 181 178 173
201 210 206 202 201 136 130 70 130 143 189 190 187 185 183 177
219 216 210 207 205 169 135 107 132 174 196 195 192 188 185 178
223 218 213 207 108 167 195 135 191 179 147 197 195 191 189 183
212 220 216 208 140 131 207 141 206 162 89 190 199 195 192 186
205 221 220 185 166 118 148 97 148 140 163 160 200 198 195 190
202 221 216 146 201 167 185 154 155 172 172 148 202 198 194 187
202 218 187 178 197 152 205 172 188 197 191 115 205 202 199 194
202 221 160 215 142 92 134 193 27 51 206 121 195 202 201 190
@soma-arc
soma-arc / data-flow-analysis-ex-9.12.scm
Created April 4, 2016 04:09
Resolve example 9.12 using Gauche from Compilers: Principles, Techniques, and Tools (Dragon book)
(use srfi-1)
(define (bit-or list1 list2)
(map (lambda (x y)
(if (or (= 1 x) (= 1 y))
1 0))
list1 list2))
(define (bit-and list1 list2)
(map (lambda (x y)