Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <chrono> | |
using namespace std; | |
auto start = chrono::high_resolution_clock::now (); | |
double x = 3; // bet this doesn't take long | |
auto now = chrono::high_resolution_clock::now (); | |
chrono::duration<double> time_span = now - start; | |
auto seconds = time_span.count(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def triangle_angles(p0, p1, p2): | |
A = p1 - p0 | |
B = p2 - p1 | |
C = p0 - p2 | |
angles = [] | |
for e1, e2 in ((A,-B), (B,-C), (C,-A)): | |
num = np.dot(e1, e2) | |
denom = np.linalg.norm(e1) * np.linalg.norm(e2) | |
angles.append(np.arccos(num/denom)) | |
return angles |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sympy.abc import x, y, z | |
from sympy.plotting import plot, plot3d | |
import sympy as sp | |
fron sympy import solve, Eq | |
def plot_line(e): | |
e = solve(e, y) | |
plot(e[0]) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# draw the figure so the animations will work | |
import matplotlib.pyplot as plt | |
fig = plt.gcf() | |
fig.show() | |
fig.canvas.draw() | |
while True: | |
# compute something | |
plt.plot([1, 2, 3, 4, 5], [2, 1, 2, 1, 2]) # plot something | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
ax = plt.gca() | |
ax.set_aspect('equal') | |
plt.xlim(-4, 4) | |
plt.ylim(0, 8) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# style the notebook | |
from IPython.core.display import HTML | |
import urllib.request | |
# this link is to my Kalman filter book CSS file. | |
response = urllib.request.urlopen('http://bit.ly/1LC7EI7') | |
HTML(response.read().decode("utf-8")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dbeta (.7, 1, 2) | |
from scipy.stats import beta | |
beta(1, 2).pdf(.7) # frozen form, very slow if only calling once!!!!!! | |
beta.pdf(.7, 1, 2) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void foo1(HANDLE start, HANDLE end, vector<Data>* data_queue, int index) | |
{ | |
int id = index; | |
vector<Data>* data = data_queue; | |
while (true) { | |
WaitForSingleObject(start, INFINITE); | |
ResetEvent(start); | |
Data& d = (*data)[index++]; | |
if (index >= data->size()) |
OlderNewer