Skip to content

Instantly share code, notes, and snippets.

@jremmen
Created March 9, 2014 00:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jremmen/9441043 to your computer and use it in GitHub Desktop.
Save jremmen/9441043 to your computer and use it in GitHub Desktop.
js: generate n x n identity matrix
function im(n) { var a = Array.apply(null, new Array(n)); return a.map(function(x, i) { return a.map(function(y, k) { return i === k ? 1 : 0; }) }) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment