This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
function [maxtab, mintab]=peakdet(v, delta, x) | |
%PEAKDET Detect peaks in a vector | |
% [MAXTAB, MINTAB] = PEAKDET(V, DELTA) finds the local | |
% maxima and minima ("peaks") in the vector V. | |
% MAXTAB and MINTAB consists of two columns. Column 1 | |
% contains indices in V, and column 2 the found values. | |
% | |
% With [MAXTAB, MINTAB] = PEAKDET(V, DELTA, X) the indices | |
% in MAXTAB and MINTAB are replaced with the corresponding | |
% X-values. |
#!/usr/bin/python2 | |
# Copyright (C) 2016 Sixten Bergman | |
# License WTFPL | |
# | |
# This program is free software. It comes without any warranty, to the extent | |
# permitted by applicable law. | |
# You can redistribute it and/or modify it under the terms of the Do What The | |
# Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See |
# Creating heatmap (slower) | |
dbins = np.linspace(0.0, 1.0, 51) | |
m = np.zeros((len(dbins), len(x_axis))) | |
m2 = np.zeros((len(dbins), len(x_axis))) | |
for r in res: | |
rd = np.digitize(r, dbins) | |
for i, d in enumerate(rd): | |
m[d, i] += 1 |
/******** Header Files ********/ | |
#include <iostream> | |
#include <sstream> | |
#include <stdio.h> | |
#include <string.h> | |
#include <string> | |
#include <vector> | |
#include <queue> |
%%time | |
from itertools import combinations as _combu | |
import numpy as np | |
from scipy.optimize import linprog | |
def inversions(X): | |
# build inequalities | |
A = [v2 - v1 for v2, v1 in _combu(X, 2)] |
https://docs.microsoft.com/en-us/windows/wsl/tutorials/wsl-containers#install-docker-desktop
https://docs.microsoft.com/en-us/windows/wsl/use-custom-distro
(set as default linux: wsl --set-default CentOS-7)
def diagonal_form(a, upper = 1, lower= 1): | |
""" | |
a is a numpy square matrix | |
this function converts a square matrix to diagonal ordered form | |
returned matrix in ab shape which can be used directly for scipy.linalg.solve_banded | |
""" | |
n = a.shape[1] | |
assert(np.all(a.shape ==(n,n))) | |
ab = np.zeros((2*n-1, n)) |
# Based on oneAPI description | |
# Both from C order | |
n, m = A.shape | |
ldm, lda = n, 3 | |
ku, kl = 1, 1 | |
B = np.zeros((lda, ldm)) | |
for j in range(n): | |
k = ku - j | |
for i in range(max(0, j-ku), min(m, j + kl + 1)): | |
B[(k + i), j] = A[i, j] |
Just head over to the GitHub page and click the "Fork" button. It's just that simple. Once you've done that, you can use your favorite git client to clone your repo or just head straight to the command line:
# Clone your fork to your local machine
git clone [email protected]:USERNAME/FORKED-PROJECT.git