Skip to content

Instantly share code, notes, and snippets.

View jmbr's full-sized avatar

Juan M. Bello-Rivas jmbr

View GitHub Profile
.text
.align 4,0x90
.globl __Z21matrix_vector_productPKdPd
__Z21matrix_vector_productPKdPd:
LFB18:
vmovsd 8(%rdi), %xmm2
vmovsd (%rdi), %xmm1
vmulsd %xmm2, %xmm2, %xmm3
vmovsd 16(%rdi), %xmm0
vmovsd 32(%rdi), %xmm6
@jmbr
jmbr / print_matrix.c
Created November 8, 2010 18:48
Print a GSL matrix.
#include <stdio.h>
#include <stddef.h>
#include <gsl/gsl_matrix.h>
int print_matrix(FILE *f, const gsl_matrix *m)
{
int status, n = 0;
for (size_t i = 0; i < m->size1; i++) {
for (size_t j = 0; j < m->size2; j++) {
@jmbr
jmbr / build-mpisbcl.sh
Created June 15, 2019 17:20
Create an MPI-enabled SBCL executable
#!/bin/sh
sbcl --eval "(ql:quickload '(:swank :cl-mpi))" \
--eval "(defun toplevel () \
(push #'mpi:mpi-finalize *exit-hooks*) \
(mpi:mpi-init) \
(let ((port (+ swank::default-server-port (mpi:mpi-comm-rank)))) \
(swank:create-server :port port :dont-close t)) \
(sb-impl::toplevel-init))" \
--eval "(save-lisp-and-die \"mpisbcl\" :executable t :toplevel #'toplevel)"
@jmbr
jmbr / gnome-flashback-stumpwm
Last active May 22, 2020 00:48
StumpWM with Gnome Flashback: all the amenities of Gnome plus the slick features of StumpWM.
This file goes in /usr/lib/gnome-flashback/
#! /bin/sh
exec gnome-session --session=gnome-flashback-stumpwm --disable-acceleration-check "$@"
@jmbr
jmbr / .stumpwmrc.lisp
Last active August 8, 2020 06:15
My StumpWM configuration file
;;; StumpWM initialization file.
(ql:quickload "swank")
(in-package :stumpwm)
(setf *window-border-style* :none
*resize-hides-windows* nil)
;;; Redirect output to ~/.stumpwm.d/stumpwm.log
@jmbr
jmbr / fig-example.gp
Created September 19, 2020 23:23
Gnuplot figure rendered in LaTeX with proper fonts and sizes
reset
load '~/gnuplot-colorbrewer/qualitative/Set2.plt' # Optional
set terminal push
set terminal epslatex size 3.22in, 2.255in
set output "fig-example.tex"
unset key
set border 3
@jmbr
jmbr / hoop.scad
Created March 23, 2021 17:03
Quarter of hoop for kitty
/*[ Radius of big circle ]*/
r0 = 150;
/*[ Radius of tube ]*/
r1 = 8; // r0/10.0;
/*[ Tolerance ]*/
rtol = 0.2;
module joint(r) {
@jmbr
jmbr / pca_experiment.py
Last active April 9, 2021 15:54
The distances between points in a linear Euclidean manifold are the same before and after dimensionality reduction with principal component analysis.
import numpy as np
from sklearn.decomposition import PCA
from scipy.spatial.distance import pdist
def get_points_from_square(num_points: int, ambient_dim: int) -> np.ndarray:
"""Get points from a grid of a linear manifold (a square in this case) endowed with the Euclidean metric.
"""
aux = np.linspace(-1, 1, int(np.sqrt(num_points)))
@jmbr
jmbr / switch-to-python-buffer.el
Created April 9, 2021 18:33
Quickly switch to (or start) a Python interpreter buffer in Emacs.
(defun switch-to-python-buffer ()
"Switch to Python shell buffer quickly."
(interactive)
(let ((python-buffer (get-buffer "*Python*")))
(if python-buffer
(switch-to-buffer python-buffer)
(run-python))))
(global-set-key (kbd "C-c z") 'switch-to-python-buffer)
(global-set-key (kbd "C-c C-z") 'switch-to-python-buffer)
@jmbr
jmbr / diffusion_maps.py
Last active April 13, 2021 04:07
Fast and simple computation of diffusion maps
from typing import Tuple
import numpy as np
import scipy.spatial
DEFAULT_NUM_EIGENPAIRS: int = 10 + 1
def diffusion_maps(points: np.ndarray, epsilon2: float,