Skip to content

Instantly share code, notes, and snippets.

View nandor's full-sized avatar

Nandor Licker nandor

  • Perplexity AI
  • London, United Kingdom
  • 06:01 (UTC)
View GitHub Profile
@nandor
nandor / simd.cc
Last active February 25, 2016 11:26
SSE + AVX Challenge
// AVX example. Compile with:
// clang++ simd.cc -O3 -osimd -lopencv_core -lopencv_highgui -lopencv_imgproc -std=c++14 -mavx -mfma
#include <chrono>
#include <iostream>
#include <immintrin.h>
#include <opencv2/opencv.hpp>
@nandor
nandor / gauss_newton_quat.py
Created February 23, 2016 00:27
Quaternion estimation using the Gauss-Newton method.
#!/usr/bin/env python2
import math
import numpy as np
import sympy
def rotation_quat(v, a):
q = np.zeros(4)
@nandor
nandor / power.cc
Created February 19, 2016 22:06
Power
/**
Computes the nth power of x in a rather funny way.
*/
template<size_t N> inline uint64_t power(int x) {
const auto half = power<N >> 1>(x);
const auto half2 = half * half;
return (N & 1) ? (half2 * x) : half2;
}
template<> inline uint64_t power<0>(int x) { return 1; }
template<> inline uint64_t power<1>(int x) { return x; }
@nandor
nandor / ssao.py
Last active November 23, 2015 01:15
Screen Space Ambient Occlusion
#!/usr/bin/env python2
import glfw
import math
import numpy as np
import random
import sys
from OpenGL.GLUT import *
from OpenGL.GLU import *
@nandor
nandor / maximum.cc
Created November 22, 2015 15:26
Computation of maximum using std::thread.
#include <mutex>
#include <thread>
#include <vector>
#include <iostream>
/**
* Computes the maximum of a vector in parallel, using n threads.
*/
template<typename T>
@nandor
nandor / sampling.py
Created November 21, 2015 18:48
Median Cut Light Proble Sampling
#!/usr/bin/env python2
import cv2 as cv
import numpy as np
import sys
SIZE = (640, 480)
def m(p, q, f):
Checking build/CMakeFiles/3.3.2/CompilerIdC/CMakeCCompilerId.c...
[build/CMakeFiles/3.3.2/CompilerIdC/CMakeCCompilerId.c]: (information) Too many #ifdef configurations - cppcheck only checks 12 of 45 configurations. Use --force to check all configurations.
Checking build/CMakeFiles/3.3.2/CompilerIdC/CMakeCCompilerId.c: SDCC...
Checking build/CMakeFiles/3.3.2/CompilerIdC/CMakeCCompilerId.c: SIMULATE_VERSION_PATCH...
Checking build/CMakeFiles/3.3.2/CompilerIdC/CMakeCCompilerId.c: SIMULATE_VERSION_PATCH;SIMULATE_VERSION_TWEAK...
Checking build/CMakeFiles/3.3.2/CompilerIdC/CMakeCCompilerId.c: _CRAYC...
Checking build/CMakeFiles/3.3.2/CompilerIdC/CMakeCCompilerId.c: _MSC_BUILD;_MSC_VER...
Checking build/CMakeFiles/3.3.2/CompilerIdC/CMakeCCompilerId.c: _MSC_FULL_VER;_MSC_VER...
Checking build/CMakeFiles/3.3.2/CompilerIdC/CMakeCCompilerId.c: _MSC_VER...
Checking build/CMakeFiles/3.3.2/CompilerIdC/CMakeCCompilerId.c: _MSC_VER;_WIN32...
@nandor
nandor / deploy.py
Created November 14, 2015 16:01
Deploy script sketch for DerpVision
#!/usr/bin/env python2
import logging
import os
import socket
import subprocess
import sys
import threading
import paramiko
#!/usr/bin/env runhaskell
{-# LANGUAGE GeneralizedNewtypeDeriving,
LambdaCase,
NamedFieldPuns,
RecordWildCards #-}
import Control.Applicative ((<$>))
import Control.Monad
import Control.Monad.Except
import Control.Monad.Reader
@nandor
nandor / plot.py
Last active November 19, 2015 19:35
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
with open('points.csv') as f:
a = np.loadtxt(f)
p3d = a[:,0:3]
p2d = a[:,3:5]