Skip to content

Instantly share code, notes, and snippets.

View t-nissie's full-sized avatar

Takeshi Nishimatsu t-nissie

View GitHub Profile
@t-nissie
t-nissie / zundoko.f
Last active March 17, 2016 10:05
dot_product()とかを使ってできるだけFortran風に書いた「ズンドコキヨシ in Fortran」(1行169バイトのzz.fもあるヨ!)
! zundoko.f -*-f90-*-
!「ズン」「ドコ」のいずれかをランダムで出力し続けて
!「ズン」「ズン」「ズン」「ズン」「ドコ」の配列が出たら
!「キ・ヨ・シ!」って出力した後終了
! Ref1: https://twitter.com/kumiromilk/status/707437861881180160
! Ref2: http://qiita.com/shunsugai@github/items/971a15461de29563bf90
!!
subroutine kiyoshi(c)
implicit none
integer,intent(in) :: c
@t-nissie
t-nissie / 00AkaiKKR.md
Last active March 8, 2016 10:18
AkaiKKRについてのメモ
@t-nissie
t-nissie / interpolations.rb
Last active March 8, 2016 03:40
いくつかの補間法
#!/usr/bin/env ruby
# interpolations.rb interpolates a data set.
# Gist: https://gist.github.com/t-nissie/9f7cd7d4991530a3fac7
# Author: Takeshi Nishimatsu
# Copying:
# Copyright (c) 2016 by Takeshi Nishimatsu
# interpolations.rb is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY.
# You can copy, modify and redistribute interpolations.rb,
# but only under the conditions described in
@t-nissie
t-nissie / 00README.md
Last active January 10, 2024 12:18
RubyのRangeを積分範囲としてブロックで与えられた関数を数値積分するライブラリ 使用例: (0.0..Math::PI).simpson(20){|x| Math::sin(x)}

RubyのRangeを積分範囲としてブロックで与えられた関数を数値積分するライブラリ

下に置いてある短いライブラリ https://gist.github.com/t-nissie/b6ef8d39229a2534498b/raw/integrations.rb はRubyのRangeを積分範囲としてブロックで与えられた関数を数値積分します。 台形公式か シンプソンの公式か が選べます。

使い方

@t-nissie
t-nissie / 00dvipdfmx.md
Last active March 24, 2016 07:45
dvipdfmxでGNUPLOTで作ったEPS画像を挿入するとずれる話

dvipdfmxでgnuplotで作ったEPS画像を挿入するとずれる話

dvipdfmxを正しく使ってもgnuplotで作ったEPS画像を挿入するとずれるようです。 tgifなどで作ったEPSは大丈夫。

http://d.hatena.ne.jp/zrbabbler/20140121/1390313675 を参考にdvipdfmxは正しく使っているつもりです。

(いつもはpdflatexでPDFの図を挿入した英語のLaTeX文章をそのままPDFに変換しているので気がつきませんでした。 古い日本語のLaTeX文章をコンパイルしないといけない…)

@t-nissie
t-nissie / fib.jl
Last active May 31, 2021 22:14
Three ways of generating n-th Fibonacci number in Julia language
#!/usr/bin/env julia
# Gist: https://gist.github.com/t-nissie/641df996b9035f85b230
# Three ways of generating n-th Fibonacci number in Julia language
# Put perfutil.jl in the same directory as:
# wget https://raw.githubusercontent.com/JuliaLang/julia/master/test/perf/perfutil.jl
# Turn off garbage collection (GC), when you get occasional bad timings. See perfutil.patch below.
###
using Base.Test
include("perfutil.jl")
@t-nissie
t-nissie / 00FFTW.md
Last active January 5, 2016 02:08
FFTW3で自分のコードレット (codelet) を作ってみる

FFTW3で自分のコードレット (codelet) を作ってみる

この文章はFFTW3の使い方を説明するものではない。

必要なもの

  • gcc
  • gfortran
  • OCaml(yum install ocamlとかでインストールできる。)
  • autoconf
  • automake(apt-get install autoconf automake libtoolとかでインストールできる。)
@t-nissie
t-nissie / 00OCaml.md
Last active December 29, 2020 14:16
OCaml練習帳

OCaml練習帳

OCamlを自習する。 浅井健一著『プログラミングの基礎』とそのWebサイト http://pllab.is.ocha.ac.jp/~asai/book-mov/ を使う。

インストール

UTF-8で漢字の入出力に対応させるのがわりと面倒。

Ubuntu 14.04 LTSへのインストール

UbuntuなどDebian系のGNU/Linuxにはapt-getで簡単にインストールできる:

@t-nissie
t-nissie / 00anatase.en.md
Last active October 7, 2018 23:44
Quantum EspressoでTiO2アナターゼの電子のバンド構造とDOSを描く

Plot band structure and DOS of TiO2 anatase

Original files are in https://gist.github.com/t-nissie/ad99810ddf1bceb602f6 .

Preparation

  • Clone files in the gist as git clone https://gist.github.com/ad99810ddf1bceb602f6.git anatase08-k6x6x4-band-dos-gist.
  • cd anatase08-k6x6x4-band-dos-gist.
  • Get O.pw-mt_fhi.UPF and Ti.pw-mt_fhi.UPF form http://www.quantum-espresso.org/pseudopotentials/ .
  • Make symlinks to bands.x, dos.x, plotband.x and pw.x in the current directory, i.e. ln -s /SOMEWHERE/espresso-5.1.2/bin/bands.x.
@t-nissie
t-nissie / sincos.F
Last active December 14, 2015 00:14
FFTの係数の準備をするときに、必ずしもsin(π/2)=1, cos(π/2)=0, sin(π/4)=cos(π/4)とかではないので、0<=θ<=π/4のsinθ, cosθを使うべき
! sincos.F
! You cannot say "sin(pi/2)=1, cos(pi/2)=0, sin(pi/4)=cos(pi/4)".
! Time-stamp: <2015-12-14 08:12:49 takeshi>
! Author: Takeshi NISHIMATSU
! Ref1: http://notabs.org/fpuaccuracy/index.htm
! Ref2: http://tomeapp.jp/archives/1282
! Ref3: https://sourceware.org/ml/libc-alpha/2015-12/msg00205.html
! Ref4: https://twitter.com/takehiro_t/status/676006684259540992
!!
#if defined(__PGI) || defined(__sparc)