Skip to content

Instantly share code, notes, and snippets.

View kmkurn's full-sized avatar
💭
I may be slow to respond.

Kemal Kurniawan kmkurn

💭
I may be slow to respond.
View GitHub Profile
@kmkurn
kmkurn / cp-template.cpp
Last active December 13, 2015 21:38
My personal template for competitive programming purpose.
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <iostream>
#include <list>
#include <map>
#include <queue>
@kmkurn
kmkurn / kernel_model.py
Last active August 29, 2015 14:02
Functions related to Gaussian kernel model.
#!/usr/bin/python2
from __future__ import division
import numpy as np
def gaussian_kernel(p, q, h):
"""Compute Gaussian kernel function."""
return np.exp(-(p-q)**2 / (2*h*h))
@kmkurn
kmkurn / parser.py
Created June 16, 2014 08:31
Parser builder for common script arguments for Pattern Information Processing course assignments.
#!/usr/bin/python2
"""
Parser builder for common script arguments.
"""
import argparse
import numpy as np
@kmkurn
kmkurn / gaussian_cls.py
Created June 16, 2014 08:33
Simple Gaussian kernel model with L1-CLS and QCLS.
#!/usr/bin/python2
from __future__ import division
from __future__ import print_function
import itertools as it
import cvxpy as cvx
import matplotlib.pyplot as plt
import numpy as np
@kmkurn
kmkurn / gaussian_huber.py
Created June 16, 2014 08:34
Simple Gaussian kernel model with Huber learning.
#!/usr/bin/python2
from __future__ import division
from __future__ import print_function
import itertools as it
import cvxpy as cvx
import matplotlib.pyplot as plt
import numpy as np
@kmkurn
kmkurn / mpi_mm.c
Last active January 4, 2023 02:32
Matrix multiplication with MPI
/******************************************************************************
* FILE: mpi_mm.c
* DESCRIPTION:
* MPI Matrix Multiply - C Version
* In this code, the master task distributes a matrix multiply
* operation to numtasks-1 worker tasks.
* NOTE: C and Fortran versions of this code differ because of the way
* arrays are stored/passed. C arrays are row-major order but Fortran
* arrays are column-major order.
* AUTHOR: Blaise Barney. Adapted from Ros Leibensperger, Cornell Theory
@kmkurn
kmkurn / BFS.hs
Last active June 18, 2022 10:06
BFS in Haskell
{-# OPTIONS_GHC -Wall #-}
module BFS where
import Control.Monad (guard)
type Node = String
type Edge = (Node, Node)
@kmkurn
kmkurn / append_movie_year.py
Created May 29, 2016 17:19
Python script to append movie release year to the movie directory name
#!/usr/bin/env python
"""
This script renames all directories in the format "<movie name>" to
"<movie name> (<year>)". The year is fetched from IMDb. The root of movie
directories to be renamed is assumed to be stored in MOVIES_DIR environment
variable.
This script is meant to be run with Python 2. IMDbPY needs to be installed.
@kmkurn
kmkurn / compress_all.py
Created July 3, 2016 04:34
Compress all directories to a .tar.gz file
#!/usr/bin/env python
import argparse
import os
import subprocess
import tarfile
"""
This scipt compresses all directories inside a root directory to a
.tar.gz file. This script should be run with Python 3 in a machine
@kmkurn
kmkurn / bptt.ipynb
Last active December 15, 2018 13:05
Backpropagation Through Time (BPTT) tutorial
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.