Skip to content

Instantly share code, notes, and snippets.

View danking's full-sized avatar

Dan King danking

View GitHub Profile
#lang racket
(provide make-partitioned-set
pset-add
pset-add*
pset-contains?
pset-contains-equivclass?
pset-equivclass-partition
pset-empty?
pset-count
@danking
danking / gist:5323483
Created April 5, 2013 23:30
Run sad on arbitrary size matrices
#include<xmmintrin.h>
#include<stdio.h>
#define WIDTH1 64
#define HEIGHT1 64
#define WIDTH2 1280
#define HEIGHT2 960
int * runsad(void* img1, int bWidth1, int bHeight1,
@danking
danking / gist:5323403
Last active December 15, 2015 21:09
SAD on arbitrary length matricies using the machine insn
#include<xmmintrin.h>
#include<stdio.h>
int inner_sad(char* pattern, char* source, int w, int h) {
int words = w/8;
int sad = 0;
int y;
#include<xmmintrin.h>
#include<stdio.h>
#define N 8
int main()
{
/* unsigned char a[N] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}; */
/* unsigned char b[N] = {0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f}; */
Targets (1): ghc-7.6.2-1
Total Installed Size: 742.43 MiB
Proceed with installation? [Y/n] Y
debug: using cachedir: /var/cache/pacman/pkg/
debug: using cachedir: /var/cache/pacman/pkg/
checking package integrity...
debug: found cached pkg: /var/cache/pacman/pkg/ghc-7.6.2-1-x86_64.pkg.tar.xz
debug: sig data: iF4EABEIAAYFAlEOKKcACgkQkFE3UKQYwP70DAEAseHY30FCwSDzJLrSL5Tr9ubfVj7Fg3oy/XCMeuXkSrkBANajfjsfu3Sn2tJ1LuyTaJzHtb9yhQUJr96a7Q/sQYPP
@danking
danking / gist:5276541
Last active December 15, 2015 14:39
scala shit
def dominantOri(hist: Histogram) = {
hist.reduceLeft ( _ max _ )
}
def goodOriFeatures(hist: Histogram, magThr: Double, feat: Feature) = {
val n = hist.length
def isGoodP(i: Int) = {
val l = if (i == 0) n - 1 else i - 1
val r = (i + 1) % n
link: namespace mismatch;
reference to a module that is not available
reference phase: 0
referenced module: "/home/danking/borg/racket/racket-5.3.2/collects/math/private/array/typed-array-indexing.rkt"
referenced phase level: 0
reference in module: '#%embedded:g4750:matrix-basic
in: Slice?
context...:
#%embedded:g4750:matrix-basic: [running body]
#%embedded:g4722:matrix-solve: [traversing imports]
#lang racket
(provide (all-defined-out))
(require ffi/unsafe
ffi/unsafe/define)
;; on systems machines use this:
;;(define-ffi-definer define-fftw (ffi-lib "libfftw3.so.3"))
(define-ffi-definer define-fftw (ffi-lib "libfftw3"))
@danking
danking / gist:5179334
Created March 17, 2013 02:47
Weirdness with #:when in for macros of typed racket
#lang typed/racket
(for*/list: : [Listof [List Integer]]
((x : Integer (in-range 0 10)))
(list x))
(for*/list: : [Listof [List Integer Integer]]
((x : Integer (in-range 0 10)))
(list x x))
(for/list: : [Listof [List Integer Integer]]
((x : Integer (in-range 0 10))
@danking
danking / gist:4747479
Last active December 12, 2015 08:58
You'll notice there's also a problem with it not realizing that the unless terms will stop execution before I try to return non-string values.
#lang typed/racket
(require racket/cmdline)
;; The command line syntax is currently:
;; spims -p <file> -s <file>
;; where the first file is a pattern image and the second file is a source image
(define-type MaybeString [U False String])