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 / ch02_perceptron.ml
Last active March 28, 2018 21:52
ゼロからOCamlで作るDeep Learning
(* perceptron : float -> float -> float -> float -> float -> float *)
(* description: perceptron with two inputs x1 and x2*)
let perceptron b w1 w2 x1 x2 = if b +. w1 *. x1 +. w2 *. x2 >= 0.0 then 1.0 else 0.0
let and_gate = perceptron ~-.0.7 0.5 0.5
let nand_gate = perceptron 0.7 ~-.0.5 ~-.0.5
let or_gate = perceptron ~-.0.5 1.0 1.0
let nor_gate = perceptron 0.5 ~-.1.0 ~-.1.0
let xor_gate x1 x2 = and_gate (nand_gate x1 x2) (or_gate x1 x2)
(* tests *)
@t-nissie
t-nissie / MacPortsFFTW.md
Last active February 12, 2018 10:30
MacPortsのmath/fftw-3のconfigureオプションに--enable-openmpを加えたい

MacPortsのmath/fftw-3のconfigureオプションに--enable-openmpを加えたい

MacPortsのmath/fftw-3のconfigureオプションに--enable-openmpを加えたいが、 /usr/bin/clangが-fopenmpを受け付けてくれないので今のところうまくいかない。

手元 (local) でmath/fftw-3/Portfileを変更してみる

MacPortsで自家製portsを使う方法を参考に。

$ sudo emacs /opt/local/etc/macports/sources.conf   # add a line of "file:///Users/t-nissie/ports"

$ mkdir -p ~/ports/math/fftw-3/files

@t-nissie
t-nissie / xtalgrowth2github.md
Last active January 1, 2018 23:00
Git と A successful Git branching model の練習のためSourceForgueのSubversionレポジトリにあるxtalgrowthをGitHubへ移動させた
@t-nissie
t-nissie / graphtest.cpp
Created September 25, 2017 19:58
graphtest.cpp tests the Boost Graph Library (BGL)
// graphtest.cpp tests the Boost Graph Library (BGL)
// Reference: http://faithandbrave.hateblo.jp/entry/20100413/1271129607
////
#include <iostream>
#include <vector>
#include <string>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/graph/graph_utility.hpp>
@t-nissie
t-nissie / saturated.c
Last active November 17, 2016 04:29
Qiitaの卜部昌平著『Cで飽和++』のコードのコピペ
/* saturated_inc(x) http://qiita.com/shyouhei/items/e960e641882da80c8932 */
#if __GNUC__ >= 7
# define saturated_inc(x) __builtin_add_overflow_p(x, 1, x) ? x : ++x
#else
# define saturated_inc(x) ({__typeof__(x) y; __builtin_add_overflow(x, 1, &y) ? x : ++x; })
#endif
signed long long
func(signed long long x)
{
return saturated_inc(x);
@t-nissie
t-nissie / large_array.c
Last active November 16, 2016 09:54
MPIで大きなsize_tをMPI_UINT64_Tとして渡して、大きな配列を確保/初期化 (first touch) する。MPI_AINTまたはMPI_COUNTを使うべき?
// large_array.c
// Gist: https://gist.github.com/t-nissie/38df694682cbdb08023567731f432fbf
// Description: pass a size_t as MPI_UINT64_T, allocate a large array of double, then first-touch it
// Author: Takeshi Nishimatsu
// License: GPLv3
// Reference: https://github.com/jeffhammond/BigMPI/blob/master/test/test_reduce_x.c
////
#include <mpi.h>
#include <stdio.h>
#include <stdlib.h>
@t-nissie
t-nissie / 00SnO2.en.md
Last active August 10, 2024 07:23
Calculation of SnO2 with Quantum Espresso
@t-nissie
t-nissie / 00ODE.en.md
Last active November 13, 2016 11:56
Learn ordinary differential equation (ODE) solvers with a harmonic oscillator
@t-nissie
t-nissie / julia.ssh
Last active September 3, 2016 11:45
highlighting Julia code with a2p(1)
# Style sheet for julia
# Ref: https://groups.google.com/forum/#!topic/julia-users/tisM_9sKPCc
# Gist: https://gist.github.com/t-nissie/83174cab99b11a2b5fa075ad845e6b4f
##
style Julia is
written by "Takeshi Nishimatsu"
version is 0.0.1
first alphabet is
@t-nissie
t-nissie / 00Cr-bcc-AFM.md
Last active August 1, 2016 02:05
金属クロムの反強磁性状態をABINITで計算してみる

金属クロムの反強磁性状態をABINITで計算してみる

金属クロムの安定な磁気構造は spin density wave (SDW) とのことだが、 長周期構造を使うわけにもいかないときのために、反強磁性 (AFM) 状態 をbccの conventional unit cell で出してみる。

用意するファイル

3つのファイルを用意する。

  • bcc-AFM.files(下記)