Skip to content

Instantly share code, notes, and snippets.

View kohnakagawa's full-sized avatar
🌴
On vacation

tsunekoh kohnakagawa

🌴
On vacation
View GitHub Profile
template<typename T>
T pow_n(T x, int n){
T a = 1.0;
while(n > 0){
if(n % 2 == 0){
x = x*x;
n = n>>1;
}else{
a = a*x;
#include <sys/time.h>
double time_dif(timeval &tv1, timeval &tv2)
{
const double dt = tv2.tv_sec - tv1.tv_sec + (tv2.tv_usec - tv1.tv_usec) * 1.0e-6;
return dt;
}
set terminal postscript eps enhanced color lw 2 defaultplex "Helvetica" 16
#set terminal postscript eps enhanced color
set output "dif.eps"
set size 0.65,1.23
set nokey
#set key graph 0.7, graph 0.8
set nogrid
set format y '%g'
set format x '%g'
set terminal postscript eps enhanced color lw 2 defaultplex "Helvetica" 16
#set terminal postscript eps enhanced color solid
set output "dif.eps"
set size 0.65,0.62
unset key
#set key graph 0.7, graph 0.9
unset grid
set format y '%g'
set format x '%g'
#!/bin/bash
flame_rate=10
output_file="out"
number_of_digit=3
ffmpeg -r ${flame_rate} -i "time%0"${number_of_digit}"d.jpeg" -qscale 0 ${output_file}".mp4"
#include <iostream>
#include <cmath>
#include <gsl/gsl_math.h>
#include <gsl/gsl_vector.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_eigen.h>
#include <gsl/gsl_sort_vector.h>
#define DIM 2
#include <iostream>
#include "Eigen/Core"
#include "Eigen/Eigenvalues"
int main(void){
using namespace Eigen;
Matrix2d A;
Vector2d a;
A << 1,-0.5,-0.5,1;
SelfAdjointEigenSolver<Matrix2d> es(A);
#include <iostream>
#include <boost/random.hpp>
int main ()
{
using namespace boost;
using namespace std;
mt19937 gen(100);
#small sample for GMM
#install.packages('mclust') #installing Mclust package
library(mclust)
dat <- read.table("./result/")
dat <- data.matrix(dat)
result.dat <- Mclust(dat)
plot(result.dat)
summary(result.dat,parameters=TRUE)
#!/bin/bash
R --vanilla --slave < gmm.R
#R --vanilla --slave --args ./infile.txt ./outfile.txt 10000 < gmm.R