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 / 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
//
// (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 / 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>
//
// 最適解: AVG BY FETCH JOIN MAX PAD SIZE SQL SUM WORK (34文字)
// 計算にかかった時間:0.01[s]
// 解法:整数計画(IP)
//
// 解説:
// 重み付き集合被覆問題.問題のサイズが小さいのでIPで解ける.
// ソルバーとして ILOG/CPLEX 12.5 を使用した.
//
@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}
@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 / lbfgs.cc
Last active January 3, 2016 00:19
Limited Memory Broyden-Fletcher-Goldfarb-Shanno (LBFGS)
#include <iostream>
#include <vector>
#include <deque>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <cmath>
#include <cstring>
#include <functional>
#include <algorithm>
@spaghetti-source
spaghetti-source / nlcg.cc
Last active January 3, 2016 00:29
Nonlinear Conjugate Gradient Descent (Polak-Ribiere)
// nonlinear conjugate gradient
#include <iostream>
#include <vector>
#include <deque>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <cmath>
#include <cstring>
@spaghetti-source
spaghetti-source / mds_ghcn.cc
Last active January 4, 2016 05:49
MDS for GHCN dataset
//
// http://www.ncdc.noaa.gov/ghcnm/v3.php
//
#include <iostream>
#include <vector>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <cmath>
% --- testcase: grid network ---
% A: adjacency matrix
inf = 999999;
w = 4;
h = 4;
A = inf*ones(w*h);
n = size(D,1);
for x = 1 : w
for y = 1 : h
if x < w