Last active
August 29, 2015 14:09
-
-
Save gregtatum/229324c6cfd33a792540 to your computer and use it in GitHub Desktop.
consoleMatrixElements() - Output multiple console.tables() for an array buffer of matrix elements
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
var consoleMatrixElements = function( els, decimalPlaces ) { | |
var i, j, el, results; | |
results = []; | |
j = 0; | |
for( i=0; i < els.length; i++ ) { | |
if( j === 0 ) { | |
results.push([]); | |
} | |
el = els[i]; | |
if( typeof decimalPlaces === "number" ) { | |
el = Math.round( Math.pow(10, decimalPlaces) * el ) / Math.pow(10, decimalPlaces); | |
} | |
results[Math.floor(i / 4) % 4].push( el ); | |
j++; | |
j %= 4; | |
if( i % 16 === 15 ) { | |
console.table( results ); | |
results = []; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment