This file contains 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
//Hash.js -- a cute little wrapper that is really great for turning data-only objects into something that | |
//javascript explictly calls a "Hash". Useful for cosmetically improving data structure representations | |
//in your favorite console. also great for making Javascript look like some of the more friendly scripting | |
//languages like Ruby. Possibly useless for anything else, and may make your code easier to read at the | |
//expense of speed and/or memory. | |
Hash = function(object) | |
{ | |
if (object && (typeof object == 'object')) //do an initial type check to see if this can be hashified. | |
{ //if not, then you should return an empty hash {}. |
This file contains 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.prototype.__defineGetter__("head",function(){return this.toString().split("{")[0].trim();}); | |
Function.prototype.__defineGetter__("body",function(){return this.toString().split("{").slice(1).join("{").slice(0,-1).trim();}); | |
Function.prototype.__defineGetter__("args",function(){return this.toString().split("{")[0].match(/\([\w\s\,]*\)/)[0].slice(1,-1).split(",");}); | |
Function.prototype.__defineGetter__("stmts",function() | |
{ | |
var str = this.body; | |
var stmtlist = []; | |
var pcount = 0; | |
var lastpos = str.length - 1; | |
for (var i = str.length - 1; i >= 0; i--) |
This file contains 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 <octave/oct.h> | |
// SPECIAL FUNCTION THAT CONVERTS A SPARSE MATRIX | |
// TO A MATRIX THAT LISTS (ROW COLUMN) OF THE FILLED VALUES | |
DEFUN_DLD (torcmtx, args, nargout, "extracts edges of a sparse matrix to a list matrix") | |
{ | |
int nargin = args.length(); | |
if (nargin != 1) | |
print_usage (); //make sure we actually sent one value in. |
This file contains 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 <octave/oct.h> | |
#include <octave/Cell.h> | |
// SPECIAL FUNCTION THAT CONVERTS A SPARSE MATRIX | |
// TO A MATRIX THAT LISTS (ROW COLUMN) OF THE FILLED VALUES | |
DEFUN_DLD (cmtxvars, args, nargout, "creates a cell matrix of variations on a sparse matrix") | |
{ | |
int nargin = args.length(); | |
if (nargin < 1) |
This file contains 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
//we're going to make a screw | |
//example values: | |
resolution = 200; | |
turns = 5; | |
height = 10; | |
deltathread = height / turns / 2; | |
trivial = 0.01; | |
for(i=[1:resolution]) { |
This file contains 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
The Open Company Definition | |
=========================== | |
(draft) | |
Introduction | |
------------ | |
The Open company is a way of organizing collective human behavior, largely inspired by Eric S. Raymond's imperative | |
to take experiential knowledge from Open source software into 'other domains'. Open companies will implement |
This file contains 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
module LevyAlphaRand | |
#a module that provides a levy alpha-stable random number in julia | |
#uses "McCulloch's algorithm", as provided in: | |
# Leccardi, M., Comparison of Three Algorithms for Levy Noise Generation | |
# | |
# Note two errors in the McCulloch formula as provided in this paper | |
# One: The phi and w values are swapped | |
# Two: The sin term should have an exponent of one, a fractional exponent would result in complex values |
This file contains 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 <stdio.h> | |
#include <string.h> | |
#include <stdint.h> | |
typedef uint8_t minifloat; | |
/* | |
minifloat variable: sign bit, then three bits of exponent, and four bits of | |
mantissa. Like the 1:4:3 minifloat, but instead with the exponent as the | |
least significant bits. |
This file contains 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 <stdio.h> | |
#include <string.h> | |
typedef struct { | |
signed int exp:4; | |
signed int val:4; | |
} minifloat; | |
float to_float(minifloat m){ | |
/* generate a product accumulator */ |
This file contains 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/julia | |
#julia matrix test program. | |
v = rand(5) | |
m = rand(5,5) | |
r = zeros(5) | |
println("right product") | |
tic() |
OlderNewer