Skip to content

Instantly share code, notes, and snippets.

#include <gtk/gtk.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define W_WIDTH 500
#define W_HEIGHT 500
#define N W_WIDTH
const double k=1.0;
const double dt=0.002,dx=0.1;
#define LEFT 1
#define RIGHT 2
main(){
FILE *pio;
int input=0,x=72,y=26;
pio=fopen("pio","a+");
if(pio==NULL) abort();
pioset(LEFT&RIGHT);
#include <GL/glut.h>
#include <complex>
using namespace std;
constexpr int w_width=640,w_height=640,countnum=100;
double dx,dy;
int convergence(const complex<double>&);
void init();
@terakun
terakun / fibo.cc
Last active August 29, 2015 13:57
#include <iostream>
using ulong=unsigned long;
ulong fibo(ulong n){
return n<2?n:fibo(n-1)+fibo(n-2);
}
int main(){
ulong n;
#include <iostream>
using ulong=unsigned long;
ulong fibo_sub(ulong,ulong,ulong);
ulong fibo(ulong n){
return (n==0)?0:fibo_sub(n,1,0);
}
#include <iostream>
#include <complex>
#include <cmath>
#include <vector>
using namespace std;
using cplx=complex<double>;
template<typename T>
constexpr T pi(){
return 3.141592653589793238463L;
@terakun
terakun / rect.cc
Created March 26, 2015 12:37
切り餅発見伝
#include <iostream>
#include <vector>
#include <string>
#include <fstream>
typedef std::vector<std::string> Table;
typedef unsigned long long int ullint;
ullint rectnum(const Table&);
@terakun
terakun / servo.sh
Last active October 27, 2016 15:26
servo
PATTERNFILE=./pattern.txt
echo 0=0% > /dev/servoblaster
echo 1=0% > /dev/servoblaster
sleep 2
ports=(`echo "100 100 100 100 100 100 100 100"`)
while read line; do
ary=(`echo $line`)
port=${ary[0]}
str=`echo "${port}=${ports[$port]}%"`
echo $str > /dev/servoblaster
#include <iostream>
#include <fstream>
#include <random>
#include <cmath>
#include <Eigen/Dense>
#include <Eigen/LU>
int main(){
constexpr int deg = 2;
constexpr double omega = 2.0*M_PI*2.0;
@terakun
terakun / DKA.cc
Created December 4, 2016 15:52
DKA method
#include <iostream>
#include <complex>
#include <vector>
#include <iomanip>
using complexd=std::complex<double>;
void showpoly(const std::vector<double> &coeffs);
complexd poly(const std::vector<double> &coeffs,const complexd &z);
void DKA(const std::vector<double> &coeffs,std::vector<complexd> &poles);