nl_tokens: TRANSPOSE // FUNCTION : transpose ( matrix [ options ] ) Computes the transpose of a matrix .
pl_tokens: function transpose ( mat , options ) { /* jshint newcap:false */ var strides , shape , opts , ctor , err , tmp , d ; if ( ! isMatrixLike ( mat ) ) { throw new TypeError ( 'transpose()::invalid input argument. First argument must be a matrix. Value: `' + mat + '`.' ) ; } opts = { } ; if ( arguments . length > 1 ) { <mask> = validate ( opts , options ) ; if ( err ) { throw err ; } } else { opts . copy = true ; } if ( opts . copy ) { // Copy the matrix data to a new typed array: ctor = ctors ( mat . dtype ) ; d = new ctor ( mat . data ) ; // Swap the dimensions: shape = [ mat . shape [ 1 ] , mat . shape [ 0 ] ] ; // Swap the strides: strides = [ mat . strides [ 1 ] , mat . strides [ 0 ] ] ; // Return a new matrix: return new mat . constructor ( d , mat . dtype , shape , mat . offset , strides ) ; } else { // Swap the dimensions... tmp = mat . shape [ 0 ] ; mat . shape [ 0 ] = mat . shape [ 1 ] ; mat . shape [ 1 ] = tmp ; // Swap the strides... tmp = mat . strides [ 0 ] ; mat . strides [ 0 ] = mat . strides [ 1 ] ; mat . strides [ 1 ] = tmp ; // Return the matrix transpose: return mat ; } }