Skip to content

Instantly share code, notes, and snippets.

View spaghetti-source's full-sized avatar

Takanori MAEHARA spaghetti-source

View GitHub Profile
@spaghetti-source
spaghetti-source / tpack.cc
Created December 26, 2013 21:52
T-Packing
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
using namespace std;
#define fst first
#define snd second
@spaghetti-source
spaghetti-source / template.tex
Created December 25, 2013 20:39
my tex template
%{{{
\documentclass[a4paper,11pt]{article} % single column
%\documentclass[a4paper,11pt,twocolumn]{article} % two columns
\usepackage[dvipdfmx]{graphicx}
\usepackage{latexsym}
\usepackage{amsthm,amsmath,amssymb}
\usepackage{enumerate}
\usepackage{multirow}
\usepackage{algorithm,algpseudocode}
//
// 最適解: AVG BY FETCH JOIN MAX PAD SIZE SQL SUM WORK (34文字)
// 計算にかかった時間:0.01[s]
// 解法:整数計画(IP)
//
// 解説:
// 重み付き集合被覆問題.問題のサイズが小さいのでIPで解ける.
// ソルバーとして ILOG/CPLEX 12.5 を使用した.
//
@spaghetti-source
spaghetti-source / maxcut-sg.cc
Created December 4, 2013 00:29
Maximum Cut Solver; Modified version of Sahni-Gonzales's greedy heuristics by Kohruman et al.
// Maximum Cut
// modified version of Sahni and Gonzales's greedy heuristics
// by S. Kahruman, E. Kolotoglu, S. Butenko, and I. V. Hicks
//
// http://ise.tamu.edu/people/faculty/butenko/papers/maxcut.pdf
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstdlib>
//
// (Simplified) Sequence Memoizer
// for (unbounded depth) Kneser-Ney smoothing
//
// Reference:
//
// - J. Gasthaus, F. Wood, and Y. W. Teh (2010):
// Lossless compression based on the Sequence Memoizer.
// In Proceedings of Data Compression Conference,
// pp. 337-345.
@spaghetti-source
spaghetti-source / FloydWarshall.m
Last active November 25, 2020 15:49
Floyd Warshall (matlab)
function D = FloydWarshall(D)
n = size(D, 1);
for k = 1 : n
i2k = repmat(D(:,k), 1, n);
k2j = repmat(D(k,:), n, 1);
D = min(D, i2k + k2j);
end
end
@spaghetti-source
spaghetti-source / bitmap.h
Last active December 20, 2015 12:39
Image Inpainting (Poisson iteration)
#pragma once
#include <vector>
typedef unsigned short WORD;
typedef unsigned long DWORD;
typedef long LONG;
typedef unsigned char BYTE;
#pragma pack(push, 1)
struct BITMAPFILEHEADER {
WORD bfType;
@spaghetti-source
spaghetti-source / eigenre.cc
Created July 19, 2013 10:43
Runtime error (Eigen 3.1.1) if compile with "g++ -O3 main.cc". if -O2 instead of -O3, runtime error.does not arise.
// Runtime error if compile with "g++ -O3 main.cc"
#include <iostream>
#include <Eigen/Eigen>
using namespace std;
using namespace Eigen;
void f() {
MatrixXd U(2,2);
U = U*U; // runtime error
@spaghetti-source
spaghetti-source / zdd.cc
Last active December 19, 2015 17:39
Zero-suppressed binary decision diagram with family algebra operations
//
// Zero-suppressed binary decision diagram with family algebra operations
//
// References:
// S. Minato (1993):
// Zero-suppressed BDDs for set manipulation in combinatorial problems.
// Proceedings of the 30st annual Design Automation Conference, pp. 272-277.
// S. Minato (1994):
// Calculation of unate cube set algebra using zero-suppressed BDDs.
// Proceedings of the 31st annual Design Automation Conference, pp. 420-424.
@spaghetti-source
spaghetti-source / ip-dualascent.m
Last active December 19, 2015 14:49
{0,1} Integer Programming; dual ascent
%
% solve min c'x s.t. Ax >= b, x in {0,1}^n
%
% Lagrangian L(x,u) := cx + ub - uAx
%
% original problem:
% min[x] max[u] L(x,u)
% Lagrangian dual
% max[u] min[x] L(x,u)
%