Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@adityaramesh
adityaramesh / mach_thread_test
Last active August 29, 2015 14:05
A simple "Hello, world" program using Mach threads.
#include <iostream>
#include <unistd.h>
#include <mach/mach.h>
#include <mach/mach_vm.h>
#include <mach/mach_error.h>
#include <mach/mach_init.h>
#include <mach/mach_types.h>
#include <mach/mach_traps.h>
@adityaramesh
adityaramesh / parse_memory_string.py
Last active February 15, 2016 21:47
Converts a human-readable memory string (e.g. "256 GiB") into an integral byte count.
import re
def parse_memory_string(mem_str):
"""
Returns the number of bytes represented by a string ``mem_str`` matching the following
regex: ::
r'^(0|[1-9][0-9]*) (byte|bytes|KiB|MiB|GiB|TiB)'
If ``mem_str`` does not match this regex, then ``None`` is returned.
require('nn')
require('nngraph')
local m
do
local x1, x2 = nn.Identity()(), nn.Identity()()
local y = nn.Bilinear(2, 2, 2){x1, x2}
m = nn.gModule({x1, x2}, {y})
end
from sympy import Symbol, init_printing
from sympy.solvers import solve
from IPython.display import display
init_printing()
x1 = Symbol('x1')
x2 = Symbol('x2')
y = Symbol('y')
@adityaramesh
adityaramesh / test.py
Created May 22, 2017 07:09
Plancherel's theorem
import numpy as np
np.set_printoptions(precision=3, linewidth=200)
a = np.random.normal(size=(3, 3))
q, _ = np.linalg.qr(a)
print(np.matmul(q, q.T))
s = np.fft.fft2(q)
print(np.matmul(s, s.conj().T))