Skip to content

Instantly share code, notes, and snippets.

View rkwitt's full-sized avatar
🎯
Focusing

Roland Kwitt rkwitt

🎯
Focusing
View GitHub Profile
@rkwitt
rkwitt / DebugMexFilesOnLinux
Last active December 14, 2015 14:58
Exemplary steps to debug segfaulting .mex* files in MATLAB (on a Linux platform)
1) Compile your code (using mex) with -g flag
2) Call gdb via MATLAB's 'matlab -Dgdb' functionality
3) Set a breakpoint for instance by 'break testfile.cpp:9'
3) Run MATLAB without the JVM by 'run -nojvm'
4) Now, run the segfaulting mex function
5) Get a backtrace via 'bt' and use your debugging magic
Example:
$ cd '/mycode/
@rkwitt
rkwitt / kw-techtip-04-03-2013-p3.py
Last active December 15, 2015 18:49
Kitware Tech-Tip 04-03-2013 Part 3: Computing a BoW representation from a feature matrix and training / testing a SVM classifier in a N-fold cross-validation setup.
"""kw-techtip-04-03-2013-p3.py
Compute BoW representations and train / test a SVM classifier in a N-fold
cross-validation setup.
Usage
-----
$ python kw-techtip-04-03-2013-p3.py <DataFile> <IndexFile> <ClassInfoFile>
"""
@rkwitt
rkwitt / kw-techtip-04-03-2013-p2.py
Last active December 15, 2015 18:49
Kitware TechTip 04-03-2013 Part 2: Computing fine-structure graph features
"""kw-techtip-04-03-2013-p2.py
Fine-structure analysis of a graph.
Usage
-----
Assuming that the file "graph.txt" generated by kw-techtip-04-03-2013-p1.py
resides in "/tmp", run
@rkwitt
rkwitt / kw-techtip-04-03-2013-p1.py
Last active December 15, 2015 18:49
Kitware TechTip 04-03-2013 Part 1: Graph construction from a binary adjacency matrix and a vertex label file.
"""kw-techtip-04-03-2013-p1.py
Simple example of how to construct a graph from a {0,1} adjacency matrix and a
file with vertex labels.
Usage
-----
$ python kw-techtip-04-03-2013-p1.py <AdjacencyFile> <LabelFile>
2014-09-29 09:29:04 +0200
make
all
clang -O -c -o vecLibFort.o vecLibFort.c
clang -shared -O -DVECLIBFORT_INTERPOSE -o libvecLibFortI.dylib -O vecLibFort.c \
-Wl,-reexport_framework -Wl,Accelerate \
-install_name /usr/local/lib/libvecLibFortI.dylib
ar -cru libvecLibFort.a vecLibFort.o
2014-09-29 09:29:04 +0200
make
all
clang -O -c -o vecLibFort.o vecLibFort.c
clang -shared -O -DVECLIBFORT_INTERPOSE -o libvecLibFortI.dylib -O vecLibFort.c \
-Wl,-reexport_framework -Wl,Accelerate \
-install_name /usr/local/lib/libvecLibFortI.dylib
ar -cru libvecLibFort.a vecLibFort.o
@rkwitt
rkwitt / test_negative_type_simple.m
Last active August 29, 2015 14:11
Indefiniteness of p-Wasserstein and Bottleneck distance based kernels
function [pos_ev_idx,neg_ev_idx,seed,data] = test_negative_type_simple(options)
% TEST_NEGATIVE_TYPE_SIMPLE evaluate the eigenvalues of Gram matrices
%
% This function evaluates the number of positive/negative eigenvalues
% of the Gram matrix M, either constructed from the (1) q-Wasserstein
% distance or (2) the bottleneck distance.
%
% Both distances lead to nonnegative (symmetric) Gram matrices and
% the question is if the Gram matrices are (conditionally) negative
% definite (see suppl. material).
@rkwitt
rkwitt / cs4all-10242016-fun.c
Created October 24, 2016 12:02
Simple function call to demonstrate stack
int f(int a, int b, int c)
{
int c;
c = a + b;
return c;
}
int main()
{
int a;
@rkwitt
rkwitt / cs4all-10172016-gp.c
Created October 24, 2016 12:03
Example to demonstrate MIPS32 GP
int a = 1111;
int main() {
a = 3333;
}
@rkwitt
rkwitt / cs4all-10242016-recursion.c
Created October 24, 2016 12:05
Simple example to demonstrate recursion and stack build up and tear down
int g(int x, int y) {
if (y > 0)
return g(x, y - 1) + 1 ;
else
return x;
}
int main() {
int a;