Skip to content

Instantly share code, notes, and snippets.

@tatyusa
tatyusa / van_der_pol.hs
Created March 3, 2014 09:09
Simulation of van der pol equation
{-
van der Pol Equation
http://mathworld.wolfram.com/vanderPolEquation.html
dx/dt = y
dy/dt = m(1-x^2)y - x
-}
type R2 = (Double, Double) --(x, y)
@tatyusa
tatyusa / julia.hs
Created February 28, 2014 03:29
Draw Julia Set of f(z) = z^2 + (-0.765+0.12i) by Haskell
import Data.Complex
type R = Double
type C = Complex R
-- 反復合成の定義
(^:) :: (C -> C) -> Int -> C -> C
(^:) f n = (flip (!!) n).(iterate f)
-- 計算する矩形領域
@tatyusa
tatyusa / kmeans.hs
Created February 23, 2014 13:27
k-means method on Haskell
import Data.List
import System.IO
import System.Random
type Cluster = Int
type Point = (Double, Double) -- Point in R^2
type CPoint = (Cluster, Point) -- Classified Point
---- Euclid Distance between Two Points
dist :: Point -> Point -> Double
@tatyusa
tatyusa / fractal.go
Last active January 2, 2016 08:39
Goでフラクタルを書いてみました。 各点がFatou集合に入ってるかどうかを並列に計算する単純なものです。 結果は同じフォルダに"result.png"として出力されます。
package main
import (
"fmt"
"math/cmplx"
"image"
"image/png"
"os"
)
@tatyusa
tatyusa / newton.go
Created January 6, 2014 02:52
Newton法で並列に根探査するプログラム
package main
import (
"fmt"
"time"
"math/cmplx"
"math/rand"
)
// 試行回数
import types
import math
# Supporting Functions
def prod(l):
temp = 1.
for i in xrange(len(l)):
temp *= l[i]
return temp
@tatyusa
tatyusa / makeRetinaImages.sh
Created September 7, 2013 06:02
Script to generate Retina conpatible iamge.
#!/bin/bash
# How to use
# $makeRetinaImages.sh folder_name
# The folder name should end by '/'.
#
for file in `ls $1`; do
if expr "$file" : ".*\.png" >/dev/null; then
file2x=`echo $file|sed 's/\(.*\)\(\.png\)/\1\@2x\2/'`
mv $1$file $1$file2x
convert -geometry 50% $1$file2x $1$file