Instantly share code, notes, and snippets.

🏠
Working from home

# Keisuke OTAKIcocomoff

🏠
Working from home
• Sort options
Created Oct 25, 2014
org.apache.commons.math3 from scala (sbt)
View build.sbt
 libraryDependencies += "org.apache.commons" % "commons-math3" % "3.2"
Created Mar 11, 2015

View fib.py
 # coding: utf-8 import time def fib(n): nums = [] a, b = 1, 1 # while b <= n: while len(nums) <= n: a, b = b, a+b
Created May 28, 2015
Build png files for a GIF anime of Langton's ant
View langton.py
 # -*- coding: utf-8 -*- # date: 2015/05/28 # author: @taki__taki__ # packages import numpy as np import matplotlib.pyplot as plt # direction (N=0, E=1, S=2, W=3) class Direction(object):
Created Jun 30, 2015

View yakinamashi.py
 # -*- coding: utf-8 -*- # author: @taki__taki__ # date: 30/06/2015 from random import random from math import exp class SA(object): # function def f(self, x):
Created Jun 30, 2015
グラフ( http://blog-imgs-27-origin.fc2.com/r/i/v/riverocean/sa.png )を再現するPythonスクリプト
View graph.py
 # -*- coding: utf-8 -*- # author: @cocomoff # date: 30/06/2015 import numpy as np import matplotlib.pyplot as plt if __name__ == '__main__': x = np.arange(-50, 50, 1, dtype='float') z = x / 10.0
Created Jul 15, 2012
Scalaで多次元配列 ref: http://qiita.com/items/01b50f3a7f2c6d0471f5
View Marray.scala
 val array = Array.ofDim[Int](2, 3) println(array.deep) /* Output Array(Array(0, 0, 0), Array(0, 0, 0)) */
Created Sep 30, 2013
View boost_version.cpp
 #include #include using namespace std; int main() { cout << ( BOOST_VERSION / 100000 ) << "." << ( BOOST_VERSION / 100 % 1000 ) << "." << BOOST_VERSION % 100; }
Created Feb 20, 2017
Computing Ground Distance on Earth from Latitude/Longtitude Point (e.g., http://www.nhc.noaa.gov/gccalc.shtml)
View ground_distance.jl
 R = 6371000 # Radius of the Earth S1 = Point(35.18028,136.90667) # Nagoya S2 = Point(35.68944,139.69167) # Tokyo # ground distance function dG(Si::Point, Sj::Point) φi, λi = deg2rad(Si.φ), deg2rad(Si.λ) φj, λj = deg2rad(Sj.φ), deg2rad(Sj.λ) v1 = sin( (φj - φi) / 2 ) v2 = sin( (λj - λi) / 2 )
Created Oct 15, 2014
CPLEX example from C++
View gist:3f3d7a918c82f46ea9c2
 #include #include #include #include using namespace std; const int num_of_threads = 1; int main () {
Created Apr 10, 2017
View jump_sample.jl
 # example: http://www.fujilab.dnj.ynu.ac.jp/lecture/system2.pdf using JuMP using Clp m = Model(solver = ClpSolver()) @variable(m, 0 <= x1 <= Inf) @variable(m, 0 <= x2 <= Inf) # 目的関数
You can’t perform that action at this time.