Return a new
ndarraycontaining the elements of an inputndarraybut whose last two dimensions are transposed.
var toTransposed = require( '@stdlib/ndarray/to-transposed' );Returns a new ndarray containing the elements of an input ndarray but whose last two dimensions are transposed.
var array = require( '@stdlib/ndarray/array' );
var x = array( [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] );
// returns <ndarray>[ [ 1, 2, 3 ], [ 4, 5, 6 ] ]
var y = toTransposed( x );
// returns <ndarray>[ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]The function accepts the following arguments:
- x: input
ndarray.
- The function operates on a stack of matrices, transposing the last two dimensions of the input ndarray.
- The input ndarray must have two or more dimensions.
var array = require( '@stdlib/ndarray/array' );
var ndarray2array = require( '@stdlib/ndarray/to-array' );
var toTransposed = require( '@stdlib/ndarray/to-transposed' );
var x = array( [ [ [ 1, 2, 3 ], [ 4, 5, 6 ] ], [ [ 7, 8, 9 ], [ 10, 11, 12 ] ] ] );
console.log( ndarray2array( x ) );
var y = toTransposed( x );
console.log( ndarray2array( y ) );