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
| git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'" |
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
| function linspace(shape, start, end, options) { | |
| /* | |
| If we use ndarray-linspace package, | |
| it returns a ndarray with dtype='array', | |
| but this dtype cannot be used by ndarray-tile package, it needs 'float'. | |
| So we need to transform dtype manually. | |
| */ | |
| let tmp = linspace(ndarray([], shape), start, end, options); | |
| return reshape(ndarray(new Float64Array(tmp.data)), shape); | |
| } |
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 [StackOverflow](https://stackoverflow.com/questions/4597820/does-haskell-have-list-slices-i-e-python) | |
| takeStep :: Int -> [a] -> [a] | |
| takeStep _ [] = [] | |
| takeStep n (x:xs) = x : takeStep n (drop (n-1) xs) | |
| slice :: Int -> Int -> Int -> [a] -> [a] | |
| slice start stop step = takeStep step . take (stop - start) . drop start |
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
| Options[plotGrid] = {ImagePadding -> 40}; | |
| plotGrid[l_List, w_, h_, opts : OptionsPattern[]] := | |
| Module[{nx, ny, sidePadding = OptionValue[plotGrid, ImagePadding], | |
| topPadding = 0, widths, heights, dimensions, positions, frameOptions | |
| = FilterRules[{opts}, FilterRules[Options[Graphics], Except[{ImagePadding, | |
| Frame, FrameTicks}]]]}, | |
| {ny, nx} = Dimensions[l]; | |
| widths = (w - 2 sidePadding) / nx Table[1, {nx}]; | |
| widths[[1]] = widths[[1]] + sidePadding; |
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
| fib[n_] := Which[n == 0, 0, n == 1, 1, n > 1, fib[n - 1] + fib[n - 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
| Clear["Global`*"] | |
| GreenChristoffelEquations[{ qx_, qy_, qz_ }] := {{ | |
| c11 qx ^ 2 + c44(qy ^ 2 + qz ^ 2), (c12 + c44) qx qy, (c12 + c44) qx qz | |
| }, { | |
| (c12 + c44) qx qy, c11 qy ^ 2 + c44(qz ^ 2 + qx ^ 2), (c12 + c44) qy qz | |
| }, { | |
| (c12 + c44) qx qz, (c12 + c44) qy qz, c11 qz ^ 2 + c44(qx ^ 2 + qy ^ 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
| def iter_islast(iterable): | |
| """ | |
| iter_islast(iterable) -> generates (item, islast) pairs | |
| Generates pairs where the first element is an item from the iterable | |
| source and the second element is a boolean flag indicating if it is | |
| the last item in the sequence. | |
| Referenced from | |
| `here <http://code.activestate.com/recipes/392015-finding-the-last-item-in-a-loop/>`_. |
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
| #!/usr/bin/env python -u -i | |
| import os | |
| import re | |
| import matplotlib.pyplot as plt | |
| import numpy as np | |
| import pandas as pd | |
| from matplotlib.ticker import ScalarFormatter |
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
| (* Taken from http://mathworld.wolfram.com/Jacobian.html *) | |
| JacobianMatrix[f_List?VectorQ, x_List] := Outer[D, f, x] /; Equal @@ (Dimensions /@ {f, x}) | |
| JacobianDeterminant[f_List?VectorQ, x_List] := Det[JacobianMatrix[f, x]] /; Equal @@ (Dimensions /@ {f, x}) |