Skip to content

Instantly share code, notes, and snippets.

@higham
higham / edelman.m
Last active June 14, 2018 08:41
MATLAB function producing Alan Edelman's matrix for which det is computed as the wrong integer.
function A = edelman
%EDELMAN Alan Edelman's matrix for which det is computed as the wrong integer.
% A = EDELMAN is a 27-by-27 matrix of 1s and -1s for which the
% MATLAB det function returns an odd integer, though the exact
% determinant is an even integer.
A = [%
1 1 1 1 -1 -1 -1 1 1 -1 1 -1 -1 1 -1 1 -1 1 -1 -1 -1 -1 -1 1 -1 -1 -1
1 -1 -1 1 -1 1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 1 -1 1 1 1
-1 1 -1 -1 1 1 1 1 1 -1 1 -1 1 1 1 1 -1 -1 1 -1 -1 1 1 -1 1 1 -1
# This file is a naive implementation of numbers of the form x + y*i where i^2 = p
#######################
# GeneralComplex type #
#######################
immutable GeneralComplex{p,T} <: Number
x::T
y::T
end
@karpathy
karpathy / min-char-rnn.py
Last active April 25, 2024 06:24
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
module LC
const MC = 384
const KC = 384
const NC = 4096
const MR = 4
const NR = 4
const _A = Array(Float64, MC*KC)
@macd
macd / gist:128ca830e8f3819985a2
Last active August 29, 2015 14:04
An IJulia Notebook translation of Higham and Higham's "Matlab Guide"
{
"metadata": {
"language": "Julia",
"name": "",
"signature": "sha256:e7ef81d627c67af3ba8c90108dc2bc0f6f44f1a0e36cb9235cccecb3b07d7494"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
@jbarratt
jbarratt / nbgrep
Last active April 27, 2023 15:00
'nbgrep', search the code of all your ipython notebooks
#!/bin/bash
# usage: nbgrep 'pattern'
SEARCHPATH=~/work/
# 'jq' technique lifted with gratitude
# from https://gist.github.com/mlgill/5c55253a3bc84a96addf
# Break on newlines instead of any whitespace
@milktrader
milktrader / bit.jl
Created May 24, 2014 17:13
Plotting bitcoin in Julia REPL
julia> using Quandl, TextPlots
julia> bt = quandl("BAVERAGE/USD", rows=1000)
1000x5 TimeArray{Float64,2} 2011-08-25 to 2014-05-23
24h Average Ask Bid Last Total Volume
2011-08-25 | 10.01 NaN NaN NaN 55547.42
2011-08-26 | 8.65 NaN NaN NaN 83026.56
2011-08-27 | 8.63 NaN NaN NaN 22010.04
2011-08-28 | 8.97 NaN NaN NaN 24159.85
@chi-feng
chi-feng / preamble
Created September 17, 2013 01:38
Latex Listings language definition/style for Julia
\usepackage{inconsolata} % very nice fixed-width font included with texlive-full
\usepackage[usenames,dvipsnames]{color} % more flexible names for syntax highlighting colors
\usepackage{listings}
\lstset{
basicstyle=\ttfamily,
columns=fullflexible, % make sure to use fixed-width font, CM typewriter is NOT fixed width
numbers=left,
numberstyle=\small\ttfamily\color{Gray},
stepnumber=1,
@nyuichi
nyuichi / 90-min-scc.scm
Created July 31, 2011 10:36
The 90 Minute Scheme to C Compiler
#!/usr/local/Gambit-C/bin/gsi
; Copyright (C) 2004 by Marc Feeley, All Rights Reserved.
; This is the "90 minute Scheme to C compiler" presented at the
; Montreal Scheme/Lisp User Group on October 20, 2004.
; Usage with Gambit-C 4.0:
;
; % ./90-min-scc.scm test.scm